10-22-2007 7:55 AM
Hi Experts,
In itab1 table there are following entries.
Vbeln posnr
360 1
360 2
360 3
361 1
361 2
362 1
362 2
363 1.
In itab2 table there are following entries.
Vbeln
360
362
I want to compare both itab and delete all vbeln from itab1 which are not in itab2.
How to write ? Guide me.
Yusuf
10-22-2007 8:43 AM
Hi,yusuf.
This is my answer,I tested it,it works.
LOOP AT TAB_TABLE1 INTO WA_TABLE1.
READ TABLE TAB_TABLE2 WITH KEY VBELN = WA_TABLE1-VBELN INTO WA_TABLE2.
IF SY-SUBRC <> 0.
DELETE TABLE TAB_TABLE1 FROM WA_TABLE1.
ENDIF.
ENDLOOP.
Regards,
feng.
10-22-2007 7:58 AM
Hi
Try like this
delete itab1 where itab1- field-name1 = itab2-field-name.
Regards
Pavan
10-22-2007 7:58 AM
Hi,
use loop on itab1 and read table itab2 using read statements,
and check sy-subrc if it is not zero then delete the record from itab1.
regards,
Prashant
10-22-2007 8:02 AM
10-22-2007 8:02 AM
10-22-2007 8:00 AM
Hi,
loop at itab1.
read table itab2 into wa_itab2 with key vbeln = itab1-vbeln.
if sy-subrc <> 0.
delete itab1.
continue.
endif.
endloop.
Hope it helps...
P.S. Please award points if it helps...
10-22-2007 8:00 AM
try this,
loop at itab1 into w_itab1.
read table itab2 into w_itab2 with key vbeln = w_itab1-vbeln.
if sy-subrc <> 0.
delete itab1.
endif.
endloop.
rewards if useful
kavitha
10-22-2007 8:02 AM
hi yusuf,
hope this helps u.
loop at itab.
read table itab1 into wa with key vbeln = itab-vbeln.
if sy-subrc <> 0.
delete itab.
continue.
endif.
endloop.
regards,
sohi
10-22-2007 8:03 AM
Or you can do it like this:
loop at itab2.
wa_vbeln-sign = 'I'.
wa_vbeln-option = 'EQ'.
move itab2-vbeln to wa_vbeln-low.
append wa_vbeln to gr_vbeln.
endloop.
if not gr_vbeln[] is initial.
delete itab1 where vbeln not in gr_vbeln.
endif.
Just declare a range table to hold the VBELN in itab2.
Hope it helps...
P.S. Please award points if it helps...
10-22-2007 8:04 AM
DATA : ITAB3 LIKE STANDARD TABLE OF ITAB1 WITH HEADER LINE.
LOOP AT ITAB1.
READ TABLE ITAB2 WITH KEY VBELN = ITAB1-VBELN.
IF SY_SUBRC NE 0.
MOVE-CORRESPONDING ITAB1 to ITAB3.
APPEND ITAB3.
ENDIF.
ENDLOOP.
ITAB3 IS REQUIRED TABLE.
REWARD IF USEFUL.
AMIT SINGLA
10-22-2007 8:43 AM
Hi,yusuf.
This is my answer,I tested it,it works.
LOOP AT TAB_TABLE1 INTO WA_TABLE1.
READ TABLE TAB_TABLE2 WITH KEY VBELN = WA_TABLE1-VBELN INTO WA_TABLE2.
IF SY-SUBRC <> 0.
DELETE TABLE TAB_TABLE1 FROM WA_TABLE1.
ENDIF.
ENDLOOP.
Regards,
feng.
10-22-2007 9:58 AM