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

DIsplaying duplicate entries

Former Member
0 Likes
1,322

Hi,

I hav an intrenal table y_itab .

i need to find out whether it has any duplicate entries , if ther are then display that record r else process .

Plz provide me some logic for this .

Thanks.

Hi,

I hav an intrenal table y_itab .

i need to find out whether it has any duplicate entries , if ther are then display that record r else process .

Plz provide me some logic for this .

Thanks.

9 REPLIES 9
Read only

Former Member
0 Likes
1,190

HI,

YOU CAN DELEATE THOSE DUPLICATE ENTRIES FROM YOUR INTERNAL TABLE BY USING

DELEATE DUPLICATE ENTRIES IN ITAB

AND THEN PROCESS THE INTERNAL TABLE

Read only

0 Likes
1,190

hi,

I need to display those duplicate records .

Read only

Former Member
0 Likes
1,190

Hi Hem,

Check this thread surely it will help you.

https://forums.sdn.sap.com/click.jspa?searchID=3455251&messageID=1260325

Thanks,

Reward If Helpful.

Read only

Former Member
0 Likes
1,190

Hi,

DELETE - duplicates

Syntax

... ADJACENT DUPLICATES FROM itab

[COMPARING { comp1 comp2 ...}|{ALL FIELDS}]... .

Addition:

... COMPARING {comp1 comp2 ...}|{ALL FIELDS}

Effect

With these additions, the statement DELETE deletes all lines in certain groups of lines, except for the first line of the group. These are groups of lines that follow one another and have the same content in certain components. If the addition COMPARING is not specified, the groups are determined by the content of the key fields.

Lines are considered to be doubled if the content of neighboring lines is the same in the components examined. In the case of several double lines following one another, all the lines - except for the first - are deleted.

Addition

... COMPARING {comp1 comp2 ...}|{ALL FIELDS}

Effect

If the addition COMPARING is specified, the groups are determined either by the content of the specified components comp1 comp2 ... or the content of all components ALL FIELDS. The specification of individual components comp is made as described in the section Specification of Components. Access to class attributes is possible through the object component selector only as of Release 6.10.

Example

Deleting all multiple-occurring lines in the internal table connection_tab. The result of this exanple corresponds to the one in the example for the position specification for INSERT.

DATA: BEGIN OF connection,

cityfrom TYPE spfli-cityfrom,

cityto TYPE spfli-cityto,

distid TYPE spfli-distid,

distance TYPE spfli-distance,

END OF connection.

DATA connection_tab LIKE SORTED TABLE OF connection

WITH NON-UNIQUE KEY cityfrom cityto

distid distance.

SELECT cityfrom cityto distid distance

FROM spfli

INTO TABLE connection_tab.

DELETE ADJACENT DUPLICATES FROM connection_tab.

Regards,

Priyanka.

Read only

jayanthi_jayaraman
Active Contributor
0 Likes
1,190

Hi,

itab1[] = itab[].

loop at itab1.

loop at itab where condition for checking duplicate.

write : / itab.

delete itab1 where condition for checking duplicate.

endloop.

endloop.

Read only

Former Member
0 Likes
1,190

hi,

take another intenal table of same structure y_itab. let it be y_itab1.

y_itab1[] = y_itab[]

then delete the duplicates in y_itab1[] w.r.t key field.

after that,

loop at y_itab1[]

loop at y_itab.......

if sy-subrc = 0.

count = count +1.

endif.

if count > 1.

display ur record.

clear count.

endif.

endloop.

endloop.

just an idea am giving.

try for other logic which doesn't containn nested loop if possible.

if useful reward points

thanks,

praveena.

Read only

0 Likes
1,190

sorry no need to check sy-surc here.

thaks,

Praveena

Read only

Former Member
0 Likes
1,190

loop at itab1.

read table itab2 with key vbeln = itab1-vbeln and check with all fields.

if sy-subrc = 0.

itab1-count = l_count.

Modify itab1 ndex sytabix transporting count .

else.

l_count = l_couynt + 1.

endif.

endloop.

itab2[] = itab1[].

Display the data from itab1 where count is similar

Read only

Former Member
0 Likes
1,190

Hem,

Create another internal table itab1 the same way as itab .

Populate itab1 with the same data of itab .

itab1[] = itab[] .

Now to display duplicate entries,

loop at itab .

Read table itab1 with key f1 = itab-f1

f2 = itab-f2

...............

fn = itab-fn .

( Here key should be ALL the fields )

if sy-subrc = 0 .

  • This is the duplicate entry and display

write : itab1.

else.

*PROCESS as you want

endif .

endloop .

~ Laxmi

  • Reward all helpful answers