<?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: Better code .... in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/better-code/m-p/4652473#M1094786</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;1st one is better...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2nd one is similar to aloop and is not usually preffered&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 24 Oct 2008 08:58:32 GMT</pubDate>
    <dc:creator>former_member195383</dc:creator>
    <dc:date>2008-10-24T08:58:32Z</dc:date>
    <item>
      <title>Better code ....</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/better-code/m-p/4652471#M1094784</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt; Of the below 2 set of codes (Set 1 and set 2 ) which is more optimized? And do i get the same output in both the set of codes? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; Set 1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  SELECT single JOBNAME &lt;/P&gt;&lt;P&gt;  FROM    tbtco&lt;/P&gt;&lt;P&gt;  into    w_jobname&lt;/P&gt;&lt;P&gt;  WHERE   jobname   = jobname AND &lt;/P&gt;&lt;P&gt;          ( status  = 'R' OR   status   = 'Y'    ).                 &lt;/P&gt;&lt;P&gt;    IF sy-subrc = 0.&lt;/P&gt;&lt;P&gt;      w_jobnam_found = 'Y'.            &lt;/P&gt;&lt;P&gt;    ENDIF.&lt;/P&gt;&lt;P&gt;    &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; set 2&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;  SELECT * FROM tbtco  WHERE jobname = jobname&lt;/P&gt;&lt;P&gt;     AND ( status = 'R'     OR status = 'Y' ). &lt;/P&gt;&lt;P&gt;    IF sy-subrc = 0.&lt;/P&gt;&lt;P&gt;      jobname_found = 'Y'.&lt;/P&gt;&lt;P&gt;      EXIT.&lt;/P&gt;&lt;P&gt;    ENDIF.&lt;/P&gt;&lt;P&gt;  ENDSELECT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regds,&lt;/P&gt;&lt;P&gt;M..&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Oct 2008 08:55:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/better-code/m-p/4652471#M1094784</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-10-24T08:55:58Z</dc:date>
    </item>
    <item>
      <title>Re: Better code ....</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/better-code/m-p/4652472#M1094785</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;If you are selecting only one job, then select single is enough and select ...endselect is not.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However you need to make sure that when you use select single, you use the primary key, always, in the where clause.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since you aren't using the primary key to select from the table  tbtco, there are chances that you will get multiple records and select single will not work as expected. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;Advait&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Advait Gode on Oct 24, 2008 10:58 AM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Oct 2008 08:58:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/better-code/m-p/4652472#M1094785</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-10-24T08:58:26Z</dc:date>
    </item>
    <item>
      <title>Re: Better code ....</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/better-code/m-p/4652473#M1094786</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;1st one is better...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2nd one is similar to aloop and is not usually preffered&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Oct 2008 08:58:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/better-code/m-p/4652473#M1094786</guid>
      <dc:creator>former_member195383</dc:creator>
      <dc:date>2008-10-24T08:58:32Z</dc:date>
    </item>
    <item>
      <title>Re: Better code ....</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/better-code/m-p/4652474#M1094787</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi madhu,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;First of all you will not get same result if there are more  data to satisfy your where condition. because SELECT... ENDSELECT works like a loop and will all the data which will satis fy the codition and SELECT SINGLE will choose only the first data which satisfy the condition.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Secondly,if you consider the performance issue , obviously 1st one is better as in SELECT...FROM...INTO works in batch process an losad all the data in the internal table and send it to apps server unlike SELECT... ENDSELECT , where each datum is fetch separately . SELECT....ENDSELECT cuase more load to data-server.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards, &lt;/P&gt;&lt;P&gt;Anirban&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Oct 2008 08:58:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/better-code/m-p/4652474#M1094787</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-10-24T08:58:51Z</dc:date>
    </item>
    <item>
      <title>Re: Better code ....</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/better-code/m-p/4652475#M1094788</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;EM&gt;why don't you just run it yourself and find out?&lt;/EM&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Oct 2008 08:59:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/better-code/m-p/4652475#M1094788</guid>
      <dc:creator>ThomasZloch</dc:creator>
      <dc:date>2008-10-24T08:59:22Z</dc:date>
    </item>
    <item>
      <title>Re: Better code ....</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/better-code/m-p/4652476#M1094789</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Madhu,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The Set of code that contains "select single" is the optmized part as it contact database only once and retreives record once based on the given condition.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Where as the second set that has SELECT and ENDSELECT, has to contact database for every single record until the given condition matches....this reduces the performance to a very large extent.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;Ram.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Oct 2008 08:59:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/better-code/m-p/4652476#M1094789</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-10-24T08:59:31Z</dc:date>
    </item>
    <item>
      <title>Re: Better code ....</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/better-code/m-p/4652477#M1094790</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If the objective is to only check if any entry exists in the table with a specific jobname and the statuse has to be R or Y, than the best way is:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT COUNT( * )
FROM tbtco
WHERE jobname EQ jobname
AND (status EQ 'R' OR status EQ 'Y').
IF sy-subrc EQ 0.
==&amp;gt; entry exists
ELSE.
==&amp;gt; entry does not exist
ENDIF.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Oct 2008 09:03:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/better-code/m-p/4652477#M1094790</guid>
      <dc:creator>JozsefSzikszai</dc:creator>
      <dc:date>2008-10-24T09:03:04Z</dc:date>
    </item>
    <item>
      <title>Re: Better code ....</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/better-code/m-p/4652478#M1094791</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;Set 1 is more optimised and better than Set2. SAP itself recommends not to use Select..Endselect because of the performance issue.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As you juset need to check whether any entry exist for the given criteria then first Set is perfect.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; Regards,&lt;/P&gt;&lt;P&gt;Navneeth K.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Oct 2008 09:18:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/better-code/m-p/4652478#M1094791</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-10-24T09:18:58Z</dc:date>
    </item>
  </channel>
</rss>

