Login Form

Best viewed in IE 7.0

ADVERTISEMENTS
ADVERTISEMENT

What is Extract dataset?

Extract dataset

There are two ways of processing large quantities of data in ABAP - either using internal tables or extract datasets.

An internal table is a dynamic sequential dataset in which all records have the same structure and a key.Internal tables provide a means of taking data from a fixed structure and storing it in working memory in ABAP. The data is stored line by line in memory, and each line has the same structure. In ABAP, internal tables fulfill the function of arrays. A particularly important use for internal tables is for storing and formatting data from a database table within a program.

Extracts are dynamic sequential datasets in which different lines can have different structures. You cannot access the individual records in an extract using key or index. Instead, you always process them using a loop.You may only create one extract in any ABAP program. The size of an extract dataset is, in principle, unlimited.The practical size of an extract is up to 2GB, as long as there is enough space in the filesystem.In one extract dataset, you can store records of different length and structure one after the other. You need not create an individual dataset for each different structure you want to store.In contrast to internal tables, the system partly compresses extract datasets when storing them. This reduces the storage space required. In addition, you need not specify the structure of an extract dataset at the beginning of the program, but you can determine it dynamically during the flow of the program.You can use control level processing with extracts just as you can with internal tables.

Defining an Extract
You must define each record type of an extract dataset as a field group, using the FIELD-GROUPS statement.
FIELD-GROUPS <fg>.
A field group combines several fields under one name.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.

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>.it also use to create the pointers to the fields <fi > in the field group <fg>, while defining the structures of the extract records.

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.


Filling an Extract with Data
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 first EXTRACT statement occurs in a program, the system creates the extract dataset and adds the first extract record to it. In each subsequent EXTRACT statement, the new extract record is added to the dataset.If you do not explicitly specify a field group <fg>, 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.

example: In continuation to above program

START-OF-SELECTION.

GET spfli.
EXTRACT flight_info.

GET sflight.
EXTRACT flight_date.

Processing Extracts
Once you have filled the extract, you can sort it and process it in a loop.

Reading an Extract
you can read the data in an extract dataset using a loop.When the LOOP statement occurs, the system stops creating the extract dataset, and starts a loop through the entries in the dataset. One record from the extract dataset is read in each loop pass. The values of the extracted fields are placed in the corresponding output fields within the loop. You can use several loops one after the other, but they cannot be nested. It is also no longer possible to use further EXTRACT statements within or after the loop. In both cases, a runtime error occurs.

example: in continuation to above-

END-OF-SELECTION.

LOOP.
AT FIRST.
WRITE / 'Start of LOOP'.
ULINE.
ENDAT.
AT FLIGHT_INFO WITH FLIGHT_DATE.
WRITE: / 'Info:', SPFLI-CARRID, SPFLI-CONNID, SFLIGHT-FLDATE, SPFLI-CITYFROM, SPFLI-CITYTO.
ENDAT.
AT FLIGHT_DATE.
WRITE: / 'Date:', SPFLI-CARRID, SPFLI-CONNID, SFLIGHT-FLDATE.
ENDAT.
AT LAST.
ULINE.
WRITE / 'End of LOOP'.
ENDAT.
ENDLOOP.


Further,You can sort an extract dataset in much the same way as an internal table only prerequisite is that all fields by which you want to sort are contained in the HEADER during the extraction process.

you can use control statements AT NEW <f>, AT END OF <f> inside the loop.A control break occurs when the value of the field <f> or a superior field in the current record has a different value from the previous record (AT NEW) or the subsequent record (AT END). Field <f> must be part of the HEADER field group.

you can access two automatically-generated fields CNT(<f>) and SUM(<g>). These fields contain the number of different values and the sums of the numeric fields respectively. The system fills these fields at the end of a control level and after reading the last record
ADVERTISEMENT
Free software downloads