2008 Jan 12 5:19 AM
Hello Gurus,
A text file has data is in the following manner
I have read the file and all properly the only problem
here is summing up the data so below is how my data looks.
Please make a note this is not stored in DDIC database table it will be read in an Internal table
Also Col3 is not a integer so I cannot use COLLECT
Please suggest a way out to handle this tricky part.
I don;t thik At New On change will work please try this program using the same test data given below , please send me the abap code if you are able to crack this nut.
Col1 Col2 Col3
ABC A 1
ABC A 2
ABC B 3
BBC A 4
BBC A 5
I want to Sum up COL3 by grouping COL1 and COL2
Output will be
ABC A 3 ( 1+ 2)
ABC B 3
BBC A 9 ( 4 + 5 )
Please let me know I tired many logic but nothing seems to be working.. your help is greatly apprecaited .
Points guranteeed !!
Reagrds,
Aryan
Hello Gurus,
A text file has data is in the following manner
I have read the file and all properly the only problem
here is summing up the data so below is how my data looks.
Please make a note this is not stored in DDIC database table it will be read in an Internal table
Also Col3 is not a integer so I cannot use COLLECT
Please suggest a way out to handle this tricky part.
I don;t thik At New On change will work please try this program using the same test data given below , please send me the abap code if you are able to crack this nut.
Col1 Col2 Col3
ABC A 1
ABC A 2
ABC B 3
BBC A 4
BBC A 5
I want to Sum up COL3 by grouping COL1 and COL2
Output will be
ABC A 3 ( 1+ 2)
ABC B 3
BBC A 9 ( 4 + 5 )
Please let me know I tired many logic but nothing seems to be working.. your help is greatly apprecaited .
Points guranteeed !!
Reagrds,
Aryan
2008 Jan 12 6:59 AM
hi,
data:
begin of fs_temp,
f1(3) type c,
f2 type c,
f3(2) type n,
end of fs_temp.
data:
w_t1(3) type c,
w_t2,
w_sum type i.
data:
t_temp like standard table of fs_temp.
fs_temp-f1 = 'ABC'.
fs_temp-f2 = 'A'.
fs_temp-f3 = '1'.
append fs_temp to t_temp.
fs_temp-f1 = 'ABC'.
fs_temp-f2 = 'A'.
fs_temp-f3 = '2'.
append fs_temp to t_temp.
fs_temp-f1 = 'ABC'.
fs_temp-f2 = 'B'.
fs_temp-f3 = '3'.
append fs_temp to t_temp.
fs_temp-f1 = 'BBC'.
fs_temp-f2 = 'A'.
fs_temp-f3 = '4'.
append fs_temp to t_temp.
fs_temp-f1 = 'BBC'.
fs_temp-f2 = 'A'.
fs_temp-f3 = '5'.
append fs_temp to t_temp.
loop at t_temp into fs_temp.
at new f2.
loop at t_temp into fs_temp where f1 eq fs_temp-f1 and f2 eq fs_temp-f2.
w_sum = w_sum + fs_temp-f3.
w_t1 = fs_temp-f1.
w_t2 = fs_temp-f2.
endloop.
endat.
if w_sum is not initial.
write: / w_t1, w_t2, w_sum.
endif.
clear: w_t1, w_t2, w_sum.
endloop.
this is code wht u asked plzz reward if it is useful...
for any further quiries u can contact me on [email protected]
2008 Jan 14 5:35 AM
Hi,
I changed above code at summing.You will get result in table t_tmp.
loop at t_temp into fs_temp.
at last f2.
t_tmp-f1 = fs_temp-f1.
t_tmp-f2 = fs_temp-f2.
t_tmp-f3 = w_sum.
clear w_sum
endat.
w_sum = w_sum + fs_temp-f3.
endloop.
L.Velu