Skip to Content
0
Former Member
May 04, 2009 at 06:56 PM

Minor programming problem

25 Views

hello, i have written this piece of code in which I am taking the result data in to IT1 then I have to do the comparison and add my keyfigures for duplicate records and delete one of the duplicate records. I am not sure how to add my keyfigures for duplicated records and delete the duplicate record in WA_IT2. can someone help?

For example: if i have the following records in WA_IT2, i want to combine those records.

Plant Division Calmonth Keyfigure1 Keyfigure2

US1 90 12/2009 1 2

US1 90 12/2009 1 3

I want it to look like:

US1 90 12/2009 2 5

IT1 is my first internal table and WA_IT1 is work area for my first internal table

IT2 is my second interbal table and WA_IT2 is work area for my second internal table

APPEND ls_target TO IT1.

sort IT1 by plant division calmonth.

CLEAR WA_IT2.

loop at IT1 INTO WA_IT1.

if wa_IT2 is initial.

WA_IT2 = WA_IT1.

****the first time the above code will execute because WA_IT2 will have nothing in it. The second time it will do the comparison which is as follows:

ELSE.

if WA_IT1-plant = WA_IT2-plant and

WA_IT1-division = WA_IT2-division and

WA_IT1-calmonth = WA_IT2-calmonth.

IF SY-SUBRC = 0

  • add key figures.

else.

append WA_IT2 to et_target.

ENDIF.

ENDIF.

endloop.

append WA_IT2 to et_target.