‎2007 May 16 4:51 PM
I have an editable ALV LIST report with the check box to it. When the user checks the check box on the report and hits a push Button it should copy the row from the internal table and insert the row to the same internal table in the next line.
I had my code in this way,
WHEN 'COPY'.
LOOP AT t_output INTO wa_output.
IF wa_output-chkbox = 'X'.
wa_output-zactual = 0.
wa_output-zqty = 0.
INSERT wa_output INTO t_output INDEX sy-tabix.
ENDIF.
ENDLOOP.However the problem was,
For e.g. let say I have only 3 rows in the internal table. So when the user selects the last, 3rd row and hits the push button the 3rd row copied and is inserted in the 3rd row. The user wanted the copied row in the next row, ie the 4th row.
SO I changed the above code as below and now it goes to an endless loop.
WHEN 'COPY'.
LOOP AT t_output INTO wa_output.
IF wa_output-chkbox = 'X'.
wa_output-zactual = 0.
wa_output-zqty = 0.
Sy-tabix = sy-tabix + 1.
INSERT wa_output INTO t_output INDEX sy-tabix.
ENDIF.
ENDLOOP.<b>I dont want to use another internal table.</b>
I hope I am clear.
Please suggest,
Ster.
‎2007 May 16 5:00 PM
try the following..
data :w_indx like sy-tabix.
WHEN 'COPY'.
LOOP AT t_output INTO wa_output
where chkbox = 'X'
and zactual = 0
and zqty = 0.
if w_indx ne sy-tabix.
w_indx = sy-tabix + 1.
INSERT wa_output INTO t_output INDEX w_indx.
ENDIF.
ENDLOOP.
~Suresh
‎2007 May 16 5:00 PM
try the following..
data :w_indx like sy-tabix.
WHEN 'COPY'.
LOOP AT t_output INTO wa_output
where chkbox = 'X'
and zactual = 0
and zqty = 0.
if w_indx ne sy-tabix.
w_indx = sy-tabix + 1.
INSERT wa_output INTO t_output INDEX w_indx.
ENDIF.
ENDLOOP.
~Suresh
‎2007 May 16 5:05 PM
‎2007 May 16 5:01 PM
Declare one variable like
data : v_tabix like sy-tabix.
WHEN 'COPY'.
LOOP AT t_output INTO wa_output.
IF wa_output-chkbox = 'X'.
wa_output-zactual = 0.
wa_output-zqty = 0.
clear v_tabix.
v_tabix = sy-tabix + 1.
INSERT wa_output INTO t_output INDEX V-tabix.
ENDIF.
ENDLOOP.
See the output and let me know the status
Thanks
Seshu
‎2007 May 16 5:07 PM
‎2007 May 16 5:05 PM
Hi,
Change the code as follows.
data: lv_cnt type i.
describe table t_output lines lv_cnt.
LOOP AT t_output INTO wa_output where wa_output-chkbox = 'X'
and wa_output-zactual = 0
and wa_output-zqty = 0.
lv_cnt = lv_cnt + 1.
INSERT wa_output INTO t_output INDEX lv_cnt.
ENDLOOP.Regards
Sailaja.