With SAP NW Gateway SP08, there is an option to create OData service by importing search help. Please refer https://help.sap.com/saphelp_gateway20sp08/helpdata/en/29/4e9c1b65f3499cbec6365f59dfa3c8/content.htm
You will find some of the details at https://help.sap.com/saphelp_gateway20sp08/helpdata/en/77/ec405224753607e10000000a441470/content.htm
In this document, I will demonstrate creation of OData service based on search help BRF_SH_CUSTOMID (Search Help for Flight Customers).
1) Create project ZSEARCH_HELP. Right click on Data Model and Select Import–>Search Help. Provide Entity type name FlightCustomer and provide Search help (from F4 ) as BRF_SH_CUSTOMID and click Next button.
2) Select parameters from RESULT_LIST which you want to include in search help and click Next. Here, I will select all parameters as shown below.
3) Mark fields which you want to be key properties. Here I will select property ID as key property. Click Finish.
Note that Create Default Entity Set is marked by default and hence we need not to create Entity set as wizard will create it.
As result of this step, entity type and entity set will get created as displayed below,
4) Now we will do service implementation for Query and Read operation. first let’s do it for Query operation. Expand Service Implementation folder and right click on GetEntitySet(Query) operation and select Map to Data Source. Select Data Source Attributes as displayed below.
Press Propose Mapping button which will enable system to select mapping automatically.
5) Now let’s map GetEntity (Read) operation. Right click and select Map to Data Source. Select Data Source Attributes as mentioned above. Click on propose Mapping but as this is read operation, we need to provide input key to read it.Click on Insert Row button and add input key property. here I will select ID. then drag the ID parameter from right screen to Data Source Parameter. This will provide input key as ID.
Now Check project consistency and if everything is okay then click on Generate Runtime Objects. This will generate runtime artifacts. Finally do the service maintenance which involves service registration. Click on Maintain which will open window for Gateway Client.
Let’s test Query operation with request URI /sap/opu/odata/sap/ZSEARCH_HELP_SRV/FlightCustomerSet
It will display the search help result as below. you can use $count, $top etc query parameters.
Now let’s test Read Operation with URI /sap/opu/odata/sap/ZSEARCH_HELP_SRV/FlightCustomerSet(‘00000017’). Output will be as below,
With the import wizard, it is very simple to create OData service based on elementary search help. please keep in mind below constraints. Reference https://help.sap.com/saphelp_gateway20sp08/helpdata/en/77/ec405224753607e10000000a441470/content.htm
The following are the constraints:
- Only elementary search helps are supported. Collective search helps are not supported.
- Search helps that call UI in their exit function are not supported, as this cannot be validated by the Service Builder.
- At runtime, a query operation that is based on a search help data source can retrieve a maximum of 9,999entries.
Also note that
Only the search helps in the local SAP system can be used as a data source.
Please feel free to put your comments and suggestions.
Happy learning and Coding!