<?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 Program  using mseg .How to reduce DB time.. in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/program-using-mseg-how-to-reduce-db-time/m-p/1703490#M308263</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;   SELECT&lt;/P&gt;&lt;P&gt;         mblnr&lt;/P&gt;&lt;P&gt;         mjahr&lt;/P&gt;&lt;P&gt;         bwart&lt;/P&gt;&lt;P&gt;         matnr&lt;/P&gt;&lt;P&gt;         werks&lt;/P&gt;&lt;P&gt;         lgort&lt;/P&gt;&lt;P&gt;         charg&lt;/P&gt;&lt;P&gt;         sobkz&lt;/P&gt;&lt;P&gt;         lifnr&lt;/P&gt;&lt;P&gt;         shkzg&lt;/P&gt;&lt;P&gt;         waers&lt;/P&gt;&lt;P&gt;         dmbtr&lt;/P&gt;&lt;P&gt;         menge&lt;/P&gt;&lt;P&gt;         meins&lt;/P&gt;&lt;P&gt;         ebeln&lt;/P&gt;&lt;P&gt;         ebelp&lt;/P&gt;&lt;P&gt;         kostl&lt;/P&gt;&lt;P&gt;         aufnr&lt;/P&gt;&lt;P&gt;         bukrs&lt;/P&gt;&lt;P&gt;  INTO CORRESPONDING FIELDS OF TABLE imseg&lt;/P&gt;&lt;P&gt;  FROM mseg CLIENT SPECIFIED&lt;/P&gt;&lt;P&gt;  FOR ALL ENTRIES IN imkpf&lt;/P&gt;&lt;P&gt;  WHERE mandt = sy-mandt&lt;/P&gt;&lt;P&gt;    AND mblnr = imkpf-mblnr&lt;/P&gt;&lt;P&gt;    AND mjahr = imkpf-mjahr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;     DELETE imseg  WHERE NOT ( sobkz EQ 'K' ) .&lt;/P&gt;&lt;P&gt;     DELETE imseg  WHERE NOT ( bwart = '411' OR bwart = '412' ) .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  IF NOT ( s_werks IS INITIAL ) .                        &lt;/P&gt;&lt;P&gt;     DELETE imseg  WHERE NOT ( werks IN s_werks ) .       &lt;/P&gt;&lt;P&gt;  ENDIF.                                                 &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  IF NOT ( p_bukrs IS INITIAL ) .                       &lt;/P&gt;&lt;P&gt;     DELETE imseg  WHERE NOT ( bukrs EQ p_bukrs ) .  &lt;/P&gt;&lt;P&gt;  ENDIF.                                               &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Above given is the query.Here &amp;lt;b&amp;gt;werks&amp;lt;/b&amp;gt; and &amp;lt;b&amp;gt;bukrs&amp;lt;/b&amp;gt; are mandatory field.&lt;/P&gt;&lt;P&gt;MSEG contains three key fields,two of them are given in where clause.&lt;/P&gt;&lt;P&gt;" INTO CORRESPONDING FIELDS OF TABLE imseg" statement can't be removed.&lt;/P&gt;&lt;P&gt;So these are the conditions.Please give some suggestion specific to this so that i can reduce the DB fetching time.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance,&lt;/P&gt;&lt;P&gt;Shyam&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 15 Nov 2006 06:29:44 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2006-11-15T06:29:44Z</dc:date>
    <item>
      <title>Program  using mseg .How to reduce DB time..</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/program-using-mseg-how-to-reduce-db-time/m-p/1703490#M308263</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;   SELECT&lt;/P&gt;&lt;P&gt;         mblnr&lt;/P&gt;&lt;P&gt;         mjahr&lt;/P&gt;&lt;P&gt;         bwart&lt;/P&gt;&lt;P&gt;         matnr&lt;/P&gt;&lt;P&gt;         werks&lt;/P&gt;&lt;P&gt;         lgort&lt;/P&gt;&lt;P&gt;         charg&lt;/P&gt;&lt;P&gt;         sobkz&lt;/P&gt;&lt;P&gt;         lifnr&lt;/P&gt;&lt;P&gt;         shkzg&lt;/P&gt;&lt;P&gt;         waers&lt;/P&gt;&lt;P&gt;         dmbtr&lt;/P&gt;&lt;P&gt;         menge&lt;/P&gt;&lt;P&gt;         meins&lt;/P&gt;&lt;P&gt;         ebeln&lt;/P&gt;&lt;P&gt;         ebelp&lt;/P&gt;&lt;P&gt;         kostl&lt;/P&gt;&lt;P&gt;         aufnr&lt;/P&gt;&lt;P&gt;         bukrs&lt;/P&gt;&lt;P&gt;  INTO CORRESPONDING FIELDS OF TABLE imseg&lt;/P&gt;&lt;P&gt;  FROM mseg CLIENT SPECIFIED&lt;/P&gt;&lt;P&gt;  FOR ALL ENTRIES IN imkpf&lt;/P&gt;&lt;P&gt;  WHERE mandt = sy-mandt&lt;/P&gt;&lt;P&gt;    AND mblnr = imkpf-mblnr&lt;/P&gt;&lt;P&gt;    AND mjahr = imkpf-mjahr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;     DELETE imseg  WHERE NOT ( sobkz EQ 'K' ) .&lt;/P&gt;&lt;P&gt;     DELETE imseg  WHERE NOT ( bwart = '411' OR bwart = '412' ) .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  IF NOT ( s_werks IS INITIAL ) .                        &lt;/P&gt;&lt;P&gt;     DELETE imseg  WHERE NOT ( werks IN s_werks ) .       &lt;/P&gt;&lt;P&gt;  ENDIF.                                                 &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  IF NOT ( p_bukrs IS INITIAL ) .                       &lt;/P&gt;&lt;P&gt;     DELETE imseg  WHERE NOT ( bukrs EQ p_bukrs ) .  &lt;/P&gt;&lt;P&gt;  ENDIF.                                               &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Above given is the query.Here &amp;lt;b&amp;gt;werks&amp;lt;/b&amp;gt; and &amp;lt;b&amp;gt;bukrs&amp;lt;/b&amp;gt; are mandatory field.&lt;/P&gt;&lt;P&gt;MSEG contains three key fields,two of them are given in where clause.&lt;/P&gt;&lt;P&gt;" INTO CORRESPONDING FIELDS OF TABLE imseg" statement can't be removed.&lt;/P&gt;&lt;P&gt;So these are the conditions.Please give some suggestion specific to this so that i can reduce the DB fetching time.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance,&lt;/P&gt;&lt;P&gt;Shyam&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Nov 2006 06:29:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/program-using-mseg-how-to-reduce-db-time/m-p/1703490#M308263</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-15T06:29:44Z</dc:date>
    </item>
    <item>
      <title>Re: Program  using mseg .How to reduce DB time..</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/program-using-mseg-how-to-reduce-db-time/m-p/1703491#M308264</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Shyam,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would suggest you create a database view using MKPF and MSEG. This will help as the databsae will handle the performance part and make the query optimised.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Nov 2006 07:20:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/program-using-mseg-how-to-reduce-db-time/m-p/1703491#M308264</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-15T07:20:46Z</dc:date>
    </item>
    <item>
      <title>Re: Program  using mseg .How to reduce DB time..</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/program-using-mseg-how-to-reduce-db-time/m-p/1703492#M308265</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear Shyam,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1)Declare a internal table for all fileds in filed list of SELECT statement (Avoid into corresponding fields clause).&lt;/P&gt;&lt;P&gt;  TYPES: BEGIN OF tys_mseg,&lt;/P&gt;&lt;P&gt;                 mblnr TYPE mblnr,&lt;/P&gt;&lt;P&gt;                 mjahr TYPE mjahr,&lt;/P&gt;&lt;P&gt;                 bwart TYPE bwart,&lt;/P&gt;&lt;P&gt;                 matnr TYPE matnr,&lt;/P&gt;&lt;P&gt;                 werks TYPE werks_d,&lt;/P&gt;&lt;P&gt;                 lgort TYPE lgort_d,&lt;/P&gt;&lt;P&gt;                 charg TYPE charg_d,&lt;/P&gt;&lt;P&gt;                 sobkz TYPE sobkz,&lt;/P&gt;&lt;P&gt;                 lifnr TYPE elifn,&lt;/P&gt;&lt;P&gt;                 shkzg TYPE shkzg,&lt;/P&gt;&lt;P&gt;                 waers TYPE waers,&lt;/P&gt;&lt;P&gt;                dmbtr TYPE dmbtr,&lt;/P&gt;&lt;P&gt;                menge TYPE menge_d,&lt;/P&gt;&lt;P&gt;                meins TYPE meins,&lt;/P&gt;&lt;P&gt;                ebeln TYPE bstnr,&lt;/P&gt;&lt;P&gt;                ebelp TYPE ebelp,&lt;/P&gt;&lt;P&gt;                kostl TYPE kostl,&lt;/P&gt;&lt;P&gt;                aufnr TYPE kostl,&lt;/P&gt;&lt;P&gt;                bukrs TYPE bukrs,&lt;/P&gt;&lt;P&gt;       END OF tys_mseg.&lt;/P&gt;&lt;P&gt;    DATA: it_mseg  TYPE TABLE OF tys_mseg.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2) Better to avoid usage of paritial key .&lt;/P&gt;&lt;P&gt;3) Don't use SY-MANDT field in where clause. System will take care (Since data is client dependent)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now query will be look like this.&lt;/P&gt;&lt;P&gt;IF  NOT imkpf[]  IS INITIAL.&lt;/P&gt;&lt;P&gt;SELECT&lt;/P&gt;&lt;P&gt;mblnr&lt;/P&gt;&lt;P&gt;mjahr&lt;/P&gt;&lt;P&gt;bwart&lt;/P&gt;&lt;P&gt;matnr&lt;/P&gt;&lt;P&gt;werks&lt;/P&gt;&lt;P&gt;lgort&lt;/P&gt;&lt;P&gt;charg&lt;/P&gt;&lt;P&gt;sobkz&lt;/P&gt;&lt;P&gt;lifnr&lt;/P&gt;&lt;P&gt;shkzg&lt;/P&gt;&lt;P&gt;waers&lt;/P&gt;&lt;P&gt;dmbtr&lt;/P&gt;&lt;P&gt;menge&lt;/P&gt;&lt;P&gt;meins&lt;/P&gt;&lt;P&gt;ebeln&lt;/P&gt;&lt;P&gt;ebelp&lt;/P&gt;&lt;P&gt;kostl&lt;/P&gt;&lt;P&gt;aufnr&lt;/P&gt;&lt;P&gt;bukrs&lt;/P&gt;&lt;P&gt;INTO TABLE it_mseg&lt;/P&gt;&lt;P&gt;FROM mseg &lt;/P&gt;&lt;P&gt;FOR ALL ENTRIES IN imkpf&lt;/P&gt;&lt;P&gt;WHERE mblnr EQ imkpf-mblnr&lt;/P&gt;&lt;P&gt;      AND mjahr EQ imkpf-mjahr.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If its helpful reward points.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Bhupal Reddy&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Nov 2006 07:24:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/program-using-mseg-how-to-reduce-db-time/m-p/1703492#M308265</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-15T07:24:32Z</dc:date>
    </item>
    <item>
      <title>Re: Program  using mseg .How to reduce DB time..</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/program-using-mseg-how-to-reduce-db-time/m-p/1703493#M308266</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Shyam!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As already said, an into table will be faster. But if you can't re-sort your fields, then an additional table, looping and filling your final result table will take longer.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Otherwise, add your additional selection criteria to your select. It will not make your select faster (because the primary key (without posnr) is fastest possible access), but you will get less entries -&amp;gt; less data to be transferred via network between DB server and application server.&lt;/P&gt;&lt;P&gt;At least werks and bukrs make sense, but also sobkz and bwart can be added. This fields can't be used for an index access (NOT), but they don't belong to the primary key anyway.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;...FROM mseg 
