Include Structure
Sometime there is a need to create structure which should have fields same as some other structure and also additional fields. Suppose we have two structures A and B. Structure A has some 10 fields and structure B needs 12 fields out of which 10 fields are same as fields of structure A.
So In this case we can include structure A in structure B using keyword include. The structure to be included can be local or a dictionary object. To include all fields from structure used including. This will create direct fields in other structure. Fields can be access directly.
EXAMPLE
REPORT ZABC.
data : begin of dept,
deptno type i,
dname(20) type c,
end of dept.
data : begin of emp,
empno type i,
ename(20) type c.
include structure dept. “注意这两个红点
data : addr(30) type c,
end of emp.
emp-empno = 1.
emp-ename = ’xyz’.
emp-deptno = 10.
emp-dname = ’HR’.
emp-addr = ’hyd’.
write :/ emp-empno,
emp-ename,
emp-deptno,
emp-dname,
emp-addr.
转自:http://www.freesaptutorials.com/sap/abap-structures-include/