Netweaver Gateway Development

OData service importing RFC/BOR interface - GET_ENTITYSET implementation

       We have created our new OData service importing RFC/BOR interface in the previous tutorial.In this tutorial we will implement Query operation of CRUD-Q operations of OData service.We will be implementing GET_ENTITYSET method just by mapping the RFC.The coding will be generated automatically for us.
Pre-requisites

  1. ZRFC_ODATA service created already by importing RFC/BOR interface.


Steps

  1. Go to SEGW tcode.Open our ZRFC_ODATA service in edit mode.Expand Service Implementation node.Expand SalesOrderHeaderSet->right click on GetEntitySet(Query)->click on Map to Data Source.
  2. A popup window will open similar to the popup  we have seen when importing RFC.Use RFC BAPI_EPM_SO_GET_LIST.
    We are choosing the RFC from Local system.You have the option to choose from remote RFC destination if your RFC resides in remote system.Click Continue button(tick mark button).
  3. Now a mapping screen will open up.In the middle we have current mapping of our fields and in the right hande side we have the selected RFC function module.In the top toolbar we can see a button called Propose Mapping(marked green in picture).Its our buddy. click on Propose Mapping button.Sometimes Propose Mapping wont be able to map all fields.Those fields will remain empty without a mapping.In such cases we have to manually drag and drop a field from right hand side RFC or we have to choose from F4 help.
  4. All the fields are mapped now.Another important thing to note is mapping direction marked green in picture.The mapping direction will be defaulted to input or output.Sometimes this may show as Question mark(?).Then we may have to set the field to input or output.Now all the fields have output direction because it is a query operation and filter criteria is not defined.
  5. Now check the project and press Generate button.Query operation is implemented.For testing open gateway client(/IWFND/GW_CLIENT) and enter uri as '/sap/opu/odata/sap/ZRFC1_SRV/SalesOrderHeaderSet' choose http method GET(selected by default) and press execute.Now you can see all the sales order entries in response tab(If the system has data).
  6. Now we have implemented query operation.We need to define filter criteria.We need to refine our sales order entries based on buyername or sales order id.To do this double click on Mapping we have done under GetEntitySet(Query).Now we need to add new rows for mapping fields for filter.For this we can either use Append Row or Insert Row buttons(marked red in image).Third button is for Delete Row.Press Insert Row.A new row will be inserted.Choose Entity Set property SoId from F4 help.Data Source Parameter can be Drag and Drop from right handside or choose from F4 help.A map range popup will be shown.Just press continue.The green area indicate its a range table like select options in abap.
  7. Now check the project and Generate.Open gateway client(/IWFND/GW_CLIENT) and enter uri as '/sap/opu/odata/sap/ZRFC_ODATA_SRV/SalesOrderHeaderSet?$filter=SoId ge '500000001' and SoId le '500000004'' and press execute.This will return 4 entries from 50000001 to 50000004.You can try different uris such as /sap/opu/odata/sap/ZRFC_ODATA_SRV/SalesOrderCollection?$filter=SoId le '0500000020' and BuyerName eq 'DelBont Industries' etc.
Note:We cant cover all use cases of filter with range tables.Like filter FieldA eq ‘A’ or FieldB eq ‘B’ because of or in filter.

If you enjoyed this post, Please Share!!

0 comments :

Post a Comment

Powered by Blogger.