‎2007 Aug 26 12:04 PM
hi all
i have a small query .
init1 i have
matnr
72100008
72100009
and in it2 i have
matnr menge
7210008 20
72100011 30
but i wnt to keep only those matnr in it2 which are same in it1and it2
without having loop at it2 how can i do it any answer plz .i it urgent.
Message was edited by:
sarabjit kaur
‎2007 Aug 26 1:12 PM
My first question (because I'm curious) would be "why can't you loop at itab2"... but purely as an academic exercise, here's a suggestion which loops at itab1 instead (not syntax checked as no system access right now):
ranges:
lr_matnr for mara-matnr.
lr_matnr-sign = 'I'.
lr_matnr-option = 'EQ'.
loop at itab1. "assume header line
lr_matnr-low = itab1-matnr.
append lr_matnr.
endloop.
delete itab2 where matnr not in lr_matnr.
‎2007 Aug 26 1:22 PM
because my proggram is already having alot of loops so i just wanted to avoid that , anyway thanx a lot,for prompt reply,i will surely try your option
‎2007 Aug 26 1:52 PM
Thanks. SAP / ABAP thrives on loops, so it may not be a problem anyhow... also you might be able to incorporate the lookup of itab1 whilst you are building up itab2. Good luck.
Jonathan
‎2007 Aug 27 9:47 AM
‎2007 Aug 27 10:02 AM
Hii Sarabjit..
This is somewhat different logic but it may work for ur Req:
Just Try once...
Sort itab1 by Matnr as TEXT ASCENDING.
Sort itab2 by Matnr AS TEXT ASCENDING.
Data: v_lastrec type i.
Describe table Itab1.
v_lastrec = sy-tfill.
Read table itab1 index v_lastrec . "Last row...
Delete itab2 Where matnr > ITAB1-MATNR.
<b>reward points if Helpful...</b>
‎2007 Aug 27 10:06 AM
u can try for this ...
loop at it1
read table it2 with key matnr ne it2-mantr.
if sy-subrc = 0.
delete it2.
endif.
endloop.
ok
bye