cancel
Showing results for 
Search instead for 
Did you mean: 

Error messages and cancel navigation - questions about concept

karsten_heth
Active Participant
0 Kudos

Hello experts,

I have a very simple Web Dynpro component:

- 2 views

- First view has an input field that is linked to a date field in the context and a button to navigate to the second view

- Second view has a button to navigate back to the first view

- There are no individual field validations implemented

If I now enter a date in a wrong format and press the button, the program navigates to the second view and displays an error message in the Message Area (comes from the WD4A framework). And in this second view the navigation is cancelled and I can't get back to the first view to correct the date.

Is this the correct behaviour? This does not make any sense to me. I would have expected that the navigation is cancelled in the first view so that it is not possible to leave the screen with the faulty data.

Referring to the book "Web Dynpro for ABAP" by Ulli Hoffman the validation of type definitions is the very first step in the phase model of the request/response cycle. But it seems as if navigation comes first and validation of type definitions comes second.

Is there a way to start the standard field validation earlier (for example in the wddobeforeaction method) so that navigation is stopped in the first view until the user enters a correct date?

Thanks, Karsten

Accepted Solutions (0)

Answers (1)

Answers (1)

SergioFerrari
Active Contributor
0 Kudos

hava a look to:

Sergio

karsten_heth
Active Participant
0 Kudos

Hi Sergio,

the method cl_wd_dynamic_tool=>check_mandatory_attr_on_view checks for mandatory fields, but not for data types. My date field is not mandatory, so calling this method does not help me here.

Karsten

Former Member
0 Kudos

Hi,

if your attribute where you put your date is of type datum ( or underlying datatype)

than a message will be thrown automatically in your message area

when the system doesn't recognize it as a date

grtz,

Koen

karsten_heth
Active Participant
0 Kudos

Hi Koen,

yes, that's what I mentioned. But the error message comes too late: in the message area of the second view. And worse: I can't get back to the first view because the application has cancelled the navigation because of this error message.

Karsten

SergioFerrari
Active Contributor
0 Kudos

I'm sorry, now I read better your question.

What about getting the instance of the message manager and verify if it is empty?

  • get message manager

DATA lo_api_controller TYPE REF TO if_wd_controller.

DATA lo_message_manager TYPE REF TO if_wd_message_manager.

IF sy-subrc EQ 0.

lo_api_controller ?= wd_This->Wd_Get_Api( ).

*

CALL METHOD lo_api_controller->GET_MESSAGE_MANAGER

RECEIVING

MESSAGE_MANAGER = lo_message_manager.

IF lo_message_manager->is_empty( ) IS initial.

fire your plug <-------

Sergio

Former Member
0 Kudos

hi,

if you implement in your eventhandler of the button a check to the

message_manager to see if there are any messages you can solve it

use the magic wand button to create message,

but wipe out all the code except the one where you get the message manager instance

do lo_message_manager->is_empty( ).

if true

fire navigation plug

else

exit.

endif.

grtz,

Koen

sorry took me too long to type it

Message was edited by:

Koen Labie

karsten_heth
Active Participant
0 Kudos

Yes, your suggestion to check the message manager works fine. But if I have to do these checks manually, I don't really understand the concept behind "cancel_navigation"

Thanks, Karsten