Mentor SAP

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 the release of a sales order. Releasing a sales order means not just changing a property’s status in an entity, but also starting several back-end processes. Other examples include confirming an order or performing an availability check.

 

 

If cardinality is set to 0…n or 1…n, a return entity set has to be selected. 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 entity set level. As a result, you must determine the name of the function import in the service implementation.

 

 

Function Imports — Data Model Definition

You define the function import and parameters with the following data:

 

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

 

Function Imports — Implementation

Use io_tech_request_context to retrieve the name of the function import and the import parameters of the function import as follows:

 

Example:

lv_function_import_name =
io_tech_request_context->get_function_import_name( ).

io_tech_request_context->get_converted_parameters(
IMPORTING
es_parameter_values = ls_parameter_values ).

CASE lv_function_import_name.
WHEN 'ConfirmOrder'.
…
ENDCASE.