简体   繁体   English

异常 CX_SY_REF_IS_INITAL

[英]Exception CX_SY_REF_IS_INITAL

I'm setting up a Method call from a class我正在设置来自 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?我错过了什么吗?

You missed to create the object.您错过了创建 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.您的异常告诉您引用( r_info )未与堆上的 object 连接。 So you need to do one of the above steps and then it should work.因此,您需要执行上述步骤之一,然后它应该可以工作。 ( depending on your class ) (取决于您的 class )

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.抱歉,我还没有代表发表评论...我注意到您的 class 是 Z,所以我想知道您是否正在尝试创建 singleton class。 In which case.在这种情况下。 Your 'Create' should be static.您的“创建”应该是 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.如果IO_DISPATCHER是构造函数的一部分并且您无法传递值,则需要更深入地了解 class 的用途。 See if you can give it what it wants.看看你能不能给它它想要的东西。 Try a 'where used' and check out the other usages of the class.尝试“使用位置”并查看 class 的其他用法。 You might find you are looking at the wrong class, or at least approaching from the wrong direction.您可能会发现您正在查看错误的 class,或者至少从错误的方向接近。
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.如果create是 class 上的某种方法,而不是 static,那么在创建 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??检查您的全局变量以查看是否已经存在 class 的实例,并且您正在尝试通过声明为数据而不是使用全局实例来访问某些内容? All guess work without more details.所有猜测都没有更多细节。

Thanks all.谢谢大家。

The solution was simply to instantiate the parent classes (properly), enabled me to instantiate the class in question.解决方案是简单地实例化父类(正确地),使我能够实例化有问题的 class。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM