Hi Pals,
My requirement is I need to pad a decimal field with zeros to which the total length is 15. After the decimal point it should contain 3 digits.
Field/Variable details:VATNetAmount = Total of "VAT Base Amount" in Sales Invoice Line table.
strVATNetAmount = Code 20
For eg: If the decimal field (VATNetAmount) is 54321.78 means, I must get the output as
000000054321780. At the end of the decimal part it should display with 0 (zero) when it contains only 2 digits. Also I need to remove the decimal point.
Almost I achieved it by doing the following piece of code.
VATNetAmount := VATNetAmount + SIL_VAT."VAT Base Amount";
strVATNetAmount2 := PADSTR('',15 - STRLEN(FORMAT(ROUND(VATNetAmount,0.001), 0, '<Precision,3:3><Standard Format,2>')),'x') + FORMAT(VATNetAmount, 0,'<Precision,3:3><Standard Format,2>');
But I am getting the out put as XXXXXX54321.780. Here I need to remove the decimal point and and preceeded with zero at starting of the decimal field.
Can anyone help me out in achieving this?
Thanks,
Aravindh.
Answers
"Never memorize what you can easily find in a book".....Or Mibuso
My Blog
You can try with :
Thanks a lot for your response. Both the approach are working. \:D/
Aravindh.
Why so long code for such a easy task? ;-)
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
But i was wondering...it's very strange that the the <Decimals> part of the format function does not have a way to remove the comma...just like we do with <Integer>/<Integer thousand> ...well, it's easy solvable with your code, but it's curious that we can't obtain just the decimal part with one function only :-k
"Never memorize what you can easily find in a book".....Or Mibuso
My Blog