Application Development 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: 

code

Former Member
0 Kudos

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>

1 ACCEPTED SOLUTION

former_member194669
Active Contributor
0 Kudos

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

3 REPLIES 3

former_member194669
Active Contributor
0 Kudos

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

0 Kudos

Hi,

It worked well.

But why does this happen?

What is the difference between the two ...

Thanks in advance.

former_member194669
Active Contributor
0 Kudos

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