Prerequisites
The packages were created in exercise Define a Data Model Based on a Data Dictionary Structure .
Task 1: Create an SAP Gateway Project for Referencing a Data Source
Steps
In the SAP Gateway Service Builder of your SAP S/4HANA (S4H) system, create a new project named ZGW100_##_REFERENCE in your ZGW100_##_BES package.
In the SAP Easy Access of your S4H, search for SAP Gateway Service Builder or start transaction SEGW.
In the SAP Gateway Service Builder, choose Create Project.
In the Create Project popup, enter the following values:
Field | Value |
---|
Project | ZGW100_##_REFERENCE |
Description | your choice |
Package | ZGW100_##_BES |
Choose Continue.
Choose Save.
In the Prompt for transportable workbench request popup, in the Request field, select the transport request provided to you.
Choose Continue.
Task 2: Reference a CDS View as Data Source
Steps
Create a referenced data source for the CDS view GW100_C_Supplier, including a navigation to articles.
Right-click the Data Model node and choose Reference → Data Source.
In the Reference Data Source Wizard popup, in the CDS-Entity field, enter GW100_C_Supplier.
Choose Next.
Choose _ARTICLE as selected.
Choose Finish.
Choose Save.
Generate the runtime objects and add them to your package ZGW100_##_BES.
Choose Generate Runtime Objects.
In the Model and Service Definition popup, to accept the proposed names, choose Continue.
In the Package field, enter ZGW100_##_BES.
Choose Save.
For every popup, choose the transport request provided to you.
Task 3: Register the SAP Gateway Service and Test the Query and Read Operations
Steps
In the SAP Gateway Service Builder of your S4H, register and activate the service in your S4H using your ZGW100_##_FES package.
Double-click the Service Maintenance node.
Right-click the LOCAL_GW system.
Select Register.
ChooseYes that you will be redirected to the service maintenance.
In the Select System Alias (Hub to Backend) popup, in the System Alias field, enter LOCAL.
Choose Continue.
In the Add Service popup, in the Package Assignment field, enter ZGW100_##_FES.
Choose Continue.
For every popup, choose the transport request provided to you.
In the SAP Gateway Client of your S4H, test the paging operation for suppliers in your service. Query the first two suppliers.
Choose SAP Gateway Client.
In the SAP Gateway Client, select HTTPS as Protocol.
Choose Entity Set.
In the Entity Sets popup, double-click Supplier.
Choose Add URI Option.
In the Add URI Option popup, double-click $top=2.
Example
/sap/opu/odata/SAP/ZGW100_##_REFERENCE_SRV/Supplier?$top=2
Choose Execute.
Result
The HTTP Response displays the first two suppliers.
Test the sorting operation for suppliers in your service. Query suppliers sorted by their company name ascending.
In the Request URI field, add &$orderby=CompanyName asc to the URI.
Example
/sap/opu/odata/SAP/ZGW100_##_REFERENCE_SRV/Supplier?$top=2&$orderby=CompanyName asc
Choose Execute.
Result
The HTTP Response displays the first two suppliers ordered by company name ascending.
Test the filter operation for suppliers in your service. Query the suppliers whose e-mail address starts with "supplier".
In the Request URI field, add $filter=startswith(EmailAddress, 'supplier') to the URI.
Example
/sap/opu/odata/SAP/ZGW100_##_REFERENCE_SRV/Supplier?$top=2&$orderby=CompanyName asc&$filter=startswith(EmailAddress, 'supplier')
Choose Execute.
Result
The HTTP Response displays the first two suppliers ordered by company name ascending whose e-mail address starts with "supplier".
Test the read operation for suppliers in your service. Read a single supplier.
In the Request URI field, replace all query options by the key of a supplier with guid in front.
Example
/sap/opu/odata/SAP/ZGW100_##_REFERENCE_SRV/Supplier(guid'00505604-4e85-1edd-b9b4-a81d353342c0')Hint
Copy the self link of a supplier from the HTTP Response. Choose Execute.
Result
The HTTP Response displays the selected supplier.
Test the navigation between suppliers and articles in your service. Query the articles of a supplier.
Hint
If no articles are found for a supplier, make sure to select a supplier with an e-mail address starting with "supplier".In the Request URI field, add /to_Article to the URI.
Example
/sap/opu/odata/SAP/ZGW100_##_REFERENCE_SRV/Supplier(guid'00505604-4e85-1edd-b9b4-a81d353342c0')/to_Article
Choose Execute.
Result
The HTTP Response displays the articles of the supplier.
Test the expand operation for suppliers and articles in your service. Read a supplier including its articles.
In the Request URI field, replace the / in front of to_Article with ?$expand=
Example
/sap/opu/odata/SAP/ZGW100_##_REFERENCE_SRV/Supplier(guid'00505604-4e85-1edd-b9b4-a81d353342c0')?$expand=to_Article
Choose Execute.
Result
The HTTP Response displays the supplier including its articles.