data 和 type

data和type有以下六种语法形式:

1.利用预定义类型(I F N P D T C X):

 DATA { {var[(len)] TYPE abap_type [DECIMALS dec]}
       | {var TYPE abap_type [LENGTH len] [DECIMALS dec]} }
       [VALUE val|{IS INITIAL}]
       [READ-ONLY].

TYPES { {dtype[(len)] TYPE abap_type [DECIMALS dec]}
        | {dtype TYPE abap_type [LENGTH len] [DECIMALS dec]} }.

2.引用已经存在的类型(包括dataelement 和 程序中定义的类型和数据):

DATA var { {TYPE [LINE OF] type}
           | {LIKE [LINE OF] dobj} }
           [VALUE val|{IS INITIAL}]
           [READ-ONLY].

TYPES dtype { {TYPE [LINE OF] type}
              | {LIKE [LINE OF] dobj} }.

3.引用变量或类型:

DATA ref { {TYPE REF TO type}
           | {LIKE REF TO dobj} }
           [VALUE IS INITIAL]
           [READ-ONLY].

TYPES dtype { {TYPE REF TO type}
              | {LIKE REF TO dobj} }.

4.定义STRUCTURE

DATA BEGIN OF struc [READ-ONLY].
     ...
     {DATA comp ...} | {INCLUDE {TYPE|STRUCTURE} ...}.
     ...
  DATA END OF struc.

TYPES BEGIN OF struc_type.
     ...
     {TYPES dtype ...} | {INCLUDE {TYPE|STRUCTURE} ...}.
     ...
TYPES END OF struc_type.

5.定义类表:

DATA itab { {TYPE tabkind OF [REF TO] type}
            | {LIKE tabkind OF dobj} }
            [WITH key] [INITIAL SIZE n]
            [WITH HEADER LINE]
            [VALUE IS INITIAL]
            [READ-ONLY].

TYPES dtype { {TYPE tabkind OF [REF TO] type}
              | {LIKE tabkind OF dobj} }
              [WITH key] [INITIAL SIZE n].

6.平行表:

DATA rtab {TYPE RANGE OF type}|{LIKE RANGE OF dobj}
            [INITIAL SIZE n]
            [WITH HEADER LINE]
            [VALUE IS INITIAL]
            [READ-ONLY].
TYPES dtype {TYPE RANGE OF type}|{LIKE RANGE OF dobj}
                  [INITIAL SIZE n].

 

 

field-symbols的用法

FIELD-SYMBOLS <fs> { typing | STRUCTURE struc DEFAULT dobj }.

其中typing的语法

... { TYPE generic_type }
  | { TYPE {[LINE OF] complete_type}
         | {REF TO {data|complete_type|class|intf}} }
  | { LIKE {[LINE OF] dobj}
         | {REF TO dobj} } ...

其中genric type 为不完全类型,一般包括

anyAny data type (suitable for any type)
any tableInternal table of any table type
cText field of generic length
clikeCharacter-type (c, d, n, t, string and character-type flat structures); in non- Unicode programs also x, xstring and any flat structures
csequenceText-type (c, string)
dataAny data type
hashed tableHashed table
index tableIndex table
nnumeric text of generic length
numericNumeric (b, i, p, f, s)
objectAny object type (root class of the inheritance hierarchy)
pPacked number of generic length and generic number of decimal places
simpleElementary data type including structured types with exclusively character-type flat components
sorted tableSorted table
Standard tableStandard table
tableStandard table
xByte field of generic length
xsequencebyte-type (x, xstring)

而complete type指具体明确的类型不具有一般性

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值