‎2009 May 19 12:25 PM
Hi Experts
I have one dynamic internal table in this i have to do some calcultaions.
dynamic inertnal table fields
quanity
c010
c020
c030
c040
c050
--
--
--
**********
i want to caluclate like for all the records in the internla table
quantity * c010
quantity * c020
quantity * c030
-
***
is it possible, how can it be done.
Thanks
Farooq
‎2009 May 19 12:37 PM
Hi ,
Try like this
1 ) 1st calculate the number of records in that internal table
2)
Do i_values_count times.
clear var1.
Var1 = quantity * <fs>-field1.
append var1 to i_itab2.
enddo.i_values_count is your total count in internal table
var1 for which your calculated value will be moved
i_itab2 which collects all the calculated sum
Regards
Sudhe
‎2009 May 19 12:49 PM
Hi,
Thanks for responce.
but here the problem is field names are dynamic.
fields names are not fixed. it may change
***
Quantiy
c010
c050
c070
c100
‎2009 May 19 12:40 PM
You can do it with field symbols
loop at itab assigning <fs>.
<fs1> = <fs>-quantity * <fs>-c010.
‎2009 May 19 12:42 PM
Hi..
Try building the logic with:
ASSIGN COMPONENT sy-index OF STRUCTURE <> TO <>. or a similar variant
Regards,
Arun
‎2009 May 19 12:45 PM
This is more or less not working code, but shows how to achieve that:
loop at itab assigning <p>.
do 5 times.
cinx = sy-index.
shift cinx left by 1 places.
overlay cinx with '000'.
concatenate '<p>-c' cinx into varname.
assign <fs> to varname.
<fs> = <fs> * qty.
enddo.
endloop.
cinx should be a c var in length 3, <p> a fieldsymbol with linetype of your table, and <fs> a field symbol type to your columns. This will upodate c010, c020, c030, c040 and c050. You have to modify the do statements to fit your needs.