一、工作区Work Area
代码语言:javascript复制DATA: gt_out TYPE STANDARD TABLE OF zssd005_out_1,
gs_out TYPE zssd005_out_1.
**********************************************
*OLD SYNTAX:先定义工作区ls_export
DATA: ls_export TYPE zssd005_out_2.
LOOP AT gt_out INTO gs_out.
MOVE-CORRESPONDING gs_out TO ls_export.
ENDLOOP.
**********************************************
*NEW SYNTAX:不需要预先定义工作区ls_export
LOOP AT gt_out INTO gs_out.
DATA(ls_export) = CORRESPONDING zssd005_out_2( gs_out ).
ENDLOOP.
工作区(mapping&except)
代码语言:javascript复制REPORT ztest.
DATA:BEGIN OF ls_data1,
fd1 TYPE char10,
fd2 TYPE char10,
fd3 TYPE char10,
END OF ls_data1.
DATA:BEGIN OF ls_data2,
fd1 TYPE char10,
fd2 TYPE char10,
fd4 TYPE char10,
END OF ls_data2.
ls_data1 = VALUE #( fd1 = |First|
fd2 = |Second|
fd3 = |Third| ).
ls_data2 = CORRESPONDING #( ls_data1 ).
WRITE: / |****************************************|.
WRITE: / |*CORRESPONDING NO MAPPING AND NO EXCEPT*|.
WRITE: / |FD1:|,ls_data2-fd1,|FD2:|,ls_data2-fd2,|FD4:|,ls_data2-fd4.
SKIP.
ls_data2 = CORRESPONDING #( ls_data1 MAPPING fd4 = fd3 ).
WRITE: / |****************************************|.
WRITE: / |*CORRESPONDING MAPPING AND NO EXCEPT*|.
WRITE: / |FD1:|,ls_data2-fd1,|FD2:|,ls_data2-fd2,|FD4:|,ls_data2-fd4.
SKIP.
ls_data2 = CORRESPONDING #( ls_data1 EXCEPT fd2 ).
WRITE: / |****************************************|.
WRITE: / |*CORRESPONDING NO MAPPING AND EXCEPT*|.
WRITE: / |FD1:|,ls_data2-fd1,|FD2:|,ls_data2-fd2,|FD4:|,ls_data2-fd4.
SKIP.
ls_data2 = CORRESPONDING #( ls_data1 MAPPING fd4 = fd3 EXCEPT fd2 ).
WRITE: / |****************************************|.
WRITE: / |*CORRESPONDING MAPPING AND EXCEPT*|.
WRITE: / |FD1:|,ls_data2-fd1,|FD2:|,ls_data2-fd2,|FD4:|,ls_data2-fd4.
二、内表 Internal table
代码语言:javascript复制REPORT ZTEST.
DATA: LT_T001 TYPE STANDARD TABLE OF ACDOCA.
SELECT
BUKRS,
BELNR,
GJAHR,
BUZEI
FROM BSEG
UP TO 3 ROWS
INTO TABLE @DATA(LT_BSEG).
"CORRESPONDING
LT_T001 = CORRESPONDING #( LT_BSEG MAPPING RBUKRS = BUKRS
DOCLN = BUZEI ).
"Display data
CL_SALV_TABLE=>FACTORY(
IMPORTING
R_SALV_TABLE = DATA(LCL_ALV)
CHANGING
T_TABLE = LT_T001 ).
LCL_ALV->DISPLAY( ).