cancel
Showing results for 
Search instead for 
Did you mean: 

How to remove a message area

christoph_rhein1
Explorer
0 Kudos

Hello,

I am using the following code to display error message. That works perfectly fine.

The only problem I have is once there is no error message the message area remains

at the top of the window and the the focus is always automatically set to the message area.

Is there a way to remove/reset the message handler?

I tried lr_message_manager->clear_messages( INCLUDING_PERMANENT_MSG = abap_true )

but this didn't help.

Thanks and regards,

Christoph

  • get message manager

lr_current_controller ?= wd_this->wd_get_api( ).

lr_message_manager = lr_current_controller->get_message_manager( ).

if lt_messages is initial.

lr_message_manager->clear_messages( INCLUDING_PERMANENT_MSG = abap_true ).

else.

LOOP AT lt_messages INTO lr_message.

  • report message

CALL METHOD lr_message_manager->report_t100_message

EXPORTING

view = 'FOUNDATION'

msgid = lr_message->mv_msgid

msgno = lr_message->mv_msgno

msgty = lr_message->mv_msgty

p1 = lr_message->mv_msgv1

p2 = lr_message->mv_msgv2

p3 = lr_message->mv_msgv3

p4 = lr_message->mv_msgv4.

ENDLOOP.

endif.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Please try to set the visibility of the Message Area based on some condition. Only if there are messages in the internal table you are using, set the visibility of the message area to TRUE otherwise FALSE. This can be done using the context attribute for VISIBILITY and bind this to the VISIBLE property of the MESSAGE_AREA then fill this attribute accordingly.

Regards,

Lekha.

christoph_rhein1
Explorer
0 Kudos

Hi Lekha,

I tried your approach and its not working.

I also tried to do this dynamically in WDDOMODIFYVIEW:

data: lr_message_area TYPE REF TO CL_WD_MESSAGE_AREA.

lr_message_area ?= view->get_element( id = 'MESSAGES' ).

lr_message_area->set_visible( '01' ). " 01 is invisible 02 is visible

but nothing works

The message area remains showing 'No Messages' and the only way to get rid of it is to click on the show list button and reset the log.

When I do create a test application the message areas works fine but in the whole application it remains. I have no idea what's causing this.

What I do in the application is basically the following.

The business object has its own message handler and in the WDDOMODIFYVIEW of the view containing the message area I read this message handler and if there are messages I do the following:

  • get message manager

lr_current_controller ?= wd_this->wd_get_api( ).

lr_message_manager = lr_current_controller->get_message_manager( ).

  • lt_messages gets filled from the business object

LOOP AT lt_messages INTO lr_message.

  • report message

CALL METHOD lr_message_manager->report_t100_message

EXPORTING

msgid = lr_message->mv_msgid

msgno = lr_message->mv_msgno

msgty = lr_message->mv_msgty

p1 = lr_message->mv_msgv1

p2 = lr_message->mv_msgv2

p3 = lr_message->mv_msgv3

p4 = lr_message->mv_msgv4.

ENDLOOP.

If there are no messages in lt_messages I just want to get rid of the message area.

christoph_rhein1
Explorer
0 Kudos

Hello,

I found the problem.

In the main window in WDDOINIT there was this code:

  • lr_api_wd_msg_area ?= wd_this->wd_get_api( ).

  • lr_wd_message_area = lr_api_wd_msg_area->get_message_area( ).

  • lr_wd_message_area->set_display_attributes( i_for_all_instances = ' '

  • i_msg_lines_visible = '5'

  • i_use_toggle_area = 'X').

After commenting out the message area works as expected.

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi, if you want to use a toggle message area you can remove the empty message area after a success message with this code:

data:

lr_view_controller type ref to IF_WD_VIEW_CONTROLLER,

lr_windows_controller TYPE REF TO IF_WD_WINDOW_CONTROLLER,

lr_MESSAGE_AREA TYPE REF TO IF_WD_MESSAGE_AREA.

lr_view_controller = wd_this->Wd_Get_Api( ).

lr_windows_controller = lr_view_controller->GET_EMBEDDING_WINDOW_CTLR( ).

lr_MESSAGE_AREA = lr_windows_controller->get_message_area( ).

lr_MESSAGE_AREA->reset_messages( ).

regards

Roland