How to remove Decimal point in decimal field?

Aravindh_Navision
Member Posts: 258
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:
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.
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.
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.
0
Answers
-
dec := 500.23; integerpart := format(dec,0,'<Integer,12><Filler Character,0>'); decimalpart := format(dec,0,'<Decimals,4><Filler Character,0>'); decimalpart := delchr(decimalpart,'=',','); message(integerpart + decimalpart);
It's raw and hardcoded, but you can elaborate it a bit (take a look at format property in the online help)0 -
Aravindh_Navision wrote: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.
You can try with :VATNetAmount := 54321.78; VATNetAmountNoDec := ROUND(VATNetAmount,1,'<'); VATNetAmountDecimals := (VATNetAmount-VATNetAmountNoDec)*1000; strVATNetAmount2 := FORMAT(VATNetAmountNoDec, 0, '<Precision,0:0><Standard Format,2>')+ FORMAT(VATNetAmountDecimals, 0, '<Precision,0:0><Standard Format,2>'); strVATNetAmount2 := '000000000000000'+DELCHR(strVATNetAmount2); strVATNetAmount2 := COPYSTR(strVATNetAmount2,STRLEN(strVATNetAmount2)-14,15);
0 -
Hi Joseph_Jordi/Belias,
Thanks a lot for your response. Both the approach are working.\:D/
Aravindh.0 -
What is wrong with this code?
VATNetAmount := ROUND(VATNetAmount,0.001) *1000; strVATNetAmount := FORMAT(VATNetAmount,0,'<Integer,12><Filler Character,0>');
Why so long code for such a easy task? ;-)0 -
kine wrote:What is wrong with this code?
VATNetAmount := ROUND(VATNetAmount,0.001) *1000; strVATNetAmount := FORMAT(VATNetAmount,0,'<Integer,12><Filler Character,0>');
Why so long code for such a easy task? ;-)
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 :-k0
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