Application Development 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: 

Dynamic Computation / Formula

Former Member
0 Kudos

Hi experts,

I want to know is it possible dynamic compute in ABAP.

Ex:

p_amt = computation

where computation = 1000 / 0.12

this is same logic with dynamic sql where in you have the option to put the table and condition dynamically. thanks

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Yes that is definitely possible.


if condition1 = 'cond1'.
   computation = 1000 / 10.
else.
   computation = 200.
endif.

data: query type string.

concatenate 'P_AMT =' (computation) into query. 

select * from <tab1> into <itab>
   where (query).

Hope this helps,

Regards,

Kiran

2 REPLIES 2

Former Member
0 Kudos

Hi,

Yes that is definitely possible.


if condition1 = 'cond1'.
   computation = 1000 / 10.
else.
   computation = 200.
endif.

data: query type string.

concatenate 'P_AMT =' (computation) into query. 

select * from <tab1> into <itab>
   where (query).

Hope this helps,

Regards,

Kiran

0 Kudos

Hi Kiran thanks for reply but i am not using the dynamic computation in sql, the reason i am doing these because the computation will just be fetch in maintenance table and i'll just replacing the value please see some sample code:

data: c_val(20) type c value 'amount / 0.12',

p_amt(16) type p decimals 2,

p_amt1(16) type p decimals 2 value '1000'.

data: command type string,

com1(16) type p.

concatenate 'p_amt1' '/' '0.12'

into command separated by space.

compute p_amt = (command). "--> unable to interpret expression (command).