The object is defined in two steps. First, the individual records must be declared and then their structure defined.
An extract dataset consists of a sequence of records. These records may have different structures. All records with the same structure form a record type. You must define each record type of an extract dataset as a field group, using the FIELD-GROUPS statement.
This statement defines a field group fg. A field group combines several fields under one name. For clarity, you should declare your field groups at the end of the declaration part of your program.
A field group does not reserve storage space for the fields, but contains pointers to existing fields. When filling the extract dataset with records, these pointers determine the contents of the stored records.
You can also define a special field group called header:
This group is automatically placed before any other field groups when you fill the extract. This means that a record of a field group fg always contains the fields of the field group header. When sorting the extract dataset, the system uses these fields as the default sort key.
To define the structure of a record, use the following statement to add the required fields to a field group:
INSERT f1... fn INTO fg.
This statement defines the fields of field group fg. Before you can assign fields to a field group, you must define the field group fg using the FIELD-GROUPSstatement. Only globally visible data objects of the ABAP program can be used as fields f1... fn. You cannot assign a local data object defined in a procedure to a field group.
The INSERT statement, just as the FIELD-GROUPSstatement, neither reserves storage space nor transfers values. You use the INSERTstatement to create pointers to the fields f1... fn in the field group fg, thus defining the structures of the extract records.
When you run the program, you can assign fields to a field group up to the point when you use this field group for the first time to fill an extract record. From this point on, the structure of the record is fixed and may no longer be changed. In short, as long as you have not used a field group yet, you can still extend it dynamically.
The special field group header is part of every extract record. Consequently, you may not change the structure of the header field group after you have filled the first extract record.
A field may occur in several field groups; however, this means unnecessary data redundancy within the extract dataset. You do not need to define the structure of a field group explicitly with INSERT. If the field group header is defined, an undefined field group consists implicitly of the fields in the field group header;otherwise, it is empty.
NODES: spfli, sflight.
FIELD-GROUPS: header, flight_info, flight_date.
INSERT: spfli-carrid spfli-connid sflight-fldate
There are three field groups. The INSERT statement assigns fields to two of the field groups.