Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

regarding extracts

Former Member
0 Likes
472

hi friends,

i am working on reports,

i am wierdly confused as to how he extracts are used,

can some one help me understand how the data is stored in extracts, and how it can be retrieved, the below is the code i am trying to understand.\

code

field-groups: header, detail.

extract detail.

loop.

at new mseg-werks.

..........

endat.

at new mseg-matnr.

...................

endat.

at detail.

..................

endat.

endloop.

3 REPLIES 3
Read only

Former Member
0 Likes
444

Hi,

Hope this helps

This statement links the current content of the fields, which were until then included in the field group header resp. field_group via the statement INSERT , to the extract dataset of the program. If there is no field group specified after EXTRACT, then the field group header is implicitly added.

At the first execution of the EXTRACT-statement of a program, the extract datset is created and the first line added. After execution of an EXTRACT-statement, it is not allowed to incorporate other fields to the specified field group field_group with the INSERT statement. If you do so, an uncatchable exception will be raised at the next EXTRACT-statement for the same field group.

Notes

As the field group header is the beginning part and sort key of every field group, it is not allowed to incorporate fields into header after execution of the first EXTRACT statement.

The lines of an extract dataset cannot be explicitly deleted and will be kept alive as long as the internal mode of the program.

Example

This example continues the example under INSERT. If the executable program is linked to a fitting logical data base, the fields of the field groups flight_info and flight_date are attached to the extract dataset during the GET-events.

REPORT demo_extract.

NODES: spfli, sflight.

FIELD-GROUPS: header, flight_info, flight_date.

START-OF-SELECTION.

INSERT: spfli-carrid spfli-connid sflight-fldate

INTO header,

spfli-cityfrom spfli-cityto

INTO flight_info.

GET spfli.

EXTRACT flight_info.

GET sflight.

EXTRACT flight_date.

Thanks,

-Anthony

Read only

Former Member
0 Likes
444

EXTRACT

Creates an extract dataset and adds lines to it.

Syntax

EXTRACT <fg>.

With the first EXTRACT statement of a program, the system creates the extract dataset and adds the first extract record. In each subsequent EXTRACT statement, the new extract record is added to the dataset. Each extract record contains exactly those fields that are contained in the field group <fg>, plus the fields of the field group HEADER (if one exists).

An extract is a sequential dataset in the memory area of the program. Greater than 500 KB are stored on O/s

Writes all fields of the field group fg (see FIELD-GROUPS) as one record to a sequential dataset (paging). If a field group HEADER has been defined, its fields prefix each record to form a sort key. You can then sort this dataset using SORT and process it with LOOP ... ENDLOOP. After this, EXTRACT cannot be executed again.

As soon as the first dataset for a field group has been extracted with EXTRACT, the field group cannot be expanded using INSERT. The field group HEADER, in particular, cannot be expanded after the first EXTRACT (regardless of field group).

Large extract datasets are not kept in main memory; instead, they are written to an external help file. You can specify the directory in which this file is to be stored using the SAP profile parameter DIR_EXTRACT. By default, the system uses the SAP file directory SAP profile parameter DIR_DATA).

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.

Each extract record contains exactly those fields that are contained in the field group <fg>, plus the fields of the field group HEADER (if one exists). The fields from HEADER occur as a sort key at the beginning of the record. 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.

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

By processing EXTRACT 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 an EXTRACT statement, extract datasets provide the advantage that you need not determine the structure at the beginning of the program.

Check this link for sample program

http://help.sap.com/saphelp_nw04/helpdata/en/9f/db9f0535c111d1829f0000e829fbfe/frameset.htm

Read only

Former Member
0 Likes
444

anuy more inputs please