‎2007 Jul 11 9:36 AM
Dear all,
does ABAP provide something like a formula parser to calculate for example:
2*(A+B)/(C-D) correctly?
Best regards,
Christoph Aschauer
‎2007 Jul 11 9:46 AM
hi,
When you combine arithmetic expressions, ABAP performs the calculation from left to right, with one exception: Powers are calculates from right to left. So <n> ** <m> ** <p> is the same as <n> ** ( <m> ** <p> ), not ( <n> ** <m> ) ** <p>.
DATA: pack TYPE p DECIMALS 0.
pack = 1 / 3 * 3.
WRITE pack.
ans: 1
i think it follows BODMAS rule
thanks
jaideep
*reward points if useful
‎2007 Jul 11 10:00 AM
Sorry guys,
I did not post the issue clearly.
I get a formula as a string: 2*(A + B)/(C+D).
the values of A ... D are stored somewhere.
I like to have the possibility to calculate the value dynamically, but like to avoid "GENERATE SUBROUTINE POOL.
Christoph Aschauer
‎2007 Jul 16 8:41 AM
Hi all,
I solved the problems as follows:
- limitation of 36 subroutines: SUBMIT program. (this program generates the generic subroutine pools (communication via DB or shared objects possible)
- limitation of subroutine pool line ( 255 chars ).
also this is an executable calculation:
calc =
(
3
+
7
)
*
2
.
So no longer line restriction when having a very long formula string to be generically processed.
Christoph
‎2007 Jul 16 8:44 AM
solved the problem on my own. Please see the comment above or feel free to ask.
Christoph