<?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: read table with key in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-with-key/m-p/7040491#M1500581</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes you are right it gives AND statement,I am not sure how you can make it OR&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Bala Duvvuri&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 30 Jun 2010 05:54:44 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2010-06-30T05:54:44Z</dc:date>
    <item>
      <title>read table with key</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-with-key/m-p/7040487#M1500577</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;dear all, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i have a BW abap question for you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;this code is to select from a table and field /BIC/ZSFPPD96 is the key.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
*   cache mapping table once
    IF g_t_sample IS INITIAL.
      SELECT /BIC/ZSFPPD96 /BIC/ZSFPPD95 /BIC/ZSFPPD94
        FROM /BIC/PZSFPPD96
        INTO CORRESPONDING FIELDS OF TABLE g_t_project
        WHERE objvers = 'A'.
    ENDIF.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;somewhere down there i have this code  and this is where my problem is... the scenario is i would like to use both field ZSFPPD95 and ZSFPPD94 as key fields and how can i get this done? thanks&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
*   look up Project code based on IO
    READ TABLE g_t_project INTO g_s_project WITH TABLE KEY
      /BIC/ZSFPPD95 = SOURCE_FIELDS-/BIC/ZSFPPD95 OR /BIC/ZSFPPD94 = SOURCE_FIELDS-/BIC/ZSFPPD94.

    IF sy-subrc = 0.
      RESULT = g_s_project-/bic/zattr1.
    ELSE.
      RESULT = ''.
    ENDIF.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Jun 2010 05:38:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-with-key/m-p/7040487#M1500577</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-06-30T05:38:34Z</dc:date>
    </item>
    <item>
      <title>Re: read table with key</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-with-key/m-p/7040488#M1500578</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;remove the OR condtion&lt;/P&gt;&lt;P&gt;READ TABLE g_t_project INTO g_s_project WITH TABLE KEY&lt;/P&gt;&lt;P&gt;      /BIC/ZSFPPD95 = SOURCE_FIELDS-/BIC/ZSFPPD95   /BIC/ZSFPPD94 = SOURCE_FIELDS-/BIC/ZSFPPD94.&lt;/P&gt;&lt;P&gt;Press F1 or read and check the syntax&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Bala Duvvuri&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Jun 2010 05:46:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-with-key/m-p/7040488#M1500578</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-06-30T05:46:27Z</dc:date>
    </item>
    <item>
      <title>Re: read table with key</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-with-key/m-p/7040489#M1500579</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hello bala, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;by removing the OR, wont it give me an AND statement?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Jun 2010 05:48:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-with-key/m-p/7040489#M1500579</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-06-30T05:48:52Z</dc:date>
    </item>
    <item>
      <title>Re: read table with key</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-with-key/m-p/7040490#M1500580</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;In the Read table Statement , we cannot use AND , OR Conditions . Remove the OR and try.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In this case , value combination of Fields /BIC/ZSFPPD95  and /BIC/ZSFPPD94 , READ TABLE STATEMENT RETRIEVE the record.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
*   look up Project code based on IO
    READ TABLE g_t_project INTO g_s_project WITH TABLE KEY
      /BIC/ZSFPPD95 = SOURCE_FIELDS-/BIC/ZSFPPD95  /BIC/ZSFPPD94 = SOURCE_FIELDS-/BIC/ZSFPPD94.
 
    IF sy-subrc = 0.
      RESULT = g_s_project-/bic/zattr1.
    ELSE.
      RESULT = ''.
    ENDIF.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Jun 2010 05:51:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-with-key/m-p/7040490#M1500580</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-06-30T05:51:29Z</dc:date>
    </item>
    <item>
      <title>Re: read table with key</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-with-key/m-p/7040491#M1500581</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes you are right it gives AND statement,I am not sure how you can make it OR&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Bala Duvvuri&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Jun 2010 05:54:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-with-key/m-p/7040491#M1500581</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-06-30T05:54:44Z</dc:date>
    </item>
    <item>
      <title>Re: read table with key</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-with-key/m-p/7040492#M1500582</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hello, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;how is that going to give me an OR statement?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Jun 2010 05:55:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-with-key/m-p/7040492#M1500582</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-06-30T05:55:02Z</dc:date>
    </item>
    <item>
      <title>Re: read table with key</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-with-key/m-p/7040493#M1500583</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;&lt;/P&gt;&lt;P&gt;you need to break the READ TABLE statement as below , it will work. as per this , read table statement will try for /BIC/ZSFPPD95 ( Key 1 ) , if It fails , REad table will try to find the record with /BIC/ZSFPPD94 ( key 2 ) , even then it fails My result ( Target value ) will be blank.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
