› Dynamics NAV › Procedure to display the Amount in Words in a report of Microsoft Dynamics NAV
Procedure to display the Amount in Words in a report of Microsoft Dynamics NAV
In this article, I will be explaining the procedure to display amount in words in a report of Microsoft Dynamics NAV.
Microsoft Dynamics NAV 2016
Declare the following variables in C/AL Globals:
- ‘RepCheck’ is a variable of DataType ‘Report’ and Subtype ‘Check’ which is Report 1401.
- ‘NoText’ is a variable of DataType ‘Text’ with Dimensions Value as 2 which is set by navigating to the properties of the ‘NoText’ variable.
- ‘AmountInWords’ is a variable of DataType ‘Text’ which will store the final result of the amount in words.
Now in my custom purchase order report, I want to display the Amount to Vendor in Words.
So in the Purchase Header – OnAfterGetRecord() trigger, I have put the following code:
I have declared a variable ‘AmountVendor’ of DataType ‘Decimal’ in which I will be storing the ‘Amount to Vendor’. I have rounded off the Amount to 2 decimal places.
AmountVendor:= ROUND("Purchase Header"."Amount to Vendor",0.01);
Now add the following code to display the Amount in Words:
RepCheck.InitTextVariable; RepCheck.FormatNoText(NoText,AmountVendor,"Purchase Header"."Currency Code"); AmountInWords:=NoText;
So the complete code looks like below:
Now get the variable ‘AmountInWords’ under the DataSource ‘Purchase Header’ in the report and display it in the design layout of the report.
After saving and running the report the Amount to Vendor will be displayed in Words as shown below:
Thus using the above procedure and the Report 1401 i.e. ‘Check’ report, the amount in words can be easily displayed in any report of Microsoft Dynamics NAV 2016.
Liked it? Share it.