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

problem with dynamic calculations

Former Member
0 Likes
351

Hi friends,

 i got formula from PLMK-Formule1 table like 
C00010 * C00020 like that.

my ITAB contain values like 0010 --- 1.2
                            0020 --- 1.3
                            0030 --- space
so my reqirement is i want to read 0010 value from ITAB using formule C00010 like that 
and finally that calculated result populated in ITAB.
ie 0030 --- 1.56

2 REPLIES 2
Read only

Former Member
0 Likes
308

As per your definition the records in ITAB has values

0010, 0020 etc...in that case follow the below logic.

lformula -> C00010 * C00020.

condense lformula no-gap.

translate lformula with '*$+$-$/$'.

split lformula at '$' into lval1 lval2.

if lop CA '*/'.

lfval = 1.

else.

lfval = 0.

endif.

do 2 times.

if sy-index = 1.

lfield = lval1+2(4).

else.

lfield = lval2+2(4).

endif.

read table itab with key val = (lfield).

if sy-subrc = 0.

case lop. "Operator +, - , * and /.

when '*'.

lfval = itab-value * lfval.

when '/'.

lfval = itab-value / lfval.

when '+'.

lfval = itab-value + lfval.

when '-'.

lfval = itab-value - lfval.

endcase.

endif.

enddo.

move '0030' to itab-val.

move lfval to itab-value.

append itab.

Message was edited by: Anurag Bankley

Message was edited by: Anurag Bankley

Read only

Former Member
0 Likes
308

Hi Siva

Can you explain me what are the name fields for your ITAB that contain your data

Regards,

David