gpt4 book ai didi

abap - 使用 LET 从 itab 填充范围表

转载 作者:行者123 更新时间:2023-12-02 00:31:10 24 4
gpt4 key购买 nike

我找到了这个用于填充范围表的代码(源已经离线):

DATA   lr_vkorg   TYPE RANGE OF vkorg.
TYPES: lr_range_t TYPE RANGE OF vkorg.

lr_vkorg = VALUE lr_range_t(
LET s = 'I'
o = 'EQ'
IN sign = s
option = o
( low = '1100' )
( low = '1200' )
( low = '1300' )
( low = '1400' )
( low = '1500' )
).

但不是做这样的事情:

( low = '1' )
( low = '2' )
...

我想用内部表 ['1', '2', ...] 的值填充它。
有谁知道如何做到这一点?

Update: This is how I did it based on the answer:

DATA:
lt_itab TYPE TABLE OF string,
lt_range_itab TYPE RANGE OF string
.

APPEND '1' TO lt_itab.
APPEND '2' TO lt_itab.
APPEND '3' TO lt_itab.
APPEND '4' TO lt_itab.

lt_range_itab = VALUE #(
FOR <ls_itab> IN lt_itab
( sign = 'I'
option = 'EQ'
low = <ls_itab> )
).

最佳答案

您可以像这样使用声明的结构来声明宏:

DEFINE range.
lr_vkorg = VALUE lr_range_t( BASE lr_vkorg ( sign = 'I' option = 'EQ' low = &1 ) ).
END-OF-DEFINITION.

然后用这个一行填充你的范围:

range: '1100', '1200', '1300', '1400', '1500', '1600'.

如果我们谈论从 itab 填充范围,请使用以下语句:

lr_vkorg = VALUE #( FOR ls_vkorg IN gt_vkorg
( sign = 'I'
option = 'EQ'
low = ls_vkorg-vkorg )
).

关于abap - 使用 LET 从 itab 填充范围表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51873592/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com