Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How to pass object reference variable as importing parameter in method ?

dipesh_kumar
Explorer
0 Likes
3,966

How can we pass object reference variable  of one class in importing parameter to the method of other classs to call mehtod of first class ?

Thanks in advance.

5 REPLIES 5
Read only

wol
Active Participant
0 Likes
1,619

The parameter must be typed as reference to object.

E. g.:

METHODS tetmeth importing im_object type ref to your_class.

Regards

Stefan

Read only

Former Member
0 Likes
1,619

Hello Dipesh,

                     Can You Please Elobarate Your requirement more specifically.

Regards,

Santosh

Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,619

Yes, but you could just try and check with a small report in some seconds, in fact, we do it all the time, never implemented a badi or use an oo-alv class ?

Regards,

Raymond

Read only

Former Member
0 Likes
1,619

by using INHERITENCE IT IS POSSIBLE

declare class c1

Declare method m1 importing obj type ref to class_name.

implement c1

create class c2 inherting for c1

method m1 redefiniton.

implement c2.

create object form class c2

call method m1 using object of class c2 and pass your reference as exporting parameter.

thanks & Regards

rajeshkumar

Read only

Former Member
1,619

CLASS A DEFINITION.
   PUBLIC SECTION.
   METHODS M1.
ENDCLASS.

CLASS A IMPLEMENTATION.
   METHOD M1.
     WRITE: 'Hi'.
   ENDMETHOD.
ENDCLASS.


CLASS B DEFINITION.
   PUBLIC SECTION.

   METHODS M2 IMPORTING OB23 TYPE REF TO A.

ENDCLASS.

CLASS B IMPLEMENTATION.
   METHOD M2.
*    WRITE: 'HELLO'.
     OB23->M1( ).
   ENDMETHOD.
ENDCLASS.

START-OF-SELECTION.

DATA: OB TYPE REF TO A.
CREATE OBJECT OB.

DATA: OB1 TYPE REF TO B.
CREATE OBJECT OB1.

CALL METHOD OB1->M2( OB23 = OB ).