Skip to Content
author's profile photo Former Member
Former Member

bad Performance in a query into table BKPF

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

      Add a comment
      10|10000 characters needed characters exceeded

      Assigned Tags

      Related questions

      3 Answers

      • Best Answer
        author's profile photo Former Member
        Former Member
        Posted on Jul 04, 2007 at 12:30 AM

        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

        Add a comment
        10|10000 characters needed characters exceeded

      • Posted on Jul 04, 2007 at 12:56 AM

        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.

        Add a comment
        10|10000 characters needed characters exceeded

      • author's profile photo Former Member
        Former Member
        Posted on Jul 04, 2007 at 12:19 AM

        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

        Add a comment
        10|10000 characters needed characters exceeded

      Before answering

      You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
      You must be Logged in to submit an answer.

      Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.