RFCまたはBAPIを使用してODataサービスを作成する方法

时间:2019-06-17
本文章向大家介绍RFCまたはBAPIを使用してODataサービスを作成する方法,主要包括RFCまたはBAPIを使用してODataサービスを作成する方法使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

1. Go to Service Gateway builder and the transaction to it is SEGW.

2. In the create project window, enter the Project name and Description. In the Attributes section leave with defaults and provide then choose the package name. Hit OK button to proceed further.

3. After entering the OK button, you can see the project got created in Gateway service builder. All the nodes in the project are empty. Our next step will be creating the Entity Types and Entity Sets required for the OData service.

4. We are using BAPI “BAPI_EPM_PRODUCT_GET_LIST” to get the list of products, so here we need the Entity Type structure which is similar to the structure BAPI_EPM_PRODUCT_HEADER in the BAPI. To create Entity Type :   right click on Data Model → Import → RFC/BOR Interface.

5. In the Create Entity Type window, enter the Entity Type Name.

  • Under Data Source Attributes section choose Type as : Remote Function Call and Name as the BAPI name – BAPI_EPM_PRODUCT_GET_LIST.
  • Under Target System section – ♦ choose “Local” if your deployment is Embedded ♦ choose “Remote” if your deployment is Hub.
  • Select the check box Create Default Entity Set, if you want the Entity Set to be create automatically.

6. Click on Next to proceed to step 2 of Entity Creation wizard. In this step choose the fields you want to be displayed in the service. Here we have selected PRODUCT_ID, CATEGORY, NAME, DESCRIPTION, SUPPLIER_NAME, PRICE and CURRENCY_CODE fields from the structure HEADERDATA[].

7. Hit Next button to navigate the step-3. In this step we need to choose the Key Field in the Entity Type which is mandatory. Choose ProductId is the key field by selecting the check box in the column “Is Key”. Hit Finish button to complete the Entity Type creation process.

8. Now we have created Entity Type – ProductList and Entity Type sets – ProductListSet.

9. Save and generate the service to create run-time artifacts.

10. By now we have modeled the service, out next step is to map the service to the BAPI to get the data. To do so go to and expand “Service Implementation” node. Expand the ProductListSet entity set , choose GetEntitySet(Query) and right click on it and then go to “Map to Data Source”.

11. In the Map to Data Source window, choose Local as Target System if your deployment is Embedded (or) Remote if your deployment is Hub.

12. In the next step, you need map the BAPI fields to the service entity type fields. Hit Propose Mapping button to automatically the map the fields or you can manually drag drop the fields from the right to the column “Data Source Parameter“.

13. Save and regenerate the service, by hitting generate button.

14. By this we have completed building the service, our next task is to register the service and test the service. We are going to discuss these steps here as i have explained in detail here OData Service Registration.

15. Test the service by using the transaction /IWFND/GW_CLIENT.

So we have successfully created OData service using RFC/BAPI. Hope this tutorial help you.

原文地址:https://www.cnblogs.com/yjyongil/p/11039052.html