11-08-2019 12:00 PM
I'm setting up a Method call from a class
DATA: r_info TYPE REF TO zcl_sv_job_offline_ctrl.
CALL METHOD r_info->create
EXPORTING
is_data = lr_test_record.
And receiving the following errors:
CX_SY_REF_IS_INITAL
You are trying to access a component with a 'ZERO' object reference (points to nothing). Variable: "R_INFO".
Am I missing something?
11-08-2019 12:22 PM
11-08-2019 12:22 PM
11-08-2019 12:24 PM
If you use directly a method this method should be static. (class-method)
DATA: r_info TYPE REF TO zcl_sv_job_offline_ctrl.
CALL METHOD zcl_sv_job_offline_ctrl=>create
EXPORTING
is_data = lr_test_record.
otherwise, if this method is instance method, you need to do something like that
new ()zcl_sv_job_offline_ctrl->create
EXPORTING
is_data = lr_test_record.
or
data(r_info) = new zcl_sv_job_offline_ctrl( ).
CALL METHOD r_info->create
EXPORTING
is_data = lr_test_record.
should be more beautiful like
data(r_info) = new zcl_sv_job_offline_ctrl( ).
r_info->create( lr_test_record ).
11-08-2019 12:48 PM
Thanks for your help.
The 1st example won't work (it's not a static method).
The 2nd example shows syntax errors so won't activate.
The 3rd example errors with (No Value was passed to the Mandatory Parameter (IO_DESPATCHER).
Any other ideas?
11-08-2019 12:50 PM
Could you give us the definition part of the ZCL_SV_JOB_OFFLINE_CTRL. All the proposal was based on supposition, it depends a lot of your code.
11-08-2019 1:10 PM
Sure.. As you can see the Class for the definition is deferent to the Class of the Method.
No sure if that matters.
11-08-2019 1:01 PM
As Frederic asked, "Could you give us the definition part of [the method CREATE of] the ZCL_SV_JOB_OFFLINE_CTRL. All the proposal was based on supposition, it depends a lot of your code." ?
11-08-2019 1:04 PM
And also, the "section" to which the method CREATE belongs to + definition of the class (especially CREATE PUBLIC/PRIVATE/PROTECTED, also FINAL and FRIENDS...)
NB: cross-referencing https://stackoverflow.com/questions/58766177/exception-cx-sy-ref-is-inital
11-08-2019 1:16 PM
class ZCL_SV_JOB_OFFLINE_CTRL definition
public
inheriting from ZCL_P2P_UI_CTRL_BASE
final
create public .
public section.
methods MERGE
importing
!IS_DATA type ref to DATA
returning
value(RS_DATA) type ref to DATA
raising
ZCX_P2P_UI_BASE_EXC .
methods CREATE
redefinition .
methods QUERY
redefinition .
methods READ
redefinition .
methods UPDATE
redefinition .
methods DELETE
redefinition
Nothing in the private or protected section...
11-08-2019 1:18 PM
11-08-2019 3:10 PM
Here is the constructor of ZCL_P2P_UI_CTRL_BASE with the io_dispatcher. parameter.
method CONSTRUCTOR.
go_dispatcher = io_dispatcher.
go_objtype = io_objtype.
endmethod.
io_dispatcher has the class ZCL_P2P_UI_DISPATCHER_BASE
method CONSTRUCTOR.
gs_gwsrv = is_gwsrv.
endmethod.
and is_gwsrv is of type table ZP2P_UI_GWSRV
MANDT
SERVICE_ID
DISPATCHER_CLASS.
I'm at a loss on how to populate io_dispatcher.
11-09-2019 8:33 AM
You'd better learn OO concept, and ask questions about OO generally speaking, because it seems that instantiating your class is not so easy. Moreover it seems that your classes are copied from the standard (not a good idea if you don't master the code that is inside), so you could search for examples in the standard code how to instantiate this class.
Note that the instantiation cannot be with NEW/CREATE OBJECT if the class definition has the attribute CREATE PRIVATE or CREATE PROTECTED, it can be done only by calling one of its static classes or via an eventual FRIEND.
Currently, the code you need is (with a little guess):
SELECT SINGLE * FROM zp2p_ui_gwsrv WHERE service_id = '???' INTO @data(ls_gwsrv).
data(r_dispatcher) = NEW zcl_p2p_ui_dispatcher_base( ls_gwsrv ).
" data(r_objtype) = ???
data(r_info) = NEW zcl_sv_job_offline_ctrl(
io_dispatcher = r_dispatcher
io_objtype = r_objtype ). " optional or mandatory?
r_info->create( lr_test_record ).
Now that you understand how to find out the way to instantiate a class, you can do the same for R_DISPATCHER and R_OBJTYPE.