<?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 by Add_from_instance method in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/error-handling-by-add-from-instance-method/m-p/2139348#M450445</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Perna&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I assume that you mean the instance method from interface &amp;lt;b&amp;gt;IF_RECA_MESSAGE_LIST&amp;lt;/b&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The logic is quite simple. Let's assume a scenario where you have a &amp;lt;b&amp;gt;model instance&amp;lt;/b&amp;gt; (containing the business logic -&amp;gt; &amp;lt;b&amp;gt;MVC &amp;lt;/b&amp;gt;model). This model instance creates instance of others classes (e.g. for sales orders, etc.). Thus, we have a &amp;lt;b&amp;gt;composition &amp;lt;/b&amp;gt;of classes.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Both the model instance and the others instances (which are customer classes) have a message handler (of TYPE REF TO if_reca_message_list). The message handler is defines as &amp;lt;b&amp;gt;public &amp;lt;/b&amp;gt;and &amp;lt;b&amp;gt;read-only&amp;lt;/b&amp;gt; instance attribute.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Following is some sample coding which demonstates the logic:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
" We are here in a method of the model instance. We access the message handler
" using me-&amp;gt;msg_msglist.

" The model instance has a list of object instance (e.g. me-&amp;gt;mt_orders).
" Before processing these orders the model instance has already added
" several messages (e.g. for validation) to its message handler.

" Now the model instance processes the order instances:

  LOOP AT me-&amp;gt;mt_orders INTO ls_order.
"   While creating the order instance they have done themselves some validation
"   an added the message to their own message handler,
"   e.g. ls_order-instance-&amp;gt;mo_msglist.

"   Now we add the messages from the order instances to the message handler
"   of the model instance.
    CALL METHOD me-&amp;gt;mo_msglist-&amp;gt;add_from_instance( ls_order-instance-&amp;gt;mo_msglist).
"   NOTE: this method has an IMPORTING parameter which allows to add
"              the messages as subnode

  ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards &lt;/P&gt;&lt;P&gt;  Uwe&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 12 Apr 2007 07:05:43 GMT</pubDate>
    <dc:creator>uwe_schieferstein</dc:creator>
    <dc:date>2007-04-12T07:05:43Z</dc:date>
    <item>
      <title>Error handling by Add_from_instance method</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/error-handling-by-add-from-instance-method/m-p/2139347#M450444</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 would like to know how can we handle errors in ABAP OO by the add_from_instance method.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kindly suggest your answers.&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;Prerna.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Apr 2007 05:14:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/error-handling-by-add-from-instance-method/m-p/2139347#M450444</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-04-12T05:14:00Z</dc:date>
    </item>
    <item>
      <title>Re: Error handling by Add_from_instance method</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/error-handling-by-add-from-instance-method/m-p/2139348#M450445</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Perna&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I assume that you mean the instance method from interface &amp;lt;b&amp;gt;IF_RECA_MESSAGE_LIST&amp;lt;/b&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The logic is quite simple. Let's assume a scenario where you have a &amp;lt;b&amp;gt;model instance&amp;lt;/b&amp;gt; (containing the business logic -&amp;gt; &amp;lt;b&amp;gt;MVC &amp;lt;/b&amp;gt;model). This model instance creates instance of others classes (e.g. for sales orders, etc.). Thus, we have a &amp;lt;b&amp;gt;composition &amp;lt;/b&amp;gt;of classes.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Both the model instance and the others instances (which are customer classes) have a message handler (of TYPE REF TO if_reca_message_list). The message handler is defines as &amp;lt;b&amp;gt;public &amp;lt;/b&amp;gt;and &amp;lt;b&amp;gt;read-only&amp;lt;/b&amp;gt; instance attribute.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Following is some sample coding which demonstates the logic:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
" We are here in a method of the model instance. We access the message handler
" using me-&amp;gt;msg_msglist.

" The model instance has a list of object instance (e.g. me-&amp;gt;mt_orders).
" Before processing these orders the model instance has already added
" several messages (e.g. for validation) to its message handler.

" Now the model instance processes the order instances:

  LOOP AT me-&amp;gt;mt_orders INTO ls_order.
"   While creating the order instance they have done themselves some validation
"   an added the message to their own message handler,
"   e.g. ls_order-instance-&amp;gt;mo_msglist.

"   Now we add the messages from the order instances to the message handler
"   of the model instance.
    CALL METHOD me-&amp;gt;mo_msglist-&amp;gt;add_from_instance( ls_order-instance-&amp;gt;mo_msglist).
"   NOTE: this method has an IMPORTING parameter which allows to add
"              the messages as subnode

  ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards &lt;/P&gt;&lt;P&gt;  Uwe&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Apr 2007 07:05:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/error-handling-by-add-from-instance-method/m-p/2139348#M450445</guid>
      <dc:creator>uwe_schieferstein</dc:creator>
      <dc:date>2007-04-12T07:05:43Z</dc:date>
    </item>
    <item>
      <title>Re: Error handling by Add_from_instance method</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/error-handling-by-add-from-instance-method/m-p/2139349#M450446</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 have a validation class which validates the data.&lt;/P&gt;&lt;P&gt;In the asmple logic, you have said that we have to collect these messages.&lt;/P&gt;&lt;P&gt;Kindly guide me as to how do I collect them.&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;Prerna&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Apr 2007 07:19:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/error-handling-by-add-from-instance-method/m-p/2139349#M450446</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-04-12T07:19:54Z</dc:date>
    </item>
    <item>
      <title>Re: Error handling by Add_from_instance method</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/error-handling-by-add-from-instance-method/m-p/2139350#M450447</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Prerna&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Assuming that the methods of your validation class return the message by raising an exception you can collect the messages as following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;" 1st validation&lt;/P&gt;&lt;P&gt;  CALL METHOD mo_myclass-&amp;gt;validate_input1&lt;/P&gt;&lt;P&gt;    EXPORTING&lt;/P&gt;&lt;P&gt;      ...&lt;/P&gt;&lt;P&gt;    EXCEPTIONS&lt;/P&gt;&lt;P&gt;      error = 1&lt;/P&gt;&lt;P&gt;      others = 2.&lt;/P&gt;&lt;P&gt;  IF sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;"  Here we collect the message that is returned in SYST&lt;/P&gt;&lt;P&gt;   me-&amp;gt;mo_msglist-&amp;gt;add_from_symsg( ).&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;" 2nd validation&lt;/P&gt;&lt;P&gt;  CALL METHOD mo_myclass-&amp;gt;validate_input2&lt;/P&gt;&lt;P&gt;    EXPORTING&lt;/P&gt;&lt;P&gt;      ...&lt;/P&gt;&lt;P&gt;    EXCEPTIONS&lt;/P&gt;&lt;P&gt;      error = 1&lt;/P&gt;&lt;P&gt;      others = 2.&lt;/P&gt;&lt;P&gt;  IF sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;"  Here we collect the message that is returned in SYST&lt;/P&gt;&lt;P&gt;   me-&amp;gt;mo_msglist-&amp;gt;add_from_symsg( ).&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;  Uwe&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Apr 2007 08:00:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/error-handling-by-add-from-instance-method/m-p/2139350#M450447</guid>
      <dc:creator>uwe_schieferstein</dc:creator>
      <dc:date>2007-04-12T08:00:30Z</dc:date>
    </item>
  </channel>
</rss>

