Skip to Content
avatar image
Former Member

How to handle an OData error in SAPUI5 properly?

Hi everyone!

I'm developing a SAPUI5 App, which offers CRUD functionality on a custom table in the SAP Backend. For this, I have an OData Service with redefined Methods for said CRUD functionalities. Now to my Problem:

As I am creating / updating records on my custom table, which has references to standard tables like USR02 I have to check the referencial integrity as opensql doesn't take care of it. For now I am able to pass an exception to my SAPUI5 frontend via /iwbep/cx_mgw_busi_exception. According to this Exception I want to highlight the inputfield with the given value in question. So what is the right way to handle backend errors? Is it possible to gather all constraint violations regarding referential integrity and show them together in a MessagePopover or something like that?

My first thought was to pass custom error code and a message via Method ADD_MESSAGE from /IWBEP/IF_MESSAGE_CONTAINER but I dont know how i can achieve this as i want to use text elements for multi language support. I've tried following:

lr_message_cont->add_message(
EXPORTING
iv_msg_type = 'E'
iv_msg_id = 'ZUI5_MESSAGES'
iv_msg_number = '003'
iv_msg_v1 = text-003

).
RAISE EXCEPTION TYPE /iwbep/cx_mgw_busi_exception
EXPORTING
message_container = lr_message_cont.

Please tell me if this is the right approach for my intend or if i can solve my problem in a cleaner way i don't know of. If more informations are needed, please let me know.

kind regards,

Marvin

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Nov 17, 2017 at 05:35 AM
    Add comment
    10|10000 characters needed characters exceeded

  • Nov 17, 2017 at 06:43 AM

    Hello,

    Please look at the guide lines, it will show you how to do it :

    https://experience.sap.com/fiori-design-web/messaging/

    Regards,

    Joseph

    Add comment
    10|10000 characters needed characters exceeded