09-04-2008 9:45 AM
Hi,
I want to write out a simple report that returns me one field from BKPF and one from BSEG. When I execute this I got program termination, please help...Any idea what is wrong..
tables: bkpf,bseg.
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.
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
where gsber in s_gsber.
loop at it_bkpf into wa_bkpf.
data t_xref1 like bsid-xref1 value ''.
select xref1 into t_xref1 from bsid where
belnr = wa_bkpf-belnr.
if t_xref1 = ''.
delete table it_bkpf from wa_bkpf.
endif.
endselect.
endloop.
loop at it_bseg into wa_bseg.
data t1_xref1 like bsid-xref1 value ''.
select xref1 into t1_xref1 from bsid where
belnr = wa_bseg-belnr.
if t1_xref1 = ''.
delete table it_bseg from wa_bseg.
endif.
endselect.
endloop.
Thanks a lot for any help...
Nihad
09-04-2008 10:57 AM
I want to take fields from bkpf and bseg only where bsid-xref1 is not empty....Any helpfull code???
09-04-2008 9:47 AM
can u please tell exactly at which line it is giving dump?
Regards,
Aparna Gaikwad
09-04-2008 9:51 AM
It gives dump before first loop
loop at it_bkpf into wa_bkpf.
Nihad
09-04-2008 9:51 AM
HI DUDE,
tables: bkpf,bseg.
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.
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
where gsber in s_gsber.
loop at it_bkpf into wa_bkpf.
data t_xref1 like bsid-xref1 value ''.
THE ERROR IS IN THE BELOW LINE,wRITE SELECT SINGLE
select xref1 into t_xref1 from bsid where
belnr = wa_bkpf-belnr.
if t_xref1 = ''.
delete table it_bkpf from wa_bkpf.
endif.
endselect.
endloop.
loop at it_bseg into wa_bseg.
data t1_xref1 like bsid-xref1 value ''.
select xref1 into t1_xref1 from bsid where
belnr = wa_bseg-belnr.
if t1_xref1 = ''.
delete table it_bseg from wa_bseg.
endif.
endselect.
endloop.
09-04-2008 9:53 AM
Hello
Time Out Dump ?
select * from bkpf into table it_bkpf
where cpudt in s_cpudt.
select * from bseg into table it_bseg
where gsber in s_gsber.
This queries are work very slow, because not uses indexes and key-fields.
Add some additional conditions into queries.
09-04-2008 9:55 AM
Hi,
Select the entries from BSEG table based on the entries in
it_bkpf table entries.
Regards,
Raju.
09-04-2008 10:39 AM
I havent solved this yet..:(
Any peace of code will be great...I am stuck with this, selects take long time really...
I am waiting for any help guys...thanks
Edited by: nihad omerbegovic on Sep 4, 2008 11:44 AM
09-04-2008 10:45 AM
Don't fetch data from table BSID in the loop of it_bkpf or it_bseg. Use 'for all entries'. This will reduce database hits and thus will increase performance.
Regards,
Aparna Gaikwad
09-04-2008 10:57 AM
I want to take fields from bkpf and bseg only where bsid-xref1 is not empty....Any helpfull code???
09-04-2008 11:00 AM
Hi nihad,
Try this code
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.
Thanks
Lakshman
09-04-2008 11:16 AM
09-05-2008 7:46 AM
Hi guys, just one more question please...
How can I add in this report a field KNA1-KUNNR? what is peace of code for this?
I can't read kunnr from any of those tables I already have in report...
I want to have customer number in report output as well...
Thanks
Nihad
09-05-2008 7:50 AM
Hi Nihad,
KUNNR is avialable in BSID table, you can use IT_BSID table for displaying KUNNR related to BELNR.
Hope this helps
Thanks
Lakshman
09-05-2008 8:52 AM
Lakshman, 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.
Edited by: nihad omerbegovic on Sep 5, 2008 9:53 AM
09-05-2008 9:01 AM
You should open a new thread for this new question.
Also, nobody specifically pointed out the major problem of your code:
select * from bkpf into table it_bkpf
where cpudt in s_cpudt.
You always want to give BUKRS when accessing BKPF, then the system will use secondary index "5" for quick access via CPUDT.
After this select the entries from BSEG using "for all entries" on BUKRS, BELNR, GJAHR.
Thomas
09-05-2008 9:29 AM
Thank you Thomas I have opened a new thread for this problem as well...
Lakshman, I wait for your reply you must have idea