二维码

[教程] DISPLAYING MESSAGES

Twilight发表于 2016-02-05 22:54Twilight 最后回复于 2016-02-05 22:54 [复制链接] 3787 0

Issuing messages to the user is very important task in any Software. Displaying messages in CRM WEB UI is not much difficult task. We need to have below information at our hand and after that we need to call one method to display the message.

Message class, message no.

I created following message class and message in transaction se91.
message 1.jpg

We need to code at appropriate place to display the message on web ui. Here I just to DO PREPARE OUTPUT method to place the code.
  1. METHOD do_prepare_output.

  2.   CALL METHOD super->do_prepare_output
  3.     EXPORTING
  4.       iv_first_time = abap_false.

  5.   DATA:lr_service TYPE REF TO cl_bsp_wd_message_service.

  6.   lr_service = me->view_manager->get_message_service( ).
  7.   lr_service->add_message( EXPORTING iv_msg_id = 'ZMSG_CLASS' iv_msg_number = '000' iv_msg_type = 'E' ).

  8. ENDMETHOD.
复制代码

Cl_bsp_wd_message_service is used to display the message on the web ui. In above code, we are getting an instance of the message service. Then we are calling its method ADD_MESSAGE by exporting the message id, message no and message type.

Here message type indicates what kind of message it is.

E for error, S for success, W for warning and I for information.  

All messages of type E , will be displayed  in Red color and all messages of type W, are displayed in light yellow color.


Here is the output what I got when I executed the application.
message 2.jpg

LONG TEXT:
Sometimes, we may want to display more information along with the error message. In those situations, we will maintain long text for our message in the message class.

Whenever there is long text maintained for our message, framework automatically shows a link with name ‘DETAILS’ in the message bar next to our message. If user clicks on that, then he will be presented with a pop up with detailed information.

Go to the message class and maintain the long text.  Do not forget to the un check the box self-explanatory.
message 3.jpg
message 4.jpg

Save it and execute the application again.
message 5.jpg
回复

使用道具 举报

快速回帖

本版积分规则
您需要登录后才可以回帖 登录 | 注册有礼

快速回复 返回顶部 返回列表