Function Imports in OData and UI5

Function Imports:

Function imports are used to perform an action on a business object that can’t be executed by using CRUD-Q methods. An example of such an action is data retrieval of a different entity not directly in the context of a bound entity. Other examples including GetLongText, SaveLongText, ReleaseInspectionLot, setUsageDecision and ReleaseSalesOrder, performAvailablitiyCheck etc...

If a function import is read-only, GET should be used as the HTTP method. If POST is used, the framework checks for a CSRF token. Therefore function imports that perform changes should use the HTTP method POST.

Function imports are defined on the service level, not the entity set level. As a result, you must determine the name of the function import in the service implementation.

Define function import


Define function import parameters

By default all input parameters are mandatory however we can make it optional by checking the nullable column. There's a hidden field in the ALV-View of the parameter list. Just change the layout,


Since all function imports are handled by the single method, /IWBEP/IF_MGW_APPL_SRV_RUNTIME~EXECUTE_ACTION, you have to use a CASE state to identify the correct one.


Use io_tech_request_context to retrieve the name of the function import and the import parameters of the function import and also observe the different parameter values as follows. 

    
            



   
Function import always returns the specified entityset under the Return Entity Set column while defining the function import.



Calling Function Import from SAPUI5: 




Comments

Popular posts from this blog

Preparing the ABAP developement environment for SAP BTP

Introducing RESTful Application Programming