Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

String of arithmetic expression - How to process it?

Former Member
0 Likes
1,043

Hi All,

I have a formula which I need to calculate. This formula is contained in a string, viz. something like :

LV_FORMULA = 'X + Y - 15*Z + 36'.

I have replaced the variables with values, so that LV_FORMULA is now something like :

LV_FORMULA = '10 + 15 - 15*12 + 36'

Now, LV_FORMULA is of type c. How can I find the value of this expression?

Hi All,

I have a formula which I need to calculate. This formula is contained in a string, viz. something like :

LV_FORMULA = 'X + Y - 15*Z + 36'.

I have replaced the variables with values, so that LV_FORMULA is now something like :

LV_FORMULA = '10 + 15 - 15*12 + 36'

Now, LV_FORMULA is of type c. How can I find the value of this expression?

4 REPLIES 4
Read only

andreas_mann3
Active Contributor
0 Likes
804

Hi,

you've to use dynamic programming

-> look for dyn. subroutine pool

http://help.sap.com/saphelp_470/helpdata/en/9f/db999535c111d1829f0000e829fbfe/frameset.htm

A.

Message was edited by:

Andreas Mann

Read only

Former Member
0 Likes
804

Hi

Declare LV_FORMULA as Type I field and use

LV_FORMULA = 10 + 15 - 15 * 12 + 36 .

the equation will be executed as per the order of preference of the operators

( +, -, *).

reward if useful

regards,

ANJI

Read only

Former Member
0 Likes
804

try this

write : (LV_FORMULA).

Read only

0 Likes
804

data LV_FORMULA(10) type C.

LV_FORMULA = 10 + 15 - 15 * 12 + 36.

write lv_formula. (Contains the Value)..

regards,

santosh