Skip to Content

Customization of Messages for OData-services generated from CDS-Views

Is it possible to customize the messages for an OData-service generated from CDS views? The question has the following concrete background: We use a value help, through which the user can search for a customer (article, plant, ...). The value help pulls its data from a CDS view. If the user gives an invalid customer number and presses Enter, the OData service responds with the following message:

Resource not found for segment "Z_I_CustomerVHType". 

Unfortunately, the user can not do much with this message. In order to get a readable message, my workaround has been to redefine the respective method in the DPC_EXT of the OData service and to replace the error case with a separate message. With multiple entities this quickly leads to a coding-mess, furthermore this approach is only possible, if I redefine my service via SEGW.

Is there a better solution to this problem?

Appendix: OData error message

odata-messages.jpg (140.3 kB)
Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Best Answer
    Posted on Feb 14, 2019 at 03:52 PM

    Hi Benedikt,

    when entering a non existing value for a value help in SAP Fiori Elements List Report Template you get a warning in the UI that you have entered a wrong value.

    Technically a GET request is sent to the backend that returns with an empty response.

    GET SEPMRA_I_ProductCategory?search-focus=ProductCategory&$filter=ProductCategory%20eq%20%27k%27

    As discussed in your case you are sending a GET request with the entered value as a key to the backend.

    In order to avoid having the need to implement each single GET_ENTITY method for each value help you can redefine the generic method


    that itself calls the entity specific Methods

    METHOD /iwbep/if_mgw_appl_srv_runtime~get_entity.
        DATA lv_entityset_name TYPE string.
        DATA lr_entity TYPE REF TO data.
        lv_entityset_name = io_tech_request_context->get_entity_set_name( ).
            CALL METHOD super->/iwbep/if_mgw_appl_srv_runtime~get_entity
                iv_entity_name          = iv_entity_name
                iv_entity_set_name      = iv_entity_set_name
                iv_source_name          = iv_source_name
                it_key_tab              = it_key_tab
                it_navigation_path      = it_navigation_path
                io_tech_request_context = io_tech_request_context
                er_entity               = er_entity
                es_response_context     = es_response_context.
          CATCH /iwbep/cx_mgw_busi_exception .
            CASE lv_entityset_name.
              WHEN 'ValueHelp1Set' or 'ValueHelp2Set'.
                "do some value help specific error handling
              WHEN OTHERS.

    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.