on 08-01-2009 9:30 AM
Hi Experts,
Am trying to use message class for displaying messages.
Am not able to find the procedure to do this.
I have my message class already created.
Can someone explain how to call this message class and use this in the error messages generated by wizard.
Hi Mohammed,
In order to show a message to the user you basically call 1 of the various methods available in IF_WD_MESSAGE_MANAGER. The Web Dynpro runtime automatically instantiates a class implementing this interface.
The source code for reporting messages can be generated using the Web Dynpro Code Wizard. The generated code consists of a common part, containing the source code for obtaining the reference to the message manager, and a part that is dependent on the method to be called.
You can generate all this coding by just going to your code wizard and selecting the option as, "Generate Message". Select 1 of the methods through F4 help in "Method" input field & press enter.
DATA lo_api_controller TYPE REF TO if_wd_controller.
DATA lo_message_manager TYPE REF TO if_wd_message_manager.
lo_api_controller ?= wd_this->wd_get_api( ).
" Obtain the reference of the class implementing the message manager interface
CALL METHOD lo_api_controller->get_message_manager
RECEIVING
message_manager = lo_message_manager.
" Use the message manager reference to call any of the methods of if_wd_message_manager to report the message
CALL METHOD lo_message_manager->report_warning
EXPORTING
message_text = 'No orders exist for this customer!'.
Regards,
Uday
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If you want to reuse a message class, specifically look for the methods of the message manager that have t100 in the method name. Like REPORT_T100_MESSAGE for example. They let you reference a message class and message number directly:
* get message manager
DATA lo_api_controller TYPE REF TO if_wd_controller.
DATA lo_message_manager TYPE REF TO if_wd_message_manager.
lo_api_controller ?= wd_this->wd_get_api( ).
lo_message_manager = lo_api_controller->get_message_manager( ).
* report message
lo_message_manager->report_t100_message(
msgid = msgid
msgno = msgno
msgty = msgty
* p1 = p1
* p2 = p2
* p3 = p3
* p4 = p4
* msg_user_data = msg_user_data
* is_permanent = ABAP_FALSE
* scope_permanent_msg = CO_MSG_SCOPE_CONTROLLER
* view = view
* show_as_popup = show_as_popup
* controller_permanent_msg = controller_permanent_msg
* msg_index = msg_index
* cancel_navigation = cancel_navigation
* enable_message_navigation = enable_message_navigation
* component = component
).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Mohammed,
As a further tip since obtaining the reference to the message manager is obligatory before a message can be reported you
can move the fragment of code wherein you obtain the reference of the class implementing the message manager
into the standard hook method WDDOINIT. Now within this method obtain the desired reference & save it on to a global
attribute of type IF_WD_MESSAGE_MANAGER. So now whenever you want to report a message you can directly re-use this
global reference and ommit fetching the reference each & every time.
" So place this coding inside your WDDOINIT method
" I have created an attribute lo_message_manager at componentcontroller level of
" type ref to if_wd_message_manager & marked it as public
DATA lo_api_controller TYPE REF TO if_wd_controller.
lo_api_controller ?= wd_this->wd_get_api( ).
CALL METHOD lo_api_controller->get_message_manager
RECEIVING
message_manager = wd_comp_controller->lo_message_manager.
So now I can use this reference from my componentcontroller in whichever view I might need & directly say like:
CALL METHOD wd_comp_controller->lo_message_manager->report_warning
EXPORTING
message_text = 'No orders exist for this customer!'.
Hope that this is clear to you.
Regards,
Uday
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.