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:
- Message processor
- Contact person
- 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.
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.
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.
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:
- Name (which holds the names of the added field in the Mail Forms id).
- 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.
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.
*--> loop the ct_att_values will have all the fields whhich described in mailforms
**** change the value for the long text(CRMS_SRQM_GEN_FIELDS-ZZTEXT_LOG) field and modify the values with required data ****
*--> Get the HEADER GUID from table CRMD_ORDERADM_H based on CRMS_SRQM_GEN_FIELDS-CRM_SRQM_NUMBER(OBJECT ID)
*--> get the order text id from FM
*--> LT_ALLTEXT will contain all the text ids which maintained in incident
*--> Add text ids values only for the SU01(REPLY) SU99(DESCRIPTION) SUSO(SOLUTION)
* Implement suitable error handling here
*--> Get the Text ID description from TTXIT tables
*--> Date Time User
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.
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.
Some SOLMAN Tutorials
- SLD Configuration
- Change Impact Analysis with SAP Solution Manager
- SAP ACTIVATE – Simplify Your SAP S/4 HANA Implementation
- How to Save Word Document on Desktop from Web Dynpro using OBN (Object Based Navigation)?
- SAP Fiori Tutorial. Part 7 – Custom Fiori App to Approve Change Requests in SOLMAN
- SOLMAN – Mail Forms Custom Enhancement Guide
- SOLMAN – Understanding Attribute Context & Action Profile in Mail Forms