Exception CX_SY_REF_IS_INITAL

ε祈祈猫儿з 提交于 2020-12-27 05:28:59

问题


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:


Sorry, I don't have the rep to comment just yet... I notice that your class is a Z so I'm wondering if you are trying to create a singleton class. In which case. Your 'Create' should be static. Your Constructor private and your Instance in a private attribute.
From the other comments, I agree, your question is missing some key details to provide an accurate answer.
If IO_DISPATCHER is part of the constructor and you are unable to pass a value, you need to dig a little deeper into the purpose of the class. See if you can give it what it wants. Try a 'where used' and check out the other usages of the class. You might find you are looking at the wrong class, or at least approaching from the wrong direction.
If create is some method on the class and it is not static then you will never get it to work until you create an instance of the class.

Another thought that comes to mind is that you might be in the right place and just doing the wrong thing. Check your globals to see if there is already an instance of the class and you are trying to access something via declaration as data rather than using the global instance?? All guess work without more details.




回答2:


You missed to create the object. so you need to to:

create object r_info.

or

r_info = new zcl_sv_job_offline_ctrl( ).

or if there is a "factory method" ( what your 'create' method indicates )

r_info = zcl_sv_job_offline_ctrl=>create( is_data = lr_test_record ).

Your Exception tells you that the reference ( r_info ) is not connected with an object on the heap. So you need to do one of the above steps and then it should work. ( depending on your class )




回答3:


Thanks all.

The solution was simply to instantiate the parent classes (properly), enabled me to instantiate the class in question.



来源:https://stackoverflow.com/questions/58766177/exception-cx-sy-ref-is-inital

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!