2008 Apr 17 7:00 AM
i have one internal table which is having no of records with key document no .for ex
docuno price qty
1 25 23
1 23 22
1 24 34
2 24 22
2 44 45
3 55 23
3 5 34
the result as follows
docuno price qty
1 72 79
2 68 67
3 60 57
how to do this ?
2008 Apr 17 7:22 AM
Hi,
Store the record
1 25 23
1 23 22
1 24 34
2 24 22
2 44 45
3 55 23
3 5 34
in an internal table say itab.
Now declare one more internal table having same structure of itab say itab1.
data: itab1 like itab occurs 0 with header line.
lopp at itab.
move-corresponding itab to itab1.
collect itab1.
clear itab1.
endloop.
now ur itab1 wil show like
docuno price qty
1 72 79
2 68 67
3 60 57
If it is helpfull pls reward pts.
Regards
Srimanta
sort itab by docno price qnty.
loop at itab.
collect itab.
endloop.
or
loop at itab.
at end of docno.
SUM.
endat.
endloop.
2008 Apr 17 7:04 AM
Hi,
Check this:
loop at itab.
IF sy-tabix = sy-index.
sum itab-2(field) and 3(field).
endif.
endloop.
Regards,
Shiva Kumar(Reward if helpful).
2008 Apr 17 7:07 AM
sort itab by docno price qnty.
loop at itab.
collect itab.
endloop.
or
loop at itab.
at end of docno.
SUM.
endat.
endloop.
2008 Apr 17 7:11 AM
use collect statement or use control break statement
http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb36d5358411d1829f0000e829fbfe/frameset.htm
2008 Apr 17 7:14 AM
data: begin of itab occurs 0,
docno(5) type c,
price type i,
qty type i,
end of itab.
data: begin of itab1 occurs 0,
docno(5) type c,
price type i,
qty type i,
end of itab1.
itab-docno = '1'.
itab-price = 20.
itab-qty = 10.
append itab.
clear itab.
itab-docno = '1'.
itab-price = 20.
itab-qty = 10.
append itab.
clear itab.
itab-docno = '1'.
itab-price = 20.
itab-qty = 10.
append itab.
clear itab.
itab-docno = '2'.
itab-price = 20.
itab-qty = 10.
append itab.
clear itab.
itab-docno = '2'.
itab-price = 20.
itab-qty = 10.
append itab.
clear itab.
itab-docno = '2'.
itab-price = 20.
itab-qty = 10.
append itab.
clear itab.
sort itab by docno.
loop at itab.
at end of docno.
sum.
itab1-docno = itab-docno.
itab1-price = itab-price.
itab1-qty = itab-price.
append itab1.
clear itab1.
endat.
endloop.
loop at itab1.
write:/ itab1-docno, 20 itab1-price, 40 itab1-qty.
clear itab1.
Reward if useful..............
2008 Apr 17 7:22 AM
Hi,
Store the record
1 25 23
1 23 22
1 24 34
2 24 22
2 44 45
3 55 23
3 5 34
in an internal table say itab.
Now declare one more internal table having same structure of itab say itab1.
data: itab1 like itab occurs 0 with header line.
lopp at itab.
move-corresponding itab to itab1.
collect itab1.
clear itab1.
endloop.
now ur itab1 wil show like
docuno price qty
1 72 79
2 68 67
3 60 57
If it is helpfull pls reward pts.
Regards
Srimanta
2008 Apr 17 7:46 AM
hai,
types: BEGIN OF tab_type,
dd(5) TYPE c,
END OF tab_type.
types: BEGIN OF tab,
d(1) TYPE c,
dd TYPE i,
END OF tab.
data: itab type standard table of tab_type with header line.
data: itabfinal type standard table of tab with header line.
itab-dd = '12523'.
append itab.
itab-dd = '12322'.
append itab.
itab-dd = '12434'.
append itab.
itab-dd = '22422'.
append itab.
itab-dd = '24445'.
append itab.
itab-dd = '35523'.
append itab.
itab-dd = '3534'.
append itab.
loop at itab.
itabfinal-d = itab-dd(1).
itabfinal-dd = itab-dd+1(4).
collect itabfinal.
endloop.
loop at itabfinal.
write 😕 itabfinal-d , itabfinal-dd.
endloop.
Thanks and Regards
Sarath p
| User | Count |
|---|---|
| 6 | |
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |