Padding in Dataport

Aravindh_Navision
Member Posts: 258
Hi Friends,
I am designing a dataport where I need to pad the Amount field (in output text file) taking from Vendor Ledger Entry with zeros in the front. The fixed length of Amount field is 18.
Eg: 4325.80 should be displayed as 000000000004325.80
How to do this? I defined Amount in dataport fields and I tried with the following piece of coding where AmountPay is text field.
AmountPay := FORMAT(Amount);
AmountPay := PADSTR('',18 - STRLEN(AmountPay),'0') + FORMAT(AmountPay);
message('%1', AmountPay);
I am getting the zero value as output like "000000000000000000', but my expected output is 000000000004325.80 in text file. Please anyone point out me where I am going wrong.
Thanks and Regards,
Aravindh
I am designing a dataport where I need to pad the Amount field (in output text file) taking from Vendor Ledger Entry with zeros in the front. The fixed length of Amount field is 18.
Eg: 4325.80 should be displayed as 000000000004325.80
How to do this? I defined Amount in dataport fields and I tried with the following piece of coding where AmountPay is text field.
AmountPay := FORMAT(Amount);
AmountPay := PADSTR('',18 - STRLEN(AmountPay),'0') + FORMAT(AmountPay);
message('%1', AmountPay);
I am getting the zero value as output like "000000000000000000', but my expected output is 000000000004325.80 in text file. Please anyone point out me where I am going wrong.
Thanks and Regards,
Aravindh
0
Answers
-
I tries like this
AmountPay := FORMAT(4325.80); AmountPay := PADSTR('',18 - STRLEN(AmountPay),'0') + FORMAT(AmountPay); message('%1', AmountPay);
and output is
Please check the value of Amount in your case..0 -
Hi Mohana,
Thanks a lot for your response. It displays the value in normal condition, but I need to get in text file in dataport.
Thanks,
Aravindh0 -
Hi,
I think you can try this:-
AmountPay := FORMAT(Amount,0,'<Precision,2:2><Standard Format,0>');
AmountPay2 := PADSTR('',18 - STRLEN(AmountPay),'0') + FORMAT(AmountPay);
message('%1', AmountPay2);
But declare another global variable for AmountPay2 and both of them datatype = Code, so the decimal places .80 will be show.
Thanks.0 -
Hi Xin,
In which trigger I need to write this code? Because I am getting zeros as output...
Thanks,
Aravindh0 -
Hi,
You can put on OnBeforeExportRecord() & for the Dataport Fields, put variable AmountPay2 instead of Amount.
Also make sure you've write the code CalcFields(Amount) (if amount is flow field) before the code.
Thanks.0 -
Hi Xin,
Great.. It works perfectly.
Thanks a lot,
Aravindh0 -
Hi,
You are welcome.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions