How to use messages in CRM web UI
In general there
are 4 different Sources for error messages:
- Important
Info Message
- BSP Framework messages
- UI Framework
messages
- BOL/Genil
global message container
- BOL/Genil object
realated message containers
The message level
is considered first before the message types are considered. Message level is
1-9 corresponding to data element: BSP_WD_MESSAGE_LEVEL
9 Only Collect in Trace Mode
8 Administrator
6 Experienced User
3 Office-Based Sales Employee
1 Customer
0 None
The message level
implies for which user group the messages are designed for.
In general the
sorting sequence corresponds to the above sequence. Within each group the
sorting corresponds to “Error” “Warning” “Info” so on the message type.
2 To No.1: How to create an important info message:Get access to UI Framework message service available in every controller class.
Data: lv_msg_service type ref to
cl_bsp_wd_message_service.
Lv_msg_service = Me-> view_manager->get_message_service().
Create an important info message:
lv_msg_service->add_message( IV_MSG_TYPE =…
IV_MSG_ID =…
IV_MSG_NUMBER=…
IV_MSG_V1=…
IV_MSG_V2=…
IV_MSG_V3=…
IV_MSG_V4=…
IV_MSG_LEVEL=…
IV_IMPORTANT_INFO = ABAP_TRUE).
The parameter iv_msg_type is ignored in
this case.
3 To No 2: How to use BSP Framework messages:
This kind of message source is available in
the context node via attribute errors which is an instance of CL_BSP_MESSAGES.
The class provides several methods to add messages in different formats like
T100, Exception Objects etc. Those messages get an severity according to the
constants in this class and messages with severity 1 or 2 (fatal error or
error) will automatically keep the user on the current page in order for him to
correct the respective error first.
Messages can be assigned to fields of the
context nodes which will lead to a highlighting of the corresponding fields on
the UI (depending on the Tag Library).
All BSP Framework messages will
automatically be deleted after the next round trip (the whole message object
will be invalidated with the next roundtrip).
Errors in the automatic type conversion
will also lead to BSP Framework messages (e.g. wrong format entries in a date
field will automatically be display via this type of messages, no application
coding is necessary here, as the framework does provide this J
4 To No.3: How to create an UI-Message:
Get access to UI Framework message service
available in every controller class.
Data: lv_msg_service type ref to
cl_bsp_wd_message_service.
Lv_msg_service = Me->
view_manager->get_message_service().
Create an important info message:
lv_msg_service->add_message( IV_MSG_TYPE
IV_MSG_ID
IV_MSG_NUMBER
IV_MSG_V1
IV_MSG_V2
IV_MSG_V3
IV_MSG_V4
IV_MSG_LEVEL
IV_VERIFICATION).
This kind of messages is intended to be set
on controller level. The optional parameter iv_verification can be used to
register a call back method to verify the message on each round trip if it is
still valid. If this is not given the message is only shown once, so it
disappears after the next round trip.
BAPI-Messages: The functionality there
corresponds to the above statements. This is only for those colleagues relevant
who are calling BAPIs from their UIs.
The corresponding method is called:
Add_bapi_messages
5 To 4 and 5: BOL/Genil global message container and BOL/Genil object realated message containers:
This automatically will be provided by the
BOL Implementation:
6 Message filtering:
There are two concepts for message
filtering:
Messages can be filtered by message level.
This is a user specific setting (User Parameter: CRM_USER_LEVEL).
In addition to this a programmed message
filter is available.
Per default messages from all sources
except 5 – special BO Messages – are shown.
In order to switch on messages of a single
BO you have to implement method:
IF_BSP_WD_HISTORY_STATE_DESCR~GET_MAIN_ENTITY
In the view controller which is loaded into
the workarea.
Windows are bypassed automatically.
Of course this is only a valid option in
that case the workarea contains “just” a single entity. In case the view in the
workarea has not the knowledge which is the main entity of the view assembly it
has to dispatch the method call to it’s sub-views (as in the bread crumb
implementation).
Since this method is also of importance for
the breadcrumb implementation it might be already implemented in your case.
If you need more control about the message
filtering you can implement method:
IF_BSP_WD_STATE_CONTEXT~GET_MESSAGE_FILTER
In the view controller which is loaded into
the workarea.
Windows are bypassed automatically.
Here you receive the current filter object
of type CL_BSP_WD_MESSAGE_FILTER.
Now you are able to switch on/off the
several message sources and/or add additional entities for which messages should
be shown.
You might change the given filter or create
a new one and you might also pass on the filter object to sub-views in order to
aggregate the applied filter settings.
In any case the filter object has to be
returned.
7 How to handle messages on user request:
Message types:
- Navigatable
messages
·
Non-navigatable
messages
Implementation:
1.
Get the message service:
DATA: lr_service TYPE REF TO
cl_bsp_wd_message_service.
lr_service = me->view_manager->get_message_service( ).
2.
For navigatable messages only:
2.1 Create
a message handler class
This class must implement the interface IF_BSP_WD_MESSAGE_HANDLER and will be called when the message link is clicked.
2.2 Subscribe
for a message
DATA: lr_handler TYPE REF TO zmsgcallback.
“Handler class from 2.1
CREATE OBJECT lr_handler.
TRY.
lr_service->subscribe_message(
iv_message_class = 'CRM_IC_APPL_UI_BDC'
iv_message_number = '114'
iv_subscriber = lr_handler
iv_activation = abap_true ).
CATCH
cx_bsp_wd_dupl_mess_subscr.
ENDTRY.
3.
Example how to add a message:
lr_service->add_message( iv_msg_type = 'E'
iv_msg_id = 'CRM_IC_APPL_UI_BDC'
iv_msg_number = '114' ).
Post a Comment