Skip to Content

Implementing optional parameters in the function import

It’s a common knowledge that those actions which cannot be directly modelled via the CRUDQ operations are implemented via function imports. Examples like – On display screen data retrieval of a different entity not directly in context of bound entity but dependent on few values of bound entity, updating the status of some items (and not entire item), on demand fetching of data from third party service, etc.


While creating function imports via the SEGW (project builder) transaction, we don’t have a provision of marking parameters as optional. We may have use cases where same function import behaves differently with different parameters which are all not mandatory. To achieve this, we can override the definition of function import in the DEFINE method of the respective model provider extension class.


Sample implementation is demonstrated below.

Figure 1: oData Service with Function Import


Sample code is

METHOD define.
* Title:   
* A. Also make the function import(Fetch User Configurations)  parameters as optional
* A. Also make the function import(Fetch User Configurations)  parameters as optional
    " Data Declarations
      lo_entity_type TYPE REF TO /iwbep/if_mgw_odata_entity_typ,
      lo_property    TYPE REF TO /iwbep/if_mgw_odata_property,
      lo_action      TYPE REF TO /iwbep/if_mgw_odata_action.

    " Start of Code
    CALL METHOD super->define( ).
    " Mark the parameters as optional in case of 'FetchUserConfigurations' function import
    lo_action = model->get_action( iv_action_name = ‘FetchUserConfigurations’ ).
    lo_property = lo_action->get_input_parameter( iv_name = ‘EmployeeUser’ ).
    lo_property->set_nullable( iv_nullable = abap_true ).

    " End of Code

Code Snippet 1: Optional parameters implementation

Note: 1. Pagination cannot be implemented in any Function Import as the IO_TECH_CONTEXT parameter for function import and GET_ENTITYSET methods inherits from different classes even though their name is same.

2. Also note that above properties are in Camel case and not all upper case.

Please share feedback and questions.

You must be Logged on to comment or reply to a post.
  • Well, I had the same issue, but the solution was quite easy and works without any coding.


    There's a hidden field in the ALV-View of the parameter List. Just Change the layout, Show the column 'Nullable' and tick it as you want 🙂




  • Thanks Ankit and Gerhard for your explanation.

    Despite the implementation of your suggested solutions (both, in method DEFINE and Nullable in SEGW) I get the error when I try to transfer an "Edm.DateTime" with the value NULL.

    Log-dbg.js:415 2020-03-17 10:50:12.914169 The following problem occurred: HTTP request failed400,Bad Request,{"error":{"code":"005056A509B11EE1B9A8FEC11C22378E","message":{"lang":"de","value":"Ungültiges Schlüsselprädikat"},"innererror":{"transactionid":"442BD4043D2C00C0E005E612B7F99456","timestamp":"20200317095014.3772460","Error_Resolution":{"SAP_Transaction":"For backend administrators: run transaction /IWFND/ERROR_LOG on SAP Gateway hub system and search for entries with the timestamp above for more details","SAP_Note":"See SAP Note 1797736 for error analysis ("}}}} -  

    I can only transfer dummy values to the back end. But that's not a very nice solution in my opinion.

    Do you have any suggestion how to resolve this?