Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

You are trying to access a component with a 'ZERO' object reference (points to nothing)

former_member239819
Participant
0 Kudos

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?

1 ACCEPTED SOLUTION

matt
Active Contributor

You haven't instantiated r_info.

11 REPLIES 11

matt
Active Contributor

You haven't instantiated r_info.

FredericGirod
Active Contributor

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 ).

0 Kudos

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?

0 Kudos

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.

0 Kudos

Sure.. As you can see the Class for the definition is deferent to the Class of the Method.

No sure if that matters.

Sandra_Rossi
Active Contributor
0 Kudos

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." ?

Sandra_Rossi
Active Contributor
0 Kudos

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

former_member239819
Participant
0 Kudos

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...

0 Kudos

and what is the definition of the ZCL_P2P_UI_CTRL_BASE ?

0 Kudos

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.


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.