‎2006 Dec 08 12:15 PM
Hi all.
does anyone know any function or class that calculates math expressions in ABAP (such as (210+(53)/2) )?
Or, if you don't, can you tell me if there is any standard class to handle stacks, so I can build my own expression calculator?
Thanks in advance.
Hermes.
points will be rewarded.
‎2006 Dec 08 12:21 PM
Hi ,
Here is a sample code
data: it type i value 4 ,
it_2 type i value 2.
data : it_3 type i.
start-of-selection.
it_3 = ( it * it_2 + ( ( it * it_2 ) / it_2 ) ).
write: it_3.
just rem to keep a space after ever open bracket and before every close bracket.
Reagrds
aRUN
‎2006 Dec 08 12:21 PM
Hi ,
Here is a sample code
data: it type i value 4 ,
it_2 type i value 2.
data : it_3 type i.
start-of-selection.
it_3 = ( it * it_2 + ( ( it * it_2 ) / it_2 ) ).
write: it_3.
just rem to keep a space after ever open bracket and before every close bracket.
Reagrds
aRUN
‎2006 Dec 08 12:28 PM
Thank you very much, Arun.
Sometimes the answer is way simpler than we are looking for...
‎2006 Dec 08 12:30 PM
u can do small tasks like math caluclations using macros.
eg:
declare ur macro 'calc', like this.
suppose ur task is to add var1 and var2 into var3.
define calc.
&3 = &1 + &2.
end-of-definition.
Now u can call the macro and pass the variables, where ever required in the code, like this.
calc var1 var2 var3.
now var3 will have sum of var1 and var2.
But be careful some people do not accept macros for performance issue.
Still as a fact of time, I have been using macros for various purposes and never had problem. If there is a concern not to use a macro, best other option is to build a FORM for ur task and call it using PERFORM.
Regards,
Suresh