Homelab, Linux, JS & ABAP (~˘▾˘)~
 

[ABAP] Fill range table directly from select statement

1
2
3
4
5
6
7
8
SELECT @if_fsbp_const_range=>sign_include AS sign,
       @if_fsbp_const_range=>option_equal AS option,
       bukrs                              AS low,
       CAST( @space AS CHAR( 4 ) )        AS high
  FROM t001
  INTO TABLE @DATA(range_of_comp_codes).
 
cl_demo_output=>display( range_of_comp_codes ).

Got this snippet from George Drakos talk from the ABAPConf 2024. Check his Github.

[ABAP] Creating a range using the VALUE operator in a short form

1
2
3
4
5
6
7
8
9
* normal way
DATA(rs1) = VALUE tt_rsdsselopt( ( sign = 'I' option = 'EQ' low = 'one'   )
                                 ( sign = 'I' option = 'EQ' low = 'two'   )
                                 ( sign = 'I' option = 'EQ' low = 'three' ).
 
* short way
DATA(rs1) = VALUE tt_rsdsselopt( sign = 'I' option = 'EQ' ( low = 'one'   )
                                                          ( low = 'two'   )
                                                          ( low = 'three' ) ).

[ABAP] Fill table rows into range table

1
2
3
4
5
6
7
8
DATA(pernrs) = VALUE pernr_tab( ( |00000001| )
                                ( |00000002| )
                                ( |00000003| ) ).
 
DATA(lr_pernr) = VALUE cchry_pernr_range( FOR pernr IN pernrs ( sign   = 'I'
                                                                option = 'EQ'
                                                                low    = pernr
                                                                high   = '' ) ).
1
2
3
4
5
"Append row to range
 
APPEND VALUE #( option = 'EQ'
                sign   = 'I'
                low    = pernr ) TO lr_pernr.