<?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: Help in OO programing in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/help-in-oo-programing/m-p/5277416#M1218124</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As you suggested I will be calling the Z-table class to update the Z-table. But this class will be called in a loop on the itab. So, will all the calls to this class be in a single LUW... I might need to Rollback everything depending on some logic which would be added at the end.. Is this possible when i have the logic to insert a record in a class...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for ur earlier response&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 19 Mar 2009 14:37:44 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2009-03-19T14:37:44Z</dc:date>
    <item>
      <title>Help in OO programing</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/help-in-oo-programing/m-p/5277413#M1218121</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi OO master:&lt;/P&gt;&lt;P&gt;  I have been using structured program all my life and am planning to use Classes for one of my new development.  My requirement is to&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1) Get data from a table (KNA1)&lt;/P&gt;&lt;P&gt;2) depending on the this table get data from one more table (KNVP)&lt;/P&gt;&lt;P&gt;3) get data from the 3rd table VBAK.&lt;/P&gt;&lt;P&gt;4) do some more processing on the VBAK data and update in a Z table..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I was planning to create 4 method for each task listed above and 1 more method which calls all of them.. Is this the correct approach, or should I call the the 4 methods in a FM?&lt;/P&gt;&lt;P&gt;Also if the inserts to the Z table are happening in a Class-method, does the Rollback work, is it still considered a single LUW..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope someone can help me on this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SG.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Mar 2009 06:10:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/help-in-oo-programing/m-p/5277413#M1218121</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-03-19T06:10:06Z</dc:date>
    </item>
    <item>
      <title>Re: Help in OO programing</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/help-in-oo-programing/m-p/5277414#M1218122</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can call the individual methods in the report as well instead of a new method for calling all methods&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope for a class method, it is still considered a single LUW..&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Mar 2009 06:33:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/help-in-oo-programing/m-p/5277414#M1218122</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-03-19T06:33:11Z</dc:date>
    </item>
    <item>
      <title>Re: Help in OO programing</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/help-in-oo-programing/m-p/5277415#M1218123</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;If you start programming in (ABAP-)OO then you should always think in terms of responsibilities. Looking at your requirements I see at least four classes:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
