×

[PR]この広告は3ヶ月以上更新がないため表示されています。
ホームページを更新後24時間以内に表示されなくなります。




Sapass

 Simplify SAP R/3 development with Excel VBA/VB RFC  
Home> UserExit>SQUE0001



Index

SQUE0001

Runtime Routines for Query Reports
Short text Extension SQUE0001 for ABAP/4 Query: Private Filing of Data Description

As of Release 2.1D, the ABAP/4 Query has several options of passing data determined by a query on to other software products. Hence this data can be passed on to EXCEL (via the XXL interface), to SAP Business Graphics and to the Management Information System EIS, or stored as a file via the download interface.
The procedure is always similar. The determined data is supplied in an internal table (data table), whose fields correspond in sequence and type to the fields which are output in the list. A further internal table (description table) contains a description of the individual fields of the data table. In addition to type and position in the list, information on the field names, for example, is contained. Both these tables are transferred to the above-mentioned products and processed further by them.
As of Release 2.1D, the ABAP/4 Query also makes this interface available, so that every customer has the option to add own software products. This is the goal of the extension SQUE0001.

The extension SQUE0001 consists of two components, the function module EXIT_RSAQEXCE_001 and the menu enhancement RSAQEXCE+DAT. The activation of the extension within a project (transaction CMOD) results in an additional interactive function (private file) being available in every report generated by the query, by whose activation the above-mentioned function module is called. The tables mentioned above (data table and description table) are basically transferred to the function module. In addition, an additional parameter is displayed on the selection screen, which, as for the other interactive functions (EXCEL, graphic, EIS, file directory, save), offers the possibility to carry out the additional function (private file) directly, that is, without previously displaying the list. Since the parameter on the selection screen is called 'Private file', it is recommended that you name the menu enhancement the same (corresponds to the SAP recommendation).

After activation of the extension, all queries should be generated again since otherwise the additional parameter does not appear on the selection screen. A regeneration is also necessary for all queries which have already been created for a former release (before 2.1D). This can be achieved by the fact that the query is selected for editing with the function Change, and subsequently saved, in the component for maintaining queries. As a result, ther report is generated again on the next execution of the query.

Which parameters are transferred to the function module EXIT_RSAQEXCE_001, and how the values of these parameters are to be interpreted or processed is described in the following. To do this, the following example is used.
A user created a query X1 in client 03 in the user group RX, which consists of a single-spaced basic list, statistics and a ranking. In the basic list, the fields

KNA1-KUNNR customer number
KNA1-NAME1 name
KNC1-GJAHR fiscal year
KNC1-UM01U sales in posting period 1
T001-WAERS currency key

are output in this sequence. In statistics, the fields

KNA1-LAND1 country key
KNC1-UM01U sales in posting period 1

are output in this sequence, where in addition specifications of the number of the read records, the percentage and the average are required for the field KNC1-UM01U. In the ranking, the fields

KNA1-KUNNR customer number
KNA1-NAME1 name
KNC1-UM01U sales in posting period 1

are output in this sequence.

The function module EXIT_RSAQEXCE_001 has the following parameters:

PROGRAM - program which initiated transfer
LIST_ID - identifier of the transferred partial list
LISTTEXT - title of the transferred partial list
DATATAB - data table
LISTDESC - description table for the fields of the data table

PROGRAM:
This parameter contains the name of the query report which initiated the calling up of the function module. From this name you can determine which query was processed, since it always has the following structure.

AQbbmmqq bb = name of the user group
mm = client
qq = name of the query

In the current example, the report name is therefore AQRX03X1.

LIST_ID:
This parameter contains an three-digit identification code for identifying the transferred data table. Every list created by a query generated list can consist of several partial lists (a basic list, several statistics, several rankings). The data table (DATATAB) transferred to the function module only contains the data of a partial list. However, the description table (LISTDESC) always contains the description for the fields of all partial lists.
The possible values of the parameter are

G00 - if DATATAB contains the data of the basic list
Txx - if DATATAB contains the data of statistics xx (01,02,...)
Rxx - if DATATAB contains the data of ranking xx (01,02,...)

Hence, the parameter LIST_ID has two functions. On the one hand, you can determine which type the transferred partial list has and on the other hand, the valid entries can be determined in the description table.
In the current example, the parameter LIST_ID contains the value G00 if the data of the basic list is transferred, the value T01 if the data of the statistics is transferred, and the value R01 if the data of the ranking is transferred..