*   look up Project code based on IO
    READ TABLE g_t_project INTO g_s_project WITH TABLE KEY
      /BIC/ZSFPPD95 = SOURCE_FIELDS-/BIC/ZSFPPD95.
 
    IF sy-subrc = 0.
      RESULT = g_s_project-/bic/zattr1.
    ELSE.

       READ TABLE g_t_project INTO g_s_project WITH TABLE KEY   /BIC/ZSFPPD94 = SOURCE_FIELDS-/BIC/ZSFPPD94.
 
       IF sy-subrc = 0.
         RESULT = g_s_project-/bic/zattr1.
        ELSE.
         RESULT = ''.
       ENDIF.
ENDIF.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Prasath Arivazhagan on Jun 30, 2010 8:00 AM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Jun 2010 06:00:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-with-key/m-p/7040493#M1500583</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-06-30T06:00:06Z</dc:date>
    </item>
    <item>
      <title>Re: read table with key</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-with-key/m-p/7040494#M1500584</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HI &lt;/P&gt;&lt;P&gt;first you need to check that your key field should be the primary key. so that you can avoid multiple records because read table will fetch only one record.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and rather using read table statement you can use llop at your internal table with condition&lt;/P&gt;&lt;P&gt;like loop at internal table itab where &amp;lt;field1&amp;gt; = 'some value' and &amp;lt;field2&amp;gt; = 'some values'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;in this case it will check both the conditions and will fethc the values only if both the conditions will meat.&lt;/P&gt;&lt;P&gt;but in this scenario if you have multiple values for the same combination you will have multiple records.&lt;/P&gt;&lt;P&gt;therefor you need to check that both the fields are primary fields of the table so that you can avoid the duplicacy of the record.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope this will clear your doubt.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;removed by moderator&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;P&gt;Lalit Gupta&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Thomas Zloch on Jun 30, 2010 12:30 PM - &lt;STRONG&gt;do not ask for points&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Jun 2010 09:30:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-with-key/m-p/7040494#M1500584</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-06-30T09:30:07Z</dc:date>
    </item>
    <item>
      <title>Re: read table with key</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-with-key/m-p/7040495#M1500585</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As you have mentioned in the table /BIC/PZSFPPD96, the key field is /BIC/ZSFPPD96. So how do you expect to get a unique record for the non-key fields ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Jun 2010 10:19:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-with-key/m-p/7040495#M1500585</guid>
      <dc:creator>SuhaSaha</dc:creator>
      <dc:date>2010-06-30T10:19:44Z</dc:date>
    </item>
    <item>
      <title>Re: read table with key</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-with-key/m-p/7040496#M1500586</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think the g_t_project is of sorted or hased type, so try this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
loop at g_t_project  INTO g_s_project where  /BIC/ZSFPPD95 = SOURCE_FIELDS-/BIC/ZSFPPD95 
                                                                        or /BIC/ZSFPPD94 = SOURCE_FIELDS-/BIC/ZSFPPD94.
RESULT = g_s_project-/bic/zattr1.
exit.
endloop.

if sy-subrc ne 0.
clear result.
endif.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;@Suhas - + 1 .... didnt notice that &lt;SPAN __jive_emoticon_name="happy"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Keshav.T on Jun 30, 2010 4:03 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Jun 2010 10:32:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-with-key/m-p/7040496#M1500586</guid>
      <dc:creator>kesavadas_thekkillath</dc:creator>
      <dc:date>2010-06-30T10:32:03Z</dc:date>
    </item>
  </channel>
</rss>

