In this step, you will map the QUERY operation based on the GetList BOR method.
Use the QUERY operation to get a list of the business objects to map to your SAP Gateway Service.
You can map specific fields from the selected BAPI to the Query operation. First, set a constant value for the Property, MaxRows.
Setting Constant Values
Select the GETLIST method under the USER object in the data source screen and perform the mapping. See Mapping the Operations.
Right-click MaxRows (left-clicking will remove the selection for the attribute), and then choose Set Constant Value.
Note that BAPIs and RFCs (which are the basis for these BOR methods) that supply a MaxRows or similar import parameter also allow for an option to limit the number of items returned from the client or consumer at runtime.
To limit the number of items returned, the runtime consumer or client can include the $top query string parameter according to OData specifications, for example, $top=5.
If a constant is set for MaxRows and the $top parameter is also provided, the value for the $top parameter will take precedence.
For example, in order to prevent a large query results, a constant value can be set for MaxRows, for example, set to 100. If a larger result set is required, the $top parameter can be specified in the request.
In Constant Value, enter the value ‘100’ (include the single quotes) and click the check mark to continue.
Setting the MaxRows attribute with the constant gives the maximum number of items to retrieve in the query results.
Set another constant using the character ‘X’ for the attribute, WithUsername.
Setting this attribute with the constant, results in the inclusion of the name field values, such as, FIRSTNAME,LASTNAME,FULLNAME in the query results.
Remove the selection for the nodes, RETURN and SELECTION_EXP.
The return structure is automatically handled by the generator tool.
Click the check mark to close the Map Operation screen.
Assigning Keys to Operations
The attribute in the data source that has been defined as key must be the Property that you assign as key in the Data Model for the operation.
For BOR and Screen Scraping data sources (unlike RFC data sources), the Data Model automatically assigns a Property of the Query operation as the key.
Using Change Mapping Route in the Map Operation dialog, you can see that the attribute, USERNAME, under the UserList node has been automatically assigned as a key.
Map each operation to the same key.
Mapping Additional Properties to the Query Operation
You can map additional Properties to the Query operation, such as, the SAP ranges tables. This provides additional filtering capabilities or selection criteria when searching for particular users in the system, at runtime.
In the Structure view, right-click the root node and select Add Property.
Create the new property called USERID of type Edm.string with an appropriate label as shown in below:
Add another property called ISLOCKED of type Edm.string with an appropriate label as shown in the image below:
You should see both Properties in the Structure view of the Data Model.
Now we want to modify the mapping to take advantage of the supplied range table in the BAPI.
From the right hand side of the screen, select the QUERY operation and click the Change Mapping button.
Select the node, SelectionRange, and click Set Range Table.
In the Map Range Table window, click Add.
Select USERID and click the checkmark to continue.
In the Map Range Table window, delete the value, P, from the Semantic column for PARAMETER.
In Constant Value, enter ‘USERNAME' (include the single quotes).
Add the following range table parameters:
ISLOCKED: For ISLOCKED, set the range table attributes as shown in the image below:
LASTNAME: For LASTNAME, set the range table attributes as shown in the image below:
Double-click each mapping route parameter to set the respective ranges table attribute.
Click the check mark icon to close the Map Range Table window and click the check mark again to close the Map Operation screen.
The Create Data Model main screen displays.
Click Generate at the top left corner.
The generated status displays the results of the generated models.
To save your work, you must generate it.
You have successfully mapped attributes for the Query operation from your data source to Properties in the Data Model.
Continue with Add the Data Model to a Consumption Model.