LISTTEXT:
This parameter contains a text, which was allocated for the definition of the query of the corresponding partial list.

DATATAB:
This table contains the data of the transferred partial list. The fields of this table correspond in sequence and type to the fields which were output in the partial list. In each case a table line corresponds to a list line. Possibly available line breaks are not taken into account in lines of basic lists, that is, such broken lines nevertheless make up a table line.
Since the structure of the data table depends on the definition of the transferred partial list, its structure cannot be transferred but must be determined in the function module itself. For this, the description table LISTDESC can be used for help. The access to individual fields of the data table is possible with the help of field symbols and the statement ASSIGN COMPONENT.
If the basic list is transferred in the example, a line of the data table consists of 5 fields with the following types, lengths and decimal places:

1st field: type C, length 10 (KNA1-KUNNR)
2nd field: Type C, length 35 (KNA1-NAME1)
3rd field: type N, length 04 (KNC1-GJAHR)
4th field: type P, length 08, dec. 02 (KNC1-UM01U)
5th field: type C, length 05 (T001-WAERS)

If the statistics are transferred, a line of the data table consists of 5 fields with the following types, lengths and decimal places:

1st field: type C, length 03 (KNA1-LAND1)
2nd field: type P, length 16, dec. 02 (total of KNC1-UM01U)
3rd field: type I, length 04 (number of records read)
4th field: type P, length 04, dec. 03 (percentage)
5th field: type P, length 08, dec. 02 (average of KNC1-UM01U)

If the ranking is transferred, a line of the data table consists of 4 fields with the following types, lengths and decimal places:

1st field: type C, length 06 (position in the ranking)
2nd field: type C, length 10 (KNA1-KUNNR)
3rd field: type C, length 35 (KNA1-NAME1)
4th field: type P, length 16, dec. 2 (total of KNC1-UM01U)

The specifications on type, length and number of decimal places can be determined either with the help of the ABAP statement DESCRIBE FIELD or with the help of the description table LISTDESC (see below).

LISTDESC:
The description table contains a description of the fields of the data table DATATAB, which also includes information in addition to type, length and number of decimal places, which cannot be determined with the help of the ABAP statement DESCRIBE FIELD. If a query consists of several partial lists (as in the current example), the description table always contains the description of the fields of all data tables (all partial lists), which can be transferred by this query. The appropriate entries can then be obtained from the description table via the parameter LIST_ID.
Thus, the description table would always contain the description of the fields of the data table of the basic list, fields of the data table of the statistics and the fields of the data table of the ranking in the current example.
The description table has the structure RSAQLDESC. This structure consists of the following fields:

LID TYPE C, length 03 ID of the partial list
FPOS TYPE N, length 02 position of the field
FCONT TYPE N, length 01 number of the continuation line
FCURPOS TYPE N, length 03 list position of the field
FGRAF TYPE C, length 01 X = text flag for graphic
FTYP TYPE C, length 01 ABAP type of the field
FLEN TYPE N, length 03 length of the field
FDEC TYPE N, length 02 number of decimal places of the field
FOLEN TYPE N, length 03 output length of the field
FCUR TYPE C, length 01 currency flag
FADD TYPE C, length 01 flag for internal field
FDESC TYPE C, length 40 field description (long text)
FNAME TYPE C, length 30 field name (source field)

