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.
:?:
0
Comments
Type conversion is not possible because one of the operators contain an invalid type
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.
Did you check the content of strformula via debugger or a message?
thanks
let me try this
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]
](*,)
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???
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!
Thanks had not thought of that functionality in codeunit 8
:whistle: