SAP ABAP SYNTAX FOR DATA PART SIX

This is in continuation with SAP ABAP SYNTAX for data part five.

Variant 4

DATA: BEGIN OF itab OCCURS n,
...
END OF itab.

Additions


... VALID BETWEEN f1 AND f2

Effect

Defines the internal table itab .

An internal table includes a header line, which is a field string containing the fields defined between " BEGIN OF itab OCCURS n " and " END OF itab " (see variant 3), and any number of table lines with the same structure as the header line.

To fill and edit an internal table, you use various statements such as APPEND , LOOP and SORT .

The OCCURS parameter n determines how many table lines are held in main storage (the roll area). If you also generate table entries, these are rolled out either to a main storage buffer or to disk (the paging area).

Example

 
DATA: BEGIN OF PERSONS OCCURS 20,
        NAME(20),
        AGE TYPE I,
      END   OF PERSONS.
PERSONS-NAME = 'Michael'.
PERSONS-AGE  = 25.
APPEND PERSONS.
PERSONS-NAME = 'Gabriela'.
PERSONS-AGE  = 22.
APPEND PERSONS.

The internal table now consists of two table entries.

PERSONS also includes the header line (work area) through which all operations on the actual table pass.

Note

Access to table entries not in main storage is considerably slower. Also, main storage cannot hold large tables in their entirety, since the size of the roll area is restricted (see above).

Addition

... VALID BETWEEN f1 AND f2

Effect

Can appear only after " END OF itab ".

The sub-fields f1 and f2 of the internal table itab must have the line-related validity range .

Variant 5

DATA: BEGIN OF COMMON PART c,
.....
END OF COMMON PART.

Effect

Defines one or more common data areas in programs linked by external PERFORM calls. If only one common data area exists, you can omit the name c . There may be just one unnamed COMMON area or one or more named COMMON areas. You assign named COMMON areas to each other by name. The structure of data areas must always be the same for both the calling and the called program (otherwise, the program terminates with an error message at runtime).
  • The table work areas are always in the common data area.
  • In general, you define the area created as COMMON with a common INCLUDE STRUCTURE . Occasionally, you use a INCLUDE report which contains precisely the definition of the COMMON PART .
  • Field symbols cannot belong to a common data area, even if the FIELD-SYMBOLS statement lies between DATA BEGIN OF COMMON PART and DATA END OF COMMON PART .
RELATED POST

No comments :

Post a Comment