‎2008 Aug 26 9:17 AM
Hi All,
The selection query with the join statement is taking too long time .
define d_select_bfo.
select bbukrs bgjahr bbelnr bgsber bprctr fblart f~bldat
from &1 as b
inner join BKPF as f
on bbukrs = fbukrs
and bbelnr = fbelnr
and bgjahr = fgjahr
into table itb_selglob_tmp
where b~bukrs in s_bukrs
and b~gjahr in s_gjahr
and b~belnr in s_belnr
and f~blart in w_blart
and ( b~gsber in l_gsber
or b~prctr in l_prctr ).
end-of-definition.
&1 = BFOD_A.
This query i have changed to
select bukrs belnr gjahr gsber prctr from &1
into table itb_bfod_a
where bukrs in s_bukrs
and belnr in s_belnr
and gjahr in s_gjahr
and ( gsber in l_gsber or prctr in l_prctr ).
if not itb_bfod_a[] is initial.
sort itb_bfod_a by bukrs belnr gjahr.
select bukrs belnr gjahr blart bldat
from bkpf into table itb_bkpf
for all entries in itb_bfod_a
where bukrs = itb_bfod_a-bukrs
and belnr = itb_bfod_a-belnr
and gjahr = itb_bfod_a-gjahr
and blart in w_blart.
This query also is taking too long time..
Could you please help me out on this issue
i am working on 4.C version....
Thanks in advance
Regards
Sudhakar
‎2008 Aug 26 9:19 AM
Dont use joines...Because join and all performance issue...
so u need to use loop and read statement..So it avoid the timings
Regards:
Prabu
‎2008 Aug 26 9:22 AM
Joins are not the sole issue to this. So do not just assume you know the answer.
I would first try reading BKPF table first. This will greatly reduce the number of records based on the document type field.
‎2008 Aug 26 9:24 AM
Hi Sudhakar,
In my opinion, your second option is better ( for all entries ).
If it takes a long time, this is also because your are retrieving data in tables that are among the hugest table in SAP.
What you can try is to restrict on criteria like BLART, ...etc
Hope this helps,
Erwan
‎2008 Aug 26 9:29 AM
‎2008 Aug 26 9:36 AM
If its a time out error...go for optimization techniques..
1) split the joins
2) give approrpiate where conditions
3)give the where clause as of in secondary index( if any )
4) if no remedy execute in background
‎2008 Aug 26 9:47 AM
Don't believe the simplistic "use for all entries".
Your join condition between BFOD_A and BKPF looks fine. If the selection ranges are empty when the select is executed, it will run a long time no matter what.
In order to use the secondary index on BKPF-BLART (in case you're dealing with just one document type) you must also select by B~BSTAT = space. Try to add this to the JOIN select statement.
Also, S_BUKRS should have maximum one value.
Thomas
‎2008 Aug 26 9:56 AM
Your select query looks fine even using For all entries will hardly increase performance, it is just becouse of high volume of data that it is giving time out
Execute the program in background or talk to basis gyes to increase the time slice for the program so that it can be executed in forgraound
Regards
Bikas