Symptom
- In Cloud BAdI SD_APM_SET_APPROVAL_REASON or BAdI SD_BIL_APM_SET_APPROVAL_REASON, the field TOTALNETAMOUNT is compared with a value like 50000 which is the net value shown in Fiori app like "Manage Sales orders" or "Manage Preliminary Billing Documents". But the check seems not working.
Environment
- Sales
- SAP S/4HANA Cloud Public Edition
Reproducing the Issue
- Open app "Manage sales orders".
- Display the sales order with currency TWD. Check the net value. It doesn't have decimal places.
- Create an implementation of BADI SD_APM_SET_APPROVAL_REASON in app "Custom field and logic".
- Write a check like the following:
If salesdocument-totalnetamount GT 50000 .
salesdocapprovalreason = 'Z000'.
endif. - The condition in the IF statement fails. If a trace is performed, you'll see the value of salesdocument-totalnetamount is 500.00 instead of 50000.
Cause
- The amount (data type CURR), like VBAK-NETWR and BSEG-WRBTR, is always stored in database tables with two decimal places.
- Currencies which have no decimal places are stored in database tables with decimal places.
- In Cloud BAdI SD_APM_SET_APPROVAL_REASON, when comparing the field SALESDOCUMENT-TOTALNETAMOUNT with the value displayed in app, the value is divided by 100 if currency doesn't have decimal places, like JPY, TWD etc.
- In Cloud BAdI SD_BIL_APM_SET_APPROVAL_REASON, when comparing the field billingprocdocument-totalnetamount with the value displayed in app, the value is divided by 100 if currency doesn't have decimal places, like JPY, TWD etc.
Resolution
Since currency TWD has zero decimal places, internally when saving to database the system divides the value by 100 so that it has 2 decimal places. So when comparing the value in your BADI implementation you need to take this into account.The IF statement should be written like "If salesdocument-totalnetamount GT 500.00 ."
See Also
Similar logic in purchasing is explained in hte following KBA:
1679279 - Wrong decimals places displayed for price fields
Other notes about currency codes:
Keywords
currency, decimal place, JPY, TWD, TOTALNETAMOUNT, SALESDOCUMENT, VBAK-NETWR, CURR, SD_BIL_APM_SET_APPROVAL_REASON, SD_APM_SET_APPROVAL_REASON, preliminary billing documents, net value, approval, workflow , KBA , SD-SLS-QUT , Inquiries / Quotations , SD-SLS , Sales , SD-SLS-QUT-2CL , Inquiries / Quotations (Public Cloud) , SD-FIO-BIL , Fiori UIs for Billing , Problem