Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
Showing results for 
Search instead for 
Did you mean: 
Some days ago I had a problem with an OData service, more specifically due to a Function Import.

The Function Import has 2 input parameters

  • Article (MATNR)

  • Serial Number (GERNR).

The developer that coded the Function Import decided to use directly IT_PARAMETERS and then run some conversion routines to ensure we have the right format.

Side Note: We all know that we should use methods get_parameters or get_converter_parameters from io_tech_request_context. If you want to deeply understand how gateway manages conversions, you must read this blog series from thomas.nitschke

Anyway, the problem is not due to conversions but in the maximum length of the parameters.

Article and Serial have maximum length of 18 characters but there is no impediment of sending an Article or Serial with more then 18 characters.

In this scenario, I was expecting that the Gateway Foundation framework handles the length violation as it already does for EntitySets, but this is not the case for Function Imports.

Since in this particular case, an alpha routine is being called for Article (CONVERSION_EXIT_MATN1_INPUT), if the Article has more then 18 characters the service terminates in a dump.

In order to avoid the dump, we then need to implement some check/control on the Data Provider Extension class.

The purpose of this blog is to share my solution for this particular problem. Here it is:

(serialdetail is the complex structure used in the Return Type Kind of the Function Import)
"UC Quickfix for Function Import parameter length control
data article type zcl_zui5srs_mpc=>serialdetail-matnr.
describe field article length data(article_length) in character mode.

if strlen( ls_parameter-value ) > article_length.
raise exception type /iwbep/cx_mgw_busi_exception
textid = /iwbep/cx_mgw_busi_exception=>business_error_unlimited
http_status_code = /iwbep/cx_mgw_busi_exception=>gcs_http_status_codes-precondition_failed
message_unlimited = |{ 'Material Number has more then 18 characters'(001) }|.

This piece of code is implemented in the /iwbep/if_mgw_appl_srv_runtime~execute_action redefinition on the Data Provider Extension Class of the service.

After some exchanges with andre.fischer, I have learned that from SAP_GWFND 752 and higher, we have a new mechanism to control Function Import lengths directly in the service model.

You can find a dedicated blog from andre.fischer with the new way of doing this one.
1 Comment
Labels in this area