2006 Apr 24 11:21 AM
I need to get the sum of the amount according the G/L Account number from BSEG.
In BSEG table
G/L Account Amount
111111111 10
111111111 20
But in my report i need sum for that G/L Account number from bseg.
Out put
G/L Account Amount
111111111 30
I used the below coding but i getting
tables : bseg.
select-options : s_hknot for bseg-hkont.
data : begin of itab occurs 0.
include structure bseg.
data : end of itab.
select * from bseg into corresponding fields of table itab.
sort itab by hkont.
write : / 'G/L Acnt', 'DOCNUMBER', 'AMOUNT'.
loop at itab.
at NEW HKONT.
write : / itab-hkont.
endat.
at END OF HKONT.
sum.
write : itab-dmbtr.
endat.
endloop.
OUTPUT
G/L Account Amount
111111111 10
111111111 20
Please help me out.
Thanks,
Pavan.
I need to get the sum of the amount according the G/L Account number from BSEG.
In BSEG table
G/L Account Amount
111111111 10
111111111 20
But in my report i need sum for that G/L Account number from bseg.
Out put
G/L Account Amount
111111111 30
I used the below coding but i getting
tables : bseg.
select-options : s_hknot for bseg-hkont.
data : begin of itab occurs 0.
include structure bseg.
data : end of itab.
select * from bseg into corresponding fields of table itab.
sort itab by hkont.
write : / 'G/L Acnt', 'DOCNUMBER', 'AMOUNT'.
loop at itab.
at NEW HKONT.
write : / itab-hkont.
endat.
at END OF HKONT.
sum.
write : itab-dmbtr.
endat.
endloop.
OUTPUT
G/L Account Amount
111111111 10
111111111 20
Please help me out.
Thanks,
Pavan.
2006 Apr 24 11:24 AM
Hi,
Sorry for the previous wrong reply..
You can use Control break processing..
SUM.
Regards,
Tanveer.
Please mark helpful answers.
Message was edited by: Tanveer Shaikh
2006 Apr 24 11:26 AM
Hello,
Create an table like
begin of itab,
hkont like bseg-hkont,
dmbtr like bseg-dmbtr,
end of itab.
then,
loop at itab.
at NEW HKONT.
write : / itab-hkont.
endat.
at END OF HKONT.
sum.
write : itab-dmbtr.
endat.
endloop.
Regards,
Naimesh
2006 Apr 24 12:03 PM
Hi,
It is fine but
HKONT should be first field in ur internal table ( other wise it will not work )
to achieve this
make new internal table with 3 fields only
loop at ur table and insert 3 fields in new internal table that
1) HKONT
2) 'DOCNUMBER
3) Amount
in the same order
apply the same logic that ur currently using
Feel free to asq further question
Regards
2006 Apr 24 12:11 PM
Hi,
Select * From bseg - is not going to help in summing because company code, belnr are left to field SAKNR.
So it would be better two select only two fields from BSEG and then sort it by G/L account and then use AT NEW.
2006 Apr 24 3:25 PM
First of all, don't use BSEG if you are looking at GL accounts. Instead, use the GL index tables BSIS and BSAS. Secondly, all of the amounts in these tables are positive. You have to take into account the debit credit indicator SHKZG.
Rob
2006 Apr 24 3:28 PM
But if all you are interested in is the GL balances, you can use table GLT0 (GL totals).
Rob
2006 Apr 24 3:35 PM
Hi Pavan,
Try to use the below code.
Tables: BSEG.
Select-options: s_hknot for bseg-hkont.
Data: begin of itab occurs 0,
hkont type bseg-hkont,
dmbtr type bseg-dmbtr,
end of itab.
select hkont
dmbtr
from bseg
into table itab
where hkont in s_hkont.
sort itab by hkont.
loop at itab.
at end of hkont.
sum.
write:/ itab-hkont,
itab-dmbtr.
endat.
endloop.Thanks,
Sreekanth
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |