[SAPABAP开发技术总结]结构复用(INCLUDE)

更新时间:2023-06-16 05:59:03 阅读: 评论:0

将来造句[SAPABAP开发技术总结]结构复⽤(INCLUDE)周武帝宇文邕
TYPES BEGIN OF struc_type.
TYPES comp ...
TYPES comp TYPE struc_type BOXED. "参照另⼀结构类型
INCLUDE { {TYPE struc_type} | {STRUCTURE struc} } "将另⼀结构包括进来
拂袖的意思[AS name [RENAMING WITH SUFFIX suffix]].
TYPES END OF struc_type.
INCLUDE { {TYPE struc_type} | {STRUCTURE struc} }
[AS name [RENAMING WITH SUFFIX suffix]].
一撇打一字该语句只能⽤在定义结构的BEGIN OF与END OF之间。作⽤是将结构类型struc_type与结构变量struc的所有组件字段拷贝到当前结构定义的指定位置,INCLUDE就是将可以重复使⽤的东西先做好,再包含进来。
AS name:给包含进来的结构类型(或结构变量)取⼀个别名,这样就可以通过结构组件符(-)来选取这个结构类型(或结构变量)
RENAMING WITH SUFFIX suffix:如果include进来的结构类型(或结构变量)的组件字段与现有的重复,则可以使⽤此选项重命
名include进来的结构类型(或结构变量)的各组件字段名,具体做法只是在原来组件名后加上了指定的后缀suffix
TYPES: BEGIN OF t_day,
work TYPE c LENGTH 8,
free TYPE c LENGTH 16,
END OF t_day.
DATA BEGIN OF week.卡农作者
INCLUDE TYPE t_day AS monday    RENAMING WITH SUFFIX _mon.
INCLUDE TYPE t_day AS tuesday  RENAMING WITH SUFFIX _tue.
INCLUDE TYPE t_day AS wednesday RENAMING WITH SUFFIX _wed.
...
述职报告
DATA END OF week.
满月祝福语男孩可以通下⾯的⽅式来访问week结构变量:
直接看作是week结构变量组件:week-work_mon, week-free_mon, week-work_tue
由于使⽤as别名,所以还可以这样访问:week-monday-work, week-monday-free, week-tuesday-work
当程序中多个结构使⽤共同的字段时,将公⽤的部分提取出来,使⽤INCLUDE将它们组装起来,编程结构更清晰。下⾯是结构对象的复⽤:
DATA: BEGIN OF comm1 OCCURS 0,
bukrs TYPE bg-bukrs,
END OF comm1.
TYPES:BEGIN OF comm2,
blart TYPE bkpf-blart,
END OF comm2.
DATA: BEGIN OF gt_result OCCURS 0,
c1 TYPE c."直接定义组件字段,但前⾯语句后⾯使⽤逗号INCLUDE STRUCTURE comm1."直接将结构对象包括进来
INCLUDE TYPE comm2."直接将结构类型包括进来
DATA:comm LIKE comm1,"直接参照
c2 TYPE c. "直接定义组件字段,但前⾯语句后⾯使⽤逗号DATA: END OF gt_result.
gt_result-bukrs = '111'.
gt_result-blart = '222'.
gt_result-comm-bukrs = '333'.
下⾯是类型的复⽤:
TYPES: BEGIN OF street_type,
name TYPE c LENGTH 40,
团的成语no  TYPE c LENGTH 4,
END OF street_type.
DATA: BEGIN OF comm1 OCCURS 0,
bukrs TYPE bg-bukrs,
END OF comm1.
TYPES: BEGIN OF address_type,
name1 TYPE c LENGTH 30."直接定义类型,但前⾯语句需使⽤逗号TYPES:street TYPE street_type,"参照另⼀结构类型
c TYPE c."直接定义类型,但前⾯语句需使⽤逗号
INCLUDE STRUCTURE comm1.
INCLUDE TYPE street_type.
TYPES: END OF address_type.
*或者是这样
*TYPES: BEGIN OF address_type,
*        name1 TYPE c LENGTH 30,
*        street TYPE street_type,
*        c TYPE c.
*        INCLUDE STRUCTURE comm1.
*        INCLUDE TYPE  street_type.
*TYPES: END OF address_type.
DATA: name TYPE address_type-street-name.
DATA: name2 TYPE address_type-name.
DATA: bukrs TYPE address_type-bukrs.

本文发布于:2023-06-16 05:59:03,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/82/965726.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:结构   类型   变量
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图