Skip to Content
0
Former Member
Aug 17, 2005 at 03:32 PM

help in the abap code

17 Views

hi folks,

In this piece of code I have to add the credits and debits for each adjustment type like 'DZ',

'ZA','ZW' separately and store it (like in zappliedcredits1, zappliedcredits2, zappliedcredits3) as I am looping the data,

<b>The question I am facing is, as I loop through patcloseditemsitab there is a possiblity that it loops through the same adjustment type more than once for a given set of data and at this situation it updates the values in 'zzdebitxx' and 'zzcreditxx' resulting in the wrong value in the overallbalance. To avoid that I used 'clear zzdebitxx' and 'clear zzcreditxx' after the loop but then the value in 'zappliedcredits1' got updated with the wrong value.</b>

I hope I have explained my issue and everytime I check each of these adjustment types it has to get updated properly in the given scenario how can i do this?

It would be really helpful.

The code goes like this...

Insert lines of patopenitemsitab into table

patcloseditemsitab.

loop at patcloseditemsitab into wa_payadjustment.

case wa_payadjustment-blart.

when 'DZ'.

if wa_payadjustment-wrbtr = ' '.

continue.

elseif wa_payadjustment-shkzg = 'H'.

add wa_payadjustment-wrbtr to zzcredit1.

elseif wa_payadjustment-shkzg = 'S'.

add wa_payadjustment-wrbtr to zzdebit1.

endif.

ctext2 = 'CUSTOMER PAYMENT'.

zappliedcredits1 = zzdebit1 - zzcredit1.

when 'ZA'.

if wa_payadjustment-wrbtr = ' '.

continue.

elseif wa_payadjustment-shkzg = 'H'.

add wa_payadjustment-wrbtr to zpayment.

add wa_payadjustment-wrbtr to zzcredit1.

elseif wa_payadjustment-shkzg = 'S'.

add wa_payadjustment-wrbtr to zpayment.

add wa_payadjustment-wrbtr to zzdebit1.

endif.

ctext2 = 'CHECK BY PHONE'.

zappliedcredits1 = zzdebit1 - zzcredit1.

.

.

.

.

.

when 'ZW'.

if wa_payadjustment-wrbtr = ' '.

continue.

elseif wa_payadjustment-shkzg = 'H'.

add wa_payadjustment-wrbtr to zzcredit2.

elseif wa_payadjustment-shkzg = 'S'.

add wa_payadjustment-wrbtr to zzdebit2.

endif.

ctext2 = 'PAYMENT'.

zappliedcredits3 = zzdebit3 - zzcredit3.

when others.

continue.

endcase.

if sy-subrc = 0.

ztotalappliedcredits = zappliedcredits1 + zappliedcredits2 ........ zappliedcredits3.

endloop.

Thanks

Santhosh