Show TOC

Mapping the Query OperationLocate this document in the navigation structure

Procedure

When mapping the Query operation of an entity set to a data source, you can map the standard input parameters or range parameters, and filter the output, for example, to enable searching for flights between certain date ranges.

You can use the Propose Mapping button to automatically generate and display the available mapping relations between the properties of the entity set and the parameters of the data source.

If there is no information about the mapping, no mapping is proposed.

To map the Query operation and set ranges tables (the range can be a table or a simple structure), proceed as follows:

  1. Map the operation, GetEntitySet (Query), to your data source in the Map to Data Source dialog.

    For more information, see Creating the Mapping.

  2. In the Mapping table, click the cell under the heading, Data Source Parameter, in the same row as the property you want to map.

  3. From the Data Source view, drag and drop the data source parameter you want to map into the selected cell in the same row as the property you want to map.

    Alternatively, press F4 in the cell under , Data Source Parameter, in the same row as the property you want to map.

  4. Specify the mapping direction; the icon for the specified mapping direction displays.

    For well defined data source parameters of type input, or output, Service Builder automatically sets the mapping direction.

  5. Save the project to continue editing the mapping, or generate the project.

    For more information, see Generating the Service.

Max Hits: Limiting the Number of Items Returned in a Query

You can limit the number of items returned in a Query, at runtime.

Some query BAPIs and RFC function modules allow you to restrict the number of returned items by means of a Max Hits importing parameter.

You can set a parameter as Max Hits in data source view.

The Service Builder automatically defines input fields from the data source as Max Hits if the field name has one of the following options:

  • MAXROWS

  • MAX_ROWS

  • MAX_HITS

  • MAX_LINES

  • MAX_CNT

You can set a data source parameter as Max Hit in the Data source view, by selecting the Set/Unset Max Hits, if it has not been set automatically.

You can either set a constant value to Max Hits and by default limit the returned items, or you can rely on the runtime handling of Max Hits.

Also, you can specify Max Hits even if the remote function module does not have explicit Max Hits parameter. You do so to enable paging at runtime.

In this case, the paging is done after getting the RFC results. The RFC returns all the results from the application, and the Service Builder deletes all the unnecessary results.

To map a Max Hits to a constant value, proceed as follows:

  1. Add a row to the Entity Set column of the Mapping table. And enter a constant value, for example, '10'.

  2. Select the max_row parameter in the Data source view, and then click Set/Unset Max Hits.

  3. Drag and drop the selected Max Hits parameter into the same row as the specified constant value in the Mapping table.

In both cases, if the returned items are controlled from the client environment (with the $top option in OData), the runtime component tries to pass the value to the BAPI or RFC only if there is an importing parameter.

You can use $top and $skip options to page through table results, at runtime.

$top and $skip can be facilitated by mapping against MAXROWS or similar parameters as listed above.

If you set a constant value and the $top option is also defined, the number in the $top option takes precedence. There is no default value.

Mapping Rules for a Query

The following are some of the mapping rules for the query operation:

  • If the data source parameter you are mapping is a table, or structure, the mapping attribute is automatically defined according to the data source parameter type.

    In case, the data source parameter is of type, changing, Service Builder does not automatically set the direction; you must manually set the mapping direction.

  • If the data source attribute you are mapping is a table, the mapping attribute is changed to the type, output.

  • If the data source attribute you are mapping is a range table, the mapping attribute is changed to the type, input.

  • You can map only one table of type, output.

  • When mapping a property that is set as key, it must be of type, output.

    Key property must be mapped to one of the attributes in a table parameter in the remote function module or data source.

    Also, it can be mapped to the input parameter of a remote function module.

    In this case, it allows you to filter the results by the key property as well.

    Example

    A remote function module returns sales order numbers but you can filter the result by sales order number in range of 1,000-2,000.