2010 Nov 30 8:09 AM
HI experts , how to pick the duplicates from the internal table . Pl see that i am not talking of delete adjacent duplicate.
any key word or function module is there in sap Abap.
Moderator message: please use more descriptive subject lines from now on.
Edited by: Thomas Zloch on Nov 30, 2010 11:53 AM
2010 Nov 30 8:25 AM
Hi,
You would have to sort the table and then read the data one by one if there is another row with the same value.
eg: loop at itab into wa_tab.
read table itab into wa_tab2 with key field1 = wa_tab-field1.
if sy-subrc = 0.
count = count + 1.
endif.
endloop.
count will give you the no of duplicates. If you want the entries that are repeates you can append the data for wa_tab2 into an internal table.
Hope it help.
Thanks,
Anju
HI experts , how to pick the duplicates from the internal table . Pl see that i am not talking of delete adjacent duplicate.
any key word or function module is there in sap Abap.
Moderator message: please use more descriptive subject lines from now on.
Edited by: Thomas Zloch on Nov 30, 2010 11:53 AM
2010 Nov 30 8:22 AM
Hi,
I don't think there is any FM in ABAP to do so.
Need to write the coding to check if there are any duplicates and get the same.
Regards,
Srini.
2010 Nov 30 8:25 AM
Hi,
You would have to sort the table and then read the data one by one if there is another row with the same value.
eg: loop at itab into wa_tab.
read table itab into wa_tab2 with key field1 = wa_tab-field1.
if sy-subrc = 0.
count = count + 1.
endif.
endloop.
count will give you the no of duplicates. If you want the entries that are repeates you can append the data for wa_tab2 into an internal table.
Hope it help.
Thanks,
Anju
2010 Nov 30 9:03 AM
Thanks , but if you check sy-subrc it will definitely be 0 , since the field is present in itab. But what about the duplicate , even if the field is not duplicate sy-subrc will be 0.
2010 Nov 30 8:40 AM
2010 Nov 30 9:09 AM
Hi,
if its indexed table.,... sort it using the field...
loop at itab into wa_itabl.
if sy-tabix eq 1.
continue.
endif.
read itabl into wb_itabl index (sy-tabix-1). "sysntax might be wrong
if wb_itab1-field eq wa_itab1-field.
append wb_itabl-field into tab2.
endif.
endloop.
delte adjacnt duplicat entries in tab2.
now tab2 contains unique duplicate entires in itab1.
thanks,
srini
<removed by moderator>
Edited by: Thomas Zloch on Nov 30, 2010 12:57 PM - please not ask for ...
2010 Nov 30 9:39 AM
Hi,
I dont know what exactly you want to do after finding the duplicate records , but you can use keyword
AT NEW
data : wfirst_rec type c.
sort itab by field1.
loop at itab.
at new field1.
" what ever logic you want to implement
endat.
endloop.
Regards,
Madhukar Shetty
2010 Nov 30 10:22 AM
SORT itab BY ebeln.
LOOP AT itab INTO wa_tab.
AT NEW ebeln.
lv_counter = 1.
ENDAT.
IF lv_counter = 1.
MOVE-CORRESPONDING wa_tab TO wa_prev.
ELSEIF lv_counter = 2. " Its duplicate Record
APPEND wa_prev TO dup_tab.
APPEND wa_tab TO dup_tab.
ELSEIF lv_counter > 2. " Its duplicate Record
APPEND wa_tab TO dup_tab.
ENDIF.
lv_counter = lv_counter + 1.
AT END OF ebeln.
CLEAR : lv_counter, wa_prev.
ENDAT.
ENDLOOP.
2010 Nov 30 10:50 AM
hi
You can use the at new to find the dupicates.
loop at itab into wa.
at new field1 .
flag = 1.
endat.
2010 Nov 30 11:00 AM
hi
You can use the at new to find the dupicates.
loop at itab into wa.
flag = 2.
at new field1 .
flag = 1.
endat.
if flag = 2.
append wa into dup_itab.
endif.
endloop.This code will read all the duplicates records .
2010 Nov 30 12:31 PM
just sort, loop the table watching the next registry
sort itab.
mirror_tab = itab.
loop at itab.
l_tabix = sy-tabix+1.
read table mirror_tab index l_tabix.
if itab-key = mirror_Tab-key.
" duplicate registry here.
endif.
endloop.regards, Sebastian
2010 Nov 30 12:37 PM
Hi obaid,
data:
itab type table of mystructure, "this is your table
itab_nodup type sorted table of mystructure with unique key table_line,
itab_dup type table of mystructure.
field-symbols:
<any> type any.
loop at itab assigning <any>.
insert <any> into table itab_nodup.
if sy-subrc <> 0.
append <any> to itab_dup.
endif.
endloop.This will put the duplicates to itab_dup.
NEXT time use a subject.
Regards,
Clemens
2010 Nov 30 12:54 PM
null
Edited by: BrightSide on Nov 30, 2010 12:54 PM
Edited by: BrightSide on Nov 30, 2010 12:56 PM
| User | Count |
|---|---|
| 6 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |