ABAP SYNTAX FOR DATA PART TWO

Addition 2

... LIKE f1

Effect

Creates the field f with the same field attributes as the field F1 which is already known. Any data objects are valid (fields, parameters, structures, ...) as long as types have been assigned.

f1 can be any Dictionary reference.

Example

DATA TABLE_INDEX LIKE SY-TABIX.

The field TABLE_INDEX now has the same attributes as SY-TABIX (the index for internal tables).

Note

This addition is often useful, since the ABAP/4 runtime system performs type changes on fields automatically. Any unnecessary and/or unwanted conversions are thus avoided.

Addition 3

... TYPE typ OCCURS n

Effect

Defines an internal table without header line. Such a table consists of any number of table lines with the type typ .
To fill and edit this table, you can use statements likeAPPEND , READ TABLE , LOOP and SORT .
The OCCURS parameter n defines how many tables lines are created initially. If necessary, you can increase the size later. Otherwise, the OCCURS parameter is of no significance, apart from the exception that applies with APPEND SORTED BY .

Example

 TYPES: BEGIN OF LINE_TYPE,
         NAME(20) TYPE C,
         AGE      TYPE I,
       END OF LINE_TYPE.
DATA:  PERSONS    TYPE LINE_TYPE OCCURS 20,
       PERSONS_WA TYPE LINE_TYPE.
PERSONS_WA-NAME = 'Michael'.
PERSONS_WA-AGE  = 25.
APPEND PERSONS_WA TO PERSONS.
PERSONS_WA-NAME = 'Gabriela'
PERSONS_WA-AGE  = 22.
APPEND PERSONS_WA TO PERSONS.
 
The internal table  PERSONS  now consists of two table entries.
 NOTE:

Access to table entries not in main memory takes much longer. On the other hand, there is not enough space in main memory to hold such large tables because the roll area is resticted (see above).

No comments :

Post a Comment