<?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: Exception handling for a standard SAP Function Module - the OO way in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/exception-handling-for-a-standard-sap-function-module-the-oo-way/m-p/7667752#M1574770</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Halo Marko,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;One thing you could do is to have an exception object as an exporting parameter in the FM.&lt;/P&gt;&lt;P&gt;if there is an exception condition you can fill that exception object inside the FM.&lt;/P&gt;&lt;P&gt;So you call the Fm and get back the exception object.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;call FM&lt;/P&gt;&lt;P&gt;importing e_exception = lx_exception.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if lx_exception is bound.&lt;/P&gt;&lt;P&gt;lx_exception-&amp;gt;get_Text( ).&lt;/P&gt;&lt;P&gt;lx_exception-&amp;gt;get_long_text( ).&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Arshad&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 08 Mar 2011 13:45:16 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2011-03-08T13:45:16Z</dc:date>
    <item>
      <title>Exception handling for a standard SAP Function Module - the OO way</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/exception-handling-for-a-standard-sap-function-module-the-oo-way/m-p/7667748#M1574766</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 was wondering what is the correct way to call a standard SAP function module inside a method of global class.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to display the error via the:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;get_text( )&lt;/EM&gt; and &lt;EM&gt;get_longtext( )&lt;/EM&gt; methods.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't want to use the sy-subrc check. Is this possible?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My example doesn't seem to work...&lt;/P&gt;&lt;P&gt;See example bellow:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;   &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA: ex_object_cx_root TYPE REF TO cx_root,
      ex_text TYPE string,
      ex_text_long TYPE string.
 
 TRY.
      CALL FUNCTION 'L_TO_CONFIRM'
        EXPORTING
          i_lgnum                        = i_lgnum      " Warehouse number
          i_tanum                        = i_tanum      " Transfer order number
          i_quknz                        = '1'          " '1' - confirm withdrawal only (picking )
          i_commit_work                  = 'X'          " Indicator whether COMMIT WORK in function module
        TABLES
          t_ltap_conf                    = it_ltap_conf " Table of items to be confirmed
        EXCEPTIONS
          to_confirmed                   = 1    " Transfer order already confirmed
          to_doesnt_exist                = 2
          item_confirmed                 = 3
          item_subsystem                 = 4
		  ...
          to_item_split_not_allowed      = 51
          input_wrong                    = 52
          OTHERS                         = 53.

    CATCH cx_root INTO ex_object_cx_root.

      ex_text = ex_object_cx_root-&amp;gt;get_text( ).
      ex_text_long = ex_object_cx_root-&amp;gt;get_longtext( ).

      " Error:
      RAISE EXCEPTION TYPE zcx_transfer_order
        EXPORTING textid = zcx_transfer_order=&amp;gt;zcx_transfer_order
             err_class = 'ZCL_WM_TRANSFER_ORDER'
             err_method = 'CONFIRM_TO_2STEP_PICKING'
             err_message_text = ex_text
             err_message_text_long = ex_text_long.

  ENDTRY.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you very much in advance&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Mar 2011 11:30:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/exception-handling-for-a-standard-sap-function-module-the-oo-way/m-p/7667748#M1574766</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-03-08T11:30:05Z</dc:date>
    </item>
    <item>
      <title>Re: Exception handling for a standard SAP Function Module - the OO way</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/exception-handling-for-a-standard-sap-function-module-the-oo-way/m-p/7667749#M1574767</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Marko,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If i understand correctly you've enclosed the call to the FM 'L_TO_CONFIRM' inside the TRY ... CATCH ... ENDTRY block. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;CATCH cx_root INTO ex_object_cx_root.
 
      ex_text = ex_object_cx_root-&amp;gt;get_text( ).
      ex_text_long = ex_object_cx_root-&amp;gt;get_longtext( ).&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can't do this because the FM 'L_TO_CONFIRM' doesn't propagate OO exceptions! &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your approach is almost correct, what you've to do is goes like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;CALL FUNCTION 'L_TO_CONFIRM'
  EXPORTING
    i_lgnum                        = i_lgnum      " Warehouse number
    i_tanum                        = i_tanum      " Transfer order number
    i_quknz                        = '1'          " '1' - confirm withdrawal only (picking )
    i_commit_work                  = 'X'          " Indicator whether COMMIT WORK in function module
  TABLES
    t_ltap_conf                    = it_ltap_conf " Table of items to be confirmed
  EXCEPTIONS
    to_confirmed                   = 1    " Transfer order already confirmed
    to_doesnt_exist                = 2
    item_confirmed                 = 3
    item_subsystem                 = 4
