Entering content frameProcedure documentation Using Programs to Retrieve Data Locate the document in its SAP Library structure

Use

You can use a program that reads data to generate dataset reports that use the automatic data retrieval process in the SAP Query.

The program you use to read the data can either be an existing part of the InfoSet or an external program independent of the InfoSet.

Note

You can convert an InfoSet that uses an external data-reading program into an InfoSet with an integrated data-reading program. From the InfoSet: Initial Screen, you follow the menu path InfoSet -> More Functions -> Integrate External Reading Program.

Prerequisites

You have created an InfoSet and given it a name and an authorization group in the InfoSet: Title and Database screen.

For more information see Assigning Data Sources.

Procedure

  1. In the InfoSet: Title and Database dialog box, choose the Data Retrieval by Program field.
  2. Specify a data structure. This structure must describe the structure of the records in the dataset that you want to report on.
  3. The Integrated Program option is set by default. This is the most suitable option in most cases.

If you do want to use an external program, specify the name of the program in the External Program input field.

Caution

If you transport an InfoSet that uses an external program to retrieve data, you must make sure that the InfoSet and the external program are transported together.

  1. Choose This graphic is explained in the accompanying text Continue.
  2. Create a data-reading program before you generate the InfoSet for the first time.

The editor you use depends on the type of data-reading program.

The data-reading program must meet the following requirements:

The data-reading program is not intended to be executed itself.

The basic structure and operating sequence of a data-reading program is as follows:

Report xxxxxxxx .

 

Tables tab .

Definition of the dictionary structure used to set up the InfoSet. This structure must contain the records that you want to report on.

Parameters .

Definition of parameters, selection criteria, and fields.

Select-Options:…

 

DATA:

 

DATA: BEGIN OF itab OCCURS xxx.
      INCLUDE STRUCTURE tab.
DATA: END of itab.

Definition of an internal table itab with structure tab providing the records that you want to report on.

* <Query_head>

Comment to finish off a data statement.

* Code to define the itab table, if such a table is used.

* Start of a loop to retrieve, one at a time, each of the records that you want to report on, and place them in the tab structure (SELECT, DO, LOOP)

* Code for formatting data

 

* <Query_body>

Comment to finish the statement in the loop. The data must be available in the tab structure.

* End of data retrieval loop for individual records (ENDSELECT, ENDDO, ENDLOOP)

 

Caution

If you arrange the components of the model report in an inappropriate sequence, SAP Query may generate meaningless reports.

The character strings for the two comment lines *<QUERY_HEAD> and *<QUERY_BODY> are set to begin immediately after the "<" character. The system does not make a distinction between capital letters and lower case letters.

In a model report, there are no restrictions on how you should organize the retrieval of your data. This means that you are able to use very complex algorithms to retrieve data, if you so wish. You can also use SELECT statements that read on a cross-client basis (CLIENT SPECIFIED extra).

Internal and external data-reading programs may also contain selections. These are displayed as standard selections in the selections overview (This graphic is explained in the accompanying text) of either the Change InfoSet screen or the Display InfoSet screen. The system checks the program for selections regularly:

Result

In the maintenance screens for an InfoSet that uses an integrated program to retrieve data, you have the same options available to you as you do when you are working with InfoSets that use other data sources.

For more information see Special Features.

Note

When you create a query for an InfoSet that uses a program to retrieve its data, the model report is used as a template when the query report is generated. The attributes of the model report are passed on to the generated reports. The model report itself is not changed as a result of this process.

This means that you also have the option of using a logical database to organize the data retrieval process. We recommend that, as a rule, you create the InfoSet directly using the logical database.

Example

The following graphic shows a model report that uses the SELECT statement:

This graphic is explained in the accompanying text

The following graphic shows a model report that uses the LOOP statement.

This graphic is explained in the accompanying text

The data is retrieved and placed in an internal table that is filled by a data import from the INDX. In the LOOP structure, each line must be read from PLANEDATA into SAPLANE. This is because the InfoSet has been created using the SAPLANE structure, and the query is expecting the data in a field string with the name SAPLANE.

Leaving content frame