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: 

Find cleared document according entry date of clearing document.

Former Member
0 Kudos

Hi,

i have poor performance in this issue. I would find cleared document according clearing document. On selection screen are cpudt and cputm clearings documents and i need to find cleared document for these document.

First statement

select bukrs gjahr belnr into table i_bkpf from bkpf where cpudt in so_cpudt and cputm

Second statement

select burks gjahr belnr into table i_itab

for all entries in i_bkpf from bsas where bukrs = i_bkpf-bukrs

<b>and augbl = i_bkpf-belnr and augdt = i_bkpf-budat</b>

Third stat.

select burks gjahr belnr appending table i_itab

for all entries in i_bkpf from bsak where bukrs = i_bkpf-bukrs

<b>and augbl = i_bkpf-belnr and augdt = i_bkpf-budat</b>

all is OK but condition augbl = i_bkpf-belnr and augdt = i_bkpf-budat has very poor performance!!

How to solve it? Do you have any solution?

Thank you very much.

2 REPLIES 2

Former Member
0 Kudos

Hi Vidlak,

If you might have noticed, BSAK has a secondary index available (number 1) with the fields :

LIFNR

BUKRS

AUGDT

AUGBL

GJAHR

BELNR

BUZEI

in the same order. Now since you cant obviously build and query on the primary key atleast try to complete the secondary index key. I can see i_bkpf has BUKRS & GJAHR key, and in the index AUGDT comes before AUGBL hence in construct your where clause for the third statement as

WHERE BUKRS EQ I_BKPF-BUKRS AND

AUGDT EQ I_BKPF-BUDAT AND

AUGBL EQ I_BKPF-BELNR AND

GJAHR EQ I_BKPF-GJAHR.

this should certainly help improve performance.

Also seeing how many FOR ALL ENTRIES clauses u are using, one thing for performance improvement is ensure the table is NOT empty before using it and sort the table with its keys.

Hope its of some help.

Regards,

Aditya

0 Kudos

Attention, this is a mistake because gjahr of clearing document could be different than gjahr of cleared document. Therefore augdt cleared doc = budat clearing doc. But poor performance