‎2011 Feb 14 8:08 PM
Hi All,
I see a performance issue when accessing tables BSEG using the data from table BKPF.
I extracted the fields from BKPF table and then made the following statemnt :
Select bukrs, belnr, gjahr, buzei, hkont, txjcd, mwart
from bseg
for all entries in it_bkpf
where bukrs EQ it_bkpf-BUKRS AND
belnr EQ it_bkpf-belnr AND
gjahr EQ it_bkpf-gjahr AND
buzei EQ it_bkpf-buzei AND
hkont EQ it_bkpf-hkont.
But this statement causes a serious performance issue and my program stops working from here.
Could someone please help me out with this.
Thanks & Regards,
Sushanth Hulkod
‎2011 Feb 14 8:17 PM
Make sure that you're checking that the internal table with BKPF entries is not empty. I hope you know what happens if that is the case. That apart, since you are using the key BUKRS/BELNR/GJAHR, am sure there shouldn't be an issue. Also, do make sure that the index based on the key fields is active. This is generally a BASIS job. Generally this index should be ON.
‎2011 Feb 14 8:44 PM
But this statement causes a serious performance issue and my program stops working from here.
Well, for how many entries in your table? It certainly would not be an issue for only a few entries. Why are you using BUZEI and HKONT in the FOR ALL ENTRIES construct - they aren't BKPF fields? Why aren't those fields processed against parameters or select-options?
‎2011 Feb 14 10:54 PM
Hi Sushanth,
Also remove the BUZEI and HKONT from the WHERE clause since these fields are not part of the BKPF table and therefore blank.
In case you are only interested in GL account items(KOART = S as opposed to vendor/customer postings), you should use table BSIS to get the open items. Use BSAS to get the cleared items.
Kind regards,
Robert
PS. Sorry Brad did not want to repeat you, was in the middle of a my reply when you replied.....
Edited by: RJ. Schamhart on Feb 14, 2011 2:54 PM
‎2011 Feb 14 11:13 PM
Your source table for the FAE clause should be sorted to get good performance.
Also, as BRAD AND rj HAVE POINTED OUT, SOME OF THE FIELDS YOU ARE USING INTHE SQL WILL NOT HAVE VALUES............. but WHAT PUZZLES ME IS HOW YOU ARE getting any results at all as the null values for these fields will not be very helpful to the select.
‎2011 Feb 15 2:12 AM
Add below code, it may solve your problem.
IF not it_bkpf[] is initial. <-- AddSelect bukrs, belnr, gjahr, buzei, hkont, txjcd, mwart
from bseg
for all entries in it_bkpf
where bukrs EQ it_bkpf-BUKRS AND
belnr EQ it_bkpf-belnr AND
gjahr EQ it_bkpf-gjahr AND
buzei EQ it_bkpf-buzei AND
hkont EQ it_bkpf-hkont.ENDIF. <-- AddRegards,
SaiRam
‎2011 Feb 15 3:06 AM
Hi All,
Though my query now is :-
If it_bkpf[] is not initial.
Select bukrs belnr gjahr buzei
from bseg into
corresponding fields of table it_bseg
for all entries in table it_bkpf
where bukrs = it_bkpf-bukrs
and belnr = it_bkpf-belnr
and gjahr = it_bkpf-gjahr.
Endif.
There still seems to be a performance issue and my pgm stops at this point.
Could someone help me out with this.
Thanks & Regards,
Sushanth Hulkod
‎2011 Feb 15 3:23 AM
I see nothing wrong with your code. Are you sure this is where the problem is?
Have you run ST05 to analyze this?
How many entries in IT_BKPF?
Rob
‎2011 Feb 15 3:40 AM
Your source table for the FAE clause should be sorted to get good performance.
ie sort it_bkpf by bukrs belnr gjahr
‎2011 Feb 15 5:02 AM
>
> Your source table for the FAE clause should be sorted to get good performance.
> ie sort it_bkpf by bukrs belnr gjahr
Hello,
In addition to what Neil has added for FAE to work effeciently; you need to perform a D.A.D on the source table based on the fields which are used in the WHERE clause. (Of couse the check for the emptiness of the table is a MUST)
BR,
Suhas
‎2011 Feb 15 5:14 AM
Hi,
Declare your it_bseg with only required fields i.e bukrs belnr gjahr buzei.
and remove"into corresponding fields of".
and use open cursor method.
Regards
Ganesh Reddy
‎2011 Feb 15 5:27 AM
Hi Sushanth
1. Always check for all entries table is initial or not, then apply the selection.
Like in your case.
if it_bkpf is not initial.
do your selection here.
endif.
2. Sort your for all entries table as well.
3. Use operators instead of character statements,
like BELNR = it_bkpf-belrn not belnr EQ it_bkpf-belnr.
4. in where condition the sequence should be same.
why are you selecting BUKRS BELNR GJAHR and BUZEI again from BSEG table though you have selected them from BKPF table?
Why are you using into corresponding fields of table?
I hope you need to take care of all the above points and your query seems ok to me,
please debugg and check where is the problem exactly accuring?
Thanks
Lalit Gupta
‎2011 Feb 15 2:38 PM
LalitG wrote:
3. Use operators instead of character statements,
like BELNR = it_bkpf-belrn not belnr EQ it_bkpf-belnr.
4. in where condition the sequence should be same.
Not really valid suggestions...
To the poster, some of the suggestions provided are valid and some are not; the valid ones are not likely to increase your performance by an order of magnitude.
You haven't answered the simple questions posed to you, such as the one both Rob and I asked - how many entries in the driver table? If you dump every single BKPF line into an internal table, it stands to reason that the performance on the BSEG SELECT would be bad, NO MATTER WHAT YOU DO. How do you know the BSEG read is the cause of the issue - have you traced the program?
‎2011 Feb 15 5:23 AM
Hi,
The query you have written is fetching all the records exist in BSEG table. You have to excecute this only if there is atleast a single entry in it_bkpf. Write if condition as below..
If it_bkpf[] is not initial.
Select bukrs, belnr, gjahr, buzei, hkont, txjcd, mwart
from bseg
for all entries in it_bkpf
where bukrs EQ it_bkpf-BUKRS AND
belnr EQ it_bkpf-belnr AND
gjahr EQ it_bkpf-gjahr AND
buzei EQ it_bkpf-buzei AND
hkont EQ it_bkpf-hkont.
Endif.
Hope this helps.
‎2011 Feb 15 5:45 AM
Use the below code, it may improve the performance.
SELECT * INTO TABLE it_bkpf FROM bkpf
WHERE belnr = '0100000000'
AND bukrs = 'XXXX'
AND gjahr = '2011'.
IF NOT it_bkpf[] IS INITIAL.
SELECT bukrs belnr gjahr txjcd mwart
INTO CORRESPONDING FIELDS OF TABLE it_bseg <-- Try to push the contents to internal table or work area
FROM bseg
FOR ALL ENTRIES IN it_bkpf
WHERE bukrs EQ it_bkpf-bukrs AND
belnr EQ it_bkpf-belnr AND
gjahr EQ it_bkpf-gjahr.
ENDIF.Regards,
SaiRam
‎2011 Feb 15 6:41 AM
If it's Possible Avoid Using BSEG table it's Cluster Table , in place of that Use
bsis "Accounting: Secondary Index for G/L Accounts
bsas "Secondary Index for G/L Accounts (Cleared Items)
bsid " Accounting: Secondary Index for Customers
bsad " Secondary Index for Customers (Cleared Items)
BSAK " Accounting: Secondary Index for Vendors (Cleared Items)
BSIK "Accounting: Secondary Index for Vendors
Edited by: Shailesh Dhanani on Feb 15, 2011 7:41 AM
‎2011 Feb 15 2:07 PM
@Shailesh Dhanani -
> If it's Possible Avoid Using BSEG table it's Cluster Table , in place of that Use...
Absolutely incorrect
@Gamesh Reddy - how would OPEN CURSOR help?
@LalitG - INTO CORRESPONDING adds a very small bi of overhead but is not really a performance issue.
Rob