WHERE mblnr = imkpf-mblnr
AND mjahr = imkpf-mjahr
AND werks = p_werks
AND bukrs = p_bukrs
AND sobkz NE 'K'
AND NOT bwart in ('411', '412').
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Christian&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Nov 2006 07:55:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/program-using-mseg-how-to-reduce-db-time/m-p/1703493#M308266</guid>
      <dc:creator>christian_wohlfahrt</dc:creator>
      <dc:date>2006-11-15T07:55:49Z</dc:date>
    </item>
    <item>
      <title>Re: Program  using mseg .How to reduce DB time..</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/program-using-mseg-how-to-reduce-db-time/m-p/1703494#M308267</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Shyam&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want use move-corresponding and the same internal table; there is nothing much left to improve the performance other than including the sobkz, bwart, werks, bukrs and avoid fetching these records.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Why do you fetch them and delete? You can restrict by giving them in Where class.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Surya.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Nov 2006 08:00:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/program-using-mseg-how-to-reduce-db-time/m-p/1703494#M308267</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-15T08:00:20Z</dc:date>
    </item>
    <item>
      <title>Re: Program  using mseg .How to reduce DB time..</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/program-using-mseg-how-to-reduce-db-time/m-p/1703495#M308268</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;as others have sadi, instead of deleting include the criteria directly in the where clause BUT they are in fact positive conditions, and therefore may utilize an index if one is available:&lt;/P&gt;&lt;P&gt;WHERE mblnr = imkpf-mblnr&lt;/P&gt;&lt;P&gt;AND mjahr = imkpf-mjahr&lt;/P&gt;&lt;P&gt;AND werks = p_werks&lt;/P&gt;&lt;P&gt;AND bukrs = p_bukrs&lt;/P&gt;&lt;P&gt;AND sobkz = 'K'&lt;/P&gt;&lt;P&gt;AND bwart in ('411', '412').&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Nov 2006 04:17:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/program-using-mseg-how-to-reduce-db-time/m-p/1703495#M308268</guid>
      <dc:creator>former_member186741</dc:creator>
      <dc:date>2006-11-16T04:17:49Z</dc:date>
    </item>
  </channel>
</rss>

