Function imports:
They are useful in performing predefined actions in the system. Function imports are implemented when the implementation cannot be done using the CRUD-Q Methods
Steps to create a function import in ODATA Service
- Go to the Transaction SEGW ( Gateway service builder ) and open the Project.
- Expand the ‘Project’ and choose the ‘Data model’ and then right click to choose ‘Create’ and then select the function import.
- The Function import is uniquely identified based on its name. so give an unique name and select the tick mark.
- Maintain the critical parameters of the Function import such as Return type kind, Return Type, Return Cardinality and HTTP method type.
- If the Return type kind is entity type, then mention the name of the entity type in the column Return Type.
- HTTP Method type can be of two different types. a) GET : to get the data. b ) POST: to post the data in the backend.
- The next step would be to save the project and generate the Runtime objects. The function import is visible in the metadata of the ODATA service.
- Now open the SAP Gateway client using the Transaction /n/IWFND/GW_CLIENT and mention the ODATA Service name in the metadata URI option and finally execute. The function import looks like this <Functionimport Name = “Function1″ EntitySet=” ” HTTPmethod=” ” ReturnType=” “>
- Function import parameters can also be inserted in the ODATA Service
- Implementation of Function import in the class DPC_EXT. The method /IWBEP/IF_MGW_APPL_SRV_RUNTIME~EXECUTE_ACTION is redefined. This method will implement the necessary functionality of the Functionimport
- Now the function import can be tested using the SAP Gateway client. Transaction: /n/IWFND/GW_CLIENT. The Request URI looks like /sap/opu/odata/SAP/service_name1/functionimport1?parameter1=’678cd’. Please set the HTTP Method to POST and execute the URI. The success message must appear on the HTTP response.