Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Need help with the following condition code

Hi All,

I am creating CreditMemo based on the open amount and I have option to create either up to 4 credit memo's or open amount is zero. When I create the CM initially then cmponum1 has to be updated in the table, for second CM cmponum2 has to be updated.

The created CM number comes out from the function as 'Salesdocument'.

The following code I wrote is working fine for CM1, if I have the CM2 then it is updating CMPONUM2 but update command is making CMPONUM1 as zero, so for CM3 as CM1 was updated as zero it is going to CMPONUM1 instead of CMPONUM3.

Can some one please help me with this code.

Thanks,

Veni.

DATA: zcmponum1 type zsdcoop-cmponum,

zcmponum2 type zsdcoop-cmponum,

zcmponum3 type zsdcoop-cmponum,

zcmponum4 type zsdcoop-cmponum.

If zsdcoop-cmponum1 is initial.

zcmponum1 = salesdocument.

elseif zsdcoop-cmponum2 is initial.

zcmponum2 = salesdocument.

elseif zsdcoop-cmponum3 is initial.

zcmponum3 = salesdocument.

elseif zsdcoop-cmponum4 is initial.

zcmponum4 = salesdocument.

endif.

Update zsdcoop

set

cmponum1 = zcmponum1

cmponum2 = zcmponum2

cmponum3 = zcmponum3

cmponum4 = zcmponum4

where kunnr = zsdcoop-kunnr and pfnum = zsdcoop-pfnum.

Tags:
Not what you were looking for? View more on this topic or Ask a question