Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

dynamic variable

Former Member
0 Likes
330

in below code, i am facing one problem.

SELECT-OPTIONS: s_perd FOR glt0-rpmax obligatory default 1 to 16.

DATA : lv_sum LIKE glt0-tsl01.

RANGES: r_tsl FOR zv_lae_crm-event.

r_tsl-sign = 'I'.

r_tsl-option = 'EQ'.

r_tsl-low = 'it_glt0-TSL01'.

APPEND r_tsl.

r_tsl-sign = 'I'.

r_tsl-option = 'EQ'.

r_tsl-low = 'it_glt0-TSL02'.

APPEND r_tsl.

r_tsl-sign = 'I'.

r_tsl-option = 'EQ'.

r_tsl-low = 'it_glt0-TSL03'.

APPEND r_tsl.

r_tsl-sign = 'I'.

r_tsl-option = 'EQ'.

r_tsl-low = 'it_glt0-TSL04'.

APPEND r_tsl.

r_tsl-sign = 'I'.

r_tsl-option = 'EQ'.

r_tsl-low = 'it_glt0-TSL05'.

APPEND r_tsl.

r_tsl-sign = 'I'.

r_tsl-option = 'EQ'.

r_tsl-low = 'it_glt0-TSL06'.

APPEND r_tsl.

DATA : lv_index type sy-tabix.

LOOP AT it_glt0.

LOOP AT it_glt0 WHERE item_code EQ it_glt0-item_code.

loop at r_tsl.

lv_index = sy-tabix.

if lv_index ge s_perd-low.

lv_sum = lv_sum + ( it_glt0-TSLVT

+ ( r_tsl-low ) ).

endif.

if lv_index = s_perd-high.

exit.

endif.

endloop.

ENDLOOP.

if lv_sum < 0.

lv_sum = lv_sum * ( -1 ).

endif.

it_output-item_code = it_glt0-item_code.

it_output-total = lv_sum.

APPEND it_output.

DELETE it_glt0 WHERE item_code EQ it_glt0-item_code.

CLEAR lv_sum.

ENDLOOP.

in the statement

lv_sum = lv_sum + ( it_glt0-TSLVT

+ ( r_tsl-low ) ).

actully it should pick up value of internal table it_glt0 i.e. numeric but instead it is taking as 'it_glt0-TSL01' and so on.

Kindly guid me on this so that r_tsl-low should actully take numeric value contain in 'it_glt0-TSL0'

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
304

This will work.

field-symbols: <fs> type any.

loop...

loop...

assign (r_tsl-low) to <fs>.

lv_sum = lv_sum + it_glt0-TSLVT + <fs>.

unassign <fs>.

endloop.
endloop.

1 REPLY 1
Read only

Former Member
0 Likes
305

This will work.

field-symbols: <fs> type any.

loop...

loop...

assign (r_tsl-low) to <fs>.

lv_sum = lv_sum + it_glt0-TSLVT + <fs>.

unassign <fs>.

endloop.
endloop.