05-11-2006 11:49 AM
Hi All,
I had 2 internal tables with HR data.
One containing old data and one containing both old as well as new data.
I want to delete old data form new table by comparing the data with the internal table containing old data.
How can i do it?
Regards,
Bharat Mistry
05-11-2006 11:53 AM
According to ur problem loop around the new table and read the second table ( new one )... when ever sy-subrc = 0... u can delete the particular record
loop at newtable.
read table old where pmkey = pmkey2.
IF SY-SUBRC = 0.
delete newtable.
ENDIF.
endloop.
<b>award points if found helpful</b>
05-11-2006 11:54 AM
Bharat,
How are you selecting data into internal table?
Cheers,
Nilesh
05-11-2006 11:54 AM
loop at itab_old.
DELETE TABLE itab WITH TABLE KEY k1 = itab_old-k1 ... kn = itab_old-kn.
endloop.
Regards,
Ravi
05-11-2006 11:54 AM
hi
loop at itab1.
delete table itba2 from itab1.
endloop.
this helps
plz reward helpful answers
05-11-2006 11:54 AM
Hi Bharat,
refer to the link..
<a href="http://help.sap.com/saphelp_erp2005/helpdata/en/fc/eb3653358411d1829f0000e829fbfe/frameset.htm">Comparing Internal Tables</a>
if the structure of itab_new and itab_old is same.
Code sample:
loop at itab_new.
read itab_old from itab_new.
if sy-subrc ne 0.
delete itab_new from itab_old.
endif.
endloop.
Hope it helps..
Lokesh
pls. reward appropriate points
05-11-2006 11:55 AM
itab1-new
itab2-old
itab3-final.
loop at itab1.
read table itab2 with key = itab1-key.
if itab1 <> itab2 .
itab3 = itab1.
append itab3.
endloop.
05-11-2006 11:57 AM
one way is like this
loop at it_old into wa_old.
read table it_new into wa_new with key fld1 = wa_old-fld2 ....
if sy-subrc = 0.
delete it_new from wa_new.
endif.
endloop.
05-11-2006 11:58 AM
loop at old_tab.
read table new_tab with key (key field) = (key field of old_tab).
if sy-subrc = 0.
delete new_tab.
endif.
endloop.
05-11-2006 11:59 AM
HI,
U CAN DO LIKE THIS
LOOP AT ITAB_NEW.
READ TABLE ITAB_OLD WITH KEY FIELD1 = ITAB_NEW-FIELD1.....
IF SY-SUBRC = 0.
DELETE FROM ITAB_NEW.
ENDIF.
HOPE THIS HELPS,
PRIYA.
05-11-2006 12:00 PM
Hai Bharst
Do the following way
data : begin of it_mara occurs 0,
matnr like mara-matnr,
mbrsh like mara-mbrsh,
mtart like mara-mtart,
meins like mara-meins,
end of it_mara.
data : begin of it_makt occurs 0,
matnr like makt-matnr,
maktx like makt-maktx,
end of it_makt.
select matnr
mbrsh
mtart
meins
from mara into table it_mara.
if sy-subrc = 0.
sort it_mara by matnr.
endif.
if not it_mara[] is initial.
select matnr
maktx
from makt into it_makt
for all entries in it_mara
where matnr = it_mara-matnr.
endif.
loop at it_mara.
read table it_makt with key matnr = it_mara-matnr binary search.
if sy-subrc = 0.
delete from it_mara with sy-index.
endif.
endloop.
Thanks & Regards
Sreenivasulu P
Message was edited by: Sreenivasulu Ponnadi