<?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: How to write SQL statement in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-write-sql-statement/m-p/5067706#M1177490</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt; COEP does have a secondary index on OBJNR/KSTAR/GJAHR/PERIO/PAROB1. Check index 2 for COEP in SE11. So your SELECT query on COEP by OBJNR will be efficient as it is the first key of the secondary index.&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Unfortunately, this index is generally &lt;EM&gt;not&lt;/EM&gt; created in the database and so won't help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A better solution is to add LEDNR (which only has a value of 0) to the SELECT and use index COEP~1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 30 Jan 2009 17:29:39 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2009-01-30T17:29:39Z</dc:date>
    <item>
      <title>How to write SQL statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-write-sql-statement/m-p/5067703#M1177487</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear Sir,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We have a following scenario :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We have an Internal Table populated having Fields : OBJNR , WBS&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We have to select all Records from table COEP which have OBJNR field value as per the records in Internal Table . The selected Records will have some Fields from table COEP and WBS Field from Internal Table .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kindly guide us as what statement we need to write so that program execution is efficient .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;With Thanks and Rgds&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sonia&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Jan 2009 16:55:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-write-sql-statement/m-p/5067703#M1177487</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-01-30T16:55:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to write SQL statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-write-sql-statement/m-p/5067704#M1177488</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;COEP does have a secondary index on OBJNR/KSTAR/GJAHR/PERIO/PAROB1. Check index 2 for COEP in SE11. So your SELECT query on COEP by OBJNR will be efficient as it is the first key of the secondary index.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now coming to your question. You need to use the OBJNRs in your internal table to read COEP. So if the OBJNRs are repeated in your table, you need to append them in a separate table containing only OBJNRs, sort them and delete adjacent duplicates. If there are no duplicate OBJNRs in your table then you need not worry.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You then do a &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT * FROM COEP INTO &amp;lt;internal table with the requried fields, itab2&amp;gt;
FOR ALL ENTRIES IN &amp;lt;internal table of unique OBJNR, say itab1&amp;gt;
WHERE OBJNR = &amp;lt;itab1&amp;gt;-OBJNR.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Once done&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;LOOP AT itab2.
  READ TABLE itab1 WITH KEY OBJNR = itab2-objnr BINARY SEARCH. "Assuming itab2 is sorted by OBJRN!
  itab2-WBS = itab1-WBS.
  MODIFY itab2
ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Jan 2009 17:22:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-write-sql-statement/m-p/5067704#M1177488</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-01-30T17:22:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to write SQL statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-write-sql-statement/m-p/5067705#M1177489</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I hope thi codes helps you...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT OBJNR WBS...  FIELD1 FIELD2 FIELD3  etc...&lt;/P&gt;&lt;P&gt;INTO CORRESPONDING FIELDS OF TABLE I_TAB_OUT&lt;/P&gt;&lt;P&gt;FOR ALL ENTRIES IN I_TAB_IN&lt;/P&gt;&lt;P&gt;FROM COEP&lt;/P&gt;&lt;P&gt;WHERE COEP-OBJNR EQ I_TAB_IN-OBJNR&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Jan 2009 17:24:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-write-sql-statement/m-p/5067705#M1177489</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-01-30T17:24:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to write SQL statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-write-sql-statement/m-p/5067706#M1177490</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt; COEP does have a secondary index on OBJNR/KSTAR/GJAHR/PERIO/PAROB1. Check index 2 for COEP in SE11. So your SELECT query on COEP by OBJNR will be efficient as it is the first key of the secondary index.&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Unfortunately, this index is generally &lt;EM&gt;not&lt;/EM&gt; created in the database and so won't help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A better solution is to add LEDNR (which only has a value of 0) to the SELECT and use index COEP~1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Jan 2009 17:29:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-write-sql-statement/m-p/5067706#M1177490</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-01-30T17:29:39Z</dc:date>
    </item>
  </channel>
</rss>

