‎2006 Dec 05 2:18 PM
Hi everyone,
I have two fields namely PERNR and PERID in the table xxxxxx.
PERNR is a unique key field where as PERID is not a unique key.
In the table i have the value as follows
PERNR PERID
65000392 717734001
65000393 717734001
65000394 717734000
65000395 717734002
65000396 717734003
65000397 717734003
What operation can be done so that the output I should get is
The duplicate records are:
PERNR PERID
65000392 717734001
65000393 717734001
65000396 717734003
65000397 717734003
Kindly help in making this output.Thanx in advance.
‎2006 Dec 05 2:47 PM
Hi Sateesh,
This is one way to acheive though cumbersome
itab_dup[] = itab[].
loop at itab.
count = 0.
loop at itab_dup where perid eq itab-perid
count = count + 1.
append itab_dup to itab_result.
endloop.
if count > 1.
loop at itab_result.
write itab_result-pernr, itab_result-perid.
endloop.
endif.
refresh itab_result.
endloop.
‎2006 Dec 05 2:27 PM
Hi ,
Try something like this ( after sorting itab by perid ) :
read table itab index 1.
w_previous_perid = itab-perid.
loop at itab.
if itab-perid eq w_previous_perid.
move-corresponding itab to itab2.
append itab2.
endif.
w_previous_perid = itab-perid.
endloop.
‎2006 Dec 05 2:29 PM
Hi,
try the following:
Sort itab by key fields.
delete adjacent duplicates from itab .
Cheers.
‎2006 Dec 05 2:42 PM
‎2006 Dec 05 2:47 PM
Hi Sateesh,
This is one way to acheive though cumbersome
itab_dup[] = itab[].
loop at itab.
count = 0.
loop at itab_dup where perid eq itab-perid
count = count + 1.
append itab_dup to itab_result.
endloop.
if count > 1.
loop at itab_result.
write itab_result-pernr, itab_result-perid.
endloop.
endif.
refresh itab_result.
endloop.
‎2006 Dec 05 2:54 PM
Hi ,
I am using the work area for all the internal tables.Moreover try to give some short methods so that i can manipulate easily.Thank you.
‎2006 Dec 05 3:08 PM
Hi Sateesh,
data:
itab_dup like table of itab,
itab_result like table of itab,
itab_final_result like table of itab,
fs_dup like line of itab_dup.
itab_dup[] = itab[].
loop at itab into fs_itab..
count = 0.
loop at itab_dup into fs_dup where perid eq fs_itab-perid
count = count + 1.
append fs_dup to itab_result.
endloop.
if count > 1.
append lines of itab_result into itab_final_result.
else.
refresh itab_result.
endif.
endloop.
loop at itab_final_result into fs_itab_final_result.
write fs_itab_final_result.
endloop.
‎2006 Dec 05 3:26 PM
Hi,
I have used the code suggested by you but it shows wrong values instead.Kindly let me know if anyone knows the exact solution.
‎2006 Dec 05 3:43 PM
Hi Sateesh,
Please modify the if condition as shown below.
............
if count > 1.
append lines of itab_result to itab_final_result.
endif.
refresh itab_result.
clear itab_result.
endloop.