Entering content frameDefining an Extract Locate the document in its SAP Library structure

To define an extract, you must first declare the individual records and then define their structure.

Declaring Extract Records as Field Groups

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.

FIELD-GROUPS <fg>.

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:

FIELD-GROUPS 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.

Defining the Structure of a Field Group

To define the structure of a record, use the following statement to add the required fields to a field group:

INSERT <f1>... <f n> 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-GROUPS statement. The fields in the field group must be global data objects in the ABAP program. You cannot assign a local data object defined in a procedure to a field group.

The INSERT statement, just as the FIELD-GROUPS statement, neither reserves storage space nor transfers values. You use the INSERT statement to create pointers to the fields <f i > 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 HEADER once 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 HEADER, otherwise, it is empty.

Example

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.

The program is linked to the logical database F1S. The NODES statement declares the corresponding interface work areas.

There are three field groups. The INSERT statement assigns fields to two of the field groups.

 

 

 

Leaving content frame