<?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: An interface between a global class (caller) and e local class (called) in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/an-interface-between-a-global-class-caller-and-e-local-class-called/m-p/6899383#M1481132</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Only the instance to the local class is needed!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As you may have found out, you can't include programs in global classes.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The local class instance doesn't need to be passed in the constructor. It could go in any other method call.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
lo_my_globalclass-&amp;gt;do_something( io_interface = lo_my_localclass ).
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Maybe this example program will help you. It uses local interfaces and classes only but it should illustrate how the interface instance needs to be passed to the class. This is generic. It's not too big a strech from this program to making A_GLOBAL_CLASS global, the interface global and having the LCL_1 and LCL_2 in two different programs.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
REPORT ytest.

INTERFACE lif_name.
  METHODS: get_name RETURNING value(rv_name) TYPE string.
ENDINTERFACE.                    "LIF_NAME

CLASS a_global_class DEFINITION.
  PUBLIC SECTION.
    METHODS: write_name IMPORTING io_name TYPE REF TO lif_name.
ENDCLASS.                    "A_GLOBAL_CLASS DEFINITION

CLASS a_global_class IMPLEMENTATION.
  METHOD write_name.
    DATA: lv_name TYPE string.
    lv_name = io_name-&amp;gt;get_name( ).
    WRITE:/ lv_name.
  ENDMETHOD.                    "WRITE_NAME
ENDCLASS.                    "A_GLOBAL_CLASS IMPLEMENTATION

CLASS lcl_1 DEFINITION.
  PUBLIC SECTION.
    INTERFACES lif_name.
ENDCLASS.                    "lcl_1 DEFINITION


CLASS lcl_1 IMPLEMENTATION.
  METHOD lif_name~get_name.
    rv_name = 'LCL_1'.
  ENDMETHOD.                    "LIF_NAME~GET_NAME
ENDCLASS.                    "lcl_1 IMPLEMENTATION


CLASS lcl_2 DEFINITION.
  PUBLIC SECTION.
    INTERFACES lif_name.
ENDCLASS.                    "lcl_2 DEFINITION


CLASS lcl_2 IMPLEMENTATION.
  METHOD lif_name~get_name.
    rv_name = 'LCL_2'.
  ENDMETHOD.                    "LIF_NAME~GET_NAME
ENDCLASS.                    "lcl_2 IMPLEMENTATION

DATA: go_global TYPE REF TO a_global_class,
      go_1 TYPE REF TO lcl_1,
      go_2 TYPE REF TO lcl_2.

START-OF-SELECTION.
  CREATE OBJECT go_global.
  CREATE OBJECT go_1.
  CREATE OBJECT go_2.

  go_global-&amp;gt;write_name( go_1 ).
  go_global-&amp;gt;write_name( go_2 ).
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 28 May 2010 12:13:32 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2010-05-28T12:13:32Z</dc:date>
    <item>
      <title>An interface between a global class (caller) and e local class (called)</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/an-interface-between-a-global-class-caller-and-e-local-class-called/m-p/6899380#M1481129</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi experts.&lt;/P&gt;&lt;P&gt;I'm following Sebastian Noetzel's advice to use an interface to a local class, to get a dynpro in a global class:&lt;/P&gt;&lt;P&gt;&lt;A class="jive_macro jive_macro_thread" href="https://community.sap.com/" __jive_macro_name="thread" modifiedtitle="true" __default_attr="1666613"&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Summarizing my code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1)	I have a local class (in a report because I must get a dynpro) with a method.&lt;/P&gt;&lt;P&gt;2)	I have a global interface with the same method name.&lt;/P&gt;&lt;P&gt;3)	I have a global class, which could have to use the dynpro method (see the first point)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How must I do to declare and use all these things? &lt;/P&gt;&lt;P&gt;Now Iu2019m doing a big jumble:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1)	REPORT myreport.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CLASS mylocalclass DEFINTION.&lt;/P&gt;&lt;P&gt;PUBLIC SECTION.&lt;/P&gt;&lt;P&gt;  INTERFACES zif_myinterface.&lt;/P&gt;&lt;P&gt;ENDCLASS.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CLASS mylocalclass IMPLEMENTATION.&lt;/P&gt;&lt;P&gt;    METHOD zif_myinterface~mymethod.&lt;/P&gt;&lt;P&gt;        u2026u2026u2026u2026u2026.all-the-code-I-need-is-here ..........&lt;/P&gt;&lt;P&gt;   ENDMETHOD.&lt;/P&gt;&lt;P&gt;ENDCLASS.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2)	(by SE24)&lt;/P&gt;&lt;P&gt;INTERFACE  zif_myinterface.&lt;/P&gt;&lt;P&gt;With one method and his parameters:&lt;/P&gt;&lt;P&gt;METHOD  mymethod.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3)	(by SE24)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; (In interfaces section)&lt;/P&gt;&lt;P&gt;    INTERFACES zif_myinterface.&lt;/P&gt;&lt;P&gt;(after that I can see zif_myinterface ~mymethod among the methods protected)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;METHOD constructor.&lt;/P&gt;&lt;P&gt;u2026.&lt;/P&gt;&lt;P&gt;CALL  METHOD zif_myinterface~mymethod&lt;/P&gt;&lt;P&gt;   IMPORTING&lt;/P&gt;&lt;P&gt;       Myparameters.&lt;/P&gt;&lt;P&gt;u2026.&lt;/P&gt;&lt;P&gt;ENDMETHOD.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It is wrong of course:  when I debug it, I can see an empty u201Czif_myinterface ~mymethodu201D that is executed.&lt;/P&gt;&lt;P&gt;Can you draught the right system?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 May 2010 16:52:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/an-interface-between-a-global-class-caller-and-e-local-class-called/m-p/6899380#M1481129</guid>
      <dc:creator>former_member1161170</dc:creator>
      <dc:date>2010-05-04T16:52:30Z</dc:date>
    </item>
    <item>
      <title>Re: An interface between a global class (caller) and e local class (called)</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/an-interface-between-a-global-class-caller-and-e-local-class-called/m-p/6899381#M1481130</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;An instance of the local class needs to be passed to the global class for this to work. I'm not sure exactly what you're doing but if you're doing this in the constructor, it would go something like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Add importing parameter io_myinterface type ref to zif_myinterface to the constructor of the global class&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;so somewhere in the report where the global class is instantiated...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
