10-09-2008 10:35 PM
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.
10-09-2008 10:49 PM
Hi All,
This code solved my req.
If zsdcoop-cmponum is initial.
zcmponum = salesdocument.
Update zsdcoop
set cmponum = zcmponum
where kunnr = zsdcoop-kunnr and pfnum = zsdcoop-pfnum.
elseif zsdcoop-cmponum2 is initial.
zcmponum2 = salesdocument.
Update zsdcoop
set cmponum2 = zcmponum2
where kunnr = zsdcoop-kunnr and pfnum = zsdcoop-pfnum.
elseif zsdcoop-cmponum3 is initial.
zcmponum3 = salesdocument.
Update zsdcoop
set cmponum3 = zcmponum3
where kunnr = zsdcoop-kunnr and pfnum = zsdcoop-pfnum.
elseif zsdcoop-cmponum4 is initial.
zcmponum4 = salesdocument.
Update zsdcoop
set cmponum4 = zcmponum4
where kunnr = zsdcoop-kunnr and pfnum = zsdcoop-pfnum.
endif.
Thanks,
Veni.
10-09-2008 10:49 PM
Instead of ELSEIF, use the separate IF... ENDIF.
Try like:
If zsdcoop-cmponum1 is initial.
zcmponum1 = salesdocument.
endif.
if zsdcoop-cmponum2 is initial.
zcmponum2 = salesdocument.
endif.
if zsdcoop-cmponum3 is initial.
zcmponum3 = salesdocument.
endif.
if zsdcoop-cmponum4 is initial.
zcmponum4 = salesdocument.
endif.
Regards,
Naimesh Patel
10-09-2008 11:08 PM
Hi Naimesh,
Initially cmponum1, cmponum2, cmponum3, cmponum4 all are initial. If I do not put Elseif it is updating all of them with one CM1 number.
Thanks,
Veni.