Hello Michael,
How about using auxiliary variables?
DATA(lt_sel1) = VALUE rsparams_tt( LET sel1 = VALUE rsparams_tt( FOR <so1> IN s_carrid ( selname = 'S_CARRID' kind = 'S' sign = <so1>-sign option = <so1>-option low = <so1>-low high = <so1>-high ) ) sel2 = VALUE rsparams_tt( FOR <so2> IN s_connid ( selname = 'S_CARRID' kind = 'S' sign = <so2>-sign option = <so2>-option low = <so2>-low high = <so2>-high ) ) IN ( LINES OF sel1 ) ( LINES OF sel2 ) ).
TBH i was not aware that multiple FORs result in a nested loop.
TYPES itab TYPE TABLE OF i WITH EMPTY KEY. DATA(itab) = VALUE itab( BASE VALUE itab( BASE VALUE itab( FOR i = 10 UNTIL i > 13 ( i ) ) FOR i = 20 UNTIL i > 23 ( i ) ) FOR i = 30 UNTIL i > 33 ( i ) ).
gives
10 11 12 13 20 21 22 23 30 31 32 33
Each FOR expression adds 4 lines to itab, one package after the other.
So, the very first example above might simply be rewritten as follows:
DATA(lt_sel) = VALUE rsparams_tt( BASE VALUE rsparams_tt( FOR <v2> IN p_reason ( selname = 'P_AUGRU' high = <v2>-high low = <v2>-low option = <v2>-option sign = <v2>-sign ) ) FOR <v1> IN p_auart ( selname = 'P_AUART' high = <v1>-high low = <v1>-low option = <v1>-option sign = <v1>-sign ) ).
Hello,
As per the ABAP Documentation, the syntax is:
... VALUE dtype|#( [let_exp] [BASE itab] [FOR for_exp1 FOR for_exp2 ... ] ( line_spec1 ) ( line_spec2 ) ... ) ...
Then, could you retry with the following code ?
DATA(lt_sel) = VALUE rsparams_tt( FOR <v2> IN p_reason FOR <v1> IN p_auart ( selname = 'P_AUGRU' high = <v2>-high low = <v2>-low option = <v2>-option sign = <v2>-sign ) ( selname = 'P_AUART' high = <v1>-high low = <v1>-low option = <v1>-option sign = <v1>-sign ) ).
Best regards, Nicolas
My comment is off topic, but you could also use the CORRESPONDING constructor to reduce the size of the code.
Add comment