Application Development 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: 

local class -> global class

Former Member
0 Kudos

Hi Friends,

Can a local class make friend with global class???

for example i have a local class in se38 editor and this local class should access the private attribute of global class which is there in se24.

Deepak

9 REPLIES 9

Former Member
0 Kudos

yes i think so

0 Kudos

<b>how????</b>

h_senden2
Active Contributor
0 Kudos

CLASS lcl_class DEFINITION CREATE PRIVATE FRIENDS cl_global.

regards,

Hans

Please reward all helpful answers !!!!!

Former Member
0 Kudos

Hi

Yo can define your ABAP Unit test class as a friend of the global class to be tested in the local class definition include of your global class. So, you have to add a line of code like

<b>CLASS <name of global class to be tested> DEFINITION LOCAL FRIENDS <name of local ABAP Unit class></b> in the include where the definition of local ABAP Unit Class is in.

Then you can call the private methods of your global class in the local abap unit class methods.

Regards,

Dinesh

Please tell if it worked and dont forget to reward if useful

0 Kudos

Hi Dinesh,

Still i am not getting your point.

where should i declare the statement

<b>CLASS <name of global class to be tested> DEFINITION LOCAL FRIENDS <name of local ABAP Unit class></b>

is it in the global class where i should declare the above statement?

bcos when i declare this statement the "local class definition" of the global class it asks for local class <b><name of local ABAP Unit class></b>.

please help me out.

Deepak Diwakar

0 Kudos

HI Deepak

Yo can define your ABAP Unit test class as a friend of the global class to be tested in the local class definition include of your global class. So, you have to add a line of code like

CLASS <name of global class to be tested> DEFINITION LOCAL FRIENDS <name of local ABAP Unit class> in the include where the definition of local ABAP Unit Class is in. Then you can call the private methods of your global class in the local abap unit class methods.

just refer these links

http://help.sap.com/saphelp_nw2004s/helpdata/en/ec/d9ab291b0b11d295400000e8353423/content.htm

Regards Rk

Former Member
0 Kudos

Hi Deepak,

Global Class Local Class

Any program Only the program where it is defined.

In the Class Repository Only in the program where it is defined.

Created using transaction SE24

Created using SE38

Must begin with Y or Z Can begin with any character

Rewords points if it helpful.

Rgds,

P.Naganjana Reddy

0 Kudos

Global Class Local Class

Any program

In the Class Repository

Created using transaction SE24

Must begin with Y or Z

Local Class

Only the program where it is defined.

Only in the program where it is defined.

Created using SE38

Can begin with any character

rgds,

P.Nag

Former Member
0 Kudos

hi ,

private members cannot be inherited from the base class or super class..

if it is friend of this class means it will access the private members also ..

regards,

kumar