ABAP : Include structures

我就是我 2022-09-30 07:13 132阅读 0赞

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/

发表评论

表情:
评论列表 (有 0 条评论,132人围观)

还没有评论,来说两句吧...

相关阅读

    相关 ABAP指针

    关于abap指针的一些资料。 1.什么是abap指针: 在abap里面,fieldsymbol就相当于c语言的指针。如果你定义并且分配了相应的结构或者变量给它,其实它