<?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: Method parameters in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/method-parameters/m-p/4560484#M1076515</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Graham Robinson,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your prompt reply. Unfortunately, I could only understand it partially.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It would greatly appreciated if you could provide me some example in code for my better understanding.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 26 Sep 2008 02:57:43 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-09-26T02:57:43Z</dc:date>
    <item>
      <title>Method parameters</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/method-parameters/m-p/4560482#M1076513</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let's say existing there is a class with 3 importing parameters into the method. But somehow there is a needs to extend the existing method into 4 importing parameters. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The question is, if we are applying OOP concept here, how should I do it? Should I create a new class for the 4 importing parameters?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the advice in advance.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 26 Sep 2008 01:11:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/method-parameters/m-p/4560482#M1076513</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-09-26T01:11:33Z</dc:date>
    </item>
    <item>
      <title>Re: Method parameters</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/method-parameters/m-p/4560483#M1076514</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Myah,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;some options of the top of my head....not all possibilities by any means....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Option 1. Use the enhancement framework to add the importing parameter to the method and to enhance the method. Note it can only be defined as an optional parameter.&lt;/P&gt;&lt;P&gt;Option 2. Create a subclass and add a new method that takes the four importing parameters. This method should call the old method to reuse all it's code, i.e. super-&amp;gt;oldmethod. This means callers need to change the way they call the method. It also assumes we are talking about a class that can be subclassed.&lt;/P&gt;&lt;P&gt;Option 3. Create a new class that "wraps" the old class. This class instantiates the old class and reuses as much of it as possible. Again callers will need to be modified to call the new class.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;P&gt;Graham Robbo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 26 Sep 2008 02:33:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/method-parameters/m-p/4560483#M1076514</guid>
      <dc:creator>GrahamRobbo</dc:creator>
      <dc:date>2008-09-26T02:33:22Z</dc:date>
    </item>
    <item>
      <title>Re: Method parameters</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/method-parameters/m-p/4560484#M1076515</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Graham Robinson,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your prompt reply. Unfortunately, I could only understand it partially.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It would greatly appreciated if you could provide me some example in code for my better understanding.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 26 Sep 2008 02:57:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/method-parameters/m-p/4560484#M1076515</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-09-26T02:57:43Z</dc:date>
    </item>
    <item>
      <title>Re: Method parameters</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/method-parameters/m-p/4560485#M1076516</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Myah,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;code samples wouldn't be very helpful.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I suggest you read up on the Enhancement Framework first as this would be the first option I would investigate. There are blogs on this and of course there is always the SAP documentation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The other options I mentioned are just standard OO programming concepts.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;P&gt;Graham Robbo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 26 Sep 2008 03:06:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/method-parameters/m-p/4560485#M1076516</guid>
      <dc:creator>GrahamRobbo</dc:creator>
      <dc:date>2008-09-26T03:06:51Z</dc:date>
    </item>
    <item>
      <title>Re: Method parameters</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/method-parameters/m-p/4560486#M1076517</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Myah&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Options (2) and (3) are demonstrated in sample report &lt;STRONG&gt;ZUS_SDN_ABAP_OO_ENH_SAMPLE.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp; Report  ZUS_SDN_ABAP_OO_ENH_SAMPLE
*&amp;amp;
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp; Thread: Method parameters
*&amp;amp; &amp;lt;a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="1063590"&amp;gt;&amp;lt;/a&amp;gt;
*&amp;amp;---------------------------------------------------------------------*

REPORT  zus_sdn_abap_oo_enh_sample.


*----------------------------------------------------------------------*
*       CLASS lcl_super DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_super DEFINITION.
  PUBLIC SECTION.
    DATA: md_message    TYPE bapi_msg.

    METHODS:
      calculate
        IMPORTING
          value(id_val_1) TYPE i
          value(id_val_2) TYPE i
          value(id_val_3) TYPE i,

      display.
ENDCLASS.                    "lcl_super DEFINITION


*----------------------------------------------------------------------*
*       CLASS lcl_subclass DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_subclass DEFINITION
                   INHERITING FROM lcl_super.

  PUBLIC SECTION.
    METHODS:
      calculate_enhanced
        IMPORTING
          value(id_val_1) TYPE i
          value(id_val_2) TYPE i
          value(id_val_3) TYPE i
          value(id_val_4) TYPE i.
ENDCLASS.                    "lcl_subclass DEFINITION


