Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Performance issue in SELECT query

Hi All,

I have been facing a performance issue in the below query . Please let me know your suggestions. The number of records in ITAB is around 7500.

        SELECT             k~vbeln k~auart k~vkorg p_posnr

        FROM               vbak AS k

        INNER JOIN         vbap AS p ON p~vbeln = k~vbeln

        INTO TABLE         it_output

        FOR ALL ENTRIES IN ITAB

        WHERE K~vbeln ne itab-vbeln

          AND k~kunnr         =  itab-kunag

          AND k~vkorg         =  itab-vkorg

          AND k~bstnk         =  itab-bstnk.             =>Timeout error

I have tried to put ITAB-VBELN values in a range table and tried with the following query. Still the same issue.

        SELECT             k~vbeln k~auart k~vkorg p_posnr

        FROM               vbak AS k

        INNER JOIN         vbap AS p ON p~vbeln = k~vbeln

        INTO TABLE         it_output

        FOR ALL ENTRIES IN ITAB

        WHERE K~vbeln not in ITAB_VBELN_RANGE_TABLE

          AND k~kunnr         =  itab-kunag

          AND k~vkorg         =  itab-vkorg

          AND k~bstnk         =  itab-bstnk.

I have tried the following variation. But no improvement.

        SELECT             k~vbeln k~auart k~vkorg p_posnr

        FROM               vbak AS k

        INNER JOIN         vbap AS p ON p~vbeln = k~vbeln

        INTO TABLE         it_output

        FOR ALL ENTRIES IN ITAB

        WHERE  k~kunnr         =  itab-kunag

          AND k~vkorg         =  itab-vkorg

          AND k~bstnk         =  itab-bstnk.

DELETE it_output WHERE vbeln in  ITAB_VBELN_RANGE_TABLE.

Thanks in advance.

Former Member

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question