‎2007 Apr 11 2:05 PM
Hi Expert,
i have two internal tables , i have to comapre a field which have no value in other it- tables. e.g.
it_tab1-posnr have value 10,20,30,40,50.
it_tab2-posnr have value 10,20,30,40.
i hav to put a condition when some posnr from it_tab1 not in it_tab2.
rgds
abaper.
‎2007 Apr 11 2:07 PM
Loop at itab1,
Read table itab2 with key Vbeln and POSNR.
If sy-subrc = 0.
Record exist in itab2.
else.
not exist in itab2.
Endloop.
‎2007 Apr 11 2:07 PM
loop at it_tab1 into wa.
read table it_tab2 with key posnr = wa-posnr.
if sy-subrc <> 0.
....
else.
...
EndIf.
EndLoop.
Santhosh
‎2007 Apr 11 2:07 PM
Hi,
Put a simple condn
if it_tab1-posnr = it_tab21-posnr (in the loop of it_tab1, after reading it_Tab2)
then move the data to some other int table
endif.
reward if useful
regards,
Anji
Message was edited by:
Anji Reddy Vangala
‎2007 Apr 11 2:07 PM
Loop at itab1,
Read table itab2 with key Vbeln and POSNR.
If sy-subrc = 0.
Record exist in itab2.
else.
not exist in itab2.
Endloop.
‎2007 Apr 11 2:08 PM
loop at itab1.
read table itab2 with key field1 eq itab1-field1.
if sy-subrc ne 0.
write : 'value itab1-field1 does not exist in itab2'.
endif.
endloop.Message was edited by:
Chandrasekhar Jagarlamudi
‎2007 Apr 11 2:09 PM
hi,
chk this:
sort itab2 by posnr.
loop at itab1.
read table itab2 with key posnr = itab1-posnr.
if sy-subrc <> 0.
.....
endif.
endloop.
regards,
madhu
‎2007 Apr 11 2:15 PM
Hi ABAP king,
try function module COMPARE_TABLES.
also have a look at demo program DEMO_INT_TABLES_COMPARE
Hope this helps
Thanks
Lakshman
‎2007 Apr 11 2:17 PM
Hi all,
thanks for ur replies, but in second internal table the value may be like
10,20,20,30,30,40. so actually my reqs is find a value in first internal table which is not in second and at that point a have to done some work.
rgds
abaper.
‎2007 Apr 11 2:22 PM
Its not a problem, anyway the read statement success if the records present in itab2. If 2 values there in itab2 the read statement get the first one.
‎2007 Apr 11 2:28 PM
Hi
Try like this
DATA: begin of it_tab1 occurs 0,
data1 type i,
end of it_tab1.
DATA: begin of it_tab2 occurs 0,
data2 type i,
end of it_tab2.
it_tab1-data1 = 10.
append it_tab1.
it_tab1-data1 = 20.
append it_tab1.
it_tab1-data1 = 30.
append it_tab1.
it_tab1-data1 = 40.
append it_tab1.
it_tab1-data1 = 50.
append it_tab1.
it_tab2-data2 = 10.
append it_tab2.
it_tab2-data2 = 30.
append it_tab2.
it_tab2-data2 = 50.
append it_tab2.
it_tab2-data2 = 70.
append it_tab2.
it_tab2-data2 = 80.
append it_tab2.
loop at it_tab1.
read table it_tab2 with key data2 = it_tab1-data1.
if sy-subrc <> 0.
write:/ 'Not there'.
else.
write:/ 'Exists'.
endif.
endloop.
Regards
Haritha.