Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fill range table from itab using LET

Tags:

abap

I found this code for filling a range table (source is already offline):

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' )
).

But instead of doing something like this:

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

I want to fill it with the values of an internal table ['1', '2', ...].
Does anyone have an idea how to do this?

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> )
).
like image 501
Cold_Class Avatar asked Oct 29 '25 03:10

Cold_Class


2 Answers

You can declare macro utilizing your declared structures like this:

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

And then fill your ranges with this one-liner:

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

If we speak about filling range from itab, use this statement:

lr_vkorg = VALUE #( FOR ls_vkorg IN gt_vkorg
                  ( sign = 'I'
                    option = 'EQ'
                    low = ls_vkorg-vkorg )
                  ).
like image 192
Suncatcher Avatar answered Nov 01 '25 14:11

Suncatcher


lr_vkorg = VALUE # ( sign   = 'I'  option = 'EQ' ( low = '1100' ) ( low = '1200' )
             ( low = '1300' ) ( low = '1400' )   ( low = '1500' ) ). 
like image 24
Gurunath reddy Avatar answered Nov 01 '25 13:11

Gurunath reddy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!