Netweaver Gateway Development

Step by Step Gateway OData Service Creation - method 2. importing RFC/BOR interface

         We have already created SAP Gateway service by importing DDIC structure.We followed codebased approach for implementing CRUD-Q operations and function import.In this tutorial we will be developing OData service by importing RFC/BOR interface.
         SAP provide lots of function modules.We can leverage them or we can develop custom function modules and use them.In this tutorial we will not be writing a single line of code.We will be mapping interfaces of RFC function modules to operations of OData service.
          This approach is commonly used because most of the netweaver gateway services are based on remote function modules.In most of the cases Netweaver Gateway system will be stand alone and and SAP system will be seperate.Then we should use remote function modules.For codebased implementation using RFC/BOR follow our DDIC tutorial series.Concept is same.

STEPS

  1. We know where to start😎.Go to SEGW tcode.Create new project by clicking Create Project button.Give project name ZRFC_ODATA.Give meaningful description and choose package.Click tick button.A project will be created.
  2. Expand the new project in edit mode.Right click on Data Model->Import->RFC/BOR Interface.This will open up Create Entity Type from Data Source screen.For Entity Type name give 'SalesOrderHeader' and choose target as Local.My gateway and sap ecc are in same system so I chose Local.If you have hub deployment structure you can choose Remote and select RFC Destination.Check Create Default Entity Set checkbox.This will create SalesOrderHeaderSet entityset for us.Select Remote Function Call from Type dropdown.Use BAPI_EPM_SO_GET_LIST.This FM is a part of Enterprise Procurement Model .Press Next button.
  3. Now interface definitions of selected data source will be shown in the screen(screen  2 of the wizard).Select SOHEADERDATA[] structure.Uncheck Assign Structure checkbox.We are unchecking this because otherwise entity type will be renamed to Soheaderdata.This is'nt pretty.So inorder to keep our pretty 'SalesOrderHeader' as intact we are unchecking it.If you dont bother about entity set name check this checkbox.Press Next button.
  4. Now we will be at 3rd window of our wizard.Select SO_ID as key and proceed to finish.
  5. Now we will follow step 2 to 4 to create another entity type called 'SalesOrderLineItem'.


  6. Now Expand Data Model node and double click on Entity Types.We will now assign corresponding abap structure to entity types.It will be autamatically assigned if we have checked assign structure checkbox.Corresponding abap types are BAPI_EPM_SO_HEADER and BAPI_EPM_SO_ITEM.Save the changes.
  7. Double click on Entity Sets node and check Creatable,Updatable,Deletable and Pageable checkboxes.Addressable will be checked by default.Save your changes.We have unchecked SalesOrderLineItemSet's addressable property because we dont need our users accessing the set directly.It should be accessed through SalesOrderHeaderSet only.
  8. Now we will create an association between these two related entities with referential constraints.This will create a navigation property using which we can fetch related sales order line items with sales order id in hand.Right click on Data Model->Create->Association.
  9. This will open up association wizard.Give Association name 'SOHeaderToSOItem'.Select Principal Entity as 'SalesOrderHeader' and Dependent Entity as 'SalesOrderLineItem'.select cardinality as 1 and 0..n.This means single sales order can have 0 or N line items.If no sales order no line item exist.Check Create related Navigation Property checkbox.Give 'LineItems' as navigation property name.Press Next button.
  10. In next screen map the key fields.Here SoId is the key field.Press Next.
  11. In next screen give Association set name as 'SOHeaderToSOItemSet' and click Finish.
  12. Now our project structure will look like below screenshot.
  13. Its time to generate.Press Generate button.Leave default values as it is.Click tick mark button.
  14. Expand Service Maintenance node and right click on the hub entry where you want to register the service and click Register.
  15. Provide the system alias which created in the hub system before.We are choosing LOCAL because we use embedded deployment.Click Okay(tick mark).
  16. In the next screen(Add Service screen) leave the default values as it is.Click on Local Object button.If you want to transport give a package.Press Okay.
  17. We have created the service and activated it.Now we can test using Gateway client(/IWFND/GW_CLIENT).Use URI '/sap/opu/odata/SAP/ZRFC_ODATA_SRV/$metadata' and execute.
In the next tutorial we will implement Query method which is GET_ENTITYSET by mapping RFC/BOR interface(No coding as I said already😌).
If you enjoyed this post, Please Share!!

0 comments :

Post a Comment

Powered by Blogger.