Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

FI Report

Former Member
0 Likes
993

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.

7 REPLIES 7
Read only

Former Member
0 Likes
955

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

Read only

naimesh_patel
Active Contributor
0 Likes
955

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

Read only

Former Member
0 Likes
955

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

Read only

Former Member
0 Likes
955

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.

Read only

Former Member
0 Likes
955

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

Read only

0 Likes
955

But if all you are interested in is the GL balances, you can use table GLT0 (GL totals).

Rob

Read only

sreekanthgo
Contributor
0 Likes
955

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