Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Problem with report and bkpf, bseg

Hi,

please can you help me with this code?

I have a problem.

When I enter input in S_CPUDT 03.09.2008 and in S_GSBER 02 I get desired output.

But when I enter 04.09.2008 and 07 for another document I dont get data from bseg, just from bkpf.

Also, when I enter in S_CPUDT 03.09.2008 - 04.09.2008 and in S_GSBER 02 - 07

I got data only from bkpf for both entries and no data at all from bseg??

Please have a look at this code...

I appreciate a lot..

tables: bkpf,bseg,bsid.

data: it_bkpf type table of bkpf with header line,

wa_bkpf type bkpf,

it_bseg type table of bseg with header line,

wa_bseg type bseg,

it_bsid type table of bsid with header line,

wa_bsid type bsid.

select-options: s_cpudt for bkpf-cpudt,

s_gsber for bseg-gsber.

select * from bkpf into table it_bkpf

where cpudt in s_cpudt.

select * from bseg into table it_bseg

for all entries in it_bkpf where

bukrs = it_bkpf-bukrs and

belnr = it_bkpf-belnr and

gjahr = it_bkpf-gjahr and

gsber in s_gsber.

select * from bsid into table it_bsid.

loop at it_bkpf into wa_bkpf.

clear it_bsid.

read table it_bsid with key belnr = wa_bkpf-belnr.

if it_bsid-xref1 is initial.

delete table it_bkpf from wa_bkpf.

endif.

endloop.

loop at it_bseg into wa_bseg.

clear it_bsid.

read table it_bsid with key belnr = wa_bkpf-belnr.

if it_bsid-xref1 is initial.

delete table it_bseg from wa_bseg.

endif.

endloop.

*write: / 'Zaglavlje'.

loop at it_bkpf into wa_bkpf.

write: wa_bkpf-cpudt, wa_bkpf-usnam.

endloop.

*skip 1.

*write: / 'Stavka'.

loop at it_bseg into wa_bseg.

write:/ wa_bseg-gsber, wa_bseg-belnr, wa_bseg-wrbtr.

endloop.

Also I want to add kna1-kunnr as output field in this report.

Thanks a lot

Tags:
replied

Hi Nihad,

You can use it_bsid internal table for displaying KUNNR,

loop at it_bkpf into wa_bkpf.

write: wa_bkpf-cpudt, wa_bkpf-usnam.

read table it_bsid with key bukrs = wa_bkpf-bukrs

belnr = wa_bkpf-belnr

gjahr = wa_bkpf-gjahr

cpudt = wa_bkpf-cpudt.

if sy-subrc = 0.

write: it_bsid-kunnr.

endif.

endloop.

*skip 1.

*write: / 'Stavka'.

loop at it_bseg into wa_bseg.

write:/ wa_bseg-gsber, wa_bseg-belnr, wa_bseg-wrbtr.

read table it_bsid with key bukrs = wa_bseg-bukrs

augbl = wa_bseg-augbl

gjahr = wa_bseg-gjahr

belnr = wa_bseg-belnr

buzei = wa_bseg-buzei.

if sy-subrc = 0.

write: it_bsid-kunnr.

endif.

endloop.

hope this helps

Thanks

Lakshman

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question