Show TOC

Filling an Extract with DataLocate this document in the navigation structure

Once you have declared the possible record types as field groups and defined their structure, you can fill the extract dataset using the following statements:

EXTRACT fg.

When the firstEXTRACT statement occurs in a program, the system creates the extract dataset and adds the first extract record to it. In each subsequentEXTRACT statement, the new extract record is added to the dataset.

Each extract record contains exactly those fields that are contained in the fg field group, plus perhaps the fields of the header field group. The fields occur as a sort key at the beginning. If you do not explicitly specify an fg field group, the

EXTRACT

statement is a shortened form of the statement

EXTRACT header.

When you extract the data, the record is filled with the current values of the corresponding fields.

As soon as the system has processed the firstEXTRACT statement for an fg field group, the structure of the corresponding extract record in the extract dataset is fixed. You can no longer insert new fields into the fg and header field groups. If you try to modify one of the field groups afterwards and use it in anotherEXTRACT statement, a runtime error occurs.

By processingEXTRACT statements several times using different field groups, you fill the extract dataset with records of different length and structure. Since you can modify field groups dynamically up to their first usage in anEXTRACT statement, extract datasets provide the advantage that you need not determine the structure at the beginning of the program.

Tip

The following program is connected to the logical database F1S.

REPORT demo_extract_extract.
NODES: spfli, sflight.
FIELD-GROUPS: header, flight_info, flight_date.
INSERT: spfli-carrid spfli-connid sflight-fldate
        INTO header,
        spfli-cityfrom spfli-cityto
        INTO flight_info.
START-OF-SELECTION.
GET spfli.
  EXTRACT flight_info.
GET sflight.
  EXTRACT flight_date.

There are three field groups. TheINSERT statement assigns fields to two of the field groups. During the GET events, the system fills the extract dataset with two different record types. The records of the field group flight_info consist of five fields: spfli-carrid, spfli-connid, sflight-fldate, spfli-cityfrom and spfli-cityto. The first three fields belong to the prefixed field group header. The records of the field group flight_date consist only of the three fields of the header field group. The following figure shows the structure of the extract dataset:

9FDB9F0535C111D1829F0000E829FBFE