<?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: question on Method interface in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/question-on-method-interface/m-p/5392668#M1239481</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This type of definition is used when you want to access other related object's attribute in your current method.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Check this code:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
*----------------------------------------------------------------------*
*       CLASS lcl_car DEFINITION
*----------------------------------------------------------------------*
CLASS lcl_car DEFINITION.

  PUBLIC SECTION.
    DATA: w_name TYPE string.

    METHODS:
      write_name
        IMPORTING
          io_obj TYPE REF TO lcl_car.

ENDCLASS.                    "lcl_car DEFINITION

*----------------------------------------------------------------------*
*       CLASS lcl_car IMPLEMENTATION
*----------------------------------------------------------------------*
CLASS lcl_car IMPLEMENTATION.

  METHOD write_name.

    WRITE: / 'Own attribute', me-&amp;gt;w_name.

    WRITE: / 'other object', io_obj-&amp;gt;w_name.

  ENDMETHOD.                    "write_name

ENDCLASS.                    "lcl_car IMPLEMENTATION

*----------------------------------------------------------------------*
*       CLASS lcl_bmw DEFINITION
*----------------------------------------------------------------------*
CLASS lcl_bmw DEFINITION INHERITING FROM lcl_car.

ENDCLASS.                    "lcl_bmw DEFINITION

*----------------------------------------------------------------------*
*       CLASS lcl_merc DEFINITION
*----------------------------------------------------------------------*
CLASS lcl_merc DEFINITION INHERITING FROM lcl_car.

ENDCLASS.                    "lcl_merc DEFINITION


START-OF-SELECTION.
  DATA: lo_bmw   TYPE REF TO lcl_bmw,
        lo_merc  TYPE REF TO lcl_merc.

  CREATE OBJECT: lo_bmw,
                 lo_merc.

  lo_bmw-&amp;gt;w_name  = 'BMW'.
  lo_merc-&amp;gt;w_name = 'Merc'.

  lo_bmw-&amp;gt;write_name( lo_merc ).
&lt;/CODE&gt;&lt;/PRE&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>Mon, 23 Mar 2009 20:19:44 GMT</pubDate>
    <dc:creator>naimesh_patel</dc:creator>
    <dc:date>2009-03-23T20:19:44Z</dc:date>
    <item>
      <title>question on Method interface</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/question-on-method-interface/m-p/5392667#M1239480</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've the following method def:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;   METHODS : METH1 IMPORTING INPUT1 TYPE I   
                                                              INPUT2 TYPE REF TO  CL_1.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;where CL_1 is the class withing where the method is defined.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Question is, what is this kind of definition and whats the use in real time implementation?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thkx&lt;/P&gt;&lt;P&gt;P.S&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Mar 2009 20:00:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/question-on-method-interface/m-p/5392667#M1239480</guid>
      <dc:creator>prabhu_s2</dc:creator>
      <dc:date>2009-03-23T20:00:16Z</dc:date>
    </item>
    <item>
      <title>Re: question on Method interface</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/question-on-method-interface/m-p/5392668#M1239481</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This type of definition is used when you want to access other related object's attribute in your current method.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Check this code:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
*----------------------------------------------------------------------*
*       CLASS lcl_car DEFINITION
*----------------------------------------------------------------------*
CLASS lcl_car DEFINITION.

  PUBLIC SECTION.
    DATA: w_name TYPE string.

    METHODS:
      write_name
        IMPORTING
          io_obj TYPE REF TO lcl_car.

ENDCLASS.                    "lcl_car DEFINITION

*----------------------------------------------------------------------*
*       CLASS lcl_car IMPLEMENTATION
*----------------------------------------------------------------------*
CLASS lcl_car IMPLEMENTATION.

  METHOD write_name.

    WRITE: / 'Own attribute', me-&amp;gt;w_name.

    WRITE: / 'other object', io_obj-&amp;gt;w_name.

  ENDMETHOD.                    "write_name

ENDCLASS.                    "lcl_car IMPLEMENTATION

*----------------------------------------------------------------------*
*       CLASS lcl_bmw DEFINITION
*----------------------------------------------------------------------*
CLASS lcl_bmw DEFINITION INHERITING FROM lcl_car.

ENDCLASS.                    "lcl_bmw DEFINITION

*----------------------------------------------------------------------*
*       CLASS lcl_merc DEFINITION
*----------------------------------------------------------------------*
CLASS lcl_merc DEFINITION INHERITING FROM lcl_car.

ENDCLASS.                    "lcl_merc DEFINITION


