06-04-2008 11:27 PM
Hello,
I have an internal table with several fields in it including 2 character fields that contain amounts in them - F_OLD and F_NEW. I need to be able to add up the data in F_OLD and put it into a variable (I_OLD) and add up the data in F_NEW and put it into a variable (I_NEW). See an example of the data in the internal table here:
F_OLD and F_NEW are CHAR 254.
Record 1:
CHANGENR 2520026
TABKEY 010920000008300010
F_OLD 100
F_NEW 200
Record 2:
CHANGENR 2520026
TABKEY 010920000008300020
F_OLD 80
F_NEW 150
I want to have I_OLD = 100 + 80 and I_NEW = 200 + 150.
I don't think I can use COLLECT because not all the non-numeric fields will be the same. I don't think I can use SUM because it can only be used with numeric data types, and my data type here is CHAR.
Thanks in advance for your help,
Angela
06-04-2008 11:32 PM
what you can do is increase your internal table by 2 more fields (numerics) and move the contents of your CHAR fields to these. Then, perform your summations.
regards,
robert.
06-04-2008 11:32 PM
You want all the same CHANGENR to have a different variable?
You can use collect, but you would need to pass it to a second table with f_old and f_new as numeric types.
Or if you want the whole sum, just sum each pass of the table into the variable
06-04-2008 11:32 PM
what you can do is increase your internal table by 2 more fields (numerics) and move the contents of your CHAR fields to these. Then, perform your summations.
regards,
robert.