Application Development 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: 

hi, how to get(display only) duplicate records in report

Former Member
0 Kudos

hi

could anyone tell me how to display only duplicate records in report.

thanx

7 REPLIES 7

abdul_hakim
Active Contributor
0 Kudos

hi raj,

We don't have any special SELECT for fetching the duplicates alone.If you normally write a query without using DISTINCT addition then you will get the duplicate entires as well as the original one.Then you need to do your validation in the program to isolate ur duplicate entires..

Cheers,

Abdul

Former Member
0 Kudos

DATA itab LIKE TABLE OF ztable.
SELECT * FROM ztable
 INTO TABLE itab.

DATA prev LIKE LINE OF itab.
LOOP AT itab.
 IF prev EQ itab.
 "Duplicate
  WRITE prev.
 ENDIF.
 prev = itab.
ENDLOOP.

Former Member
0 Kudos

Raj,

SORT the table by the same fields which will be your criteria for finding duplicates.

Then loop at the table and write the record (have a counter and start writing from counter 2) till the time you encounter a different record by comparing the key.

Then reset the counter and repeat the same.

Regards,

Ravi

Note : Please mark the helpful answers

vinod_gunaware2
Active Contributor
0 Kudos

Hi

U can use <b>SELECT with DISTICT clause</b>

OR U can use SORT on primary key then u

<b>DELETE ADJACENT DUPLICATES FROM itab</b>

Or u can use<b> if condition</b> in loop or select endselect

regards

vinod

Former Member
0 Kudos

Hai Raj,

Say your internal table is ITAB.

DATA KEEP_TAB LIKE ITAB.

SORT ITAB .

LOOP AT ITAB.

IF ITAB = KEEP_TAB .

WRITE 😕 ITAB.

ENDIF.

KEEP_TAB = ITAB.

ENDLOOP.

The above code will only write the duplicates.

Cheers

Srikanth.

Former Member
0 Kudos

hi Raj,

you can do something like this..

data : wa like line of itab.
 sort itab by <f>
loop at itab .
IF WA EQ ITAB   .
 WRITE : / WA-<f>.
endif.
WA = ITAB.
endloop.

regards

satesh

Former Member
0 Kudos

Hi raj,

1. by using some logic we can do.

(this is one way)

2. a,b,b,c,d

the program will print only b

3. just copy paste.

REPORT abc.

*parameters: p_vbeln like vbap-vbeln.

*parameters: p_posnr like vbap-vbeln.

*

*

*----


DATA : BEGIN OF itab OCCURS 0,

f(5) TYPE c,

END OF itab.

DATA : final LIKE itab OCCURS 0 WITH HEADER LINE.

itab-f = 'a'.

APPEND itab.

itab-f = 'b'.

APPEND itab.

itab-f = 'c'.

APPEND itab.

itab-f = 'd'.

APPEND itab.

itab-f = 'b'.

APPEND itab.

*----


SORT itab BY f.

*----


LOOP AT itab.

IF final-f <> itab-f.

final = itab.

APPEND final.

DELETE itab.

ENDIF.

ENDLOOP.

*----


LOOP AT itab.

WRITE 😕 itab-f.

ENDLOOP.

regards,

amit m.