F How to pass internal table data to range table in SAP ABAP | CodeTheta

How to pass internal table data to range table in SAP ABAP

July 16, 2024

Code: 
TYPES: BEGIN OF ty_str,
         id   TYPE int4,
         name TYPE name1,
         site TYPE werks_d,
       END OF ty_str.

DATA: it TYPE STANDARD TABLE OF ty_str,
      wa TYPE ty_str.

DATA: r_site TYPE RANGE OF werks_d.

it = VALUE #( ( id = '1' name = 'AAA' site = 'H021' )
              ( id = '2' name = 'BBB' site = 'H067' )
              ( id = '3' name = 'CCC' site = 'H022' )
              ( id = '4' name = 'DDD' site = 'H055' )
              ( id = '5' name = 'EEE' site = 'H033' )
              ( id = '6' name = 'FFF' site = 'H064' ) ).

r_site = VALUE #( FOR <fs_it> IN it
                    ( sign = 'I'
                      option = 'EQ'
                      low = <fs_it>-site ) ).

cl_demo_output=>display( r_site ).

You can also use below code section -

r_site = VALUE #( FOR <fs_it> IN it
                    ( sign = if_fsbp_const_range=>sign_include
                      option = if_fsbp_const_range=>option_equal
                      low = <fs_it>-site ) ).

IDE Used To Test This Code : SAP ABAP Editor.

Try this code in your computer for better understanding. Enjoy the code. If you have any Question you can contact us or mail us. We will reply you as soon as possible.

Post a Comment