ABAP数据类型定义

2020-09-18  本文已影响0人  黑白木笛
1、ABAP-基本数据类型
ABAP基本数据类型.jpg
2、ABAP-变量声明
data test1(15) type c value 'Hello World'.

注:定义长度为 10 类型是 c 值是 "Hello World" 的变量 test1,语句以 "." 结束

如果不定义变量长度,系统默认变量的长度为类型的默认长度(见上面ABAP基本数据类型的默认长度),长度也可用 "LENGTH" 关键字,如下

data test1 type c length 15 value 'Hello World'.

如果要同时声明多个变量,可以一句一句写也可以在 "DATA" 后加 ":" 冒号,语句中间用 "," 连接,以 "." 结束

data: player(35)   type c,
      nickname(35),
      points       type i value '29',
      games        type i value '10',
      average(5)   type p,
      acquired     type d.

注:VALUE 定义值时,值的最大长度不能超过变量定义的长度,不然系统会按设定长度自动截取,"data test1(5) type c value 'Hello World'." 变量定义的长度为5,实际值为"Hello",未使用 "TYPE" 声明数据类型,则该变量默认为 "C" 类型(字符类型)

data: test1(15) type c value 'Hello World',
      test2 like test1.

注:TEST1和TEST2具有相同的属性,值也相同

clear: test1,test2.
constants: team1(20) type c value '76ers',
           team2     like team1 value 'celtics',
           total     type i value 82. 
types: name(10) type c,
       teams(20) type c.
data: player   type name value 'Jerry',
      nickname like player.
constants: team1 type teams value 'Team1',
           team2 like team1 value 'Team2';
3、ABAP-定义变量注意事项
上一篇 下一篇

猜你喜欢

热点阅读