START-OF-SELECTION.
  DATA: lo_bmw   TYPE REF TO lcl_bmw,
        lo_merc  TYPE REF TO lcl_merc.

  CREATE OBJECT: lo_bmw,
                 lo_merc.

  lo_bmw-&amp;gt;w_name  = 'BMW'.
  lo_merc-&amp;gt;w_name = 'Merc'.

  lo_bmw-&amp;gt;write_name( lo_merc ).
&lt;/CODE&gt;&lt;/PRE&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>Mon, 23 Mar 2009 20:19:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/question-on-method-interface/m-p/5392668#M1239481</guid>
      <dc:creator>naimesh_patel</dc:creator>
      <dc:date>2009-03-23T20:19:44Z</dc:date>
    </item>
    <item>
      <title>Re: question on Method interface</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/question-on-method-interface/m-p/5392669#M1239482</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It can also be used in generic calls. Suppose we have vehicle class.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
CLASS lcl_vehicle DEFINITION.
   PUBLIC SECTION.
      METHODS: add_vehicle IMPORTING l_veh TYPE REF TO lcl_vehicle,
                        estimate_fuel.
      
      "table storing vehicles
      DATA: BEGIN OF it,
                   vehicle TYPE REF TO lcl_vehicle,
                 END OF it,
      
                 wa LIKE LINE OF it.
ENDCLASS.

CLASS lcl_vehicle IMPLEMENTATION.
    METHOD add_vehicle.
        wa-vehicle = l_veh.
        APPEND wa TO it.
    ENDMETHOD.

    METHOD estimate_fuel.
        LOOP at IT into WA.
           wa-vehicle-&amp;gt;estimate_fuel( ).              "here we can call same method of different subclasses with different implementation
        ENDLOOP.
    ENDMETHOD.
ENDCLASS.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now we create to subclasses. &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
CLASS lcl_plane DEFINITION INHERITING FROM lcl_vehicle.
   PUBLIC SECTION. 
      METHODS estimate_fuel REDEFINITION.
ENDCLASS.

CLASS lcl_ship DEFINITION INHERITING FROM lcl_vehicle.
   PUBLIC SECTION. 
      METHODS estimate_fuel REDEFINITION.
ENDCLASS.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Two different vehicles will redefine an &lt;EM&gt;estimate_fuel&lt;/EM&gt; method as each has to take different factors into account when tanking up.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We would like to handle both &lt;STRONG&gt;plane&lt;/STRONG&gt; and &lt;STRONG&gt;ship&lt;/STRONG&gt; from one point. For this we add our new vehicles to the table of lcl_vehicle class.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
DATA: r_vehicle TYPE REF TO lcl_vehicle,
          r_plane    TYPE REF TO lcl_plane,
          r_ship      TYPE REF TO lcl_ship.

CREATE OBJECT: r_vehicle, r_plane, r_ship.

"add all vehicles to the table
r_vehicle-&amp;gt;add( r_plane ).
r_vehicle-&amp;gt;add( r_ship ).

"Now we can perform generic call
r_vehicle-&amp;gt;estimate_fuel( ).  "this will call same method of two subclasses with different implementation, from one point 
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It would be easy now to handle new vehicle&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
CLASS lcl_motorbike DEFINITION INHERITING FROM lcl_vehicle.
   PUBLIC SECTION. 
      METHODS estimate_fuel REDEFINITION.
ENDCLASS.

DATA: r_motorbike TYPE REF TO lcl_motobike.

r_vehicle-&amp;gt;add( r_motorbike ). "it is enough to add the vehicle, this already suits our model and appropriate method will be called for estimating fuel
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Marcin&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Marcin Pciak on Mar 23, 2009 10:17 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Mar 2009 21:16:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/question-on-method-interface/m-p/5392669#M1239482</guid>
      <dc:creator>MarcinPciak</dc:creator>
      <dc:date>2009-03-23T21:16:44Z</dc:date>
    </item>
    <item>
      <title>Re: question on Method interface</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/question-on-method-interface/m-p/5392670#M1239483</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt; Hi &lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; I've the following method def:&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;/CODE&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;CODE&gt;   METHODS : METH1 IMPORTING INPUT1 TYPE I   
&amp;gt;                                                               INPUT2 TYPE REF TO  CL_1.
&amp;gt; &lt;/CODE&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; where CL_1 is the class withing where the method is defined.&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; Question is, what is this kind of definition and whats the use in real time implementation?&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; thkx&lt;/P&gt;&lt;P&gt;&amp;gt; P.S&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A simple example of this kind of definition which uses a Bank account class can be found in the below link (in Page 33)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;[Eight Reasons Why Every ABAP Developer...|https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/37c5db90-0201-0010-3a9b-d0a5288f3c15]&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Mar 2009 08:59:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/question-on-method-interface/m-p/5392670#M1239483</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-03-24T08:59:15Z</dc:date>
    </item>
  </channel>
</rss>

