Thanks for sticking to this multi-part step-by-step guide.
Looking into this part (3) means that you have successfully completed the first part (1) and the second part (2) and you are now curious to see how our EPM OData Service will be extended with an Association and a Navigation Property. This will allow us to navigate from the Sales Order to the related Sales Order Line Items by using a link instead of manually putting a filter together. Furthermore this also allows us to use the $expand statement to fetch the Sales Order together with all Sales Order Line Items in one http call.
We are still in the Service Builder and enhancing our project that we created in part 1 and extended in part 2.
1. Double-click Associations:
2. Choose the Create pushbutton:
3. Enter the following values for the Association and choose Enter:
Name | SalesOrderSalesOrderItems |
Principal Entity* | SalesOrder |
Principal Entity Cardinality* | 1 |
Dependent Entity* | SalesOrderItem |
Dependent Entity Cardinality* | M |
*) This field has an input help
Now we will Create a referential constraint for the association
1. Expand the Associations node and the SalesOrderSalesOrderItems node and double-click Referential Constraints:
2. Choose the Create pushbutton:
3. Enter the following values and choose Enter:
Principal Key* | SoId |
Dependent Property* | SoId |
*) This field has an input help
Now we create an association set for the association
1. Double-click Association Sets:
2. Choose the Create pushbutton:
3. Enter the values and choose Enter:
Name | SalesOrderSalesOrderItems |
Association* | SalesOrderSalesOrderItems |
*) This field has an input help
And finally we create a navigation property based on the referential constraint
1. Expand Data Model -> Entity Types -> SalesOrder and double-click Navigation Properties:
2. Choose the Create pushbutton:
3. Enter the following values and choose Enter:
Name | SalesOrderItems |
Relationship Name* | SalesOrderSalesOrderItems |
*) This field has an input help
Now we need to re-generate the runtime objects and we’re then ready to test the service
1. Choose the Generate pushbutton:
2. Verify that the runtime objects have been generated successfully:
3. Start the Gateway Client (Transaction /IWFND/GW_CLIENT) in a separate window to run the service. Provide the following URI to get the metadata for the service:
/sap/opu/odata/sap/ZGW100_XX_SO_SRV/$metadata
The Sales Order collection now includes a navigation property.
4. When you now select a sales order entry using
/sap/opu/odata/sap/ZGW100_XX_SO_SRV/SalesOrderCollection('0500000001'), for example, you can simply add the navigation link /SalesOrderItems to navigate to the line items without having to set a filter yourself:
5. And finally you can use $expand to read all sales order items for a given sales order in a single http call.
Simply provide the following URI:
/sap/opu/odata/sap/ZGW100_XX_SO_SRV/SalesOrderCollection('0500000001')/?$expand=SalesOrderItems
The $expand statement is handled by the framework (no additional implementation is required). Since the framework does not know that both entities can be obtained using a single RFC call, it executes two calls to the underlying BAPI. This can be improved by manually implementing (re-defining) the GET_EXPANDED_ENTITY method.
So we are done. The Service is up and running.
I hope you enjoyed creating and consuming an OData Service that is based on RFC modules.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
10 | |
10 | |
10 | |
9 | |
8 | |
7 | |
6 | |
5 | |
5 | |
4 |