abap 数据引用

数据引用:

DATA: dref1 TYPE REF TO data, "定义引用对象
CREATE DATA dref1 TYPE t_struct. "创建数据引用,指定具体类型
*&---------------------------------------------------------------------*
*& Report Z10_13
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT Z10_13.

TYPES: BEGIN OF t_struct,
  col1 TYPE char15,
  col2 TYPE char15,
  END OF t_struct.

DATA: dref1 TYPE REF TO data, "定义引用对象
      dref2 TYPE REF TO data.

FIELD-SYMBOLS: <fs1> TYPE t_struct,
               <fs2> TYPE char15.

CREATE DATA dref1 TYPE t_struct. "创建数据引用,指定具体类型
ASSIGN dref1->* to <fs1>.

<fs1>-COL1 = 'Enjoy ABAP'.
<fs1>-COL2 = 'ABAP PROGRAMMING'.

dref2 = dref1.

ASSIGN dref2->* to <fs2> CASTING. "数据引用可以使用->* 取出值。

WRITE / <fs2>.

get REFERENCE OF <fs1>-COL2 into dref2.
ASSIGN dref2->* to <fs2>.
write / <fs2>.

 

猜你喜欢

转载自www.cnblogs.com/liyafei/p/11185153.html
0条评论
添加一条新回复