Wednesday, 07 August 2019 14:10

SOLMAN – Mail Forms Custom Enhancement Guide

Written by https://sapyard.com/solman-mail-forms-custom-enhancement-guide/
Rate this item
(0 votes)

SOLMAN is a very powerful system. Many team use it for documentation and project planning. Many client use it for transport and change management system too. In one

of our previous articles, we showed how to create a custom Fiori App for change management in SOLMAN.

Today, we will look into the Mail Forms which is used in the incident management area. In this tutorial, we will learn how to add a new custom filed in MailForm Attribute category for Attribute context.

What are Mail Forms?

Let me try to explain it in as simple sentences as possible. In SOLMAN system we create Incident or Ticket for the user requests. Whenever incident is created or changed in the system there is an automatic mail that will be triggered. This notification is done with the help of mail forms.

Who gets the mail from SOLMAN?

All the stakeholders of the particular incident/ticket are supposed to receive the mail. In short the below users receive the mail:

  1. Message processor
  2. Contact person
  3. Reported by

What is the t-code to create Incident in SOLMAN?

SM_CRM is the transaction used for creating Incidents.

Depending on the SOLMAN settings, SM_CRM Solution Manager IT Service Management will open in SAP GUI session or it will open in separate webpage link in internet explorer (chrome or other default web browsers).

Once the incident is created, it would look like below.

Mail will be delivered to concern person or team.

Example of a real mail for the generated incident.

Mail will be triggered in above format.

But, clients are a different breed of human. They would usually be not satisfied with what the standard SAP provide. In our case, the business requirement was to have provision to send Long Text Log with the historical updated at the end of the mail.

Consultants throughout the world thrive because of enhancement and customization requests like this. We need to thank our clients for such learning and working opportunities. ? . I am serious.

A sample log of the incident.

But solution is not straight forward.

For ABAP developers, nothing is impossible. You put a requirement, you would get a solution. Sometimes the design is optimized and smooth while at times the developers take a dirty route to meet the business need. ?

In our case, we can achieved this by using Mail Forms with some ABAP enhancements.

Assuming, we have completed our enhancement. The incident alerts after complete of the change would like below with addition of Text log (Long description).

How did we achieve it?

Have patience. ? I will show you step by step, how to enhance the Mail Forms in SOLMAN.

Step 1

For our example, the custom field is added for Attribute Context “Service Request Attributes”.

This Service Request Attributes uses services Attribute Category “SRQ Standard Attributes”.

SRQ Standard Attributes in turn uses the standard structure “CRMS_SRQM_GEN_FIELDS”.

In the structure CRMS_SRQM_GEN_FIELDS, append the required fields using append structure.

We created the append structure ZZCRM_SRQM_TEXT_LOG with domain ZSTRING and data type String to accept long text values.

Step 2

Once the required field is added to the structure CRMS_SRQM_GEN_FIELDS, go to the t-code SM_CRM.

In the left panel, click on Service Operations (highlighted above).

Now click on Mail Forms and Search for Mail Form ID.

For our case, we are doing for Z_MESSAGE_PROCESSOR. Select the Mail Form ID you want to enhance.

Now we need to add the custom field at the required place. In order to add the new place holder, click on Attribute as shown below.

In the next screen search for our field, but here we cannot find technical name. We need to search based on the description we gave to the data element. For us the field label is “Text Log”.

Select the field with Text Log and click on Insert button.

Place the new field at the desired position as demonstrated below.

Step 3

The structure and position of new field is done. Now we need to implement the BADI: “CRM_IM_ADD_DATA_BADI”. This BADI works for Maintain Additional Attributes for Mail Forms Attribute Contexts. It is filter dependent, so we need to select required Attribute Context and Type.

In the Attribute Context select SERVICE REQUEST and Type SQM.

Implement the BADI.

In the method CRM_IM_BPSELE, We need to write our logic to modify the values to populate long text values for Text Log.

Basically, we need to modify the internal table CT_ATT_VALUES. This internal table have two fields:

  1. Name (which holds the names of the added field in the Mail Forms id).
  2. Value (which holds the values of the fields).