data: lo_mylcl type ref to mylocalclass,
         lo_mygc type ref to yourglobalclass.

create object lo_mylcl.
create object lo_mygc exporting io_myinterface = lo_mylcl.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;then in the constructor of the global class, you do this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
io_myinterface-&amp;gt;zif_myinterface~mymethod( ).
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Erik Peterson on May 27, 2010 1:49 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 May 2010 17:48:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/an-interface-between-a-global-class-caller-and-e-local-class-called/m-p/6899381#M1481130</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-05-27T17:48:33Z</dc:date>
    </item>
    <item>
      <title>Re: An interface between a global class (caller) and e local class (called)</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/an-interface-between-a-global-class-caller-and-e-local-class-called/m-p/6899382#M1481131</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I made a global class like a generic class. Everybody can instantiate this class.&lt;/P&gt;&lt;P&gt;When somebody instantiates it, the class is not starting from a specific report within the involved local class.&lt;/P&gt;&lt;P&gt;So:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
data: lo_mylcl type ref to mylocalclass,
         lo_mygc type ref to yourglobalclass.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How can I tell to my global class where is the local class code?&lt;/P&gt;&lt;P&gt;Where can I put the report/include name?&lt;/P&gt;&lt;P&gt;This is the question, because I can have several report with the same local class name. How can the global class find It?&lt;/P&gt;&lt;P&gt;Can I put an include somewhere?&lt;/P&gt;&lt;P&gt;Perhaps it's a banal question but I'm a newbie ...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 May 2010 07:07:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/an-interface-between-a-global-class-caller-and-e-local-class-called/m-p/6899382#M1481131</guid>
      <dc:creator>former_member1161170</dc:creator>
      <dc:date>2010-05-28T07:07:16Z</dc:date>
    </item>
    <item>
      <title>Re: An interface between a global class (caller) and e local class (called)</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/an-interface-between-a-global-class-caller-and-e-local-class-called/m-p/6899383#M1481132</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Only the instance to the local class is needed!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As you may have found out, you can't include programs in global classes.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The local class instance doesn't need to be passed in the constructor. It could go in any other method call.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
lo_my_globalclass-&amp;gt;do_something( io_interface = lo_my_localclass ).
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Maybe this example program will help you. It uses local interfaces and classes only but it should illustrate how the interface instance needs to be passed to the class. This is generic. It's not too big a strech from this program to making A_GLOBAL_CLASS global, the interface global and having the LCL_1 and LCL_2 in two different programs.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
REPORT ytest.

INTERFACE lif_name.
  METHODS: get_name RETURNING value(rv_name) TYPE string.
ENDINTERFACE.                    "LIF_NAME

CLASS a_global_class DEFINITION.
  PUBLIC SECTION.
    METHODS: write_name IMPORTING io_name TYPE REF TO lif_name.
ENDCLASS.                    "A_GLOBAL_CLASS DEFINITION

CLASS a_global_class IMPLEMENTATION.
  METHOD write_name.
    DATA: lv_name TYPE string.
    lv_name = io_name-&amp;gt;get_name( ).
    WRITE:/ lv_name.
  ENDMETHOD.                    "WRITE_NAME
ENDCLASS.                    "A_GLOBAL_CLASS IMPLEMENTATION

CLASS lcl_1 DEFINITION.
  PUBLIC SECTION.
    INTERFACES lif_name.
ENDCLASS.                    "lcl_1 DEFINITION


CLASS lcl_1 IMPLEMENTATION.
  METHOD lif_name~get_name.
    rv_name = 'LCL_1'.
  ENDMETHOD.                    "LIF_NAME~GET_NAME
ENDCLASS.                    "lcl_1 IMPLEMENTATION


CLASS lcl_2 DEFINITION.
  PUBLIC SECTION.
    INTERFACES lif_name.
ENDCLASS.                    "lcl_2 DEFINITION


CLASS lcl_2 IMPLEMENTATION.
  METHOD lif_name~get_name.
    rv_name = 'LCL_2'.
  ENDMETHOD.                    "LIF_NAME~GET_NAME
ENDCLASS.                    "lcl_2 IMPLEMENTATION

DATA: go_global TYPE REF TO a_global_class,
      go_1 TYPE REF TO lcl_1,
      go_2 TYPE REF TO lcl_2.

START-OF-SELECTION.
  CREATE OBJECT go_global.
  CREATE OBJECT go_1.
  CREATE OBJECT go_2.

  go_global-&amp;gt;write_name( go_1 ).
  go_global-&amp;gt;write_name( go_2 ).
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 May 2010 12:13:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/an-interface-between-a-global-class-caller-and-e-local-class-called/m-p/6899383#M1481132</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-05-28T12:13:32Z</dc:date>
    </item>
  </channel>
</rss>

