Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/unix/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
访问返回参数的组件时,这不是ObjectReference错误_Reference_Components_Abap - Fatal编程技术网

访问返回参数的组件时,这不是ObjectReference错误

访问返回参数的组件时,这不是ObjectReference错误,reference,components,abap,Reference,Components,Abap,当我试图处理这样一个完全类型的数据引用表达式时,会收到ThisNotObjectReference语法消息: method getDataReference. rr_value = ref #( varStructure ). endmethod. data(lr_value) = object->getDataReference( )->structureComponent. 我知道检索对象引用的语法是相同的,但如何处理表达式中的全类型数据引用?我在猜测您在这里想要实现什么,

当我试图处理这样一个完全类型的数据引用表达式时,会收到ThisNotObjectReference语法消息:

method getDataReference.
 rr_value = ref #( varStructure ).
endmethod.

data(lr_value) = object->getDataReference( )->structureComponent.

我知道检索对象引用的语法是相同的,但如何处理表达式中的全类型数据引用?

我在猜测您在这里想要实现什么,但据我所知,您需要先取消引用数据引用,然后才能访问其内容。下面扩展了您在上面发布的代码

report ztest.

class lcl_test definition.

  public section.

    methods getDataReference
      returning value(rr_value) type ref to tadir.

  private section.

    data varStructure type tadir.

endclass.

class lcl_test implementation.

  method getDataReference.

    varstructure-author = sy-uname.
    rr_value = ref #( varStructure ).

  endmethod.

endclass.

start-of-selection.

  data(object) = new lcl_test( ).
  data(lr_value) = object->getDataReference( ).

  field-symbols <structure> type tadir.
  assign lr_value->* to <structure>. " This is the dereferencing step
  write / <structure>-author.
报告ztest。
类lcl_测试定义。
公共部分。
方法getDataReference
返回值(rr_值)类型ref到tadir。
私人部分。
数据结构类型tadir。
末级。
类lcl_测试实现。
方法getDataReference。
varstructure author=sy uname。
rr_值=ref#(varStructure)。
endmethod。
末级。
开始选择。
数据(对象)=新的lcl_测试()。
数据(lr_值)=对象->getDataReference()。
字段符号类型为tadir。
将lr_值->*分配给。“这是取消引用的步骤
写/写作者。

不能将方法调用与引用组件访问链接起来。应使用如下辅助变量:

CLASS lcl_class DEFINITION.
PUBLIC SECTION.
 METHODS: getdatareference RETURNING VALUE(rr_value) TYPE REF TO mara.
ENDCLASS.

CLASS lcl_class IMPLEMENTATION.
  METHOD getdatareference.
    DATA: ls_mara TYPE mara.
    rr_value = REF #( ls_mara ).
    SELECT SINGLE * FROM mara INTO rr_value->*.
  ENDMETHOD.
ENDCLASS.

START-OF-SELECTION.
  DATA(lcl)     = NEW lcl_class( ).
  DATA(lv_mara) = lcl->getdatareference( ).
  DATA(l_matnr) = lv_mara->matnr.