<?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: error handling in a select statement in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/error-handling-in-a-select-statement/m-p/8373372#M1642135</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi goel,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;... or, as I love it simple.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;AT SELECTION-SCREEN ON s_lifnr.
  LOOP AT s_lifnr WHERE SIGN NE 'I' OR OPTION NE 'EQ'.
    MESSAGE TYPE 'E' 'Enter distinct numers only!'.
  ENDLOOP.
  
START-OF-SELECTION.

LOOP AT s_lifnr .
  SELECT COUNT ( * )  FROM lfa1
    WHERE lifnr = s_lifnr-low 
      AND bukrs = '001'.
  CHECK sy-subrc &amp;amp;lt;&amp;amp;gt; 0.
  it_invalid-lifnr = s_lifnr-low  .
  APPEND it_invalid.
ENDLOOP&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Clemens&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Clemens Li on Nov 1, 2011 10:36 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 01 Nov 2011 21:36:37 GMT</pubDate>
    <dc:creator>Clemenss</dc:creator>
    <dc:date>2011-11-01T21:36:37Z</dc:date>
    <item>
      <title>error handling in a select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/error-handling-in-a-select-statement/m-p/8373362#M1642125</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;I am working on a report andwe have two fields on the selection screen: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Vendor Number: &lt;/P&gt;&lt;P&gt;Sortl: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;on the selection screen user will enter the list of vendors and then I need to update the field SORTL with what user enters on the field SORTL on the selection screen. for this I have written the following code: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT lifnr FROM lfa1
                   INTO TABLE it_lfa1
                   WHERE lifnr IN s_lifnr AND
                         bukrs = '001'.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;the above code is updating the table it_lfa1with the valid vendor numbers, but I need to put a logic that if a user enters an invalid vendor number then it should produce an error log for all the invalid vendor number and for thsi I modify the above code as: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT lifnr FROM lfa1
                   INTO TABLE it_lfa1
                   WHERE lifnr IN s_lifnr AND
                         bukrs = '001'.

if sy-subrc &amp;lt;&amp;gt; 0.
move s_lifnr to it_invalid-lifnr.
endif.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;but when I use the above code it just look for the first vendor and then just don't continue with the other vendors entered by the user. can you please tell what am i doing wrong here?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 Nov 2011 14:51:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/error-handling-in-a-select-statement/m-p/8373362#M1642125</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-11-01T14:51:18Z</dc:date>
    </item>
    <item>
      <title>Re: error handling in a select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/error-handling-in-a-select-statement/m-p/8373363#M1642126</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;your code seems to be incomplete. What do you mean &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;if sy-subrc  0.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 Nov 2011 15:08:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/error-handling-in-a-select-statement/m-p/8373363#M1642126</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-11-01T15:08:38Z</dc:date>
    </item>
    <item>
      <title>Re: error handling in a select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/error-handling-in-a-select-statement/m-p/8373364#M1642127</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am sorry I meant: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;IF sy-subrc ne 0.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 Nov 2011 15:18:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/error-handling-in-a-select-statement/m-p/8373364#M1642127</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-11-01T15:18:51Z</dc:date>
    </item>
    <item>
      <title>Re: error handling in a select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/error-handling-in-a-select-statement/m-p/8373365#M1642128</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi rahul , &lt;/P&gt;&lt;P&gt;i think you r missing the loop statement .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
loop at s_lifnr .
SELECT lifnr FROM lfa1
                   INTO TABLE it_lfa1
                   WHERE lifnr IN s_lifnr AND
                         bukrs = '001'.
 
if sy-subrc = 0.
move s_lifnr to it_invalid-lifnr.
endif.
endloop 
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards &lt;/P&gt;&lt;P&gt;ranjan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 Nov 2011 15:29:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/error-handling-in-a-select-statement/m-p/8373365#M1642128</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-11-01T15:29:32Z</dc:date>
    </item>
    <item>
      <title>Re: error handling in a select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/error-handling-in-a-select-statement/m-p/8373366#M1642129</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This code won't work because it absolutely incorrect. I think you've meant that "it_invalid" is a table. If yes, you don't have any appends or inserts to fill this table.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 Nov 2011 15:35:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/error-handling-in-a-select-statement/m-p/8373366#M1642129</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-11-01T15:35:24Z</dc:date>
    </item>
    <item>
      <title>Re: error handling in a select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/error-handling-in-a-select-statement/m-p/8373367#M1642130</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;
