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: 

About Duplicate entries

Former Member
0 Kudos

Hi experts,

In internal table i have many account numbers.

There are some duplicate entries. i have removed all the duplicates using the following code.

but i cannot remove all the duplicate entries.

certain scenarios i should have duplicate elements also in my output.

certain scenario i should remove the duplicates.

is there any way to remove few duplicate entries from internal table.

your furthur clarification i will send the code also.

DELETE ADJACENT DUPLICATES FROM itab_temp COMPARING RI_ACCT_NO .

LOOP AT ITAB_temp.

LOOP AT ITAB WHERE RI_ACCT_NO = ITAB_TEMP-RI_ACCT_NO.

SUM_BETRH = SUM_BETRH + itab-BETRH.

SUM_BETRW = SUM_BETRW + itab-BETRW.

ENDLOOP.

ITAB_ALS = ITAB.

ITAB_ALS-BETRH = SUM_BETRH.

ITAB_ALS-BETRW = SUM_BETRW.

APPEND ITAB_ALS.

CLEAR: SUM_BETRH, SUM_BETRW, ITAB_ALS.

ENDLOOP.

if u know pls send me documents to

Jmailgarden@gmail.com

its very urgent.

Thank you in advance.

Jeyanthi

7 REPLIES 7

Former Member
0 Kudos

well you gotta remove the duplicates you dont wish to have manually.

Loop at itab into wa.

IF *here check your conditions if this entry has to be removed or not.

remove entry.

ENDIF

endloop.

0 Kudos

hi,

i have tried with that, but it has'nt work.

is that any syntax modification i need to do?

Former Member
0 Kudos

before deleting duplicates entries are you sorting your internal table?????

SORT itab_temp by RI_ACCT_NO.

DELETE ADJACENT DUPLICATES FROM itab_temp COMPARING RI_ACCT_NO .

Former Member
0 Kudos

Hi,

Pls try to add the following code before,

DELETE ADJACENT DUPLICATES FROM itab_temp COMPARING RI_ACCT_NO .

code:

Sort itab_temp by RI_ACCT_NO .

Former Member
0 Kudos

Hi,

keep more than one conditions in your delete adjacent duplicates based on the requirement you have.

This will delete the entries in itab based on the condition

Regards

Shiva

Former Member
0 Kudos

Hi

You have add the following statement before the delete duplicate statement

SORT itab_temp BY RI_ACCT_NO.

DELETE ADJACENT DUPLICATES FROM itab_temp COMPARING RI_ACCT_NO .

I think now it will work. Otherwise some problem internal table fields.

Moreover this code not efficient. You are using nested loops, it is performance killer. Instead you can use for all entries. Already u have data in ITAB_TEMP.

Select f1 f2... from XTABLE into table ITAB for all entries in ITAB_TEMP where RI_ACCT_NO = ITAB_TEMP-RI_ACCT_NO .

then u can add addition logic by using one loop and endloop.

Reward me if it is useful

johndeconinck
Participant
0 Kudos

Hi Jeyanthi,

Your code is correct if you just put ' SORT itab_temp BY RI_ACCT_NO' statement before.

If you wish, you can make your code better by using the COLLECT statement to sum up the values. This way you can avoid looping on to nested internal tables.

Kind Regards,

John.