CREATE DATA

来源:互联网 发布:mac无法登陆app store 编辑:程序博客网 时间:2024/05/17 02:26

CREATE DATA dref.

This short form, without further additions, is only allowed for completely typed data references, that is references whose complete reference type is known statically. The system creates a data object with the statically specified reference type.

Example

In the following example a data object with the type SBOOK is dynamically created and dereferenced for use:

data DREF type ref to SBOOK.

create data DREF.
select *
from   SBOOK
into   DREF->*.
  ...
endselect.

 

CREATE DATA dref TYPE simpletype.

Effect

For a simple type specification you can use the REF TO or LINE OF additions to specify a reference type or line type of a table type resepectively. If you are declaring an elementary type, you can also use the LENGTH and DECIMALS additions. The type specification must be compatible with the reference variable type.

Example

In the following example, we create an anonymous data object to which the reference dref points. The type of the data object is the type of the work area in the database table SBOOK. We then assign the data object to the field symbol <fs> using the dereferencing operator ->*. Any other dereferencing is not possible here, because the reference variable is not completely typed. You can now work with the fieldsymbol as normal.

DATA: dref TYPE REF TO DATA.
FIELD-SYMBOLS: <fs> TYPE ANY.

" Create object of type SBOOK and attach the field symbol
CREATE DATA dref TYPE sbook.
ASSIGN dref->* TO <fs>.

原创粉丝点击