Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

retreive duplicate

Former Member
0 Likes
585

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
561

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.

4 REPLIES 4
Read only

Former Member
0 Likes
561

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

Read only

Former Member
0 Likes
561

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.

Read only

Former Member
0 Likes
562

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.

Read only

0 Likes
561

could you please adivise another solution apart for using at new