loop at s_lifnr .
SELECT lifnr FROM lfa1
                   INTO TABLE it_lfa1
                   WHERE lifnr IN s_lifnr AND
                         bukrs = '001'.
 
if sy-subrc &amp;lt;&amp;gt;  0.
 it_invalid-lifnr  =  s_lifnr  .

append  it_invalid  .
endloop .
endif.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards &lt;/P&gt;&lt;P&gt;ranjan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 Nov 2011 15:53:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/error-handling-in-a-select-statement/m-p/8373367#M1642130</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-11-01T15:53:26Z</dc:date>
    </item>
    <item>
      <title>Re: error handling in a select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/error-handling-in-a-select-statement/m-p/8373368#M1642131</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;And what to do if the SELECT-OPTIONS contain ranges or exclusions or patterns or...?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 Nov 2011 15:58:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/error-handling-in-a-select-statement/m-p/8373368#M1642131</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-11-01T15:58:06Z</dc:date>
    </item>
    <item>
      <title>Re: error handling in a select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/error-handling-in-a-select-statement/m-p/8373369#M1642132</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I agree Rob... any suggestion please?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 Nov 2011 16:03:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/error-handling-in-a-select-statement/m-p/8373369#M1642132</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-11-01T16:03:06Z</dc:date>
    </item>
    <item>
      <title>Re: error handling in a select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/error-handling-in-a-select-statement/m-p/8373370#M1642133</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It's a mug's game. Explain the problems to the person who gave you the requirements and see if they will change them to something more reasonable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 Nov 2011 16:12:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/error-handling-in-a-select-statement/m-p/8373370#M1642133</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-11-01T16:12:38Z</dc:date>
    </item>
    <item>
      <title>Re: error handling in a select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/error-handling-in-a-select-statement/m-p/8373371#M1642134</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;Well, If the user always enter a list as selection (no range, exclusion, ...), I can understand the need.. otherwise this is indeed a bit strange... In case they only need to use single element list in SO, you could restrict all other SO features with the FM SELECT_OPTIONS_RESTRICT and then loop on values and select each single vendor... &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;E.g under your INITIALIZATION event:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
* Only option 'EQ' and sign 'I' are allowed
  lt_opt_list-name        = 'ONLY_EQ'.
  lt_opt_list-options-eq  = 'X'.
  APPEND lt_opt_list TO ls_restriction-opt_list_tab.

  lt_ass-kind             = 'S'.        "select-option
  lt_ass-name             = 'S_LIFNR'.  "name of select-option
  lt_ass-sg_main          = 'I'.        "only inclusive
  lt_ass-sg_addy          = space.
  lt_ass-op_main          = 'ONLY_EQ'.
  lt_ass-op_addy          = space.
  APPEND lt_ass TO ls_restriction-ass_tab.

  CALL FUNCTION 'SELECT_OPTIONS_RESTRICT'
    EXPORTING
      restriction            = ls_restriction
    EXCEPTIONS
      too_late               = 1
      repeated               = 2
      selopt_without_options = 3
      selopt_without_signs   = 4
      invalid_sign           = 5
      empty_option_list      = 6
      invalid_kind           = 7
      repeated_kind_a        = 8
      OTHERS                 = 9.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then just loop on SO table, select single and check subrc...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kr,&lt;/P&gt;&lt;P&gt;Manu.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 Nov 2011 18:33:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/error-handling-in-a-select-statement/m-p/8373371#M1642134</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-11-01T18:33:20Z</dc:date>
    </item>
    <item>
      <title>Re: error handling in a select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/error-handling-in-a-select-statement/m-p/8373372#M1642135</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi goel,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;... or, as I love it simple.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;AT SELECTION-SCREEN ON s_lifnr.
  LOOP AT s_lifnr WHERE SIGN NE 'I' OR OPTION NE 'EQ'.
    MESSAGE TYPE 'E' 'Enter distinct numers only!'.
  ENDLOOP.
  
