cancel
Showing results for 
Search instead for 
Did you mean: 

Web Dynpro Error Messages

Former Member
0 Kudos

Hi Guys,

I have the ff scenario:

1. I have a web dynpro with a tabstrip.

2. I have a save button.

My problems are:

1. When I raise error message via lo_message_manager->report_attribute_error_message, the error message is raised and the field in error is highlighted but when I navigate to another tab, the error message disappears.

I want the error to show even when I navigate to another tab.

2. When I click the 'save' button, i tried to read the error message via lo_message_manager->get_messages( ), but there's no data returned. There's an error and yet it executes the save button.

I want the error to show until all the issues were solved before it can actually proceed with the saving.


How can I achieve this?

Accepted Solutions (0)

Answers (2)

Answers (2)

0 Kudos

hello navi,

You will have to make the message as permanent. So that the message is intact even after round trips just as case when you switch tabs.

  DATA : lo_comp TYPE REF TO if_wd_view_controller,
              lo_mang TYPE REF TO if_wd_message_manager.

  lo_view = wd_this->wd_get_api( ).
  IF lo_view IS BOUND.
    CALL METHOD lo_view->if_wd_controller~get_message_manager
      RECEIVING
        message_manager = lo_mang.
  ENDIF.
  IF lo_mang IS BOUND.
    CALL METHOD lo_mang->report_attribute_error_message
      EXPORTING
        message_text    = 'This is an error'
        element             = lo_lead (Context Element)
        attribute_name  = <your_attribute_name>
        is_permanent   = abap_true.
  ENDIF.

former_member184578
Active Contributor
0 Kudos

Hi,

Pass the parameter is_permanent = abap_true to the report_attribute_error_message( ) method.

hope this helps,

Regards,

Kiran

Former Member
0 Kudos

Hi Kiran and Deepankar,

i marked is_permanent, issue#1 is solved but #2 is not.

I still can't catch the errors when I click the button.

Please help.

Thanks.

ramakrishnappa
Active Contributor
0 Kudos

Hi Navi,

Make sure that, you have written the validation logic and error message logic in method WDDOBEFOREACTION( ).

If so, there is any error message related to attributes/elements, phase model skips the further executions of action.

Regards,

Rama

0 Kudos


Hello Navi,

You should do all the validations in the WDDOBEFOREACTION method. make sure you trigger the error message that are attribute specific. Showing a simple error message will not skip the phase model and it will trigger the ONACTION. Also make sure the action is "Standard' and not 'Validation Independent'.

Now, If you want to capture the messages using the mentioned. You need to do this WDDOBEFORENAVIGATION in the COMPONENTCONTROLLER. This method is exclusively for error handling.

DATA : lo_comp TYPE REF TO if_wd_component,

             lo_mang TYPE REF TO if_wd_message_manager.

lo_comp ?= wd_this->wd_get_api( ).
CALL METHOD lo_comp->if_wd_controller~get_message_manager
RECEIVING
message_manager = lo_mang.

IF lo_mang IS NOT INITIAL.
CALL METHOD lo_mang->get_messages
RECEIVING
result = lt_mess.
ENDIF.

Former Member
0 Kudos

Oh no, I raise all the error message on ONACTION event. And I have several error messages.

Former Member
0 Kudos

Hi Deepankar,

I guess putting all the validations in WDDOBEFOREACTION is okay if I have few views and fields.

But I have a lot.

I cannot do all my validations in WDDOBEFOREACTION.

It is important that I do my validation in ONACTION events on each fields.

So that when the user hits enter or click a dropdown list or click a checkbox, the error would then be raised right away if there's any.

Because I have so many tabs and dropdowns and checkbox and validations on enter, WDDOBEFOREACTION will get triggered so many times.

I can't activate is_permanent also because it sometimes prevents the user in doing any action. I have non-editable fields that are dependent on other fields for entry. When I tried correcting the field that it's depending to, it won't trigger the onaction event, thus the screen seems not responding which in fact it just want the context attribute to be corrected.

Is there no other way to catch the errors when the user clicks the button?

I noticed that I can only read the messages in WDDOBEFORENAVIGATION and not in any other places, but this WDDOBEFORENAVIGATION is executed after ONACTION event of the button. My processing is already executed before I had the chance to read the error.

Please advice.

0 Kudos

Hello Navi,

What I understand is that you need to have all checks when you click on save button. You can have this in two approaches:

1. Create a central context in the main view which have the tabs and do all the validations here in the main view, but i think this will make your job complicated, as all the checks for all the tabs needs to be done in main view.

2. Create an events VALIDATE in the COMPONENT CONTROLLER. Raise event VALIDATE in the BEFOREACTION of the save button, then in every view (that is embedded in the tabstrip) have a event handler for this event VALIDATE. In this event handler do all the checks. if any error is found then raise an attribute error message. if all the validatios are successful, then in the ONACTIONSAVE proceed with the save.

Hope this helps.

Former Member
0 Kudos

Thanks Deepankar for the inputs.

I really appreaciate it.

I can't do option #1 as I'm already in the last phase of my development.

I'm afraid that implementing option #2 will make the runtime and coding of validations to x2.

As what I've mentioned, I have many checking in input field's ONACTION events and same as #1, it can make my job complicated.

Since the order is this:

WDDOBEFOREACTION->EVENT->WDDOAFTERACTION->WDDOBEFORENAVIGATION.

I will create a variable holder.

In EVENT, I will populate it with the clicked button: clicked_button = 'Save'.

I will put a checking in WDDOBEFORENAVIGATION that if the clicked_button is 'Save', then I will get all the previously raised messages via get_messages.

If there is msg_type = '2', then I will not perform the 'Save' action.

If there is no msg_type = '2', that's the time that I will perform the 'Save' action.

I'll implement it and see if everything is covered.

0 Kudos

Thanks Navi.

My only doubt is that by the time you will do the following checks in WDDOBEFORENAVIGATION

If there is msg_type = '2', then I will not perform the 'Save' action.

If there is no msg_type = '2', that's the time that I will perform the 'Save' action.

Save action would already have been executed.

Regards

Deepankar Bhowmick