Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
Showing results for 
Search instead for 
Did you mean: 
Active Contributor
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.