Business Example
- Template:
- GW100_S_CUD (SAP Gateway Project)
- Solution:
- GW100_S_BORRFC (SAP Gateway Project)
Note
This exercise requires an SAP Learning system. Login information are provided by your system setup guide.Note
You may continue with your solution of the previous exercise or copy the template to ZGW100_##_BORRFC. Whenever the values or object names in this exercise include ##, replace ## with the number of your user.Prerequisites
The data model for business partner was defined in exercise Add an Additional Entity to a Data Model.
Task 1: Define the Entity SalesOrder based on a Function Module
Steps
In the SAP Gateway Service Builder of your SAP S/4HANA (S4H) system, import the parameter HEADERDATA of the RFC/BOR interface BAPI_EPM_SO_GET_DETAIL as entity SalesOrder. Select the following fields and define SO_ID as key:
Structure | Component |
---|
HEADERDATA | SO_ID |
HEADERDATA | NOTE |
HEADERDATA | BUYER_ID |
HEADERDATA | BUYER_NAME |
HEADERDATA | CURRENCY_CODE |
HEADERDATA | GROSS_AMOUNT |
HEADERDATA | NET_AMOUNT |
HEADERDATA | TAX_AMOUNT |
HEADERDATA | LIFECYCLE_STATUS |
HEADERDATA | BILLING_STATUS |
HEADERDATA | DELIVERY_STATUS |
In the SAP Easy Access of your S4H, search for SAP Gateway Service Builder or start transaction SEGW.
In the SAP Gateway Service Builder, in the context menu of Data Model, choose Import → RFC/BOR Interface.
In the Create Entity Type from Data Source popup, enter the following values:
Field | Value |
---|
Entity Type Name | SalesOrder |
Type (Data Source Attributes) | Remote Function Call |
Name (Data Source Attributes) | BAPI_EPM_SO_GET_DETAIL |
Choose Next.
Expand the tree node HEADERDATA.
Select the checkbox for the following components:
Structure | Component |
---|
HEADERDATA | SO_ID |
HEADERDATA | NOTE |
HEADERDATA | BUYER_ID |
HEADERDATA | BUYER_NAME |
HEADERDATA | CURRENCY_CODE |
HEADERDATA | GROSS_AMOUNT |
HEADERDATA | NET_AMOUNT |
HEADERDATA | TAX_AMOUNT |
HEADERDATA | LIFECYCLE_STATUS |
HEADERDATA | BILLING_STATUS |
HEADERDATA | DELIVERY_STATUS |
Choose Next.
Select the Is Key checkbox for the field SO_ID.
Choose Finish.
Note
Don't worry about the Potential loss of data; ABAP type is more restrictive warnings . This should just remind you to check the system customizing for amount fields. There is no such customizing active in the learning system.Choose Save.
Task 2: Model a Navigation between BusinessPartner and SalesOrder
Steps
Model navigation BusinessPartner_SalesOrders between the entities BusinessPartner and SalesOrder connecting one BusinessPartnerID to many BuyerId. Create the navigation properties SalesOrders and Buyer in the according entity types.
In the SAP Gateway Service Builder of your S4H, expand the node Data Model → Entity Types.
In the context menu of Associations, choose Create.
In the Create Association popup, in the Association Name field, enter BusinessPartner_SalesOrders.
For the Principal Entity, enter the following values:
Field | Value |
---|
Entity type name | BusinessPartner |
Cardinality | 1 |
Navigation Property | SalesOrders |
Select the Create related Navigation Property checkbox for the Dependent Entity.
For the Dependent Entity, enter the following values:
Field | Value |
---|
Entity type name | SalesOrder |
Cardinality | 1..n |
Navigation Property | Buyer |
Click Next.
In the Dependent Property field, enter BuyerId by using the value help.
Click Next.
Click Finish.
Choose Save.
Task 3: Map the Query and Read Operations of SalesOrder to a Function Module
Steps
In the SAP Gateway Service Builder of your S4H, map the read operation of entity set SalesOrderSet to the function module BAPI_EPM_SO_GET_DETAIL.
In the SAP Gateway Service Builder of your S4H, expand the node Service Implementation → SalesOrderSet.
In the context menu of GetEntity (Read), choose Map to Data Source.
In the Map to Data Source popup, enter the following values:
Field | Value |
---|
Type | Remote Function Call |
Name | BAPI_EPM_SO_GET_DETAIL |
Choose Continue.
Choose Propose Mapping.
Choose Append Row.
In the Entity Set property field, enter SoId by using the value help.
In the Data Source Parameter view on the right, expand the node SO_ID.
Drag and drop the Data Source ParameterSO_ID from the right to the Data Source Parameter field of the new table entry to the left.
Choose Check Project Consistency.
Choose Save.
Map the query operation of entity set SalesOrderSet to the function module BAPI_EPM_SO_GET_LIST. Set the maximum hits and map filters for SoId and BuyerName.
Expand the node Service Implementation → SalesOrderSet.
In the context menu of GetEntitySet (Query), choose Map to Data Source.
In the Map to Data Source popup, enter the following values:
Field | Value |
---|
Type | Remote Function Call |
Name | BAPI_EPM_SO_GET_LIST |
Choose Continue.
Choose Propose Mapping.
In the Data Source Parameter view on the right, expand the node MAX_ROWS.
Select BAPIMAXROW and choose Set/Unset Max Hits.
Choose Append Row.
In the field Entity Set property, enter SoId by using the value help.
Drag and drop the Data Source ParameterSELPARAMSOID from the right to the Data Source Parameter field of the new table entry to the left.
In the Map Range popup, choose Continue.
Choose Append Row.
In the field Entity Set property, enter BuyerName by using the value help.
Drag and drop the Data Source ParameterSELPARAMBUYERNAME from the right to the Data Source Parameter field of the new table entry to the left.
In the Map Range popup, choose Continue.
Choose Generate Runtime Objects.
For every popup, choose the transport request provided to you.
Task 4: Test the Query and Read Operations of SalesOrder
Steps
In the SAP Gateway Client of your S4H, test the paging operation for sales orders in your service. Query the first two sales orders.
In the SAP Gateway Service Builder of your S4H, double-click Service Maintenance.
Choose SAP Gateway Client.
In the SAP Gateway Client, select HTTPS as Protocol.
Choose Entity Set.
In the Entity Sets popup, double-click SalesOrderSet.
Choose Add URI Option.
In the Add URI Option popup, double-click $top=2.
Example
/sap/opu/odata/SAP/ZGW100_##_STUDENT_SRV/SalesOrderSet?$top=2
Choose Execute.
Result
The HTTP Response displays the first two sales orders.
Test the filter operation for sales orders in your service. Filter the sales orders with the buyer name "SAP".
In the Request URI field, add &$filter=BuyerName eq 'SAP' to the URI.
Example
/sap/opu/odata/SAP/ZGW100_##_STUDENT_SRV/SalesOrderSet?$top=2&$filter=BuyerName eq 'SAP'
Choose Execute.
Result
The HTTP Response displays the first two sales orders of the buyer "SAP".
Test the read operation for sales orders in your service. Read a single sales order.
In the Request URI field, replace ?$top=3&$filter=BuyerName eq 'SAP' with the key of a sales order.
Example
/sap/opu/odata/SAP/ZGW100_##_STUDENT_SRV/SalesOrderSet('500000000')
Choose Execute.
Result
The HTTP Response displays the sales order.
Memorize the sales order ID.
Task 5: Define the Entity SalesOrderItem based on a Function Module
Steps
In the SAP Gateway Service Builder of your S4H, import the parameter ITEMDATA[] of the RFC/BOR interface BAPI_EPM_SO_GET_DETAIL as entity SalesOrderItem. Select the following fields and define SO_ID and SO_ITEM_POS as key:
Structure | Component |
---|
ITEMDATA[] | SO_ID |
ITEMDATA[] | SO_ITEM_POS |
ITEMDATA[] | PRODUCT_ID |
ITEMDATA[] | NOTE |
ITEMDATA[] | CURRENCY_CODE |
ITEMDATA[] | GROSS_AMOUNT |
ITEMDATA[] | NET_AMOUNT |
ITEMDATA[] | TAX_AMOUNT |
ITEMDATA[] | DELIVERY_DATE |
ITEMDATA[] | QUANTITY |
ITEMDATA[] | QUANTITY_UNIT |
In the SAP Gateway Service Builder of your S4H, in the context menu of Data Model, choose Import → RFC/BOR Interface.
In the Create Entity Type from Data Source popup, enter the following values:
Field | Value |
---|
Entity Type Name | SalesOrderItem |
Type (Data Source Attributes) | Remote Function Call |
Name (Data Source Attributes) | BAPI_EPM_SO_GET_DETAIL |
Choose Next.
Expand the tree node ITEMDATA[].
Select the checkbox for the following components:
Structure | Component |
---|
ITEMDATA[] | SO_ID |
ITEMDATA[] | SO_ITEM_POS |
ITEMDATA[] | PRODUCT_ID |
ITEMDATA[] | NOTE |
ITEMDATA[] | CURRENCY_CODE |
ITEMDATA[] | GROSS_AMOUNT |
ITEMDATA[] | NET_AMOUNT |
ITEMDATA[] | TAX_AMOUNT |
ITEMDATA[] | DELIVERY_DATE |
ITEMDATA[] | QUANTITY |
ITEMDATA[] | QUANTITY_UNIT |
Choose Next.
Select the Is Key checkbox for the fields SO_ID and SO_ITEM_POS.
Choose Finish.
Note
Don't worry about the Potential loss of data; ABAP type is more restrictive warnings . This should just remind you to check the system customizing for amount fields. There is no such customizing active in the learning system.Choose Save.
Task 6: Model a Navigation between SalesOrder and SalesOrderItem
Steps
Model navigation SalesOrder_SalesOrderItems between the entities SalesOrder and SalesOrderItem connecting one SoId of sales order to many SoId of sales order items. Create the navigation properties Items and SalesOrder in the according entity types.
In the SAP Gateway Service Builder of your S4H, expand the node Data Model → Entity Types.
In the context menu of Associations, choose Create.
In the Create Association popup, in the field Association Name, enter SalesOrder_SalesOrderItems.
For the Principal Entity, enter the following values:
Field | Value |
---|
Entity Type Name | SalesOrder |
Cardinality | 1 |
Navigation Property | Items |
Select the Create related Navigation Property checkbox for the Dependent Entity.
For the Dependent Entity, enter the following values:
Field | Value |
---|
Entity Type Name | SalesOrderItem |
Cardinality | 1..n |
Navigation Property | SalesOrder |
Choose Next.
In the Dependent Property field, enter SoId by using the value help.
Choose Next.
Choose Finish.
Choose Save.
Task 7: Map the Query Operation of SalesOrderItem to a Function Module
Steps
In the SAP Gateway Service Builder of your S4H, map the query operation of entity set SalesOrderItemSet to the function module BAPI_EPM_SO_GET_DETAIL including the filter for SoId
In the SAP Gateway Service Builder of your S4H, expand the node Service Implementation → SalesOrderItemSet.
In the context menu of GetEntitySet (Query), choose Map to Data Source.
In the Map to Data Source popup, enter the following values:
Field | Value |
---|
Type | Remote Function Call |
Name | BAPI_EPM_SO_GET_DETAIL |
Choose Continue.
Choose Propose Mapping.
Choose Append Row.
In the Entity Set property field, enter SoId by using the value help.
In the Data Source Parameter view on the right, expand the node SO_ID.
Drag and drop the Data Source ParameterSO_ID from the right to the Data Source Parameter field of the new table entry to the left.
Choose Generate Runtime Objects.
Task 8: Test the Query and Operation of SalesOrderItem
Steps
In the SAP Gateway Client of your S4H, test the navigation between sales order and sales order items in your service. Query the items of the sales order you read before.
In the SAP Gateway Service Builder of your S4H, double-click Service Maintenance.
Choose SAP Gateway Client.
In the SAP Gateway Client, select HTTPS as Protocol.
Choose Entity Set.
In the Entity Sets popup, double-click SalesOrderSet.
In the Request URI field, add the memorized key of the sales order you read before to the URI.
In the Request URI field, add /Items to the URI.
Example
/sap/opu/odata/SAP/ZGW100_##_STUDENT_SRV/SalesOrderSet('500000000')/Items
Choose Execute.
Result
The HTTP Response displays the items of the sales order.
Test the expand operation for sales order and sales order items in your service. Read the sales order you read before including its items.
In the Request URI field, replace the / in front of Items with ?$expand=.
Example
/sap/opu/odata/SAP/ZGW100_##_STUDENT_SRV/SalesOrderSet('500000000')?$expand=Items
Choose Execute.
Result
The HTTP Response displays the sales order and its items.
Task 9: Document the Query Options Generated via BOR/RFC Generator in the Metadata
Steps
In the SAP Gateway Service Builder of your S4H, set the entity set SalesOrderSet to be Pageable and set the entity set SalesOrderItemSet to be Pageable and RequiresFilter.
In the SAP Gateway Service Builder of your S4H, expand Data Model.
Double-click Entity Sets.
For of the SalesOrderSet, set the Pageable checkbox.
For of the SalesOrderItemSet, set the Pageable and RequiresFilter checkbox.
Set the properties SoId and BuyerName of the entity type SalesOrder to be Filterable. Set the property SoId of the entity type SalesOrderItem to be Filterable.
Expand Data Model → Entity Types → SalesOrder.
Double-click Properties.
For the properties SoId and BuyerName, set the Filterable checkbox.
Expand SalesOrderItem.
Double-click Properties.
For the property SoId, set the Filterable checkbox.
Choose Generate Runtime Objects.