1. 程式人生 > 其它 >【ABAP】結構體巢狀宣告的幾種方式

【ABAP】結構體巢狀宣告的幾種方式

**********************************************************************
TYPES:BEGIN OF typ_address,
        country(50) TYPE c,
        city(100)   TYPE c,
        street(100) TYPE c,
      END OF typ_address.

TYPES:BEGIN OF typ_emp,
        empNo(50)    TYPE c,
        empName(100) TYPE c,
        address      
TYPE typ_address, END OF typ_emp. DATA: gt_emp TYPE TABLE OF typ_emp, gs_emp TYPE typ_emp. gs_emp-empNo = '10031000'. gs_emp-empName = 'Tom'. gs_emp-address-country = 'CN'. gs_emp-address-city = 'BJ'. APPEND gs_emp TO gt_emp. gs_emp-empNo = '10031001'. gs_emp-empName = 'Jim'. gs_emp-address-country = '
CN'. gs_emp-address-city = 'BJ'. APPEND gs_emp TO gt_emp. ********************************************************************** types:BEGIN OF typ_address03, country(50) TYPE c, city(100) TYPE c, street(100) TYPE c, END OF typ_address03. DATA:BEGIN OF gs_emp03. INCLUDE
type typ_address03 AS address. DATA: empNo(50) TYPE c, empName(100) TYPE c, END OF gs_emp03. DATA:gt_emp03 LIKE TABLE OF gs_emp03. gs_emp03-empNo = '10031990'. gs_emp03-empName = 'Jack'. gs_emp03-address-country = 'CN'. APPEND gs_emp03 TO gt_emp03. ********************************************************************** DATA:BEGIN OF gs_address01, country(50) TYPE c, city(100) TYPE c, street(100) TYPE c, END OF gs_address01. DATA:BEGIN OF gs_emp01, address LIKE gs_address01, empNo(50) TYPE c, empName(100) TYPE c, END OF gs_emp01. DATA:gt_emp01 LIKE TABLE OF gs_emp01. gs_emp01-empNo = '10031990'. gs_emp01-empName = 'Jack'. gs_emp01-address-country = 'CN'. APPEND gs_emp01 TO gt_emp01. ********************************************************************** DATA:BEGIN OF gs_address02, country(50) TYPE c, city(100) TYPE c, street(100) TYPE c, END OF gs_address02. DATA:BEGIN OF gs_emp02. INCLUDE STRUCTURE gs_address02 AS address. DATA: empNo(50) TYPE c, empName(100) TYPE c, END OF gs_emp02. DATA:gt_emp02 LIKE TABLE OF gs_emp02. gs_emp02-empNo = '10031990'. gs_emp02-empName = 'Jack'. gs_emp02-address-country = 'CN'. APPEND gs_emp02 TO gt_emp02.