<?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 - identify no match in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-identify-no-match/m-p/1937641#M387624</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;You can code like this:&lt;/P&gt;&lt;P&gt;READ TABLE T_MARA WITH KEY MATNR = '12121'.&lt;/P&gt;&lt;P&gt;IF SY-SUBRC = 0.&lt;/P&gt;&lt;P&gt;WRITE: / 'One Entry Found'.&lt;/P&gt;&lt;P&gt;ELSEIF SY-SUBRC =1.&lt;/P&gt;&lt;P&gt;WRITE: / '2 ENTRIES FOUND'.&lt;/P&gt;&lt;P&gt;ELSEIF SY-SUBRC =2.&lt;/P&gt;&lt;P&gt;WRITE: / '3 ENTRIES FOUND'.&lt;/P&gt;&lt;P&gt;ELSEIF SY-SUBRC =3.&lt;/P&gt;&lt;P&gt;WRITE: / 'MORE THAN 3 ENTRIES FOUND'.&lt;/P&gt;&lt;P&gt;ELSE&lt;/P&gt;&lt;P&gt;WRITE: / 'NO ENTRIES FOUND'.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;iF HELPS PLS MARK POINTS.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;THANKS.&lt;/P&gt;&lt;P&gt;radha.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 20 Feb 2007 17:19:38 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-02-20T17:19:38Z</dc:date>
    <item>
      <title>Read table - identify no match</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-identify-no-match/m-p/1937639#M387622</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;I have got a read table statement with a where clause. The thing is that I have do one thing if there is exactly one match and another thing if there is not match.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As I understand the sy-subrc returns 0 if the query was executed correct. Due to this I will get a sy-subrc=0 if there is no match. So how do I check weather there is one or no matches in the read table statement?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Torben&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Feb 2007 17:03:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-identify-no-match/m-p/1937639#M387622</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-02-20T17:03:40Z</dc:date>
    </item>
    <item>
      <title>Re: Read table - identify no match</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-identify-no-match/m-p/1937640#M387623</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;The sy-subrc will be greater than zero if there is no entry for the corresponding match..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;READ TABLE T_MARA WITH KEY MATNR = '12121'.&lt;/P&gt;&lt;P&gt;IF SY-SUBRC = 0.&lt;/P&gt;&lt;P&gt;  WRITE: / 'Entry found for the corresponding material'.&lt;/P&gt;&lt;P&gt;ELSE.&lt;/P&gt;&lt;P&gt;  WRITE: / 'Entry NOT found'.&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;THanks,&lt;/P&gt;&lt;P&gt;Naren&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Feb 2007 17:06:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-identify-no-match/m-p/1937640#M387623</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-02-20T17:06:19Z</dc:date>
    </item>
    <item>
      <title>Re: Read table - identify no match</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-identify-no-match/m-p/1937641#M387624</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;You can code like this:&lt;/P&gt;&lt;P&gt;READ TABLE T_MARA WITH KEY MATNR = '12121'.&lt;/P&gt;&lt;P&gt;IF SY-SUBRC = 0.&lt;/P&gt;&lt;P&gt;WRITE: / 'One Entry Found'.&lt;/P&gt;&lt;P&gt;ELSEIF SY-SUBRC =1.&lt;/P&gt;&lt;P&gt;WRITE: / '2 ENTRIES FOUND'.&lt;/P&gt;&lt;P&gt;ELSEIF SY-SUBRC =2.&lt;/P&gt;&lt;P&gt;WRITE: / '3 ENTRIES FOUND'.&lt;/P&gt;&lt;P&gt;ELSEIF SY-SUBRC =3.&lt;/P&gt;&lt;P&gt;WRITE: / 'MORE THAN 3 ENTRIES FOUND'.&lt;/P&gt;&lt;P&gt;ELSE&lt;/P&gt;&lt;P&gt;WRITE: / 'NO ENTRIES FOUND'.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;iF HELPS PLS MARK POINTS.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;THANKS.&lt;/P&gt;&lt;P&gt;radha.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Feb 2007 17:19:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-identify-no-match/m-p/1937641#M387624</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-02-20T17:19:38Z</dc:date>
    </item>
    <item>
      <title>Re: Read table - identify no match</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-identify-no-match/m-p/1937642#M387625</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;To Check if there is exactly one match or no mat at all:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;read table itab with key field = &amp;lt;value&amp;gt;.&lt;/P&gt;&lt;P&gt;if sy-subrc = 0.&lt;/P&gt;&lt;P&gt;write:/ 'One match'.&lt;/P&gt;&lt;P&gt;else.&lt;/P&gt;&lt;P&gt;write:/ 'No match'.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Check for Not even one match/ atleast one match&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at itab where field = &amp;lt;value&amp;gt;.&lt;/P&gt;&lt;P&gt;exit.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if sy-subrc = 0.&lt;/P&gt;&lt;P&gt;write:/ 'Atleast one match'.&lt;/P&gt;&lt;P&gt;else.&lt;/P&gt;&lt;P&gt;write:/ 'No matches at all'.&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;Regards,&lt;/P&gt;&lt;P&gt;Ravi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Feb 2007 17:21:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-identify-no-match/m-p/1937642#M387625</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-02-20T17:21:04Z</dc:date>
    </item>
    <item>
      <title>Re: Read table - identify no match</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-identify-no-match/m-p/1937643#M387626</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
DATA: next    LIKE sy-tabix,
      counter TYPE i,
      old_key LIKE itab-f1.

SORT itab BY f1.

READ TABLE itab WITH KEY
  f1 = 'whatever'
  BINARY SEARCH.

IF sy-subrc &amp;lt;&amp;gt; 0.
  WRITE 'No matches'.
ELSE.
  next    = sy-tabix + 1.
  old_key = itab-f1.
  READ TABLE itab INDEX next.
  IF sy-subrc = 0.
    IF itab-f1 = old_key.
      WRITE 'More than one match'.
    ELSE.
      WRITE 'Exactly one match'.
    ENDIF.
  ELSE.
    WRITE 'Exactly one match'.
  ENDIF.
ENDIF.
&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, 20 Feb 2007 17:42:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-table-identify-no-match/m-p/1937643#M387626</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-02-20T17:42:11Z</dc:date>
    </item>
  </channel>
</rss>

