DATA TYPE CONVERSION

Kim
Member Posts: 85
Hi, Am having some trouble converting data types. am working on a payroll
where am supposed to use formulas. for example: strformula:='((([BPAY]/20)/8)*1.5)*[P003]';
Am holding the formula first on a Text Variable because the value of BPAY and P003 can vary from employee to
another.
Am stuck in trying to convert the text variable strFormula to Decimal so i can insert the formula to a decimal field.
any one got an idea how i can do this.
:?:
where am supposed to use formulas. for example: strformula:='((([BPAY]/20)/8)*1.5)*[P003]';
Am holding the formula first on a Text Variable because the value of BPAY and P003 can vary from employee to
another.
Am stuck in trying to convert the text variable strFormula to Decimal so i can insert the formula to a decimal field.
any one got an idea how i can do this.
:?:
0
Comments
-
What's the error message?0
-
Hi,
easier way is to change your code
strformula:='((([BPAY]/20)/8)*1.5)*[P003]';
to
strformula:='(((%1/20)/8)*1.5)*%2';
and then use
formula := STRSUBSTNO(strformula, BPAY, P003);
and then use EVALUATE function to obtain final result.0 -
lubost wrote:Hi,
easier way is to change your code
strformula:='((([BPAY]/20)/8)*1.5)*[P003]';
to
strformula:='(((%1/20)/8)*1.5)*%2';
and then use
formula := STRSUBSTNO(strformula, BPAY, P003);
and then use EVALUATE function to obtain final result.
if i try to use the EVALUATE function this way:
EVALUATE(finalformula,strformula);
finalformula is a decimal variable
am getting
an error [You cannot insert "(((100/20)/8)*1.5)*110"] in decimal]
](*,)0 -
May be someone who has customized or developed payroll system can assist.
Some values in payroll are as a result of calculation formulas provided for by the Revenue authorities
or any other body for example. VALUE:='(((BASICPAY/20)/8)*1.5)*NOOFHRS'
for my case i intent to handle them from setup since from previous experience they have proved to be
enough problems if done within the code.
Has anyone handled such kind of formulas and how did u go about it???0 -
Kim wrote:lubost wrote:Hi,
easier way is to change your code
strformula:='((([BPAY]/20)/8)*1.5)*[P003]';
to
strformula:='(((%1/20)/8)*1.5)*%2';
and then use
formula := STRSUBSTNO(strformula, BPAY, P003);
and then use EVALUATE function to obtain final result.
if i try to use the EVALUATE function this way:
EVALUATE(finalformula,strformula);
finalformula is a decimal variable
am getting
an error [You cannot insert "(((100/20)/8)*1.5)*110"] in decimal]
](*,)
The error is clear and your posts show that you may be lacking on basic knowledge of datatypes. You simply cannot put a string into a decimal field, period!0 -
Why are you trying to put the formula string into the decimal field? Wouldn't it be logical to put the result of the formula into it?0
-
OK so basically you are trying to develop a solution where calculations can be defined by users via formulas or expression. What you need is basically developing an expression evaluator - take a look at the EvaluateExpression function in Codeunit 8 and create something similar.0
-
Miklos Hollender wrote:OK so basically you are trying to develop a solution where calculations can be defined by users via formulas or expression. What you need is basically developing an expression evaluator - take a look at the EvaluateExpression function in Codeunit 8 and create something similar.
Thanks had not thought of that functionality in codeunit 8
:whistle: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