Skip to Content
author's profile photo Former Member
Former Member

Problem with customer function in gateway service

Hi all,

I have a problem with a customer function implemented in a gateway service.

1. I did modify the DEFINE method in Model Provider Extension Class.

METHOD define.

super->define( ).

DATA lo_action TYPE REF TO /iwbep/if_mgw_odata_action.

DATA lo_parameter TYPE REF TO /iwbep/if_mgw_odata_parameter.

lo_action = model->create_action( 'ChangeIcon' ).

lo_action->set_return_entity_type( 'ZWADTABLE' ).

lo_action->set_http_method( 'GET' ).

lo_action->set_return_multiplicity( cardinality_entity ).

lo_parameter = lo_action->create_input_parameter( iv_parameter_name = 'Id'

iv_abap_fieldname = 'ID' ).

lo_parameter->bind_data_element( 'CHAR1' ).


2. Redefined the EXECUTE_ACTION method in Data Provider Extension Class.

METHOD /iwbep/if_mgw_appl_srv_runtime~execute_action.


CALL METHOD super->/iwbep/if_mgw_appl_srv_runtime~execute_action


iv_action_name = iv_action_name

it_parameter = it_parameter

io_tech_request_context = io_tech_request_context


er_data = er_data.

CATCH /iwbep/cx_mgw_busi_exception .

CATCH /iwbep/cx_mgw_tech_exception .


CASE iv_action_name.

WHEN 'ChangeIcon'.

DATA lv_id TYPE guid.

lv_id = '0050569E00201EE396808B5F2C284A43'.



id = lv_id.



3. The service and the function are working well. A test in /IWFND/GW_CLIENT using GET and /sap/opu/odata/sap/zwadsack_test_srv/ChangeIcon?Id='X' was succesfull.

4. Also calling the BSP - deployed over team provider in eclipse - http://.../sap/opu/odata/sap/zwadsack_test_srv/ChangeIcon?Id='X' - worked fine. The customer function is called.

But calling the function through SAPUI5 did not work.

var url  = "/sap/opu/odata/sap/zwadsack_test_srv/ChangeIcon?Id='X'";
var user = "username";
var password = "password";
var model = new sap.ui.model.odata.ODataModel(url, true, user, password);

The console.log says "The request URI is not valid. The segment 'ChangeIcon' must be the last segment". For some reason the requested url is:


Does anybody know where the $metadata comes from!?

Best regards.


Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    Posted on Jan 02, 2014 at 03:58 PM

    Hi Ben,

    The URL for "new sap.ui.model.odata.ODataModel" should point only till service name.

    That is,

    url = "/sap/opu/odata/sap/zwadsack_test_srv";

    Whenever the above instance is created, sapui5 loads metadata by making a call adding '$metadata'.

    To call an action/function, you can use $.ajax function of jquery or OData.request of data.js library or callFunction of ODATAModel.

    See examples here.



    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.