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: 

bad Performance in a query into table BKPF

Former Member
0 Kudos

Hi forum i have a really problem in the second query under the table

BKPF.. some body cans help me, please

*THIS IS THE QUERY UNDER MSEG

SELECT tmsegmblnr tmkpfbudat tmsegbelnr tmsegbukrs tmseg~matnr

tmsegebelp tmsegdmbtr tmsegwaers tmsegwerks tmseg~lgort

tmsegmenge tmsegkostl

FROM mseg AS tmseg JOIN mkpf AS tmkpf ON tmsegmblnr = tmkpfmblnr

INTO CORRESPONDING FIELDS OF TABLE it_docs

WHERE

tmseg~bukrs IN se_bukrs AND

tmkpf~budat IN se_budat AND

tmseg~mjahr = d_gjahr AND

( tmsegbwart IN se_bwart AND tmsegbwart IN (201,261) ).

IF sy-dbcnt > 0.

      • I CREATE AWKEY FOR CONSULTING BKPF

LOOP AT it_docs.

CONCATENATE it_docs-mblnr d_gjahr INTO it_docs-d_awkey.

MODIFY it_docs.

ENDLOOP.

  • THIS IS THE QUERY WITH BAD BAD PERFOMANCE

  • I NEED KNOW "BELNR" FOR GO TO THE BSEG TABLE

SELECT belnr awkey

FROM bkpf

INTO CORRESPONDING FIELDS OF TABLE it_tmp

FOR ALL ENTRIES IN it_docs

WHERE

bukrs = it_docs-bukrs AND

awkey = it_docs-d_awkey AND

gjahr = d_gjahr AND

bstat = space .

THNKS

1 ACCEPTED SOLUTION

Former Member
0 Kudos

If possible remove into corresponing

  • I NEED KNOW "BELNR" FOR GO TO THE BSEG TABLE

SELECT belnr awkey

FROM bkpf

INTO <b>CORRESPONDING FIELDS OF TABLE<b> it_tmp

FOR ALL ENTRIES IN it_docs

WHERE

bukrs = it_docs-bukrs AND

awkey = it_docs-d_awkey AND

gjahr = d_gjahr AND

bstat = space .

It will give little bit good performance and if you give full key in where condition,then you will get good performance but i know as per req we can't provide .

Thanks

Seshu

3 REPLIES 3

Former Member
0 Kudos

Hi Josue,

Change the code as,

IF it_docs[] IS NOT INITIAL>

SELECT <b>BUKRS belnr GJAHR awkey</b>

FROM bkpf

INTO CORRESPONDING FIELDS OF TABLE it_tmp

FOR ALL ENTRIES IN it_docs

WHERE

bukrs = it_docs-bukrs AND

awkey = it_docs-d_awkey AND

gjahr = d_gjahr AND

bstat = space .

ENDIF.

This can improve a performance a bit, but you can't get a very good performance as you don't have the whole key.

Regards,

Atish

Former Member
0 Kudos

If possible remove into corresponing

  • I NEED KNOW "BELNR" FOR GO TO THE BSEG TABLE

SELECT belnr awkey

FROM bkpf

INTO <b>CORRESPONDING FIELDS OF TABLE<b> it_tmp

FOR ALL ENTRIES IN it_docs

WHERE

bukrs = it_docs-bukrs AND

awkey = it_docs-d_awkey AND

gjahr = d_gjahr AND

bstat = space .

It will give little bit good performance and if you give full key in where condition,then you will get good performance but i know as per req we can't provide .

Thanks

Seshu

Sougata
Active Contributor
0 Kudos

Hi Josue,

The bad performance is because you're not specifying the primary keys of the table BKPF in your WHERE condition; BKPF usually is a big table.

What you really need is to create a new index on database for table BKPF via the ABAP Dictionary on fields BUKRS, AWKEY, GJAHR & BSTAT. You'll find the performace of the program will significantly increase after the new index is activated. But I would talk to the Basis first to confirm they have no issues if you create a new index for BKPF on the database system.

Hope this helps.

Cheers,

Sougata.