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

Duplicate Entries in Internal table

Former Member
0 Likes
440

Hi All,

As per my requirement

1. The internal table is the input.

2. I need the duplicate records of the internal table with the combination of 2 key fields.

3. I should not use SORT because i need the index number in order as per in the table .

EX : Take Table MSEG.

Take key fields as MBLNR and WERKS.

I want the duplicate records of the combination of these 2 key fields.

The *Index Number * should not to be changed as per the table entry. ( So i avoided sorting the internal table)

Kindly give some solutions.

Thanks,

Pradeep.

Moderator message : Duplicate post locked,follow forum Rules of Engagement. Thread locked.

Edited by: Vinod Kumar on Mar 1, 2012 4:59 PM

1 ACCEPTED SOLUTION
Read only

SharathYaralkattimath
Contributor
0 Likes
402

Hi Pradeep,

Try this...

first you copy your internal table to another temporary table of same type.

itab_temp[] = itab[].
sort itab_temp[].
DELETE ADJACENT DUPLICATES FROM ITAB COMPARING MBLNR WERKS.
LOOP AT ITAB_TEMP INTO WA_ITAB1.
DO.
    READ TABLE ITAB INTO WA_ITAB2 WITH KEY MBLNR = WA_ITAB1-MBLNR AND  WERKS = WA_ITAB1-WERKS.
    IF SY-SUBRC EQ 0.
         APPEND WA_ITAB2 TO ITAB_NEW.
    ELSE.
         EXIT.
    ENDIF.
ENDDO.
ENDLOOP.

you may get the duplicate records in itab_new.

Hi All,

As per my requirement

1. The internal table is the input.

2. I need the duplicate records of the internal table with the combination of 2 key fields.

3. I should not use SORT because i need the index number in order as per in the table .

EX : Take Table MSEG.

Take key fields as MBLNR and WERKS.

I want the duplicate records of the combination of these 2 key fields.

The *Index Number * should not to be changed as per the table entry. ( So i avoided sorting the internal table)

Kindly give some solutions.

Thanks,

Pradeep.

Moderator message : Duplicate post locked,follow forum Rules of Engagement. Thread locked.

Edited by: Vinod Kumar on Mar 1, 2012 4:59 PM

1 REPLY 1
Read only

SharathYaralkattimath
Contributor
0 Likes
403

Hi Pradeep,

Try this...

first you copy your internal table to another temporary table of same type.

itab_temp[] = itab[].
sort itab_temp[].
DELETE ADJACENT DUPLICATES FROM ITAB COMPARING MBLNR WERKS.
LOOP AT ITAB_TEMP INTO WA_ITAB1.
DO.
    READ TABLE ITAB INTO WA_ITAB2 WITH KEY MBLNR = WA_ITAB1-MBLNR AND  WERKS = WA_ITAB1-WERKS.
    IF SY-SUBRC EQ 0.
         APPEND WA_ITAB2 TO ITAB_NEW.
    ELSE.
         EXIT.
    ENDIF.
ENDDO.
ENDLOOP.

you may get the duplicate records in itab_new.