Customer Relationship Management Blogs by Members
Find insights on SAP CRM and other customer relationship management products and topics in blog posts from community members and share your own perspective.
Showing results for 
Search instead for 
Did you mean: 
Active Contributor

Hi All,

You would have seen most of the times our IC agent inbox e-mails will be with "Medium" priority by default. One of the interesting requirement I got recently was to set the priority of incoming e-mails based on different conditions. Requirement in complete was, if user has marked the email as 'High importance' or the email subject contains some words like 'Urgent', 'Last reminder' etc, then the IC agent inbox email also should have priority as 'High'. As usual, the first place for getting something for this requirement was nowhere else other than SCN. I didn't get a complete solution though, I got something to start from one of the threads' question answer section.

First thing I checked was, whether it's possible to set the priority like this manually for an email. Yes..It's possible via transaction code SWI1 to change the priority. Now the question is, how to automate this functionality.

For debugging an incoming email, we can set the debugging parameter in the following path,

SPRO->Customer Relationship Management->E-mail response management system->Define Repository or transaction CRMC_ERMS_REPOSITORY. For context ERMS, insert a property 'DEBUG' and value as 'X'. This is a SAP hard-coded break that stops the routing and waits for you in sm50 to debug. Now you can debug in SM50.

Following are the steps I found after some debugging and analysis.

1. Go to tcode SWO1 and create a sub object for ERMSSUPRT2.


2. Redefine the method RuleExecution in the Z-object.

3. Now this method is the place where you have to make the code changes.

In our case, we created a custom table where we can store the words which needs to be considered as high priority. This allows if in case tomorrow we need some extra words also to be considered.

Insert following code here,..
*   Get specific words from customizing table
INTO TABLE lt_prio_key.

IF sy-subrc = 0.
* Loop to check if subject contains any string from the table maintained values.
LOOP AT lt_prio_key INTO ls_prio_key.
TRANSLATE ls_prio_key-key_string TO UPPER CASE.

lv_sub_upper = sub .

IF lv_sub_upper CS ls_prio_key-key_string.
lv_wi_text_import = 1.

Now we got whether there are any words which is to be set to high. We need to check whether the email was sent with high priority also. Hence, add the following code.
      lt_factbase =  service_manager->factbase.
* Get priority email setting
CALL METHOD lt_factbase->get_by_xpath
id_xpath = '/parts/EMAIL/PRIORITY/text()'
rd_result = lv_prio.

Considering the values found from above, we have to set the priority of email. Hence, use the FM "SAP_WAPI_CHANGE_WORKITEM_PRIO" for setting the priority.
IF lv_wi_text_import EQ 1 OR lv_prio EQ 1.
* Change priority
workitem_id = flowitemid
priority = '4'
language = sy-langu.

4. We are done with coding part now. The next is to set the z-bject type is released.

5. And the last step is making the z-object as the delegated type for ERMSSUPRT2. This is to be done in SWO6 transaction.

Now go to your inbox and see whether the email with 'High importance' has come with priority 'High'.

Please let me know if you have any queries.