START-OF-SELECTION.

LOOP AT s_lifnr .
  SELECT COUNT ( * )  FROM lfa1
    WHERE lifnr = s_lifnr-low 
      AND bukrs = '001'.
  CHECK sy-subrc &amp;amp;lt;&amp;amp;gt; 0.
  it_invalid-lifnr = s_lifnr-low  .
  APPEND it_invalid.
ENDLOOP&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Clemens&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Clemens Li on Nov 1, 2011 10:36 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 Nov 2011 21:36:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/error-handling-in-a-select-statement/m-p/8373372#M1642135</guid>
      <dc:creator>Clemenss</dc:creator>
      <dc:date>2011-11-01T21:36:37Z</dc:date>
    </item>
    <item>
      <title>Re: error handling in a select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/error-handling-in-a-select-statement/m-p/8373373#M1642136</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;SELECT lifnr&lt;/P&gt;&lt;P&gt;   FROM lfa1&lt;/P&gt;&lt;P&gt;     INTO TABLE it_lfa1&lt;/P&gt;&lt;P&gt; WHERE lifnr IN s_lifnr&lt;/P&gt;&lt;P&gt;     AND burks eq '100'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT s_lifnr ASSIGNING &amp;lt;lfs_lifnr&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  READ TABLE it_lfa1 ASSIGNING &amp;lt;lfs_lfa1&amp;gt;&lt;/P&gt;&lt;P&gt;  WHERE lifnr = &amp;lt;lfs_lifnr&amp;gt;-low&lt;/P&gt;&lt;P&gt;  TRANSPORTING NO FIELDS&lt;/P&gt;&lt;P&gt;  BINARY SEARCH.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  IF sy-subrc NE 0.&lt;/P&gt;&lt;P&gt;    lw_invalid_lifnr-lifnr = &amp;lt;lfs_lifnr&amp;gt;-lifnr.&lt;/P&gt;&lt;P&gt;    APPEND lw_invalid_lifnr to it_invalid_lifnr.&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is what i think can help you solve your problem.  (Sorry if i misunderstood)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope it helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Thyaga.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Thyaga on Nov 3, 2011 9:10 AM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Nov 2011 08:08:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/error-handling-in-a-select-statement/m-p/8373373#M1642136</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-11-03T08:08:26Z</dc:date>
    </item>
    <item>
      <title>Re: error handling in a select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/error-handling-in-a-select-statement/m-p/8373374#M1642137</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Goel,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;s_lifnr in your code is a type RANGE variable, and it can not be moved to a variable with data type LIFNR (if i am not wrong).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;please consider this code sample:&lt;/P&gt;&lt;P&gt;select-options: s_lifnr for lfa1-lifnr no interval. &lt;/P&gt;&lt;P&gt;data: wa_lifnr type range of lifnr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT lifnr &lt;/P&gt;&lt;P&gt;FROM lfa1&lt;/P&gt;&lt;P&gt;INTO TABLE it_lfa1&lt;/P&gt;&lt;P&gt;WHERE lifnr IN s_lifnr AND&lt;/P&gt;&lt;P&gt;bukrs = '001'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at s_lifnr into wa_lifnr.&lt;/P&gt;&lt;P&gt;  read table it_lfa1 with key&lt;/P&gt;&lt;P&gt;    lifnr = wa_lifnr-low.&lt;/P&gt;&lt;P&gt;  if sy-subrc ne 0.&lt;/P&gt;&lt;P&gt;    move wa_lifnr-low to it_invalid-lifnr.&lt;/P&gt;&lt;P&gt;    append it_invalid.&lt;/P&gt;&lt;P&gt;  endif.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;By the way, why should you need to collect the invalid vendor instead of the valid ?&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;Oki&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Nov 2011 10:51:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/error-handling-in-a-select-statement/m-p/8373374#M1642137</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-11-03T10:51:13Z</dc:date>
    </item>
  </channel>
</rss>