We need to modify this table only for the CTT_ATT_VALUES-NAME = “CRMS_SRQM_GEN_FIELDS-ZZTEXT_LOG”.

Then modify the CTT_ATT_VALUES-VALUES = “with respected required info”.

As you can see, field VALUE Data Type is STRING, this is the reason while creating custom field for Text Log we have used String as Data Type. You might be tempted to use char 255 and it might work. But you still run the risk of truncating the characters if they exceed.

Since Text Logs are free texts, using STRING is the safest bet. ?

How to modify internal table CT_ATT_VALUES?

We need to Loop at CT_ATT_VALUES. As mentioned earlier, we need to modify only for the TEXT LOG field “CRMS_SRQM_GEN_FIELDS-ZZTEXT_LOG”.

Below code snippet can be used for reference.

All the Long Text (Text Log details) we have read using FM “CRM_DNO_READ_ORDER_TEXT”.

We need to pass GUID of the Object id (nothing but Incident number).

We can get GUID from table TABLE: CRMD_ORDERADM_H

Then loop at LT_ALLTEXTS (which holds the long text).

Here we have added Text Log only for SU01 (Reply), SU99 (Description), SUSO (Solution). You may debug and check what other codes you may get for the Text Log.

In order to read the text we need to use the world famous FM”READ_TEXT” and pass Text ID, Language, Name, Object.

These values are readily available in LT_ALLTEXTS.
LT_ALLTEXTS-STXH-TDID
LT_ALLTEXTS-STXH-TDNAME,
Object will be CRM_ORDERH.
Language you know. ?

Retrieve the Text Id description from table TTXIT

For Text ID description please check belowscreen shot.

Loop the LT_LINE retrieved from READ_TEXT FM and modify the CT_ATT_VALUES-VALUE.

When we use string all values will be printedin single line like below.

But you do not want a clustered paragraph. You want space and good format.

How to format the string values?

In order to avoid this, we use the command CONCATENATE and SEPARATED BY CL_ABAP_CHAR_UTILITIES=>CR_LF. No need to mention, this command creates new line (it is like return, enter key).

After using CL_ABAP_CHAR_UTILITIES=>CR_LF, the paragraph looks better.

