09-15-2008 6:20 AM
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
09-15-2008 6:25 AM
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
09-15-2008 6:25 AM
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
09-15-2008 6:38 AM
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).