*&---------------------------------------------------------------------*
*& Report ZWXS_HTKJ_TEST_01
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZWXS_HTKJ_TEST_01 MESSAGE-ID ZWXS_MESSAGE .
WRITE 'hello' .
MESSAGE S000 .
* 数据类型
* 变量
* 创建变量 参照标准类型
DATA GV_CHAR TYPE C LENGTH 10 VALUE 'CHAR类型'. "参考标准类型声明变量,
DATA GV_NUMC TYPE N LENGTH 10 VALUE '123' .
DATA GV_DEC TYPE P LENGTH 10 DECIMALS 2 VALUE '3.14' .
DATA GV_INT TYPE I VALUE 10 .
DATA GV_DATE1 TYPE D VALUE '20171121' .
DATA GV_DATE2 TYPE D VALUE '19940705' .
DATA GV_DATE3 LIKE GV_DATE2 . "参考对象创建对象
DATA GV_TIME1 TYPE T VALUE '151901' .
DATA GV_TIME2 TYPE T VALUE '180000' .
WRITE : / 'CHAR类型:' NO-GAP, GV_CHAR ,
/ '数值类型:' NO-GAP,GV_NUMC NO-ZERO, "去掉前导零
/ '小数类型:' NO-GAP ,GV_DEC .
GV_INT = GV_DATE1 - GV_DATE2 . "日期相减
WRITE : / '日期相减:', GV_INT .
GV_DEC = GV_TIME1 - GV_TIME2 .
WRITE : / '时间相减;' , GV_DEC . "时间相减
WRITE : / GV_DATE1+0(4) . "截取字符 第0位开始截取4位
WRITE : / GV_DATE2+4(*) . "第4位开始 ,截取所有
* 赋值
GV_DATE1 = GV_DATE2 .
MOVE GV_DATE2 TO GV_DATE1 .
WRITE GV_DATE2 TO GV_DATE1 . "WRITE辅助不能是 I 类型 和 P 类型
WRITE / GV_DATE1 .
* 创建变量 参照全局类型 即数据字典中创建的类型
DATA GV_SEX TYPE ZSTUSEX . " 参考 data element
GV_SEX = '男' .
write / gv_sex .
DATA GV_WEIGHT TYPE ZSTUDENT_WXS-ZSTUWEIGH . " 参考字段创建变量
GV_WEIGHT = '60' .
WRITE / GV_WEIGHT .
* 在程序中声明局部类型
TYPES GTY_CHAR01 TYPE C LENGTH 20 .
DATA GV_CHAR01 TYPE GTY_CHAR01 VALUE '参考局部类型创建变量' .
WRITE / GV_CHAR01 .
* 参考结构体类型 创建结构体变量
DATA GS_SCHOOL TYPE ZSCHOOL_WXS_STR_01 . " 参考全局类型的结构体 创建变量
GS_SCHOOL-ZSCHOOL = '101' .
GS_SCHOOL-ZSNAME = '清华大学' .
GS_SCHOOL-ZADD = '北京 中国' .
WRITE : / GS_SCHOOL .
WRITE : / GS_SCHOOL-ZSCHOOL , GS_SCHOOL-ZSNAME , GS_SCHOOL-ZADD .
DATA GS_SCHOOL2 TYPE ZSCHOOL_WXS_STR_01 .
MOVE-CORRESPONDING GS_SCHOOL TO GS_SCHOOL2 . "对应赋值
WRITE: / GS_SCHOOL2-ZSCHOOL , GS_SCHOOL2-ZSNAME , GS_SCHOOL2-ZADD .
* 结构体
* 在程序中声明结构体类型
TYPES : BEGIN OF GTY_SCHOOL3_S ,
ZSCHOOL TYPE ZSCHOOL_WXS_TEST-ZSCHOOL ,
ZSNA
*&---------------------------------------------------------------------*
*& Report ZWXS_HTKJ_TEST_01
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZWXS_HTKJ_TEST_01 MESSAGE-ID ZWXS_MESSAGE .
WRITE 'hello' .
MESSAGE S000 .
* 数据类型
* 变量
* 创建变量 参照标准类型
DATA GV_CHAR TYPE C LENGTH 10 VALUE 'CHAR类型'. "参考标准类型声明变量,
DATA GV_NUMC TYPE N LENGTH 10 VALUE '123' .
DATA GV_DEC TYPE P LENGTH 10 DECIMALS 2 VALUE '3.14' .
DATA GV_INT TYPE I VALUE 10 .
DATA GV_DATE1 TYPE D VALUE '20171121' .
DATA GV_DATE2 TYPE D VALUE '19940705' .
DATA GV_DATE3 LIKE GV_DATE2 . "参考对象创建对象
DATA GV_TIME1 TYPE T VALUE '151901' .
DATA GV_TIME2 TYPE T VALUE '180000' .
WRITE : / 'CHAR类型:' NO-GAP, GV_CHAR ,
/ '数值类型:' NO-GAP,GV_NUMC NO-ZERO, "去掉前导零
/ '小数类型:' NO-GAP ,GV_DEC .
GV_INT = GV_DATE1 - GV_DATE2 . "日期相减
WRITE : / '日期相减:', GV_INT .
GV_DEC = GV_TIME1 - GV_TIME2 .
WRITE : / '时间相减;' , GV_DEC . "时间相减
WRITE : / GV_DATE1+0(4) . "截取字符 第0位开始截取4位
WRITE : / GV_DATE2+4(*) . "第4位开始 ,截取所有
* 赋值
GV_DATE1 = GV_DATE2 .
MOVE GV_DATE2 TO GV_DATE1 .
WRITE GV_DATE2 TO GV_DATE1 . "WRITE辅助不能是 I 类型 和 P 类型
WRITE / GV_DATE1 .
* 创建变量 参照全局类型 即数据字典中创建的类型
DATA GV_SEX TYPE ZSTUSEX . " 参考 data element
GV_SEX = '男' .
write / gv_sex .
DATA GV_WEIGHT TYPE ZSTUDENT_WXS-ZSTUWEIGH . " 参考字段创建变量
GV_WEIGHT = '60' .
WRITE / GV_WEIGHT .
* 在程序中声明局部类型
TYPES GTY_CHAR01 TYPE C LENGTH 20 .
DATA GV_CHAR01 TYPE GTY_CHAR01 VALUE '参考局部类型创建变量' .
WRITE / GV_CHAR01 .
* 参考结构体类型 创建结构体变量
DATA GS_SCHOOL TYPE ZSCHOOL_WXS_STR_01 . " 参考全局类型的结构体 创建变量
GS_SCHOOL-ZSCHOOL = '101' .
GS_SCHOOL-ZSNAME = '清华大学' .
GS_SCHOOL-ZADD = '北京 中国' .
WRITE : / GS_SCHOOL .
WRITE : / GS_SCHOOL-ZSCHOOL , GS_SCHOOL-ZSNAME , GS_SCHOOL-ZADD .
DATA GS_SCHOOL2 TYPE ZSCHOOL_WXS_STR_01 .
MOVE-CORRESPONDING GS_SCHOOL TO GS_SCHOOL2 . "对应赋值
WRITE: / GS_SCHOOL2-ZSCHOOL , GS_SCHOOL2-ZSNAME , GS_SCHOOL2-ZADD .
* 结构体
* 在程序中声明结构体类型
TYPES : BEGIN OF GTY_SCHOOL3_S ,
ZSCHOOL TYPE ZSCHOOL_WXS_TEST-ZSCHOOL ,
ZSNA