Complete Code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<code>METHODif_ex_crm_im_add_data_badi~crm_im_bpsele.
DATA:lt_alltextsTYPEcomt_text_textdata_t.
DATA:lv_idTYPEthead-tdid,
lv_langTYPEthead-tdsprasVALUE'EN',
lv_nameTYPEthead-tdname,
lv_objectTYPEthead-tdobjectVALUE'CRM_ORDERH',
lt_lineTYPETABLEOFtline,
lv_stringTYPEstring,
lv_string2TYPEstring,
lv_string3TYPEstring.
*--> loop the ct_att_values will have all the fields whhich described in mailforms
LOOP ATct_att_valuesASSIGNINGFIELD-SYMBOL(&lt;line>).
**** change the value for the long text(CRMS_SRQM_GEN_FIELDS-ZZTEXT_LOG) field and modify the values with required data ****
CASE&lt;line>-name.
WHEN'CRMS_SRQM_GEN_FIELDS-ZZTEXT_LOG'.
*--> Get the HEADER GUID from table CRMD_ORDERADM_H based on CRMS_SRQM_GEN_FIELDS-CRM_SRQM_NUMBER(OBJECT ID)
READ TABLEct_att_valuesINTODATA(ls_att_value)WITHKEYname='CRMS_SRQM_GEN_FIELDS-CRM_SRQM_NUMBER'.
IFsy-subrc=0.
SELECTSINGLEguidFROMcrmd_orderadm_hINTO@DATA(lv_guid)
WHEREobject_id=@ls_att_value-value.
*--> get the order text id from FM
CALL FUNCTION'CRM_DNO_READ_ORDER_TEXT'
EXPORTING
iv_header_guid=lv_guid
IMPORTING
et_alltexts=lt_alltexts.
*--> LT_ALLTEXT will contain all the text ids which maintained in incident
LOOP ATlt_alltextsASSIGNINGFIELD-SYMBOL(&lt;fs_alltexts>).
*--> Add text ids values only for the SU01(REPLY) SU99(DESCRIPTION) SUSO(SOLUTION)
IF&lt;fs_alltexts>-stxh-tdid='SU01'OR&lt;fs_alltexts>-stxh-tdid='SU99'OR&lt;fs_alltexts>-stxh-tdid='SUSO'.
lv_id=&lt;fs_alltexts>-stxh-tdid.
lv_name=&lt;fs_alltexts>-stxh-tdname.
CALL FUNCTION'READ_TEXT'
EXPORTING
client=sy-mandt
id=lv_id
language=lv_lang
name=lv_name
object=lv_object
TABLES
lines=lt_line
EXCEPTIONS
id=1
language=2
name=3
not_found=4
object=5
reference_check=6
wrong_access_to_archive=7
OTHERS=8.
IFsy-subrc&lt;>0.
* Implement suitable error handling here
ENDIF.
*--> Get the Text ID description from TTXIT tables
SELECTSINGLEtdtextFROMttxitINTO@DATA(lv_desc)
WHEREtdspras=@lv_lang
ANDtdobject=@lv_object
ANDtdid=@&lt;fs_alltexts>-stxh-tdid.
*--> Date
CONCATENATE&lt;fs_alltexts>-stxh-tdfdate+6(2)&lt;fs_alltexts>-stxh-tdfdate+4(2)&lt;fs_alltexts>-stxh-tdfdate+0(4)
INTODATA(lv_date)SEPARATED BY'.'.
*--> Time
CONCATENATE&lt;fs_alltexts>-stxh-tdftime+0(2)&lt;fs_alltexts>-stxh-tdftime+2(2)&lt;fs_alltexts>-stxh-tdftime+4(2)
INTODATA(lv_time)SEPARATED BY':'.
*--> Date Time User
CONCATENATElv_datelv_time&lt;fs_alltexts>-stxh-tdfuser
INTODATA(lv_date_user)SEPARATED BYspace.
CONCATENATElv_desclv_date_userINTOlv_stringSEPARATED BYcl_abap_char_utilities=>cr_lf.
LOOP ATlt_lineINTODATA(ls_line).
CONCATENATElv_string2ls_line-tdlineINTOlv_string2SEPARATED BYcl_abap_char_utilities=>cr_lf.
ENDLOOP.
CONCATENATE&lt;line>-valuelv_stringlv_string2INTO&lt;line>-valueSEPARATED BYcl_abap_char_utilities=>cr_lf.
lv_string3='------------------------------------------------------------------------------------------------------'.
CONCATENATE&lt;line>-valuelv_string3INTO&lt;line>-valueSEPARATED BYcl_abap_char_utilities=>cr_lf.
REFRESHlt_line.
CLEAR:lv_string,lv_string2,lv_string3,ls_line,lv_desc,lv_id,
lv_name,lv_date_user,lv_string2,lv_date,lv_time.
ENDIF.
ENDLOOP.
ENDIF.
ENDCASE.
ENDLOOP.
ENDMETHOD.</code>

That’s it. You are done. Now ask you business owner to create the incident and get the Text Log in the email. Tell them to send an appreciation mail for you to your reporting manager. ? Don’t forget to showcase this enhancement in your quarterly performance review meeting with your manager. This development is not child’s play. Seriously. ?

On a serious note, I had to toil some late nights to get it done. It might look simple now after going through this article. But believe me, it was not that easy when it was assigned to me.

I have tried to put all the details in this tutorial. But if you still have any doubt, feel free to put your questions in the comments section. I will make sure to reply to each and every query.

Also, this is my first article at SAPYard. Please leave your feedback, suggestions and criticism.

Comments Please!!!

Join our SAP Technical Telegram Group for daily discussion and learning. Ask – Answer, Propose – Defend, Share and Learn in our Motto.You need to install Telegram App first and then click the link in your mobile device. You may also install it in your desktop.

Please SUBSCRIBE to SAPYard’s Youtube Channel for Free End to End SAP Video Course and Training.

Some SOLMAN Tutorials

Read 198 times

Leave a comment

Make sure you enter all the required information, indicated by an asterisk (*). HTML code is not allowed.