07-12-2007 1:04 AM
Hi ,
I added this code to delete the records if they are with S, T or K and also with A , D & E.
but my issue is ...when the commented lines were uncommented...the lines in the loop did not work but the when the sy-subrc was there.
I just wanted to know the reason...for this
<b> DATA : lt_tb_all_data LIKE tb_all_data OCCURS 0 WITH HEADER LINE.
DATA : lw_data LIKE lt_tb_all_data.
lt_tb_all_data[] = tb_all_data[].
LOOP AT lt_tb_all_data WHERE zttype = 'T'
OR zttype = 'K'
OR zttype = 'S'.
LOOP AT tb_all_data INTO lw_data
WHERE lifnr = lt_tb_all_data-lifnr
AND matnr = lt_tb_all_data-matnr
AND werks NE lt_tb_all_data-werks
AND ( zttype = 'A' OR zttype = 'D'
OR zttype = 'E' ).
if sy-subrc = 0 .
lw_data-flag_type = 'X'.
MODIFY tb_all_data FROM lw_data
INDEX sy-tabix TRANSPORTING flag_type.
CLEAR lw_data.
endif.
ENDLOOP.
ENDLOOP.
DELETE tb_all_data WHERE flag_type = 'X'.</b>
07-12-2007 1:45 AM
Hi,
LOOP AT tb_all_data INTO lw_data
WHERE lifnr = lt_tb_all_data-lifnr
AND matnr = lt_tb_all_data-matnr
AND werks NE lt_tb_all_data-werks
AND ( zttype = 'A' OR zttype = 'D'
OR zttype = 'E' ).
You have already given all your conditions in the where condition, then there is no necessary to put sy-subrc inside the loop,
aRs
07-12-2007 1:24 AM
Hi,
check this
DATA : lt_tb_all_data LIKE tb_all_data OCCURS 0 WITH HEADER LINE.
DATA : lw_data LIKE lt_tb_all_data.
lt_tb_all_data[] = tb_all_data[].
LOOP AT lt_tb_all_data WHERE zttype = 'T'
OR zttype = 'K'
OR zttype = 'S'.
LOOP AT tb_all_data INTO lw_data
WHERE lifnr = lt_tb_all_data-lifnr
AND matnr = lt_tb_all_data-matnr
AND ( zttype = 'A' OR zttype = 'D'
OR zttype = 'E' ).
if werks NE lt_tb_all_data-werks.
lw_data-flag_type = 'X'.
MODIFY tb_all_data FROM lw_data
INDEX sy-tabix TRANSPORTING flag_type.
CLEAR lw_data.
endif.
ENDLOOP.
ENDLOOP.
DELETE tb_all_data WHERE flag_type = 'X'.
aRs
07-12-2007 1:41 AM
Hi,
It worked well.
But why does this happen?
What is the difference between the two ...
Thanks in advance.
07-12-2007 1:45 AM
Hi,
LOOP AT tb_all_data INTO lw_data
WHERE lifnr = lt_tb_all_data-lifnr
AND matnr = lt_tb_all_data-matnr
AND werks NE lt_tb_all_data-werks
AND ( zttype = 'A' OR zttype = 'D'
OR zttype = 'E' ).
You have already given all your conditions in the where condition, then there is no necessary to put sy-subrc inside the loop,
aRs