Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to enhance selection of BKPF and BSEG

Former Member
0 Kudos

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!

3 REPLIES 3

tamas_hoznek
Product and Topic Expert
Product and Topic Expert
0 Kudos

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.

0 Kudos

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

Former Member
0 Kudos

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