<?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: Improve your ABAP Code Performance. in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/improve-your-abap-code-performance/m-p/914371#M57781</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Rajesh&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for sharing this note. It would be really useful for SD ABAPers.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*--Serdar &amp;lt;a href="https://www.sdn.sap.com:443http://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.sdn.businesscard.sdnbusinesscard?u=qbk%2bsag%2bjiw%3d"&amp;gt;[ BC ]&amp;lt;/a&amp;gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 31 May 2005 08:21:34 GMT</pubDate>
    <dc:creator>ssimsekler</dc:creator>
    <dc:date>2005-05-31T08:21:34Z</dc:date>
    <item>
      <title>Improve your ABAP Code Performance.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/improve-your-abap-code-performance/m-p/914370#M57780</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;SAP Note : 185530&lt;/P&gt;&lt;P&gt;Long Text&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;     Symptom&lt;/P&gt;&lt;P&gt;     Customer-specific programs and program enhancements ("User Exits") have&lt;/P&gt;&lt;P&gt;     a bad performance. The bad performance is noticed during accesses to the&lt;/P&gt;&lt;P&gt;     following SAP SD tables: VBAK, VBAP, VMVA, LIKP, LIPS, VBRK, VBRP, VBFA&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;     Additional key words&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;     Cause and prerequisites&lt;/P&gt;&lt;P&gt;     The R/3 System contains no secondary indexes to the most important SD&lt;/P&gt;&lt;P&gt;     transaction data tables in the delivery. Instead, the R/3 System has&lt;/P&gt;&lt;P&gt;     proprietary index tables (sales document indexes, for example the tables&lt;/P&gt;&lt;P&gt;     VAKPA and VAPMA, matchcode tables for example M_VMVAB, M_VMVAC or&lt;/P&gt;&lt;P&gt;     matchcode views for example M_VMVAA, M_VMVAE), which allow an efficient&lt;/P&gt;&lt;P&gt;     access.&lt;/P&gt;&lt;P&gt;     In order to use these efficiently a certain basic knowledge of the SAP&lt;/P&gt;&lt;P&gt;     data model is required. For this this note lists the most important&lt;/P&gt;&lt;P&gt;     errors which are made and it offers alternatives.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;     However note the following WARNINGS:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;        o  Before you use the listed alternatives productively, you must&lt;/P&gt;&lt;P&gt;           check your program closely for functional accuracy.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;        o  The sales document indexes must be maintained correctly in your&lt;/P&gt;&lt;P&gt;           system. This is usually automatically the case, however, there can&lt;/P&gt;&lt;P&gt;           be inconsistencies. Carefully read and follow Notes 128947 and&lt;/P&gt;&lt;P&gt;           178328.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;     Consider the following NOTES:&lt;/P&gt;&lt;P&gt;     In the following examples, there are often accesses to several tables,&lt;/P&gt;&lt;P&gt;     for example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;       SELECT FROM vakpa WHERE kunde = ...&lt;/P&gt;&lt;P&gt;          SELECT FROM vbak WHERE vbeln = vakpa-vbeln.&lt;/P&gt;&lt;P&gt;     It can increase the performance, to define a selection view on the&lt;/P&gt;&lt;P&gt;     corresponding tables (here: VAKPA and VBAK) in order to combine the&lt;/P&gt;&lt;P&gt;     accesses to the two tables in one access.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;     Solution&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;     1. Accesses to sales orders (tables VBAK, VBAP)&lt;/P&gt;&lt;P&gt;                                                                       Page 2&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;        a) Search orders for customer number (field VBAK-KUNNR):&lt;/P&gt;&lt;P&gt;           Incorrect:&lt;/P&gt;&lt;P&gt;             SELECT FROM vbak WHERE kunnr = ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;           Correct:&lt;/P&gt;&lt;P&gt;             SELECT FROM vakpa WHERE kunde = ...&lt;/P&gt;&lt;P&gt;               SELECT FROM vbak WHERE vbeln = vakpa-vbeln.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;        b) Search order items for material number (field VBAP-MATNR):&lt;/P&gt;&lt;P&gt;           Incorrect:&lt;/P&gt;&lt;P&gt;             SELECT FROM vbap WHERE matnr = ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;           Correct:&lt;/P&gt;&lt;P&gt;             SELECT FROM vapma WHERE matnr = ...&lt;/P&gt;&lt;P&gt;               SELECT FROM vbap WHERE vbeln = vapma-vbeln&lt;/P&gt;&lt;P&gt;                                  AND posnr = vapma-posnr&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;        c) Other search helps for sales orders offer the matchcode tables and&lt;/P&gt;&lt;P&gt;           views M_VMVAx, x. = A, B, C, ... M; for example search for&lt;/P&gt;&lt;P&gt;           purchase order number of the customer, description and so on&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;     2. Accesses to deliveries (tables LIKP, LIPS)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;        a) Search for deliveries with customer number (field LIKP-KUNNR):&lt;/P&gt;&lt;P&gt;           Incorrect:&lt;/P&gt;&lt;P&gt;             SELECT FROM likp WHERE kunnr = ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;           Correct:&lt;/P&gt;&lt;P&gt;             SELECT FROM vlkpa WHERE kunde = ...&lt;/P&gt;&lt;P&gt;               SELECT FROM likp WHERE vbeln = vlkpa-vbeln.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;        b) Search for delivery items with material number (field LIKP-MATNR):&lt;/P&gt;&lt;P&gt;           Incorrect:&lt;/P&gt;&lt;P&gt;             SELECT FROM lips WHERE matnr = ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;           Correct:&lt;/P&gt;&lt;P&gt;             SELECT FROM vlpma WHERE matnr = ...&lt;/P&gt;&lt;P&gt;               SELECT FROM lips WHERE vbeln = vlpma-vbeln&lt;/P&gt;&lt;P&gt;                                  AND posnr = vlpma-posnr&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;        c) Search for deliveries with sales order number (preceding document,&lt;/P&gt;&lt;P&gt;           field LIPS-VGBEL):&lt;/P&gt;&lt;P&gt;           Incorrect:&lt;/P&gt;&lt;P&gt;             SELECT FROM lips WHERE vgbel = ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;           Correct:&lt;/P&gt;&lt;P&gt;             SELECT FROM vbfa WHERE VBELV  = ... and VBTYP_N = 'J'&lt;/P&gt;&lt;P&gt;               SELECT FROM lips WHERE vbeln = vbfa-vbeln&lt;/P&gt;&lt;P&gt;                                  AND posnr = vbfa-posnn&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;        d) Other search helps for deliveries offer matchcode tables and views&lt;/P&gt;&lt;P&gt;           M_VMVLx, x. = A, B, C, ... M; for example search for goods issue&lt;/P&gt;&lt;P&gt;           date, picking date, transportation planning date and so on.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;     3. Accesses to invoices (tables VBRK, VBRP)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;        a) Search for invoices with customer number ("payer") (field&lt;/P&gt;&lt;P&gt;                                                                       Page 3&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;           VBRK-KUNRG):&lt;/P&gt;&lt;P&gt;           Incorrect:&lt;/P&gt;&lt;P&gt;             SELECT FROM vbrk WHERE kunrg = ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;           Correct:&lt;/P&gt;&lt;P&gt;             SELECT FROM vrkpa WHERE kunde = ...&lt;/P&gt;&lt;P&gt;               SELECT FROM vbrk WHERE vbeln = vrkpa-vbeln&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;        b) Search for invoice items with material number (field VBRP-MATNR):&lt;/P&gt;&lt;P&gt;           Incorrect:&lt;/P&gt;&lt;P&gt;             SELECT FROM vbrp WHERE matnr = ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;           Correct:&lt;/P&gt;&lt;P&gt;             SELECT FROM vrpma WHERE matnr = ...&lt;/P&gt;&lt;P&gt;               SELECT FROM vbrp WHERE vbeln = vrpma-vbeln&lt;/P&gt;&lt;P&gt;                                  AND posnr = vrpma-posnr&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;        c) Search for invoices with delivery number (preceding document,&lt;/P&gt;&lt;P&gt;           field VBRP-VGBEL):&lt;/P&gt;&lt;P&gt;           Incorrect:&lt;/P&gt;&lt;P&gt;             SELECT FROM vbrp WHERE vgbel = ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;           Correct:&lt;/P&gt;&lt;P&gt;             SELECT FROM vbfa WHERE vbtyp_n = 'M'&lt;/P&gt;&lt;P&gt;                                AND vbelv  = ...&lt;/P&gt;&lt;P&gt;               SELECT FROM vbrp WHERE vbeln = vbfa-vbeln&lt;/P&gt;&lt;P&gt;                                  AND posnr = vbfa-posnn&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;        d) Search for invoices with order number (preceding document, field&lt;/P&gt;&lt;P&gt;           VBRP-AUBEL):&lt;/P&gt;&lt;P&gt;           Incorrect:&lt;/P&gt;&lt;P&gt;             SELECT FROM vbrp WHERE aubel = ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;           Correct:&lt;/P&gt;&lt;P&gt;             SELECT FROM vbfa WHERE vbtyp_n = 'M'&lt;/P&gt;&lt;P&gt;                                AND vbelv   = ...&lt;/P&gt;&lt;P&gt;               SELECT FROM vbrp WHERE vbeln = vbfa-vbeln&lt;/P&gt;&lt;P&gt;                                  AND posnr = vbfa-posnn&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;     4. Other accesses in SD:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;        a) Document flow:&lt;/P&gt;&lt;P&gt;           Incorrect:&lt;/P&gt;&lt;P&gt;             SELECT vbelv FROM vbfa WHERE vbeln ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;           In table VBFA only the preceeding document is used to search for&lt;/P&gt;&lt;P&gt;           the subsequent document (for example, delivery for order).&lt;/P&gt;&lt;P&gt;           Searching the other way makes no sense with this table since the&lt;/P&gt;&lt;P&gt;           preceding documents (for example, order for delivery) are stored&lt;/P&gt;&lt;P&gt;           directly in the document tables. Thus reading in table VBFA is a&lt;/P&gt;&lt;P&gt;           one-way street.&lt;/P&gt;&lt;P&gt;           Correct:&lt;/P&gt;&lt;P&gt;             SELECT vgbel FROM lips WHERE vbeln = ...; or&lt;/P&gt;&lt;P&gt;             SELECT vgbel FROM vbrp WHERE vbeln = ...; or&lt;/P&gt;&lt;P&gt;             SELECT aubel FROM vbrp WHERE vbeln = ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;        b) Search for shipping unit item with delivery&lt;/P&gt;&lt;P&gt;           Incorrect:&lt;/P&gt;&lt;P&gt;                                                                       Page 4&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;             SELECT FROM vepo WHERE vbtyp = 'J'&lt;/P&gt;&lt;P&gt;                                AND vbeln = i_lips-vbeln&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;           Correct:&lt;/P&gt;&lt;P&gt;             SELECT FROM vbfa WHERE vbtyp_n = 'X'&lt;/P&gt;&lt;P&gt;                                AND vbelv = i_lips-vbeln&lt;/P&gt;&lt;P&gt;             SELECT FROM vepo WHERE venum = vbfa-vbeln&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 31 May 2005 06:11:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/improve-your-abap-code-performance/m-p/914370#M57780</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-05-31T06:11:49Z</dc:date>
    </item>
    <item>
      <title>Re: Improve your ABAP Code Performance.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/improve-your-abap-code-performance/m-p/914371#M57781</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Rajesh&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for sharing this note. It would be really useful for SD ABAPers.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*--Serdar &amp;lt;a href="https://www.sdn.sap.com:443http://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.sdn.businesscard.sdnbusinesscard?u=qbk%2bsag%2bjiw%3d"&amp;gt;[ BC ]&amp;lt;/a&amp;gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 31 May 2005 08:21:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/improve-your-abap-code-performance/m-p/914371#M57781</guid>
      <dc:creator>ssimsekler</dc:creator>
      <dc:date>2005-05-31T08:21:34Z</dc:date>
    </item>
  </channel>
</rss>

