‎2007 Feb 07 11:54 AM
Hello Friends,
How do we call Private Methods? How it would be in case of Subclass?
Thanks & Regards
Sathish Kumar
‎2007 Feb 07 1:22 PM
Hi Satish,
You can call a private method of a class, if this class has made you a friend with the syntax of FRIEND
REPORT zex33.
CLASS mytest DEFINITION FOR TESTING.
PRIVATE SECTION.
METHODS test FOR TESTING.
ENDCLASS.
CLASS myclass DEFINITION FRIENDS mytest.
PUBLIC SECTION.
CLASS-METHODS my_method.
ENDCLASS.
CLASS myclass IMPLEMENTATION.
METHOD my_method.
ENDMETHOD.
ENDCLASS.
CLASS mytest IMPLEMENTATION.
METHOD test.
CALL METHOD myclass=>my_method.
ENDMETHOD.
ENDCLASS.
If my_method is not a class method, then you need to create an object of the class first, whose methods you want to test.
‎2007 Feb 07 12:14 PM
Try this:
CALL METHOD method .
CALL METHOD super->method.
http://help.sap.com/saphelp_erp2004/helpdata/en/1d/df5f57127111d3b9390000e8353423/content.htm
‎2007 Feb 07 1:06 PM
you can try this one.
CALL METHOD method .
CALL METHOD super->method.
still you have any doubt send your doubt clearly.
regards
veera nagi reddy
‎2007 Feb 07 1:13 PM
Hi Sathish Kumar,
Go through the following Code
DATA: L_APP TYPE STRING VALUE 'EXCEL' ,
L_PARAMETER TYPE STRING VALUE 'C:\ZRPP030.XLS'.
<b> CALL METHOD CL_GUI_FRONTEND_SERVICES=>EXECUTE</b> EXPORTING
APPLICATION = L_APP
PARAMETER = L_PARAMETER
EXCEPTIONS
CNTL_ERROR = 1
ERROR_NO_GUI = 2
BAD_PARAMETER = 3
FILE_NOT_FOUND = 4
PATH_NOT_FOUND = 5
FILE_EXTENSION_UNKNOWN = 6
ERROR_EXECUTE_FAILED = 7
SYNCHRONOUS_FAILED = 8
NOT_SUPPORTED_BY_GUI = 9
others = 10.
Regards
Sreeni
‎2007 Feb 07 1:16 PM
hi
<b>
Private methods</b>
Can only be called from inside the class. They are placed in the PRIVATE section of the class.
<i><b>Private section. Not accessable by subclasses</b></i>
<b>
Private attributes</b>
Private attributes are defined in the PRIVATE section. The can only be viewes and changed from within the class. There is no direct access from outside the class.
PRIVATE SECTION.
DATA: name(25) TYPE c,
planetype LIKE saplane-planetyp,
with regards
vinayaka
‎2007 Feb 07 1:22 PM
Hi Satish,
You can call a private method of a class, if this class has made you a friend with the syntax of FRIEND
REPORT zex33.
CLASS mytest DEFINITION FOR TESTING.
PRIVATE SECTION.
METHODS test FOR TESTING.
ENDCLASS.
CLASS myclass DEFINITION FRIENDS mytest.
PUBLIC SECTION.
CLASS-METHODS my_method.
ENDCLASS.
CLASS myclass IMPLEMENTATION.
METHOD my_method.
ENDMETHOD.
ENDCLASS.
CLASS mytest IMPLEMENTATION.
METHOD test.
CALL METHOD myclass=>my_method.
ENDMETHOD.
ENDCLASS.
If my_method is not a class method, then you need to create an object of the class first, whose methods you want to test.
‎2007 Feb 07 2:59 PM
Hi Sathish.
The syntax for calling a private method is no different from that of calling any other instance method.
It is call method object->method
exporting
<>
importing
<>.
But remember, that you can call the private method only within the same class.
Hope this helps. Remember to reward points if it does.
Rgds,
Prashanth.
SAP.