06-28-2007 12:53 PM
Hello,
I am wondering, if it might be possible to calculate the result of a formula stored in an string.
Two quick examples:
1.) The text in the formula-string might be: "2 * 2 + 2"
2.) The text in the formula-string might be: "( 2 + 2 * ( 2 + 2 ) )"
The first example can be solved by splitting the elements and calculate the result with some if-else-endif statements...this will just work, because the multiplication is located before the addition.
Such a simple (dumb) logic won't work for the second one, because things must be calculated in a different order to get the right result.
Is there a abap-functions that is able to convert such strings into "real" formulas or - even better - anything that passes the result back to me?
I was able to solve the issue within Excel by using the "evaluate" function...
Thanks in advance,
Chris
06-28-2007 1:34 PM
Hi,
Actually there is a function module for your purpose:
CS_QU_EVALUATE_FORMULA
send the formula without brackets and set the field I_ROMEI.
I tried to run it from se37, it worked.
Revert back in case of questions,
Reward if this helps you,
Regards,
Sooness.
06-28-2007 1:34 PM
Hi,
Actually there is a function module for your purpose:
CS_QU_EVALUATE_FORMULA
send the formula without brackets and set the field I_ROMEI.
I tried to run it from se37, it worked.
Revert back in case of questions,
Reward if this helps you,
Regards,
Sooness.
06-28-2007 1:37 PM
Hi,
Sorry , I meant :
send the formula without qquotes(") and set the field I_ROMEI.
I tried to run it from se37, it worked.
Regards,
Sooness
06-28-2007 1:46 PM
Ok, that FM seems to work - unfortunately the FM does not exist in BW.
I will try to copy and paste it into an own FM.
@all:
Are there more solutions?
Meanwhile I tired to solve the issue by using a temp. generated program. Works fine, but seem to be slow...
06-28-2007 2:06 PM
While copy'n'pasting things form R3 to BW I saw, that the named FM used another FM called EVAL_FORMULA.
The last one (EVAL...) is also available in BW - therefore I can use this one. It works perfect...
Thanks,
Chris