Show TOC

Definition of Query Result FieldsLocate this document in the navigation structure

Use

During the definition of a new query (see Definition of Queries) you have to define query result fields. Query result fields define the structure and type of the data provided by the query after query processing.

Features

The definition of a query result field involves the following:

  • You have to select one of the query fields that you have previously defined as a result field with field type Output or Input/Output.

  • You can define the sequence number of the result field.

  • By selecting a value source, you can define which of the following methods the system uses to fill the result field during the query processing: search connector, aggregation, formula (see Definition of Query Formulas), or Business Add-In (BAdI). For result fields that use a formula or a BAdI, the system can use the values of all fields of the current result data record as well as the values of all query input fields as input. If you use a formula or a BAdI, you can define the following:

    • By selecting a fill time, you can define whether the system fills the result field before or after grouping.

    • By defining the fill sequence number, you can define in which order the system fills the result fields.

    Note

    To use a BAdI as a value source, you have to implement the Fill the value of a result field in a result record (FILL_RESULT_ATTR) method of the BAdI: Processing of Query Results (/BCV/QRM_QUERY_RESULT) Business Add-In of the Query Management and Processing (/BCV/QRM) enhancement spot.

    For more information, see Customizing under Start of the navigation path Cross Application Components Next navigation step Processes and Tools for Enterprise Applications Next navigation step Business Context Viewer Next navigation step Query Management Next navigation step Business Add-Ins (BAdIs) for Query Management Next navigation step BAdI: Processing of Query Results End of the navigation path.

  • You can use aggregation and grouping if you are interested in general information, while the available data provider provides information on a more detailed level.

    Example

    The data provider provides information about individual quality notifications, however, you are only interested in the total complaint quantities per material and month. You can define a grouping and aggregation procedure in the query definition.

    First, you mark the result fields by which the system groups the data. All result data records with the same values of these fields belong to the same group. You mark fields Material and Month. Then, you define how the system aggregates the other result fields within a group. You can choose among different aggregation functions as Sum of Values, Average of Values, or Minimum Value. You set the aggregation function Sum of Values for field Complaint Quantity.

    You can define aggregation functions only for numerical and period-based (for example, date, or week) result fields. For period-based result fields, you can only choose between aggregation functions Minimum Value and Maximum Value.

  • You can define the order and direction in which the system sorts result data. The system can sort result data retrieved from the search according to the values of certain fields. The system specifies the sort order by a sequence of fields and the information (per field) whether sorting should be done in ascending or descending order. For example, you can define that the system sorts sales orders first ascending by customer, and then descending by quantity. If you do not define the sort order, you cannot have any assumption about the sequence of the data records returned by query processing.

    Note

    You can also define the sort order in the query view. In this case, the system presents the result data according to the sort order of the query view, not the query. For more information, see Definition of Query Views.

  • You can define a row limit in the query header (see Definition of Query Headers) to specify how many result records the query returns at most. If you do not use result classes, the limit refers to the overall number of result records. Otherwise, it refers to the number of records per result class.

    A result class contains all records where certain result fields have the same values. The system divides the result records into classes regarding all result fields for which you defined a sort sequence number not higher than the sort sequence number for row limit.

    You can use row limit and result classes to realize top statistics, like the top three customers per year regarding sales volume. For such statistics, you have to define result classes regarding the result fields that describe the segments of the statistics (in the above example: year). Then, you have to define the rating of the result records by defining a sort sequence number and sort direction for an additional result field not part of the result class definition (in the above example: sales volume, sorted descending). Finally, you have to set the row limit to the number of highest-rated result records you want to obtain per segment of the statistics (in the above example: 3).

Recommendation

For more information about the setting of individual fields, see the field help and input help texts.