06-07-2007 9:16 AM
Hello!
I need to make a simple report program that will display all journal entries based on Posting Date Range.
So for example, user will enter 2006.01.03, I will select document nos. from BKPF based on posting date, then select each line item from BSEG. Then I will print them on the screen.
So I now have two loops, one bye selecting each line item per document from BSEG then by printing them..
As we know, these are a lot of records! Haha.
So when I select even just a week, it takes so long..
How can I optimize this?
Thanks!
06-07-2007 5:47 PM
BKPF has a standard index by Posting Date. However the index usage is only optimal if you also specify the company code and the document status in your SELECT statement.
In case that is not feasible in your scenario, you may create a new index on BKPF for the posting date only, but I'd do it only as the last resort because creating indexes for just one program is not a smart idea.
Once you selected the document headers in an optimal way, reading the corresponding BSEG records via the primary key is no problem and should not cause performance issues.
06-07-2007 6:28 PM
This is code I just posted to almost the same question:
SELECT bukrs belnr gjahr blart budat usnam dbblg stblg stjah
bktxt grpid awkey tcode
INTO TABLE it_bkpf
FROM bkpf
WHERE bukrs IN s_bukrs AND
bstat IN (' ', 'A', 'B', 'D', 'M', 'S', 'V', 'W', 'Z') AND
budat IN postdate AND
Rob
06-08-2007 5:39 AM
Instead of using BKPF and BSEG You can use following table
BSAS Accounting: Secondary Index for G/L Accounts (Cleared Items)
BSIS Accounting: Secondary Index for G/L Accounts
BSAK Accounting: Secondary Index for Vendors (Cleared Items)
BSIK Accounting: Secondary Index for Vendors
BSAD Accounting: Secondary Index for Customers (Cleared Items)
BSID Accounting: Secondary Index for Customers
Regards
M Sajid