1) Get data from a table (KNA1)  " &amp;lt;&amp;lt;&amp;lt; customer class
2) depending on the this table get data from one more table (KNVP) " &amp;lt;&amp;lt;&amp;lt; customer class, too
3) get data from the 3rd table VBAK.  " &amp;lt;&amp;lt;&amp;lt; sales order class
4) do some more processing on the VBAK data and update in a Z table.. 
                                                      " &amp;lt;&amp;lt;&amp;lt; perhaps own z-table class
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Where is the fourth class? It is a "model" class consisting of all the other classes (=&amp;gt; &lt;STRONG&gt;composition&lt;/STRONG&gt; ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The model class would create a single instance of the customer class.&lt;/P&gt;&lt;P&gt;The model class has an itab holding references of sales order instances (which you create depending on some selection criteria).&lt;/P&gt;&lt;P&gt;If the Z-table is tightly linked to the sales orders (VBAK) then it might be part of the sales order class.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The model instance is responsible to orchestrate all these different instances in a proper way.&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, 19 Mar 2009 06:44:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/help-in-oo-programing/m-p/5277415#M1218123</guid>
      <dc:creator>uwe_schieferstein</dc:creator>
      <dc:date>2009-03-19T06:44:31Z</dc:date>
    </item>
    <item>
      <title>Re: Help in OO programing</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/help-in-oo-programing/m-p/5277416#M1218124</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As you suggested I will be calling the Z-table class to update the Z-table. But this class will be called in a loop on the itab. So, will all the calls to this class be in a single LUW... I might need to Rollback everything depending on some logic which would be added at the end.. Is this possible when i have the logic to insert a record in a class...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for ur earlier response&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Mar 2009 14:37:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/help-in-oo-programing/m-p/5277416#M1218124</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-03-19T14:37:44Z</dc:date>
    </item>
    <item>
      <title>Re: Help in OO programing</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/help-in-oo-programing/m-p/5277417#M1218125</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 assume you you have a 1:n relationship between a sales order (VBAK) and your Z-table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your model class contains a single instance of your customer class (KNA1) multiple instance of your sales order class (VBAK) which may include an itab for Z-table records related to the sales order.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;One possible approach would be that you define an event (e.g. UPDATE_DB) in your model class and an event handler method (e.g. HANDLE_UPDATE_DB) within your sales order class. When you create the sales order instances you register this event handler method, e.g.:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
LOOP AT me-&amp;gt;mt_orders INTO ls_order.
  CREATE OBJECT lo_order
    EXPORTING
      id_order_number = ls_order-vbeln.
 
  SET HANDLER: lo_order-&amp;gt;handle_update_db    FOR me.

  APPEND lo_order TO me-&amp;gt;mto_orders.  " itab for collecting sales order instances
ENDLOOP.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When the user pushes the SAVE button your model class (or better a controller class which takes care of the interaction between user and model class -&amp;gt; MVC paradigm) you may call a method &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;go_model-&amp;gt;save_data( ).&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A possible approach to handle the DB update is shown in the following sample class ZCL_ALV_TEST. This class contains an event USER_COMMAND which take a reference of IF_RECA_MESSAGE_LIST as input.&lt;/P&gt;&lt;P&gt;For the sake of simplicity I have defined the event handler method HANDLE_USER_COMMAND within the same class:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
METHOD constructor.

  " create message handler
  me-&amp;gt;mo_msg_list ?= cf_reca_message_list=&amp;gt;create( ).

  " set event handler
  SET HANDLER: me-&amp;gt;handle_user_command FOR me.

ENDMETHOD.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
METHOD save_data.
* define local data
  DATA: lx_error_exists  TYPE c.

  me-&amp;gt;save_data_internal( ).

  CALL METHOD me-&amp;gt;mo_msg_list-&amp;gt;has_messages_of_msgty
    EXPORTING
      id_msgty     = 'E'
*      if_or_higher = ABAP_TRUE
    RECEIVING
      rf_exists    = lx_error_exists.

  IF ( lx_error_exists = space ).
    COMMIT WORK.

  ELSE.
    ROLLBACK WORK.
  ENDIF.

  me-&amp;gt;mo_msg_list-&amp;gt;clear( ).


ENDMETHOD.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When the event is raised all registered event handler methods will be called:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
method SAVE_DATA_INTERNAL.

  raise event user_command
    exporting
      io_msg_list = me-&amp;gt;mo_msg_list.

endmethod.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If something goes astray during updating your Z-table then you just add an E-message to the message collector. This message collector is finally evaluated in the SAVE_DATA method where it causes either the COMMIT WORK or the ROLLBACK WORK.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
METHOD handle_user_command.

  IF ( 1 = 2 ).

  " Condition failed
  ELSE.
    CALL METHOD io_msg_list-&amp;gt;add
      EXPORTING
*        is_message   =
        id_msgty     = 'E'
*        id_msgid     =
*        id_msgno     =
*        id_msgv1     =
*        id_msgv2     =
*        id_msgv3     =
*        id_msgv4     =
*        id_msgd1     =
*        id_msgd2     =
*        id_msgd3     =
*        id_msgd4     =
*        id_detlevel  =
*        if_cumulate  =
*        id_probclass =
*        id_tabname   =
*        id_fieldname =
*        id_value     =
*        id_index     =
*        id_intreno   =
*        id_custact   =
*        id_sublog    =
*        id_context   =
*      IMPORTING
*        es_message   =
        .

  ENDIF.


ENDMETHOD.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope I could give you some ideas for your project.&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, 19 Mar 2009 21:16:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/help-in-oo-programing/m-p/5277417#M1218125</guid>
      <dc:creator>uwe_schieferstein</dc:creator>
      <dc:date>2009-03-19T21:16:11Z</dc:date>
    </item>
  </channel>
</rss>

