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

Delete Duplicate only

former_member659396
Participant
0 Likes
1,344

Dear Friends,

I am working On report,

In that i have to delete only duplicate records , ( Delete adjestent duplicate comapring field will delete the entire row)

I dont want to delete entire row just want to show duplicate records empty on the next row.

For EXample

DOc.NO Customr Advnce scheme

1234 11111 1000 400

1234 1111 1000 200

Above doc number customer and advnce fields are having same values and scheme is having differnt value

in that i just want to delete duplicate records in second row i.e. ( 1234 1111 1000)

Is there any way,

Please help me out.

Regards

Rohan

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,278

Hi

A Question: Is it that a document will always have one advance? If Yes, then:

1.Loop on your table. At NEW Docno, clear a flag.

2. Set the flag only if you get an advance,

3. For all the following records, you can check the falg and process.

Regards

Raj

12 REPLIES 12
Read only

Former Member
0 Likes
1,278

Hi,

I think it is not duplicate records because the scheme value is different.

Better short the output by DOc.NO Customer Advnce.

or post forum bit clearly.

Arun.

Read only

0 Likes
1,278

Hi Arun

Few records are duplicate and

For same Document and customer 2 schems are there and advance given is only once..

but it is showing that advance 2 times after sorting .

So my calculations are going wrong.

ok is there any method to delete only perticular records not entire row.

Read only

0 Likes
1,278

Hi Katyare,

I assume you are using the internal table for calculating a total of advances for a particular document. If a document has multiple schema - then the same advance comes multiple times and hence creates havoc with your summation.

Solution needed is to retain the records in internal table, but for every duplicate document number occurence clear out the advance amount.

Instead of using delete adjacent duplicates - try using control break statements within the loop/ endloop scope. What you can do is clear out the advance amount for all records except AT NEW docnr.

Hope this helps.

Regards,

Adi

Read only

0 Likes
1,278

Hi Aditya,

Thanks For the reply

i am using t_final and wa_final.

u mean

Loop at itab

Atend of t_final-kwert.

Clear t_final.

endat.

endloop.

is it that

Read only

0 Likes
1,278

not yet, because it will not elimitate triple records. Easiest solution is after sorting, loop and insert into a sorted table with unique key. If success (sy-subrc = 0), ist is no duplicate, otherwise it is and should not be consiedered for calculation.

Regards,

Clemens

Read only

0 Likes
1,278

Is this the final internal table ? if you are displaying in alv use sort and group .. if its a classic report use control break statements and format your output .. deleting the specific fields doesnt make any sense ..

Read only

0 Likes
1,278

its not working,

Can u give me sample..

Read only

0 Likes
1,278

Hi,

can you please post your relevant code as formatted code and tell us where what does not work.

I think I can help you. As an abstract guiding obviously does not help you, I need at least the code that does not work.

Thank you.

Regards,

Clemens

Read only

0 Likes
1,278

Hi You can go through the code

READ TABLE T_KONV INTO WA_KONV WITH KEY KNUMV = WA_VBRK-KNUMV

KPOSN = WA_VBRP-POSNR

KSCHL = 'ZOT1' .

IF SY-SUBRC = 0.

WA_FINAL-KWERT = WA_KONV-KWERT.

ENDIF.

CLEAR WA_T001W.

READ TABLE T_T001W into wa_t001w WITH KEY WERKS = WA_VBRP-WERKS.

IF SY-SUBRC = 0.

WA_FINAL-NAME1 = WA_T001W-NAME1.

ENDIF.

CLEAR wa_t005u.

READ TABLE t_t005u into wa_t005u with key bland = wa_vbrp-wkreg.

if sy-subrc = 0.

wa_final-BEZei = WA_T005U-BEZEI.

endif.

clear wa_kna1.

READ TABLE t_kna1 into wa_kna1 with key kunnr = wa_vbrk-kunrg.

IF SY-SUBRC = 0.

wa_final-Name2 = wa_kna1-name1.

endif.

wa_final-kwert = wa_final-kwert * ( -1 ).

IF wa_final-FKLMG <> 0.

if sy-subrc = 0.

wa_final-ADVNCE = WA_FINAL-KWERT / wa_final-FKLMG.

wa_final-RATE = wa_final-ZRB_ACAMT / wa_final-FKLMG.

endif.

endif.

.

WA_FINAL-DIFFRENCE = WA_FINAL-KWERT - WA_FINAL-ZRB_ACAMT.

IF wa_final-VBTYP = '0'.

if sy-subrc = 0.

wa_final-fklmg = wa_final-fklmg * ( -1 ).

wa_final-kwert = wa_final-kwert * ( -1 ).

endif.

endif.

APPEND WA_FINAL TO T_FINAL.

sort t_final by KWERT.

CLEAR WA_FINAL.

endloop.

See KWERT is the Advance Given

For Same Document number Advance given will be only once but schemes are two,

I dont want to consider Advance given evry time for each scheme for same document number.

It gives problem while calculating differnce in Advance given and acrrual amount.

I hope u undstand my problem

Read only

Former Member
0 Likes
1,279

Hi

A Question: Is it that a document will always have one advance? If Yes, then:

1.Loop on your table. At NEW Docno, clear a flag.

2. Set the flag only if you get an advance,

3. For all the following records, you can check the falg and process.

Regards

Raj

Read only

0 Likes
1,278

its not working,

Can u give me sample..

Read only

0 Likes
1,278

Thanks ,

I used At new and gave flag to same document number,

Problem solved..

regards

Rohan