LID indicates which partial list of the query the described field belongs to. The same values as for the parameter LIST_ID are possible (see above).
FPOS describes the position of the field in the partial list indicated by LID. The positions are counted sequentially from 1 (01, 02, ...).
FCONT describes the number of the continuation line in which the field is output (0, 1, ...). This can only occur for basic lists which are broken due to a too low list width (LINE-SIZE). The numbering of the fields (according to FPOS) is not affected by it, that is, the numbering is carried out sequentially and regardless of the value of the field FCONT. This field is not normally needed for the private file.
FCURPOS describes the start position of the field in the list line if the field is a numeric field (FTYP = P, I, F). Otherwise, FCURPOS has the value 000. This field is not normally needed for the private file.
FGRAF has the value X if the value of the described non-numeric field is to be used as a help text for the graphic. This field is not normally needed for the private file.
FTYP describes the ABAP type of the field and can take the values C, D, F, I, N, P, T or X.
FLEN describes the length of the field in bytes.
FDEC describes the number of decimal places of the field. This specification is only of interest if FTYP has the value P. In all other cases, FDEC has value 00.
FOLEN describes the output length of the field in the partial list, how they were determined for the definition of the query.
FCUR marks a field as a currency amount field (F) or as a currency key or currency field (W). For all other fields FCUR has the value space.
FADD describes whether the field is an additional field, generated by the query itself. The following values are possible:
R - rank specification (only in rankings)
C - number of records read (only in statistics)
P - percentage rate (only in statistics)
M - average (only in statistics)
FDESC contains the field description, that is, the ID for the field, which is also available to the user on definition of the query.
FNAME contains the ABAP name of the field (source field) from which the value comes, which was output in the partial list and is contained in the data table. Thus the origin of data can be determined from this name. For statistics and rankings, please note that data is first gathered in an internal table. Nevertheless, the name of the field can also be determined here, from which the data for these internal tables was obtained. The example below illustrates this.

In the current example, the table LISTDESC would have the following structure (the values of the fields FDESC are listed below).

FDESC FNAME
G00|01|0|000|X|C|010|00|010| | | 1) |KNA1-KUNNR |
G00|02|0|000|X|C|035|00|035| | | 2) |KNA1-NAME1 |
G00|03|0|000|X|N|004|00|004| | | 3) |KNC1-GJAHR |
G00|04|0|053| |P|008|02|021|F| | 4) |KNC1-UM01U |
G00|05|0|000|X|C|005|00|005|W| | 5) |T001-WAERS |
T01|01|0|000|X|C|003|00|003| | | 6) |T01-KNA1-LAND1 |
T01|02|0|005| |P|016|02|021|F| | 7) |T01-KNC1-UM01U |
T01|03|0|027| |I|004|00|008| |C| 8) |T01-C$T-KNC1-UM01U |
T01|04|0|036| |P|004|03|009| |P| 9) |T01-P$R-KNC1-UM01U |
T01|05|0|047| |P|008|02|021|F|M| 10) |T01-A$G-KNC1-UM01U |
R01|01|0|000| |C|006|00|008| |R| 11) |V01-RANGCT |
R01|02|0|000|X|C|010|00|010| | | 12) |V01-KNA1-KUNNR |
R01|03|0|000|X|C|035|00|035| | | 13) |V01-KNA1-NAME1 |
R01|04|0|057| |P|016|02|021|F| | 14) |V01-KNC1-UM01U |

1) customer number
2) name
3) fiscal year
4) sales in posting period 1
5) currency key
6) country key
7) sales in posting period 1
8) total number
9) portion in %
10) average
11) rank
12) customer number
13) name
14) sales in posting period 1

When calling up the function module, all of the entries from the table LISTDESC are of importance, for which LISTDESC-LID = LIST_ID applies.

A simple example of an implementation of the function module EXIT_RSAQEXCE_001 should finally be given. The transferred tables LISTDESC and DATATAB are in this case simply output again as a list, where the output of the fields FCONT, FCURPOS and FGRAF are discarded in the case of the table LISTDESC. However, this simple example clearly shows how the individual parameters are to be interpreted and how the data table can be accessed.

***INCLUDE ZXQUEU01 .

FIELD-SYMBOLS .

NEW-PAGE LINE-SIZE 132.
WRITE: / 'Query', PROGRAM+6(2), 'of user group', PROGRAM+2(2).
ULINE. SKIP 1.
WRITE: / 'Fields of sublist', LIST_ID.
ULINE.
LOOP AT LISTDESC WHERE LID = LIST_ID.
WRITE: / LISTDESC-FDESC,
LISTDESC-FNAME,
LISTDESC-FPOS,
LISTDESC-FTYP,
LISTDESC-FLEN,
LISTDESC-FDEC,
LISTDESC-FOLEN,
LISTDESC-FCUR,
LISTDESC-FADD.
ENDLOOP.
SKIP 1.
WRITE: / 'Data table'.
ULINE.
LOOP AT DATATAB.
NEW-LINE.

Function/Program:

  • RSAQEXCE+DAT: Private file
  • EXIT_RSAQEXCE_001: SAP Query: Private data file

02-Oct-2005