Friday, March 9, 2012
In the previous post Web Dynpro ABAP - Message handling, discussed about IF_WD_MESSAGE_MANAGER and its methods. Here we use two methods to show Success and Error message.
Fundamental principle of displaying any message in Web Dynpro
Fundamental principle of displaying any message in Web Dynpro
- We define MESSAGE_AREA Ui element on view.
- Define reference to IF_WD_MESSGE_MANAGER
- Call method REPORT_SUCCESS and pass text to show success message.
- Call method REPORT_ERROR_MESSAGE and pass text to show error message.
- Message Manager will display the message on view in the Message area.
Example program
- Create Web Dynpro component and Save as local object.
- Go to view -> Context tab -> Create node N1 and ADDRESS_TYPE inside the node.
- Go to layout --> Place Input field and bind with context attribute.
- ---------------> Place one button
- ---------------> Place Message Area where you want to display messages.
- Create OnAction event for Button write code as shown below.
- Code for SHOW_MESSAGE action event
METHOD onactionshow_message . * Context related declaration DATA: lo_nd_n1 TYPE REF TO if_wd_context_node, lo_el_n1 TYPE REF TO if_wd_context_element, ls_n1 TYPE wd_this->element_n1. * get message manager DATA: lo_api_controller TYPE REF TO if_wd_controller, lo_message_manager TYPE REF TO if_wd_message_manager. * Structure and variables DATA: ls_t591s TYPE t591s, lv_msg TYPE string. * navigate from <context> to <n1> via lead selection lo_nd_n1 = wd_context->get_child_node( name = wd_this->wdctx_n1 ). * get element via lead selection lo_el_n1 = lo_nd_n1->get_element( ). * get all declared attributes lo_el_n1->get_static_attributes( IMPORTING static_attributes = ls_n1 ). SELECT SINGLE * FROM t591s INTO ls_t591s WHERE sprsl = sy-langu AND infty = '0006' AND subty = ls_n1-address_type. IF sy-subrc EQ 0. "Success message display lo_api_controller ?= wd_this->wd_get_api( ). CALL METHOD lo_api_controller->get_message_manager RECEIVING message_manager = lo_message_manager. CONCATENATE 'Selected addrees is:' ls_t591s-stext INTO lv_msg SEPARATED BY space. * report message CALL METHOD lo_message_manager->report_success EXPORTING message_text = lv_msg. ELSE. "Error message display lo_api_controller ?= wd_this->wd_get_api( ). CALL METHOD lo_api_controller->get_message_manager RECEIVING message_manager = lo_message_manager. * report message CALL METHOD lo_message_manager->report_error_message EXPORTING message_text = 'Please enter correct address type'. ENDIF. ENDMETHOD.
- Create Web Dynpro Application and save.
- Execute the Web Dynpro application.
Followers
Popular Posts
- ABAP - ALV Report example with steps
- ABAP - Step by step tutorial on Smart Forms - Template Node
- ABAP - Sending email with pdf attachment
- SAP Adobe Form - Steps to create simple ADOBE Form and calling it from ABAP Program
- SAP ABAP - CL_ABAP_CHAR_UTILITIES class usage
- ABAP - Multiple value selection from F4 help for SELECT-OPTIONS
- Execute ABAP Report using SUBMIT statement
- ABAP - Select all or Deselect all in ALV or Check box handling in ALV
- Web Dynpro ABAP ALV - ON_CLICK event
- ABAP - Dynamic WHERE clause
Hi,
ReplyDeleteYou have a nice and very helpful blog...
I am facing one issue.. Is it possible for you to helpme..
Issue is: need to display error/warning message and it is showing in the top. But the user need to scroll up to see the message. I mean, when they click on a button, the warning message not showing up right away... user need to scroll the vertical scroll bar to top, to see the error message..
can you guide me on this.
Regards,
Akila
Hi Akila,
ReplyDeletePlease check the below post for the answer.
http://www.an-sap-consultant.com/2013/07/web-dynpro-abap-set-focus-on-message-area-scroll-to-top-of-the-page-on-getting-an-error-message.html
Thanks
Nice tutorial, easily understandable.
ReplyDelete