‎2006 Mar 07 9:51 AM
Hi,
i would choose an private Method of an global class (for example class: CL_GUI_ALV_GRID private Method: SEARCH_START) in a local class.
class lcl_test definition for testing.
private section.
methods test for testing.
data ref_alv type ref to cl_gui_alv_grid.
endclass.
class lcl_test implementation.
method for test.
create object ref_alv ...
* How to call a private Method?
call method ref_alv->search_start( ). "not possible!
endmethod.
endclass.
Is this possible?
Regards,
Damir
‎2006 Mar 07 10:01 AM
it is not possible ....can u describe the exact func that u required so that i can find some public method which would help u...
‎2006 Mar 07 9:55 AM
‎2006 Mar 07 9:56 AM
Hi,
You can't call a private method since it is "private". Private method can be called within the class where it is defined. We can use public methods or protected methods through inheritance.
regards
austin
‎2006 Mar 07 9:56 AM
Hi,
private is private, so it's not possible to play with it.
Rgd
Frédéric
‎2006 Mar 07 9:57 AM
‎2006 Mar 07 9:59 AM
It is used for internal puprose od cl_gui_alv_grid, call method cannot be done externally.
Regards
vijay
‎2006 Mar 07 10:01 AM
it is not possible ....can u describe the exact func that u required so that i can find some public method which would help u...
‎2006 Mar 07 10:21 AM
The context is, that I would write ABAPUnit Tests for an own global class! In this class I have some private Methods, and I would test this methods. So I´m search for a possibility to Test this Methods with ABAPUnit.
class myclass definition.
private section.
methods my_method.
endclass.
class myclass implementation.
method my_method.
endmethod.
endclass.
class mytest defintion for testing.
private section.
methods test for testing.
endclass.
class mytest implementation.
method test.
* How to call private Methods from local class myclass?
endmethod.
endclass.
I couldn´t believe, that it is impossible to test private Methods..
regards,
Damir
‎2006 Mar 07 11:17 AM
Damir, of course you can call a private method of a class, if this class has made you a friend with the syntax element FRIENDS (available since Release 6.10). Here is a syntactically correct example, when my_method is a private class method:
REPORT test.
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.
Kind regards,
Michael Kraemer
‎2006 Mar 07 11:25 AM