<?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 performance of a SQL request in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/improve-performance-of-a-sql-request/m-p/2984238#M704670</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; Do like this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; declare independent internal tables for each tables&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;select ebeln ebelp werks matkl mtart from ekpo into table git_ekpo
 where werks in so_werks
   and matkl in so_matkl
   and mtart in so_mtart.
if sy-subrc = 0.
 if not git_ekpo[] is initial.
  select lifnr bstyp ekgrp bsart zzreldt from ekko into table git_ekko
    for all entries in git_ekpo
      where ebeln = git_ekpo-ebeln
        and bstyp in so_bstyp
        and lifnr in so_lifnr
        and ekgrp in so_ekgrp
        and bsart in so_bsart.
  if sy-subrc = 0.
   delete git_ekpo where banfn = ' '.
   select ebeln ebelp slfdt from eket into table git_eket
    for all entries in git_ekpo
     where ebeln = git_ekpo-ebeln
       and ebelp = git_ekpo-ebelp
       and etenr = '1'.
   if sy-subrc = 0.
     select ebeln ebelp budat banfn bnfpo from ekbe into table git_ekbe
      for all entries in git_ekpo
       where ebeln = git_ekpo-ebeln
         and ebelp = git_ekpo-ebelp
         and budat in so_budat.
     if sy-subrc = 0.
      select &amp;lt;fields&amp;gt; from mseg into table git_mseg
       for all entries in git_ekpo
        where ebeln = git_ekpo-ebeln
          and ebelp = git_ekpo-ebelp
          and bwart = '101'
          and insmk = '3'.
     endif.
   endif. 
  endif.
 endif.
endif.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;once you get the whole data merge into a single internal table with all the fields.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope your problem will get resolve.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;Reward points if it helps&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Satish&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 06 Nov 2007 19:45:43 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-11-06T19:45:43Z</dc:date>
    <item>
      <title>Improve performance of a SQL request</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/improve-performance-of-a-sql-request/m-p/2984236#M704668</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;I have a sql request with multiple joins in it and when i launch my program i have some performance problems.&lt;/P&gt;&lt;P&gt;I think it's because of the multiple Joins.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How can i improve it ?&lt;/P&gt;&lt;P&gt;Do i need to split it in different smaller requests ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your help and tips.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
    SELECT e~ebeln
           e~ebelp
           e~werks
           e~matkl
           e~mtart
           k~lifnr
           k~bstyp
           k~ekgrp
           k~bsart
           k~zzreldt
           t~slfdt
           b~budat
           e~banfn
           e~bnfpo
    FROM ekpo AS e JOIN ekko AS k ON e~ebeln = k~ebeln
                   JOIN eket AS t ON e~ebeln = t~ebeln
                                  AND e~ebelp = t~ebelp
                   JOIN ekbe AS b ON e~ebeln = b~ebeln
                                  AND e~ebelp = b~ebelp
                   JOIN mseg AS m ON e~ebeln = m~ebeln
                                  AND e~ebelp = m~ebelp
    INTO CORRESPONDING FIELDS OF TABLE t_commande
    WHERE k~bstyp IN so_bstyp
    AND   k~lifnr IN so_lifnr
    AND   e~werks IN so_werks
    AND   e~matkl IN so_matkl
    AND   e~mtart IN so_mtart
    AND   k~ekgrp IN so_ekgrp
    AND   k~bsart IN so_bsart
    AND   b~budat IN so_date
    AND   t~etenr EQ '1'
* Ajout des restriction sur code mouvement et stock bloqué
    AND   m~bwart EQ '101'
    AND   m~insmk EQ '3'
* On ne prend que le commandes ayant une référence à une DA
    AND   e~banfn NE ''.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Nov 2007 16:47:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/improve-performance-of-a-sql-request/m-p/2984236#M704668</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-11-06T16:47:58Z</dc:date>
    </item>
    <item>
      <title>Re: Improve performance of a SQL request</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/improve-performance-of-a-sql-request/m-p/2984237#M704669</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can check before the SELECT to make sure that the select-options against key fields are not empty. For example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;CHECK NOT so_lifnr IS INITIAL.

SELECT ...
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Nov 2007 17:02:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/improve-performance-of-a-sql-request/m-p/2984237#M704669</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-11-06T17:02:04Z</dc:date>
    </item>
    <item>
      <title>Re: Improve performance of a SQL request</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/improve-performance-of-a-sql-request/m-p/2984238#M704670</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; Do like this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; declare independent internal tables for each tables&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;select ebeln ebelp werks matkl mtart from ekpo into table git_ekpo
 where werks in so_werks
   and matkl in so_matkl
   and mtart in so_mtart.
if sy-subrc = 0.
 if not git_ekpo[] is initial.
  select lifnr bstyp ekgrp bsart zzreldt from ekko into table git_ekko
    for all entries in git_ekpo
      where ebeln = git_ekpo-ebeln
        and bstyp in so_bstyp
        and lifnr in so_lifnr
        and ekgrp in so_ekgrp
        and bsart in so_bsart.
  if sy-subrc = 0.
   delete git_ekpo where banfn = ' '.
   select ebeln ebelp slfdt from eket into table git_eket
    for all entries in git_ekpo
     where ebeln = git_ekpo-ebeln
       and ebelp = git_ekpo-ebelp
       and etenr = '1'.
   if sy-subrc = 0.
     select ebeln ebelp budat banfn bnfpo from ekbe into table git_ekbe
      for all entries in git_ekpo
       where ebeln = git_ekpo-ebeln
         and ebelp = git_ekpo-ebelp
         and budat in so_budat.
     if sy-subrc = 0.
      select &amp;lt;fields&amp;gt; from mseg into table git_mseg
       for all entries in git_ekpo
        where ebeln = git_ekpo-ebeln
          and ebelp = git_ekpo-ebelp
          and bwart = '101'
          and insmk = '3'.
     endif.
   endif. 
  endif.
 endif.
endif.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;once you get the whole data merge into a single internal table with all the fields.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope your problem will get resolve.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;Reward points if it helps&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Satish&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Nov 2007 19:45:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/improve-performance-of-a-sql-request/m-p/2984238#M704670</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-11-06T19:45:43Z</dc:date>
    </item>
    <item>
      <title>Re: Improve performance of a SQL request</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/improve-performance-of-a-sql-request/m-p/2984239#M704671</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for your suggestion.&lt;/P&gt;&lt;P&gt;It partially solved my problem.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Nov 2007 10:02:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/improve-performance-of-a-sql-request/m-p/2984239#M704671</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-11-09T10:02:51Z</dc:date>
    </item>
    <item>
      <title>Re: Improve performance of a SQL request</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/improve-performance-of-a-sql-request/m-p/2984240#M704672</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Still what is pending to resolve your whole problem?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Nov 2007 10:07:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/improve-performance-of-a-sql-request/m-p/2984240#M704672</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-11-09T10:07:18Z</dc:date>
    </item>
  </channel>
</rss>

