2008 Jan 28 11:54 AM
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
its very urgent.
Thank you in advance.
Jeyanthi
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
its very urgent.
Thank you in advance.
Jeyanthi
2008 Jan 28 11:58 AM
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.
2008 Jan 28 12:16 PM
hi,
i have tried with that, but it has'nt work.
is that any syntax modification i need to do?
2008 Jan 28 12:00 PM
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 .
2008 Jan 28 12:02 PM
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 .
2008 Jan 28 12:17 PM
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
2008 Jan 28 12:59 PM
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
2008 Jan 28 1:13 PM
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.
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |