‎2008 Jun 19 9:26 AM
HI,
I want to use methods from protected class directly by creating instace of that class.
without inheriting it to child class.
Is it posible.......... direclty its not possible. Is there any other way?
Regards,
sarath
‎2008 Jun 19 9:31 AM
Hi,
if class A contains protected methods and you want to use it from class B, when B is not a child of A, then you can define class B as friend class in class A. With that you can use protected and private methods.
See [Defining Friends Relationships|http://help.sap.com/saphelp_nw70/helpdata/EN/b5/693ec8185011d5969b00a0c94260a5/frameset.htm]
Regards Rudi
‎2008 Jun 19 9:31 AM
Hi,
if class A contains protected methods and you want to use it from class B, when B is not a child of A, then you can define class B as friend class in class A. With that you can use protected and private methods.
See [Defining Friends Relationships|http://help.sap.com/saphelp_nw70/helpdata/EN/b5/693ec8185011d5969b00a0c94260a5/frameset.htm]
Regards Rudi
‎2008 Jun 19 9:59 AM
Hi,
Thanks for u r replay.
I want to use that protected class in ABAP editor.
Not in a class.
Regards,
sarath
‎2008 Jun 19 10:05 AM
Hi,
I think, then is the way to achieve this to define a local class that inherits from the global class. Then you can define a public method within this local class that calls the protected method.
Regards Rudi
‎2008 Jun 19 10:07 AM
Hi,
Only Child Classes and Friend Classes can use the Protected/Private methods or Protected/Private variables.
‎2008 Jun 19 10:14 AM
Hi,
We can use the protected metothod by inheriting only.
the sample code is
CLASS c2 DEFINITION INHERITING FROM CL_GUI_ALV_GRID.
PUBLIC SECTION.
METHODs m2.
ENDCLASS.
CLASS c2 IMPLEMENTATION.
METHOD m2.
CALL METHOD DELETE_ALL_MENUS.
ENDCLASS.
Here DELETE_ALL_MENUS is the protected method which is present in cl_gui_alv_grid..
I think it is useful for you.
Reward points if useful.
Thanks & regards
Deepika.
‎2008 Oct 08 7:38 AM