<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Performance problem in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-problem/m-p/2379919#M528093</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Another thing you can do is to avoid the statement SELECT SINGLE and do it as SELECt .... UP TO 1 ROWS.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 19 Jun 2007 15:30:15 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-06-19T15:30:15Z</dc:date>
    <item>
      <title>Performance problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-problem/m-p/2379917#M528091</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;i am using the following stmt .but i am not using the primary key to fetch record from vbkd table. so it takes more time to run the program. the code i am using is&lt;/P&gt;&lt;P&gt;    SELECT SINGLE  vbeln posnr&lt;/P&gt;&lt;P&gt;    INTO (v_vbeln,v_posnr)&lt;/P&gt;&lt;P&gt;    FROM vbkd&lt;/P&gt;&lt;P&gt;   WHERE  bstkd = i_bsid-xref1&lt;/P&gt;&lt;P&gt;     and  posnr = i_bsid-buzei.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    SELECT SINGLE arktx&lt;/P&gt;&lt;P&gt;    INTO i_tab-arktx&lt;/P&gt;&lt;P&gt;    FROM vbap&lt;/P&gt;&lt;P&gt;   WHERE vbeln = v_vbeln&lt;/P&gt;&lt;P&gt;     and posnr = v_posnr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;can anybody fine tune the code i am using.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;P&gt;Madhu&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Jun 2007 09:19:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-problem/m-p/2379917#M528091</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-06-19T09:19:30Z</dc:date>
    </item>
    <item>
      <title>Re: Performance problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-problem/m-p/2379918#M528092</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This statament is wrong because the field POSNR (sales order item) is not linked to field BUZEI (FI invoice item)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*SELECT SINGLE vbeln posnr&lt;/P&gt;&lt;P&gt;*INTO (v_vbeln,v_posnr)&lt;/P&gt;&lt;P&gt;*FROM vbkd&lt;/P&gt;&lt;P&gt;*WHERE bstkd = i_bsid-xref1&lt;/P&gt;&lt;P&gt;*and posnr = i_bsid-buzei.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, try this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;* Get header data
SELECT SINGLE * FROM BKPF WHERE BUKRS = I_BSID-BUKRS
                                                      AND BELNR = I_BSID-BELNR
                                                      AND GJAHR = I_BSID-GJAHR.
* Get original document
IF BKPF-AWTYP = 'VBRK'.
* Get the bill number
  BILL_NUMBER = BKPF-AWKEY(10).
* The sales order and item are in VBRP table:
  DATA: BEGIN OF T_VBRP OCCURS 0,
                VGBEL TYPE VBAP-VBELN,
                VGPOS TYPE VBAP-POSNR,
             END    OF T_VBAP.
  
  SELECT VGBEL VGPOS FROM VBRP INTO TABLE T_VBRP
                                              WHERE VBELN =    BILL_NUMBER. 

   DATA: BEGIN OF T_MATNR OCCURS 0,
                 ARTKX LIKE VBAP-ARTKX
             END    OF T_MATNR.

     SELECT ARTKX FROM VBRP INTO TABLE T_MATNR
                                FOR ALL ENTRIES IN T_VBRP
                                              WHERE VBELN  = T_VBRP-VGBEL
                                                    AND POSNR = T_VBRP-VGPOS.

     READ TABLE T_MATNR INDEX 1.
     IT_ITAB-ARKTX.
ENDIF.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Anyway you can get the material definition from bill items, you don't need to read the sales order data:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;* Get header data
SELECT SINGLE * FROM BKPF WHERE BUKRS = I_BSID-BUKRS
                                                      AND BELNR = I_BSID-BELNR
                                                      AND GJAHR = I_BSID-GJAHR.
* Get original document
IF BKPF-AWTYP = 'VBRK'.
* Get the bill number
  BILL_NUMBER = BKPF-AWKEY(10).

  SELECT ARTKX FROM VBRP INTO IT_ITAB-ARKTX.
                                              WHERE VBELN  = BILL_NUMBER.
     EXIT.
  ENDSELECT. 
ENDIF.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Max&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Jun 2007 09:40:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-problem/m-p/2379918#M528092</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-06-19T09:40:50Z</dc:date>
    </item>
    <item>
      <title>Re: Performance problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-problem/m-p/2379919#M528093</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Another thing you can do is to avoid the statement SELECT SINGLE and do it as SELECt .... UP TO 1 ROWS.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Jun 2007 15:30:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-problem/m-p/2379919#M528093</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-06-19T15:30:15Z</dc:date>
    </item>
  </channel>
</rss>

