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

Simple report program

Former Member
0 Likes
1,019

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.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
995

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.

8 REPLIES 8
Read only

Former Member
0 Likes
995

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.

Read only

Former Member
0 Likes
995

Hi,

try the following:

Sort itab by key fields.

delete adjacent duplicates from itab .

Cheers.

Read only

0 Likes
995

Hi satheesh

I changed my code.

hope this helps,

Erwan

Read only

Former Member
0 Likes
996

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.

Read only

0 Likes
995

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.

Read only

0 Likes
995

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.

Read only

0 Likes
995

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.

Read only

0 Likes
995

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.