Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Community
[SAP HCP-IS ]Exception Sub Process-How to create Alert body for Error Noti cation
Follow RSS feed Like
Introduction:
This blog describes how to create and handle dynamic alert noti cation inside the Exception Sub Process in SAP HCI.
About Exception Sub Process:
Exception Sub Process can catch any exceptions thrown in the integration process and process them.Below parameters will give more details of the the
exception raised.
Use Case:
Lets create Custom integration where we will pull the File from SFTP server and save it in data store.
https://blogs.sap.com/2017/01/16/sap-hcp-is-exception-sub-process-how-to-create-alert-body-for-error-notification/ 1/20
1/28/2020 [SAP HCP-IS ]Exception Sub Process-How to create Alert body for Error Notification | SAP Blogs
3. Content Modi er: To read the key details of incoming message.In our case we are capturing input le name.
https://blogs.sap.com/2017/01/16/sap-hcp-is-exception-sub-process-how-to-create-alert-body-for-error-notification/ 2/20
1/28/2020 [SAP HCP-IS ]Exception Sub Process-How to create Alert body for Error Notification | SAP Blogs
4. Script: To read the tenant details in run time( in our case tenant id is of 5 character length like X1234 ,L1234 ) and stores it in property.
5. Script: Erroneous script to forcefully fail the message and trigger exception.
6. Data Store: Store the output ( In the above case its just added to have an end to end ow ).
7. Content Modi er: Content Modi er [ Body ] to build the email body.
Content Modi er [ Header ] to set the exception stack trace into header which is later sent as a attachment.
https://blogs.sap.com/2017/01/16/sap-hcp-is-exception-sub-process-how-to-create-alert-body-for-error-notification/ 3/20
1/28/2020 [SAP HCP-IS ]Exception Sub Process-How to create Alert body for Error Notification | SAP Blogs
8. Send: Send step is used to send the message to External Systems Asynchronously.
9. Channel: Mail adapter to send the exception details to mail receiver.
Once you are done with above con guration save and deploy the Integration Project.
Place a test le in SFTP share and you will be able to nd the below Error Alert Mail triggered from Exception Sub Process.
https://blogs.sap.com/2017/01/16/sap-hcp-is-exception-sub-process-how-to-create-alert-body-for-error-notification/ 4/20
1/28/2020 [SAP HCP-IS ]Exception Sub Process-How to create Alert body for Error Notification | SAP Blogs
Regards,
Sriprasad Shivaram Bhat
Alert Moderator
Assigned tags
SAP Cloud Platform Integration for process services | SAP Cloud Platform Integration tools | SAP Process Integration |
How to Integrate S4Hana Cloud and On-premise System Using SAP Cloud Platform Integration – Part2
By Pavan kumar , Jun 12, 2018
Related Questions
https://blogs.sap.com/2017/01/16/sap-hcp-is-exception-sub-process-how-to-create-alert-body-for-error-notification/ 6/20
1/28/2020 [SAP HCP-IS ]Exception Sub Process-How to create Alert body for Error Notification | SAP Blogs
Is it possible to capture the exceptions and send that to mail ID by using scripts in SAP HCI.?
By Devaraj R , Jun 12, 2017
How to handle exception in HCI IFLow
By Poornapragna TS , Mar 06, 2017
20 Comments
Aditya W. Sharma
Like (1)
aravind pujari
Hi Sriprasad,
https://blogs.sap.com/2017/01/16/sap-hcp-is-exception-sub-process-how-to-create-alert-body-for-error-notification/ 7/20
1/28/2020 [SAP HCP-IS ]Exception Sub Process-How to create Alert body for Error Notification | SAP Blogs
Like (1)
Former Member
Thanks Sri..
Very informative..
We are working on SF integration, where we need to fetch employee records and send those records to SFTP server via SAP HCI. We have placed
transformation rules in HCI to validate the data coming from SF.. Just wanted to check what is the possibility to check the below
Thanks in advance..
Aman
Like (2)
Former Member
https://blogs.sap.com/2017/01/16/sap-hcp-is-exception-sub-process-how-to-create-alert-body-for-error-notification/ 8/20
1/28/2020 [SAP HCP-IS ]Exception Sub Process-How to create Alert body for Error Notification | SAP Blogs
I am using your code in sub process exception and when trying to execute am getting the substring can’t be invoked. Please nd the code which am using
below and please let me know if you see any error. I have also pasted the error message for your reference.
/*
The integration developer needs to create the method processData
This method takes Message object of package com.sap.gateway.ip.core.customdev.util
which includes helper methods useful for the content developer:
The methods available are:
public java.lang.Object getBody()
public void setBody(java.lang.Object exchangeBody)
public java.util.Map<java.lang.String,java.lang.Object> getHeaders()
public void setHeaders(java.util.Map<java.lang.String,java.lang.Object> exchangeHeaders)
public void setHeader(java.lang.String name, java.lang.Object value)
public java.util.Map<java.lang.String,java.lang.Object> getProperties()
public void setProperties(java.util.Map<java.lang.String,java.lang.Object> exchangeProperties)
public void setProperty(java.lang.String name, java.lang.Object value)
*/
import com.sap.gateway.ip.core.customdev.util.Message;
import java.util.HashMap;
def Message processData(Message message) {
//Body
def body = message.getBody();
// Fetch Application URL
String appUrl = System.getenv(“HC_Application_URL”);
// Retrieve HCI tenant name
String TMN_ShortName = appUrl.substring(8,13);
// Set Tenant name to property
message.setproperty (“P_Tenant_Name”,TMN_ShortName);
return message;
}
https://blogs.sap.com/2017/01/16/sap-hcp-is-exception-sub-process-how-to-create-alert-body-for-error-notification/ 9/20
1/28/2020 [SAP HCP-IS ]Exception Sub Process-How to create Alert body for Error Notification | SAP Blogs
HS
Like (0)
Hello Hari,
You must correct the line where you are pulling environment details.Since there are no details being pulled its giving an error.
Environment variables are case sensitive and you must pass the above one it will solve your issue.
Regards,
Like (0)
Hari Sonnenahalli
Sri-
https://blogs.sap.com/2017/01/16/sap-hcp-is-exception-sub-process-how-to-create-alert-body-for-error-notification/ 10/20
1/28/2020 [SAP HCP-IS ]Exception Sub Process-How to create Alert body for Error Notification | SAP Blogs
Thanks for quick reply. One quick question, Where did you provide the environment variable (“HC_APPLICATION_URL“).
Thanks
HS
Like (0)
Hello Hari,
https://blogs.sap.com/2017/01/16/sap-hcp-is-exception-sub-process-how-to-create-alert-body-for-error-notification/ 11/20
1/28/2020 [SAP HCP-IS ]Exception Sub Process-How to create Alert body for Error Notification | SAP Blogs
Like (0)
Hari Sonnenahalli
Yes, I know where you have used in the code. My question is the naming convention(HC_APPLICATION_URL) which you have used is retrieved from somewhere
on the tenant and is it a standard. The reason I am asking is when used a proper case it was throwing an exception.
Thanks
HS
Like (0)
https://blogs.sap.com/2017/01/16/sap-hcp-is-exception-sub-process-how-to-create-alert-body-for-error-notification/ 12/20
1/28/2020 [SAP HCP-IS ]Exception Sub Process-How to create Alert body for Error Notification | SAP Blogs
Hello Hari,
I am able to successfully retrieve the Tenant ID using below script may be you can try copy pasting the same.
import com.sap.gateway.ip.core.customdev.util.Message;
import java.util.HashMap;
import java.io.*;
//Retrieve Body
def body = message.getBody();
return message;
}
Regards,
https://blogs.sap.com/2017/01/16/sap-hcp-is-exception-sub-process-how-to-create-alert-body-for-error-notification/ 13/20
1/28/2020 [SAP HCP-IS ]Exception Sub Process-How to create Alert body for Error Notification | SAP Blogs
Like (0)
Former Member
regards,
Christian Caldwell
Like (0)
Former Member
Is there any way to set a cadence to when these alerts are sent? We have a ow that was built and it checks every 10 minutes for new data (we need the
systems in sync as much as possible). And if there is an API error, for example, we will get an error email every 10 minutes. Is it possible to send once an hour
or some other time frame? We ultimately just need to be noti ed the rst couple times that there is an issue.
Thanks,
https://blogs.sap.com/2017/01/16/sap-hcp-is-exception-sub-process-how-to-create-alert-body-for-error-notification/ 14/20
1/28/2020 [SAP HCP-IS ]Exception Sub Process-How to create Alert body for Error Notification | SAP Blogs
Kenny
Like (0)
Yes you can do it with some more extra e orts:(,inside Exception Sub Process instead of Send Step you can have a data store ( with Global Scope ) and store
every error message in some XML format.
Create one more ow which is Scheduled for every hour to pull the data from the data-store which was created earlier in Exception SubProrcess and send an
alert email to Support Team or whomever you want to send.
Regards,
Like (0)
Former Member
Like (0)
Devaraj R
Hi Sriprasad,
https://blogs.sap.com/2017/01/16/sap-hcp-is-exception-sub-process-how-to-create-alert-body-for-error-notification/ 15/20
1/28/2020 [SAP HCP-IS ]Exception Sub Process-How to create Alert body for Error Notification | SAP Blogs
But in our case we have around 60+ integrations in our tenant and we need this mail noti cation to be triggered immediately for each message failure which is
occurring in our tenant for all these integrations.
It’s di cult to con gure this Exceptional sub process in all our integrations.
Any possibility to simplify this and achieve or any other alternative ways.?
Regards,
Deva
Like (0)
Hello Deva,
If you want to receive the email for each integration then you have to add it explicitly in 60+ scenarios. In case if you are yet to create custom integration you
can have some simple ow with above steps and save it as Template.Later for other integration,template with error handling steps would be starting point.
Regards,
Sriprasad S Bhat
Like (0)
Devaraj R
https://blogs.sap.com/2017/01/16/sap-hcp-is-exception-sub-process-how-to-create-alert-body-for-error-notification/ 16/20
1/28/2020 [SAP HCP-IS ]Exception Sub Process-How to create Alert body for Error Notification | SAP Blogs
Hello Sriprasad,
Plz provide further details on how to use Save as template and where I can get that.
I am getting the mail if there is any exception/error in the integration. But messages are showing as completed even if there is any exception/error. It should be
shown as failed message right.?
But no messages shown in failed status even if there is error in the integration, showing all messages are completed. While opening MPL Logs only I am able to
check whether there is any error or any issue. Why is it so.?
Regards,
Deva
Like (0)
Hello Deva,
https://blogs.sap.com/2017/01/16/sap-hcp-is-exception-sub-process-how-to-create-alert-body-for-error-notification/ 17/20
1/28/2020 [SAP HCP-IS ]Exception Sub Process-How to create Alert body for Error Notification | SAP Blogs
I have written a blog on the same refer the same for more detail.
https://blogs.sap.com/2017/06/15/sap-cloud-platform-integration-creating-reusable-templates/
By default in Exception Sub process End Message step will be there.From past 3 release onward behavior of the End Message step changed.End Message step
inside exception will set the Overall Message Status to Completed,if you want to set it as Failed please use Error End Event instead of End Message Event.
Regards,
Like (0)
Sidharth Mehta
Hi Sriprasad,
Please help.
https://blogs.sap.com/2017/01/16/sap-hcp-is-exception-sub-process-how-to-create-alert-body-for-error-notification/ 18/20
1/28/2020 [SAP HCP-IS ]Exception Sub Process-How to create Alert body for Error Notification | SAP Blogs
Regards,
Sidharth
Like (0)
Former Member
Can we send email noti cations to particular users only based on reading error records?
Like (0)
Amber Badam
Excellent blog!! kudos to you. Thank you for sharing. Didn’t knew we could retrieve the tenant name and system URL.
Like (0)
Find us on
https://blogs.sap.com/2017/01/16/sap-hcp-is-exception-sub-process-how-to-create-alert-body-for-error-notification/ 19/20
1/28/2020 [SAP HCP-IS ]Exception Sub Process-How to create Alert body for Error Notification | SAP Blogs
Newsletter Support
https://blogs.sap.com/2017/01/16/sap-hcp-is-exception-sub-process-how-to-create-alert-body-for-error-notification/ 20/20