cancel
Showing results for 
Search instead for 
Did you mean: 

IC WebClient Alert text block

Former Member
0 Kudos

I've been using the IC cookbook to add an alert. I've done all the steps - created a Z class using IF_CRM_IC_EVENT_LISTENER, setup the alert & event profiles. The alert currently works as far as the message I've put into the <messageText> tag in the alert profile shows up for my new event. The piece that I need help with is how to change the message text to be displayed to be dynamic. According to the cookbook I should be able to do this using <placeholder> but I cannot get this to work. In my handle_event method I add a parameter to the event with the string that needs to be displayed in the alert. The code in my handle_event method for this is:

data: new_event type ref to cl_crm_ic_event.

  • create event object

create object new_event.

new_event->set_name( 'BPIndustryCode' ).

call method new_event->add_param

exporting name ='class' value = 'Homecare Dealer'.

  • raise event

event_service->raise( new_event ).

For testing purposes I have the value hardcoded to 'Homecare Dealer'. In reality the value will come from a table depending on the BP industry code. In my testing to date, the event occurs, gets handled & a message gets displayed, but it's not the value "Homecare Dealer".

Here's the contents of my Alert profile:

<alert id="IndustryCode">

<desc>Respironics Industry Code for BP</desc>

<class>com.sap.ic.service.alert.GenericAlert</class>

<triggeringEvents>

<triggeringEvent>BPIndustryCode</triggeringEvent>

</triggeringEvents>

<inputParams>

</inputParams>

<usedProperties>

</usedProperties>

<placeholders>

<placeholder id="class" property="false"/>

<placeholder id="param1" property="true"/>

</placeholders>

<message>

<messageText>[class]</messageText>

</message>

</alert>

The message that displays in my alert is what I've defined in <messageText> above.

I've tried <messageText>[class]</messageText>, as shown in the cookbook for runtime text replacement but then what shows up in the Alert is literally the string "[class]".

Is it possible, using GenericAlert class, to have different text blocks display in the Alert message? If so, what do I need to change in my setup?

Thanks for any help you can provide.

Bela

Message was edited by: John Burton

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hello Bela,

It is possible to use Generic alert class for your purpose. In that case, you must name event parameter names as param0, param1 etc.

So your handle_event( ) method will have:

call method new_event->add_param

exporting name ='param0' value = 'Homecare Dealer'.

And the xml file will be:

<placeholders>

<placeholder id="param0" property="true"/>

</placeholders>

<message>

<messageText>[param0]</messageText>

</message>

If you are using java IC WebClient, then you will also need to define a parameter converter class and add it to the IMG: Define event handling profiles.

A sample parameter converter class is: CL_CRM_IC_EVCNV_BPCONFIRM.

Regards

Benolin

Former Member
0 Kudos

Hi Benolin -

I actually found the solution poking around on CR4 sandbox system where I found a converter class I was able to steal (ahem, copy) wholesale, and I have it working now. Just for future reference I'm adding in the details of what I changed into this forum.

My event profile changed to:

<event id="BPIndustryCode" paramConvert="ZCL_ALERT_TEST_CONV"/>

My alert profile changed to:

<alert id="IndustryCode">

<desc>Respironics Industry Code for BP</desc>

<class>com.sap.ic.service.alert.GenericAlert</class>

<triggeringEvents>

<triggeringEvent>BPIndustryCode</triggeringEvent>

</triggeringEvents>

<inputParams>

</inputParams>

<usedProperties>

</usedProperties>

<placeholders>

<placeholder id= "param0" property="false"/>

</placeholders>

<message>

<messageText>Industry code [param0]</messageText>

</message>

</alert>

The new conversion method code is:

method CONVERT .

data: param_entry type O2PARAVALU.

data: param type crmt_ic_event_param.

field-symbols: <lv_Any> TYPE ANY.

data: empty_string type string.

data: event_params type table of crmt_ic_event_param.

data: value type string.

data: idx type string.

event_params = event->get_params( ).

loop at event_params into param.

if sy-subrc = 0.

ASSIGN param-value->* TO <lv_Any>.

param_entry-value = <lv_Any>.

else.

  • if parameter not found return empty string (dirty!)

assign empty_string to <lv_Any>.

param_entry-value = <lv_Any>.

endif.

move sy-tabix to idx.

concatenate 'param' '0' into param_entry-name.

append param_entry to params.

endloop.

endmethod.

And the method has 2 input parameters:

1. EVENT, Importing, Type Ref To, CL_CRM_IC_EVENT

2. PARAMS, Returning, Public, Type, O2PARAVALU_TABLE.

Thanks for your quick response.

Suggestion - the cookbook should be enhanced with this level of detail for text replacement using parameters.

Bela

Answers (0)