‎2013 Sep 19 6:09 PM
Hi All,
I am trying to call a protected method from sap given class, and I am getting the below error , please help.
"method active_infotypes is unknown or protected or private."
Here is the code where i am trying to access the method from the sap standard class (method was defined as protected..)
CALL METHOD cl_hrecm00_status_change_appl=>activate_infotypes
EXPORTING
iv_orgunit = iv_orgunit
iv_test_mode = iv_test_mode
iv_note = iv_note
io_message_handler = io_message_handler
IMPORTING
ev_is_ok = ev_is_ok.
Thanks
Krishna
‎2013 Sep 19 7:09 PM
You cannot call a protected method of a class from outside.
It can only be called in the class methods or in its subclasses.
‎2013 Sep 19 7:20 PM
I am trying to make use of some of the standard sap class methods which are protected, so in that case it is not possible to reuse sap given methods in my program...
Thanks
Krishna
‎2013 Sep 19 7:15 PM
As you know concept of OOPS..
All of the components declared in the public section are accessible to all users of the class, and to the methods of the class and any classes that inherit from it. The public components of the class form the interface between the class and its users.
All of the components declared in the protected section are accessible to all methods of the class and of classes that inherit from it. Protected components form a special interface between a class and its subclasses. Since inheritance is not active in Release 4.5B, the protected section currently has the same effect as the private section.
Components that you declare in the private section are only visible in the methods of the same class. The private components are not part of the external interface of the class.
So if you want to use it outside of class then make it public.
‎2013 Sep 19 7:23 PM
Hi Chandra,
****All of the components declared in the protected section are accessible to all methods of the class and of classes that inherit from it.
As per this statement, if I inherit sap standard class can I access methods from protected class? Also we are on ECC6 EHP5.
Thanks
Krishna
‎2013 Sep 19 7:27 PM
If you inherit any class , then you can access its protected property in the sub class. This is OOPS concept.
Super class..
private Section.
Method1
Protected section:
Method2.
Sub class inherited form Super class..
Now Method2 will be accessible into it...
****Its a just simple English text. Not a code..
‎2013 Sep 19 7:35 PM
I am trying as below to access the sap given standard class method, still not able to access , please suggest what I am doing wrong:
form perform_action
* Create a reference type for the class:
DATA: obj_cl_hrecm00 TYPE REF TO cl_hrecm00_status_change_appl.
*Create object for the referenced class
CREATE object obj_cl_hrecm00.
* Call method with object reference:
CALL METHOD obj_cl_hrecm00=>activate_infotypes
EXPORTING
iv_orgunit = iv_orgunit
iv_test_mode = iv_test_mode
iv_note = iv_note
io_message_handler = io_message_handler
IMPORTING
ev_is_ok = ev_is_ok.
endform.
Please advice what I am missing.
Thanks
Krishna
‎2013 Sep 19 7:44 PM
‎2013 Sep 19 9:00 PM
create a new class with CL_HRECM00_STATUS_CHANGE_APPL as superclass. it is not final. you will be able to call protected methods.
‎2013 Sep 19 9:01 PM
And btw, ACTIVATE_INFOTYPES is instnace method not static. So you call it like -> not like =>