在尝试处理如下所示的FullyTyped dataReference表达式时,我得到了一个" ThisIsNotAObjectReference" -syntaxMessage:
method getDataReference.
rr_value = ref #( varStructure ).
endmethod.
data(lr_value) = object->getDataReference( )->structureComponent.
我理解检索objectReferences的语法是一样的,但是如何处理表达式中的fullyTyped dataReferences?
答案 0 :(得分:0)
我有点猜测你想在这里实现什么,但据我所知,你需要在访问其内容之前取消引用数据引用。以下内容扩展了您在上面发布的代码。
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.
答案 1 :(得分:0)
您不能将方法调用与参考组件访问链接在一起。这样做:
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.