Skip to Content

Improve selection for AVL report

I'm attempting to improve the performance of my data selection for a report. Any suggestions?

  SELECT  vbak~vbeln

          vbak~vkbur

          vbak~vkgrp

          vbak~kunnr

          vbak~kunnr

          vbak~bstnk

          vbak~kvgr3

          vbap~matnr

          vbap~arktx

          vbap~zmeng

          vbak~guebg

          vbak~gueen

          vbap~netwr

          vbak~angdt

          vbak~bnddt

          vbap~waerk

          vbap~posnr

          vbak~knumv

          knvv~ernam



    INTO CORRESPONDING FIELDS OF wa_data

    FROM vbak

      JOIN vbap ON vbak~vbeln EQ vbap~vbeln

      JOIN knvv  ON vbak~kunnr EQ knvv~kunnr

*    UP TO 500 ROWS

    WHERE vbak~vbeln IN s_vbeln AND

          vbak~vkbur IN s_vkbur AND

          vbak~vkgrp IN s_vkgrp AND

          knvv~ernam IN s_ernam AND

          vbak~erdat IN s_erdat AND

          vbak~bstnk IN s_bstnk AND

          vbak~kunnr IN s_soldto AND

          vbak~gueen IN s_gueen AND

          vbak~guebg IN s_guebg.



    SELECT SINGLE kbetr

      FROM konv

      INTO wa_data-kbetr_zb

      WHERE knumv = wa_data-knumv

        AND kschl = 'ZBID'

        AND kposn = wa_data-posnr.



    SELECT SINGLE kbetr

      FROM konv

      INTO wa_data-kbetr_pr

      WHERE knumv = wa_data-knumv

        AND kschl = 'PR00'

        AND kposn = wa_data-posnr.



    SELECT SINGLE bezei

      FROM tvkbt

      INTO wa_data-bezei_so

      WHERE vkbur = wa_data-vkbur.



    SELECT SINGLE bezei

      FROM tvgrt

      INTO wa_data-bezei_sg

      WHERE vkgrp = wa_data-vkgrp.



    SELECT SINGLE name1

      FROM kna1

      INTO wa_data-name1_st

      WHERE kunnr = wa_data-kunnr.



    SELECT SINGLE kunnr

      FROM vbpa

      INTO wa_data-kunnr_eu

      WHERE vbeln = wa_data-vbeln

        AND parvw = 'EN'.



    SELECT SINGLE name1

      FROM kna1

      INTO wa_data-name1_eu

      WHERE kunnr = wa_data-kunnr_eu.



    SELECT SINGLE bezei

      FROM tvv3t

      INTO wa_data-bezei_ps

      WHERE kvgr3 = wa_data-kvgr3.



    APPEND wa_data TO it_data.



  ENDSELECT.
Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Best Answer
    Posted on Sep 09, 2017 at 11:27 PM
    • Check Other VBAK / VBAP - Related Posts in the SAP Community in previous years, they are numerous and will present some Refactoring options ...
    • Do your Checks via Trx."SAT" (ABAP Trace) and "ST05" (SQL Trace)
    • Check the use of Indexes on the main Tables ...
    • Check if you can make use of DB-Views or SD IndexTables ...


    There used to be an Accessible SAP-KBA 185530 on "Customer Developments in SD" (it is no longer reachable in SAP ONE Support?), but it is also mentioned on the web : link.

    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.