‎2008 Mar 11 7:33 AM
hiii
suppose i have a an internal table with 10 field (field1, field2, field3 ...)
i need to retreive duplicate record as per the the first 5 field .
please advise if below is correct
LOOP at itab
if itab-field1 EQ L_field1
AND itab-field2 EQ L_field2
AND itab-field3 EQ L_field3
AND itab-field4 EQ L_field4
AND itab-field5 EQ L_field5
/// mode duplicate
endif.
re-initialise l_field1,2,3,4,5 with next entry
endloop
‎2008 Mar 11 7:46 AM
Hi take a new internal t5able itab2 and fill it like this.
loop at itab1 .
at new itab1-fild5.
continue.
end at.
itab2 = itab1.
append itab2.
clear itab2.
endloop.
in above code the internal table should be sortes frist with all the first 5 fields. it form s a key. when any fild changes it will trigger at new event and processing will continue.
if it is duplicate reord it will get added to internal table.
‎2008 Mar 11 7:36 AM
Hi,
You can do as below:
itab2[] = itab1[].
loop at itab1.
read table itab2 with key field1 = itab1-field1
field2 = itab1-field2
field3 = itab1-field3
field4 = itab1-field4
field5 = itab1-field5.
if sy-subrc eq 0.
new_tab = itab1.
append new_tab.
clear new_tab.
endif.
endloop.
Now you will have common records in new_tab.
Thanks,
Sriram Ponna
‎2008 Mar 11 7:41 AM
Hi,
u need to sort this itab before this loop otherwise u may miss some data.
sort itab by field1 field2 field3 field4 field5.
rgds,
bharat.
‎2008 Mar 11 7:46 AM
Hi take a new internal t5able itab2 and fill it like this.
loop at itab1 .
at new itab1-fild5.
continue.
end at.
itab2 = itab1.
append itab2.
clear itab2.
endloop.
in above code the internal table should be sortes frist with all the first 5 fields. it form s a key. when any fild changes it will trigger at new event and processing will continue.
if it is duplicate reord it will get added to internal table.
‎2008 Mar 11 9:04 AM
could you please adivise another solution apart for using at new