*----------------------------------------------------------------------*
*       CLASS lcl_wrapper DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_wrapper DEFINITION.

  PUBLIC SECTION.
    DATA: mo_super    TYPE REF TO lcl_super.

    METHODS:
      constructor,
      calculate
        IMPORTING
          value(id_val_1) TYPE i
          value(id_val_2) TYPE i
          value(id_val_3) TYPE i
          value(id_val_4) TYPE i,

      display.

ENDCLASS.                    "lcl_wrapper DEFINITION



*----------------------------------------------------------------------*
*       CLASS lcl_super IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_super IMPLEMENTATION.

  METHOD calculate.
    me-&amp;gt;md_message = 'SUPER CLASS: Method has 3 IMPORTING parameters'.
  ENDMETHOD.                    "calculate

  METHOD display.
    MESSAGE me-&amp;gt;md_message TYPE 'I'.
  ENDMETHOD.                    "display

ENDCLASS.                    "lcl_super IMPLEMENTATION

*----------------------------------------------------------------------*
*       CLASS lcl_subclass IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_subclass IMPLEMENTATION.

  METHOD calculate_enhanced.
    CALL METHOD me-&amp;gt;calculate
      EXPORTING
        id_val_1 = id_val_1
        id_val_2 = id_val_2
        id_val_3 = id_val_3.

    me-&amp;gt;md_message = 'SUB CLASS: Method has 4 IMPORTING parameters'.
  ENDMETHOD.                    "calculate_enhanced

ENDCLASS.                    "lcl_subclass IMPLEMENTATION

*----------------------------------------------------------------------*
*       CLASS lcl_wrapper IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_wrapper IMPLEMENTATION.

  METHOD constructor.
    CREATE OBJECT me-&amp;gt;mo_super.
  ENDMETHOD.                    "constructor

  METHOD calculate.
    CALL METHOD me-&amp;gt;mo_super-&amp;gt;calculate
      EXPORTING
        id_val_1 = id_val_1
        id_val_2 = id_val_2
        id_val_3 = id_val_3.

    me-&amp;gt;mo_super-&amp;gt;md_message = 'WRAPPER CLASS: Method has 4 IMPORTING parameters'.

  ENDMETHOD.                    "calculate

  METHOD display.
    me-&amp;gt;mo_super-&amp;gt;display( ).
  ENDMETHOD.                    "display

ENDCLASS.                    "lcl_wrapper IMPLEMENTATION


DATA: go_super    TYPE REF TO lcl_super,
      go_sub      TYPE REF TO lcl_subclass,
      go_wrapper  TYPE REF TO lcl_wrapper.

START-OF-SELECTION.

  CREATE OBJECT: go_super,
                 go_sub,
                 go_wrapper.

  " Genuine method
  CALL METHOD go_super-&amp;gt;calculate
    EXPORTING
      id_val_1 = 1
      id_val_2 = 2
      id_val_3 = 3.
  go_super-&amp;gt;display( ).


  " Subclass
  CALL METHOD go_sub-&amp;gt;calculate  " inherited method
    EXPORTING
      id_val_1 = 1
      id_val_2 = 2
      id_val_3 = 3.
**      id_val_4 = 4. This parameter could be implemented using enhancement
  go_sub-&amp;gt;display( ).

  CALL METHOD go_sub-&amp;gt;calculate_enhanced
    EXPORTING
      id_val_1 = 1
      id_val_2 = 2
      id_val_3 = 3
      id_val_4 = 4.
  go_sub-&amp;gt;display( ).

  " Wrapper class
  CALL METHOD go_wrapper-&amp;gt;calculate
    EXPORTING
      id_val_1 = 1
      id_val_2 = 2
      id_val_3 = 3
      id_val_4 = 4.
  go_wrapper-&amp;gt;display( ).



END-OF-SELECTION.
&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;  Uwe&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 26 Sep 2008 03:39:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/method-parameters/m-p/4560486#M1076517</guid>
      <dc:creator>uwe_schieferstein</dc:creator>
      <dc:date>2008-09-26T03:39:55Z</dc:date>
    </item>
    <item>
      <title>Re: Method parameters</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/method-parameters/m-p/4560487#M1076518</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Uwe and Graham, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the input and patient. Both of you are so helpful. I have the ideas now &lt;SPAN __jive_emoticon_name="happy"&gt;&lt;/SPAN&gt; .&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 26 Sep 2008 04:41:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/method-parameters/m-p/4560487#M1076518</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-09-26T04:41:24Z</dc:date>
    </item>
  </channel>
</rss>

