<?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: Reg. Exception handling for a Function Module inside a Method in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/reg-exception-handling-for-a-function-module-inside-a-method/m-p/7106031#M1509135</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Do you have any special requirement regarding this one? I don't see where the problem lies. The template for handling this would be:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
method my_method.
   call function 'SOME_FUNCTION'
          exporting
                   ....
          importing
                   ....
          exceptions 
              exc1 = 1 
              exc2 = 2
              ...
              others = 9.

      case sy-subrc. "holds value of raised exception
          when 1.
                "exc1 was raised, handle it here i.e. by giving some message 
          when 2.
                 "exc2 was raised....
         when 0.
                "ok, no exception
            ....
          when others.
                "some undefined exception was raised, handle it here
     endcase.
endmethod.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Marcin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 20 Jul 2010 10:47:20 GMT</pubDate>
    <dc:creator>MarcinPciak</dc:creator>
    <dc:date>2010-07-20T10:47:20Z</dc:date>
    <item>
      <title>Reg. Exception handling for a Function Module inside a Method</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/reg-exception-handling-for-a-function-module-inside-a-method/m-p/7106030#M1509134</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear Experts,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My requirement is that i am calling an SAP Function Module inside a Method of a class. I need to handle exceptions for the FM call inside the method. Kindly help me in the above regard.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I searched the Forum completely and not able to search the thread.&lt;/P&gt;&lt;P&gt;&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;Ramesh Manoharan&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: ramesh.manoharan on Jul 20, 2010 12:04 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Jul 2010 10:03:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/reg-exception-handling-for-a-function-module-inside-a-method/m-p/7106030#M1509134</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-07-20T10:03:19Z</dc:date>
    </item>
    <item>
      <title>Re: Reg. Exception handling for a Function Module inside a Method</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/reg-exception-handling-for-a-function-module-inside-a-method/m-p/7106031#M1509135</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Do you have any special requirement regarding this one? I don't see where the problem lies. The template for handling this would be:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
method my_method.
   call function 'SOME_FUNCTION'
          exporting
                   ....
          importing
                   ....
          exceptions 
              exc1 = 1 
              exc2 = 2
              ...
              others = 9.

      case sy-subrc. "holds value of raised exception
          when 1.
                "exc1 was raised, handle it here i.e. by giving some message 
          when 2.
                 "exc2 was raised....
         when 0.
                "ok, no exception
            ....
          when others.
                "some undefined exception was raised, handle it here
     endcase.
endmethod.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Marcin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Jul 2010 10:47:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/reg-exception-handling-for-a-function-module-inside-a-method/m-p/7106031#M1509135</guid>
      <dc:creator>MarcinPciak</dc:creator>
      <dc:date>2010-07-20T10:47:20Z</dc:date>
    </item>
    <item>
      <title>Re: Reg. Exception handling for a Function Module inside a Method</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/reg-exception-handling-for-a-function-module-inside-a-method/m-p/7106032#M1509136</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Marcin,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for ur immediate reply. I am unable to use the below statements inside the Method of a class to handle exceptions:&lt;/P&gt;&lt;P&gt;Method Meth1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;call function 'FUNCTION'&lt;/P&gt;&lt;P&gt;exporting.....&lt;/P&gt;&lt;P&gt;importing....&lt;/P&gt;&lt;P&gt;exception&lt;/P&gt;&lt;P&gt;  excep1 = 1&lt;/P&gt;&lt;P&gt;  excep2 = 2&lt;/P&gt;&lt;P&gt;  other     = 3.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if sy-subrc ne 0.&lt;/P&gt;&lt;P&gt; case sy-subrc.&lt;/P&gt;&lt;P&gt;  when 1.&lt;/P&gt;&lt;P&gt;    raise excep1.&lt;/P&gt;&lt;P&gt;  when 2.&lt;/P&gt;&lt;P&gt;    raise excep2.&lt;/P&gt;&lt;P&gt;   when 3.&lt;/P&gt;&lt;P&gt;     raise unknown_error.&lt;/P&gt;&lt;P&gt; endcase.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endmethod.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Are the above statements correct? Plz. correct me if i am wrong.&lt;/P&gt;&lt;P&gt;&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;Ramesh Manoharan&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: ramesh.manoharan on Jul 20, 2010 1:29 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Jul 2010 11:26:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/reg-exception-handling-for-a-function-module-inside-a-method/m-p/7106032#M1509136</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-07-20T11:26:35Z</dc:date>
    </item>
    <item>
      <title>Re: Reg. Exception handling for a Function Module inside a Method</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/reg-exception-handling-for-a-function-module-inside-a-method/m-p/7106033#M1509137</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ramesh,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What you are trying to do here is catch FM's exception and raise Method's one. So in fact you want to propagate the catched excpetion up in the call hierarchy (pass it to the method's caller). So you do the same as you would be calling exception for FM.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
"in class
Method Meth1.

call function 'FUNCTION'
exporting.....
importing....
exception
excep1 = 1
excep2 = 2
other = 3.

if sy-subrc ne 0.
case sy-subrc.
when 1.
raise excep1.
when 2.
raise excep2.
when 3.
raise unknown_error.
endcase.
endif.

endmethod.


"in calling program
call method my_class-&amp;gt;meth1
  exceptions 
       excep1 = 1
       excep2 = 2
       unknown_error = 3.

if sy-subrc = 1.
   message "EXCEPT1 was raised' ...
...
  
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;All these exceptions must be however listed in methods interface. If it is a global class go to se24 -&amp;gt; click on method -&amp;gt; choose &lt;EM&gt;exceptions&lt;/EM&gt; -&amp;gt; list them here. If it is a local one you list them in the parameter list&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
class lcl DEFINITION.
  public SECTION.
   methods meth1 EXCEPTIONS exc1 exc2 ...
endclass.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Anyhow I suggest to get familarized with &lt;EM&gt;exception classes&lt;/EM&gt; which are modern way of handling exceptions. You handle them in &lt;STRONG&gt;TRY...CATCH...ENTRY&lt;/STRONG&gt; block.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Marcin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Jul 2010 11:41:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/reg-exception-handling-for-a-function-module-inside-a-method/m-p/7106033#M1509137</guid>
      <dc:creator>MarcinPciak</dc:creator>
      <dc:date>2010-07-20T11:41:47Z</dc:date>
    </item>
    <item>
      <title>Re: Reg. Exception handling for a Function Module inside a Method</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/reg-exception-handling-for-a-function-module-inside-a-method/m-p/7106034#M1509138</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Check method GUI_UPLOAD of the class CL_GUI_FRONTEND_SERVICES on how to cascade the "Classical" Exceptions from the FM to method callee. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You may also want to translate those classical exceptions to new class based exceptions. Check this help: &lt;A href="http://help.sap.com/abapdocu_70/en/ABENEXCEPTIONS.htm" target="test_blank"&gt;http://help.sap.com/abapdocu_70/en/ABENEXCEPTIONS.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Naimesh Patel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Jul 2010 13:43:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/reg-exception-handling-for-a-function-module-inside-a-method/m-p/7106034#M1509138</guid>
      <dc:creator>naimesh_patel</dc:creator>
      <dc:date>2010-07-20T13:43:07Z</dc:date>
    </item>
    <item>
      <title>Re: Reg. Exception handling for a Function Module inside a Method</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/reg-exception-handling-for-a-function-module-inside-a-method/m-p/7106035#M1509139</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;closing the thread&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Jul 2010 09:24:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/reg-exception-handling-for-a-function-module-inside-a-method/m-p/7106035#M1509139</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-07-27T09:24:52Z</dc:date>
    </item>
  </channel>
</rss>

