2009 May 26 4:05 PM
Hi All,
I have internal table like this.
Field1 Field2 Field3
a 1 5.000
b 1 5.000
b 1 3.000
b 1 10.000
b 1 10.000
b 2 15.000
c 1 10.000
c 2 10.000
Now i have to sum field3 based on field1 and field2 i.e My Output will be like this.
Field1 Field2 Field3
a 1 5.000
b 1 28.000
b 2 15.000
c 1 10.000
c 2 10.000.
Please suggest some solution as I guess this output is not possible thru At end of or at new.
We can get the desired output using on change of but the summation is not possible thru on change of.
Thanks and regards
Nazmul Azad
2009 May 26 5:12 PM
Hi,
Please refer the below program:
data : var(20) type c,
var1(20) type c,
var2(20) type c.
data : begin of itab occurs 0,
f1 type c,
f2 type i,
f3 type i,
end of itab.
itab-f1 = 'a'.
itab-f2 = '1'.
itab-f3 = '5'.
append itab.
clear itab.
itab-f1 = 'b'.
itab-f2 = '1'.
itab-f3 = '5'.
append itab.
clear itab.
itab-f1 = 'b'.
itab-f2 = '1'.
itab-f3 = '3'.
append itab.
clear itab.
itab-f1 = 'b'.
itab-f2 = '1'.
itab-f3 = '10'.
append itab.
clear itab.
itab-f1 = 'b'.
itab-f2 = '2'.
itab-f3 = '15'.
append itab.
clear itab.
itab-f1 = 'c'.
itab-f2 = '1'.
itab-f3 = '10'.
append itab.
clear itab.
itab-f1 = 'c'.
itab-f2 = '2'.
itab-f3 = '10'.
append itab.
clear itab.
//Sorted based on field1 and field2 and used At new
sort itab by f1 f2.
loop at itab.
at new f2.
sum.
endat.
endloop.
Best Regards,
Sumana
Hi All,
I have internal table like this.
Field1 Field2 Field3
a 1 5.000
b 1 5.000
b 1 3.000
b 1 10.000
b 1 10.000
b 2 15.000
c 1 10.000
c 2 10.000
Now i have to sum field3 based on field1 and field2 i.e My Output will be like this.
Field1 Field2 Field3
a 1 5.000
b 1 28.000
b 2 15.000
c 1 10.000
c 2 10.000.
Please suggest some solution as I guess this output is not possible thru At end of or at new.
We can get the desired output using on change of but the summation is not possible thru on change of.
Thanks and regards
Nazmul Azad
2009 May 26 4:11 PM
2009 May 26 5:12 PM
Hi,
Please refer the below program:
data : var(20) type c,
var1(20) type c,
var2(20) type c.
data : begin of itab occurs 0,
f1 type c,
f2 type i,
f3 type i,
end of itab.
itab-f1 = 'a'.
itab-f2 = '1'.
itab-f3 = '5'.
append itab.
clear itab.
itab-f1 = 'b'.
itab-f2 = '1'.
itab-f3 = '5'.
append itab.
clear itab.
itab-f1 = 'b'.
itab-f2 = '1'.
itab-f3 = '3'.
append itab.
clear itab.
itab-f1 = 'b'.
itab-f2 = '1'.
itab-f3 = '10'.
append itab.
clear itab.
itab-f1 = 'b'.
itab-f2 = '2'.
itab-f3 = '15'.
append itab.
clear itab.
itab-f1 = 'c'.
itab-f2 = '1'.
itab-f3 = '10'.
append itab.
clear itab.
itab-f1 = 'c'.
itab-f2 = '2'.
itab-f3 = '10'.
append itab.
clear itab.
//Sorted based on field1 and field2 and used At new
sort itab by f1 f2.
loop at itab.
at new f2.
sum.
endat.
endloop.
Best Regards,
Sumana
2009 May 27 4:44 AM
2009 May 26 8:56 PM
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |