Enhancement SQUE0001: Private File 
SAP Query has several options which allow you to pass on data generated in queries to other software products for further processing. These options include:
In each case, the procedure is the same. The generated data is placed in an internal table (the data table), where the field sequence and type corresponds to that in the query list. Another internal table (the description table) contains a description of the individual fields in the data table. Apart from the type and position in the list, the table also contains information about the field names. Both these tables are passed to the above-mentioned software products for further processing.
Through enhancement SQUE0001, SAP Query also allows you to use the same interface to access other software products. SQUE0001 consists of the following components:

The Private file function has largely been made obsolete with the introduction of the Additional function pool (see
Be aware that additional function pool functions can only be processed online in the foreground and thus CANNOT be called during background processing. In contrast, contents of the private file CAN be called during background processing.
SQUE0001 consists of the following two components:
When you activate the enhancement in a project (using Transaction CMOD), an additional interactive function called Private file (function code: + DAT) is made
available in each report generated by the SAP query, which calls the aforementioned function module when activated. The tables mentioned above (data table and description table) are then passed to the function module. The selection screen thus contains an additional parameter which, like the other interactive functions (EXCEL, Graphics, EIS, Download to file and Save), allows the user to execute the query without displaying the list beforehand. Since the name of this parameter on the selection screen is Private file, you are recommended to give the menu enhancement the same name. This corresponds to the SAP standard.
When you have activated the enhancement, you should regenerate all queries, so that the additional parameter appears on the selection screen. You can achieve this best by going into the component Maintain InfoSets and selecting Goto
Function module EXIT_RSAQEXCE_001
This section describes which parameters are passed to the function module EXIT_RSAQEXCE_001 and how the values they contain are interpreted or processed. The following example demonstrates this process.
In client 03, a user in user group RX has created a query X1 which consists of a one-line basic list, a statistic and a ranked list. The basic list outputs the following fields in order:
KNA1-KUNNR |
Customer number |
KNA1-NAME1 |
Name |
KNC1-GJAHR |
Fiscal year |
KNC1-UM01U |
Sales in posting period 1 |
T001-WAERS |
Currency key |
. The statistic outputs the following fields in order:
KNA1-LAND1 |
Country key |
KNC1-UM01U |
Sales in posting period 1 |
For the field KNC1-UM01U, details are also required about the number of records read, the percentage value and the average value. The ranked list outputs the following fields in order:
KNA1-KUNNR |
Customer number |
KNA1-NAME1 |
Name |
KNC1-UM01U |
Sales in posting period 1 |
.
Parameters of function module EXIT_RSAQEXCE_001
The function module EXIT_RSAQEXCE_001 has the following parameters:
PROGRAM |
The program which passes the parameters |
LIST_ID |
The ID of the passed sub-list |
LISTTEXT |
The title of the passed sub-list |
DATATAB |
The data table |
LISTDESC |
The description table for the fields of the data table |
PROGRAM parameter
The PROGRAM parameter contains the name of the query report which called the function module. From this name, you can determine which query has been processed, since the structure of the name is always as follows:
Aqmmb...bq...q
cc |
= client or ZZ in the global area |
b…b |
= user group name |
q…q |
= query name |
In terms of our example, the name of the report is therefore
AQRX==========X1============ .LIST_ID parameter
The LIST_ID parameter contains a three-character ID which specifies the data table passed. Each list generated by a query can comprise several sub-lists (a basic list, several statistics and several ranked lists). The data table (DATATAB) transferred to the function module contains only the data for one sub-list respectively. The description table (LISTDESC), however, always contains the description for the fields of all sublists.
The possible parameter values are
G00 |
if DATATAB contains the data of the basic list |
Txx |
if DATATAB contains the data of the statistic xx (01,02,...) |
Rxx |
if DATATAB contains the data of the ranked list xx (01,02,...) |
The
LIST_ID parameter thus has two functions. Firstly, it allows you to determine the sub-list type involved. Secondly, you can define the relevant entries in the description table.In the current example, if the data of the basic list is transferred, the parameter
LIST_ID contains the value G00 . If the statistics data is transferred then the value is T01 . If the ranked list data is transferred then the parameter contains the value R01 .LISTTEXT parameter
The LISTTEXT parameter contains a text which is assigned to the relevant list when you define the query.
DATATAB parameter
The DATATAB table contains the data of the sub-list passed. The sequence and type of the fields correspond to the sequence of the fields output in the sub-list. One table line corresponds to one list line respectively. Any existing line breaks in basic lists are ignored here (that is they always form one table line).
Since the structure of the data table depends on how you define the sub-list to be passed, you have to define this structure beforehand in the function module. For this purpose, you can use the description table LISTDESC. To access individual fields in the data table, you use field symbols and the ASSIGN COMPONENT statement.
If you pass the basic list in our example, one line of the data table consists of 5 fields with the following types, lengths and number of decimal places:
1. Field: Type C, Length 10 |
(KNA1-KUNNR) |
2. Field : Type C, Length 35 |
( KNA1 - NAME1 ) |
3. Field: Type N, Length 04 |
( KNC1 - GJAHR ) |
4. Field: Type P, Length 08, Dec. 02 |
( KNC1 - UM01U ) |
5. Field : Type C, Length 05 |
( T001 - WAERS ) |
If you pass the statistic, one line of the data table consists of 5 fields with the following types, length and decimal places:
1. Field: Type C, Length 03 |
(KNA1 - LAND1) |
2. Field: Type P, Length 16, Dec . 02 |
(total of KNC1-UM01U) |
3. Field: Type I, Length 04 |
(number of records read) |
4. Field: Type P, Length 04 , Dec . 03 |
(percentage value) |
5. Field: Type P, Length 16, Dec . 02 |
(average value of KNC1-UM01U) |
If you pass the ranked list, one line of the data table consists of 4 fields with the following types, lengths and decimal places:
1. Field: Type C, Length 06 |
(rank in the ranked list) |
2. Field: Type C, Length 10 |
(KNA1-KUNNR) |
3. Field: Type C, Length 35 |
(KNA1-NAME1) |
4. Field: Type P, Length 16, Dec. 2 |
(total of KNC1-UM01U) |
To define the type, length and number of decimal places, you use either the ABAP statement DESCRIBE FIELD or the description table LISTDESC (see below).
LISTDESC parameter
The LISTDESC description table contains a description of the fields in the data table DATATAB. This includes not only the type, length and number of decimal places, but also any information you cannot define with the DESCRIBE FIELD statement. If a query comprises several sub-lists (as in our example), the description table always contains a description of the fields in all data tables (that is all sub-lists) which can be passed by this query. You can use the LIST_ID parameter to retrieve the appropriate entries from the description table.
In our example then, the description table always contains the descriptions of fields of the data tables for the basic list, the statistics and the ranked list.
The description table has the structure RSAQLDESC. This structure is made up of the following fields:
FNAMENEW |
type C, length 70 |
field name (source field) (Rel.4.0) |
FNAMEINT |
type C, length 30 |
field name (data table) |
FKEY |
type C, length 1 |
flag for lead column |
FGTYPE |
type C, length 1 |
flag for graphic type |
FNZERO |
type C, length 1 |
flag for zero display |
FSUM |
type C, length 1 |
summation flag |
FSONLY |
type C, length 1 |
sorting flag |
FSORT |
type N, length § |
sorting level |
FSODS |
type C, length 1 |
sorting direction |
FSUBT |
type C, length 1 |
subtotal flag |
FLPOS |
type N, length 4 |
position of field (like FPOS) |
FNUMB |
type C, length 2 |
Field group ID |
FNUMBT |
type C, length 24 |
Field group text |
LID |
type C, length 03 |
ID of the sub-list |
FPOS |
type N, length 02 |
position of field |
FCONT |
type N, length 01 |
number of continuation line |
FCURPOS |
type N, length 03 |
list position of field |
FGRAF |
type C, length 01 |
text flag for graphic |
FTYP |
type C, length 01 |
ABAP type of field |
FLEN |
type N, length 03 |
length of field |
FDEC |
type N, length 02 |
number of decimal places for field |
FOLEN |
type N, length 03 |
output length of 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) |
FCOL |
type C, length 30 |
column header for field |
LID |
indicates to which query sub-list the field belongs. The parameter values can be the same as for the LIST_ID parameter (see above) | |
FPOS |
describes the position of the field in the sub-list specified by the LID parameter. The positions are counted consecutively from 1 (for example 01, 02,...). | |
FCONT |
describes the number of the continuation line in which the field is output (0,1...). This can occur with basic lists that collapse due to a too small list width (LINE SIZE). Field numbering (as in FPOS) is not affected, since it is independent of the FCONT value. Normally, this field is not required for the Private file function. | |
FCURPOS |
describes the start position of the field in the list line, if the field is numeric (FTYP = P, I, F). Otherwise, FCURPOS contains the value 000. Normally, this field is not required for the Private file function. | |
FGRAF |
contains the value X, if you use the value of the non-numeric field as a help text for the graphic. Normally, this field is not required for the Private file function. | |
FTYP |
describes the ABAP type of the field and can accept 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 for the field. This specification is only significant if FTYP contains the value P. In all other cases, FDEC contains the value 00. | |
FOLEN |
describes the output length of the field in the sub-list, as specified when defining the query. | |
FCUR |
identifies the field as F currency amount field W currency key or currency field M quantity field E unit field | |
FADD |
indicates whether the field is an additional field generated by the query itself. The following values are allowed: R rank specification (only in ranked lists) C number of records read (only in statistics) P percentage specification (only in statistics) M average value (only in statistics) | |
FDESC |
contains the field description which the user sees when defining the query. | |
FNAME |
contains the field name from the query report from which the information for the data table is derived (up to Release 4.0) | |
FCOL |
contains the one line column header for the data table field described by an entry in the LISTDESC table. | |
FNAMENEW |
like FNAME (from Release 4.0) | |
FNAMEINT |
contains the field name from the data table. Use this name together with the statement ASSIGN COMPONENT to dynamically access the field in the data table. | |
FKEY |
contains the value X if the field has been output as a key field (lead column) in the list. | |
FGTYPE |
identifies the field’s contents as | |
FNZERO |
contains the value X if the field has been output with the option NO-ZERO in the list. | |
FSUM |
contains the value X if the field has been totaled in the list. | |
FSONLY |
contains the value X if the list has been sorted according to this field, but the field itself was not output. | |
FSORT |
contains the sorting number if the list has been sorted according to the field. | |
FSODS |
contains the value X if the list has been sorted in descending order according to the field. | |
FSUBT |
contains the value X if the list has been sorted according to the field and sub-totals were generated during sorting. | |
FLPOS |
like FPOS | |
FNUMB |
field group of the field whose name is stored in FNAMENEW. | |
FNUMBT |
Long text of the field group | |