03-22-2018 9:01 AM
Hi Experts
I have written cds view for budget report using BPJA & COSP tables.
So far everything is working as expected until last step where I encounter a weird behavior which I don't understand.
Final formula I am using to calculate the available budget is as below :
Budget(BPJA value) - Spend(COSP) = Available.
Please point me to possible cause of this issue.
06-02-2020 11:26 AM
This is my personal observation, I noticed that the value you might see in Spend(COSP) in the CDS output might show as '0.00', but in general it would be either initial or null.
In order to avoid such situation, you need to check the value first and then perform the arithmetic operations:
case
when ( ( Spend(COSP) is initial or Spend(COSP) is null )
then Budget(BPJA value)
else
Budget(BPJA value) - Spend(COSP)
end as Available
You can also use the COALESCE function:
COALESCE((Budget(BPJA value) - Spend(COSP)), Budget(BPJA value)) as Available