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 .
TRANSLATE lv_sub_upper TO UPPER CASE.