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

delete itab

Former Member
0 Likes
770

Hello Experts,

I have to delete some of the itab records based on a condition. There are 2 internal tables.

ITAB1:

EBELN EBELP MATNR LIFNR

45001 00010 10044 10101

45002 00010 10044 10101

45003 00010 10044 10222

45004 00020 10044 10222

45005 00030 10044 10350

45006 00040 10044 10350

ITAB2:

EBELN EBELP MATNR LIFNR

000000 00000 10044 10101

000000 00000 10044 10222

now i have delete the records of ITAB1 where <b>ITAB1-LIFNR <> ITAB2-LIFNR.</b>

Can you please suggest me the way.

Thanks a lot for the help.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
746

SORT itab2 BY lifnr.
LOOP AT itab1.
  READ TABLE itab2 WITH KEY lifnr = itab1-lifnr
                            BINARY SEARCH.
  IF sy-subrc <> 0.
    DELETE itab1.
  ENDIF.
ENDLOOP.
7 REPLIES 7
Read only

Former Member
0 Likes
746
LOOP AT ITAB2.
  DELETE ITAB1 WHERE LIFNR <> ITAB2-LIFNR.
ENDLOOP.

Message was edited by: Matt Nagel

Read only

Former Member
0 Likes
747

SORT itab2 BY lifnr.
LOOP AT itab1.
  READ TABLE itab2 WITH KEY lifnr = itab1-lifnr
                            BINARY SEARCH.
  IF sy-subrc <> 0.
    DELETE itab1.
  ENDIF.
ENDLOOP.
Read only

Former Member
0 Likes
746

Hi Sey,

Loop at ITAB1 into wa_itab1.

loop at i_tab2 into wa_itab2 where ITAB2-LIFNR <> ITAB1-LIFNR.

delete i_tab1 from wa_itab1.

endloop.

endloop.

reward points if this helps.

Manish

Read only

Former Member
0 Likes
746

sort itab1 by lifnr.

sort itab2 by lifnr.

Loop at itab2.

read table itab1 where lifnr = itab2-lifnr.

if sy-subrc <> 0.

delete from itab1 where index = sy-index.

endif.

endloop.

Read only

Former Member
0 Likes
746

Hi,

sort itab2 by ebeln ebelp matnr lifnr.

Loop at itab1.

gv_index = sy-tabix.

read table itab2 with key ebeln = itab1-beeln

ebelp = itab1-ebelp

matnr = itab1-matnr

lifnr = itab1-lifnr.

if sy-subrc <> 0.

delete itab1 index gv_index.

endif.

endloop.

Hope this will help you.

Regards,

Satya.

Read only

Former Member
0 Likes
746

Hi,

LOOP at itab1 into lw_itab1.

read table itab2 into lw_itab2

with key lifnr = lw_itab1-lifnr.

If sy-subrc<> 0.

delete itab1.

endif.

ENDLOOP.

If helpful pl reward.

Cheers.

Read only

0 Likes
746

thnk you all a ton.