...
    to_item_split_not_allowed      = 51
    input_wrong                    = 52
    OTHERS                         = 53.

IF sy-subrc &amp;lt;&amp;gt; 0.
  MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
          WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4
          INTO ex_text. "Get the ex_text by this technique &amp;amp; not by CX_ROOT-&amp;gt;GET_TEXT()
ENDIF.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'll have to check how to fetch the long text of the message &lt;SPAN __jive_emoticon_name="wink"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BR,&lt;/P&gt;&lt;P&gt;Suhas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Mar 2011 12:19:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/exception-handling-for-a-standard-sap-function-module-the-oo-way/m-p/7667749#M1574767</guid>
      <dc:creator>SuhaSaha</dc:creator>
      <dc:date>2011-03-08T12:19:43Z</dc:date>
    </item>
    <item>
      <title>Re: Exception handling for a standard SAP Function Module - the OO way</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/exception-handling-for-a-standard-sap-function-module-the-oo-way/m-p/7667750#M1574768</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you for fast response.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;a) How do you know which standard SAP FM does propagate OO exceptions and which doesn't?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;b) If you know how to fetch the long text - that would be superb.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Mar 2011 12:26:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/exception-handling-for-a-standard-sap-function-module-the-oo-way/m-p/7667750#M1574768</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-03-08T12:26:46Z</dc:date>
    </item>
    <item>
      <title>Re: Exception handling for a standard SAP Function Module - the OO way</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/exception-handling-for-a-standard-sap-function-module-the-oo-way/m-p/7667751#M1574769</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;&amp;gt; a) How do you know which standard SAP FM does propagate OO exceptions and which doesn't?&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Check in the "Exceptions" tab, "Exception Class" checkbox is not checked.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;b) If you know how to fetch the long text - that would be superb.&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;You can get the long text using DOCU_GET_FOR_F1HELP FM. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BR,&lt;/P&gt;&lt;P&gt;Suhas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Mar 2011 13:16:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/exception-handling-for-a-standard-sap-function-module-the-oo-way/m-p/7667751#M1574769</guid>
      <dc:creator>SuhaSaha</dc:creator>
      <dc:date>2011-03-08T13:16:42Z</dc:date>
    </item>
    <item>
      <title>Re: Exception handling for a standard SAP Function Module - the OO way</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/exception-handling-for-a-standard-sap-function-module-the-oo-way/m-p/7667752#M1574770</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Halo Marko,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;One thing you could do is to have an exception object as an exporting parameter in the FM.&lt;/P&gt;&lt;P&gt;if there is an exception condition you can fill that exception object inside the FM.&lt;/P&gt;&lt;P&gt;So you call the Fm and get back the exception object.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;call FM&lt;/P&gt;&lt;P&gt;importing e_exception = lx_exception.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if lx_exception is bound.&lt;/P&gt;&lt;P&gt;lx_exception-&amp;gt;get_Text( ).&lt;/P&gt;&lt;P&gt;lx_exception-&amp;gt;get_long_text( ).&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Arshad&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Mar 2011 13:45:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/exception-handling-for-a-standard-sap-function-module-the-oo-way/m-p/7667752#M1574770</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-03-08T13:45:16Z</dc:date>
    </item>
    <item>
      <title>Re: Exception handling for a standard SAP Function Module - the OO way</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/exception-handling-for-a-standard-sap-function-module-the-oo-way/m-p/7667753#M1574771</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you both for your answers!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Mar 2011 14:01:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/exception-handling-for-a-standard-sap-function-module-the-oo-way/m-p/7667753#M1574771</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-03-09T14:01:24Z</dc:date>
    </item>
  </channel>
</rss>

