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
0
Answers
and output is
Please check the value of Amount in your case..
-Mohana
http://mohana-dynamicsnav.blogspot.in/
https://www.facebook.com/MohanaDynamicsNav
Thanks a lot for your response. It displays the value in normal condition, but I need to get in text file in dataport.
Thanks,
Aravindh
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.
In which trigger I need to write this code? Because I am getting zeros as output...
Thanks,
Aravindh
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.
Great.. It works perfectly.
Thanks a lot,
Aravindh
You are welcome.