cancel
Showing results for 
Search instead for 
Did you mean: 

Use alert display box in for custom message in IC Context Area

Former Member
0 Kudos

Hi,

I want do display some message in the Alert Box of SAP IC Context Area but not using alert in an event.

Could not find any code for this purpose. I checked BSP Component ICCMP_HDR_CNTNT where all the 3 text boxes of Context Area are configured.

Is there any way to enhance this component and push a message to UI Alert Box.

Accepted Solutions (1)

Accepted Solutions (1)

dmitry_sharshatkin
Active Participant
0 Kudos

Hello Tapas,

I'm not sure I understood your question correctly, but here it comes now, how you can send alert messages using the standard functionality...

Result:

Code:

data: lr_alert_srv    type ref to cl_crm_ic_abap_alert,

           lv_alertobj     type ref to cl_crm_ic_alert,

           lv_alert_return type ref to cl_crm_ic_alert_return,

           lv_alertid      type crm_ic_alert_id,

           lv_id           type string,

           lv_jalert       type ref to if_crm_ic_jalert_srv,

           lv_alert_msg    type string,

           lv_alert_text   type string,

           lv_source       type crmt_ic_alert_src.

     create object lv_alertobj.

     lv_alert_text = '<b>Hello Tapas !!!</b>'.

     lv_alertobj->set_message( lv_alert_text ).

     lv_alertobj->set_tooltip( lv_alert_text ).

     lv_alertid = 'zdmsh_test'.

     lv_source = cl_crm_ic_active_alerts=>gc_extern.

     lv_id = lv_alertid.

     lv_alertobj->set_alertid( lv_id ).

     create object lv_alert_return.

     lv_alert_return->set_timer( '' ).

     lv_jalert = cl_crm_ic_services=>get_jalert_srv_instance( ).

     lr_alert_srv = lv_jalert->get_alert_service( ).

     try.

         lr_alert_srv->if_crm_ic_alert_service~send_alert_cancel( alertid = lv_alertid

                                                                  session_id = '' ).

         lv_alert_msg = lr_alert_srv->if_crm_ic_alert_service~compose_message_text(

                                        alertobj    = lv_alertobj

                                        alertreturn = lv_alert_return

                                        ).

         lr_alert_srv->if_crm_ic_alert_service~send_alert_message(

                                           alert_id   = lv_alertid

                                           timer      = ''

                                           message    = lv_alert_msg

                                           session_id = '' ).

       catch cx_root.

     endtry.


If you need more fancy solution, you can modify ICCMP_HDR_CNTNT/AlertInfo, register your own event listener and trigger your own SAM event as it was already described by Michael in his post:

Former Member
0 Kudos

Hi Dmitrii,

Thanks for the code. Its really useful. It may solve the purpose but what I was asking that is there a way we can display message in Alert Box without using the Alert functionality.

I mean by redefining or using some method which actually pushes the message to Alert Box so that we can simply pass a string.

dmitry_sharshatkin
Active Participant
0 Kudos

Hi Tapas,

I'm totally confused now. In the example above I simply pass a string.

See:


data: lv_alert_text type string.

lv_alert_text = '<b>Hello Tapas !!!</b>'.


I'm not using any Alert  functionality, except maybe some classes. But this is so, because they contain exactly the right coding. If you don't like them, for some reason, you can copy the code from inside, but to my mind it's look rather weird.

BR, Dima

Former Member
0 Kudos

Hi Dmirtii,

Sorry the confusion. The code you provided is fit for my solution but I am facing some issue in the code.

1. I have created am FM and executed the code but no messages in UI. So I checked that the inside the last method if_crm_ic_alert_service~send_alert_message the code is unable to fetch the session ID. Here do I need to put this code so that it will get the session ID? Is it from any method of UI component.

2. I guess this message will be only displayed to me as it will fetch my session ID.

dmitry_sharshatkin
Active Participant
0 Kudos

Hello Tapas,

Basically you are saying that cl_icwc_session_registry=>get_session_id( ) has returned you nothing. This is strange, for me it's working out of the box. You should then check why this static variable is not populated. Set a break-point in CL_ICWC_SESSION_REGISTRY-> REGISTER_AS_AGENT_SESSION or simply search for this class on SDN, there are some posts.

It's hard to help you as I don't get this kind of error.

BR, Dmitry

Former Member
0 Kudos

Hi Dmitrii,

I have called my FM from a method of UI component and its working now.

Thanks a lot for this solution.

Could you also let me know whether I can run the code and display message to some other users.

Answers (0)