Send Email Confirmation After Successful Delivery of the File to Receiver
Introduction
The common requirement is to send email confirmation after successful delivery of the file to the receiver, i see this question asked so many times in SCN example discussion com.sap.aii.utilxi.misc.api.BaseRuntimeException; Content is not allowed in prolog
I want to show you step by step how to implement above requirement in this blog.
Design
Create the data type like below, it can be any data type because the file is non XML.
Create a message type and refer the above data type and create the below service interfaces. One is sender side receive the file, one is to send the file to the receiver and other one for send the mail.
Since file is non XML so select the interface pattern to Stateless (XI30-Compatible) for SenderData_Out service interface then we no need to remove the software component in ICO.
Create below java mapping for dynamic email body when sending the mail.
import java.text.SimpleDateFormat;
import java.util.Date;
import com.sap.aii.mapping.api.AbstractTransformation;
import com.sap.aii.mapping.api.DynamicConfiguration;
import com.sap.aii.mapping.api.DynamicConfigurationKey;
import com.sap.aii.mapping.api.StreamTransformationException;
import com.sap.aii.mapping.api.TransformationInput;
import com.sap.aii.mapping.api.TransformationOutput;
public class DynamicEmailBodyJavaMap extends AbstractTransformation {
@Override
public void transform(TransformationInput transformationInput, TransformationOutput transformationOutput)
throws StreamTransformationException {
StringBuilder sb = new StringBuilder();
try {
DynamicConfiguration conf = transformationInput.getDynamicConfiguration();
sb.append(conf.get(DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File", "FileName")));
sb.append(" file has been sent to POD on ");
sb.append(new SimpleDateFormat("dd/MM/yyyy").format(new Date()));
transformationOutput.getOutputPayload().getOutputStream().write(sb.toString().getBytes());
} catch (Exception e) {
throw new StreamTransformationException(e.getMessage());
}
}
}
Create imported archive and import the java mapping jar.
Create a operation mapping between SenderData_Out and MailReceiverData_In
Configuration
Create IFLOW with interface split, one is to send the file and one is to send the mail. Create 3 sender channels one is pick up the file, one is send the file to receiver and other one is send the mail. Select the operation mapping for mail interface.
Select the check box maintain order at runtime to maintain order for file interface and mail interface, the mail will send only the file delivered successfully.
Receiver mail channel configuration, don’t select the mail package as mentioned in this blog Stop using Mail Package! © – Simplify your mail receiver adapter scenarios and type from, to and subject fields.
Maintain below module configuration in the mail channel.
Testing
Place the file in source directory.
The file delivered successfully and the mail also sent successfully. The order also maintained at runtime according to our configuration.
The file placed in the target directory.
The email sent to the respective person.
Conclusion
Using interface split and maintain separate interface for send the mail and using maintain order at runtime option we can able to send the email after successfully delivered the file to the receiver, i hope this question will not repeat again in the forum ๐ .














Thanks! Praveen
I was struggling for this requirement since 3 months. Finally I did it. ๐
Thanks
Gayathri.
Hi Praveen, Thanks for sharing the document. Praveen. Is there a way that i can generate the Subject of the mail dynamically. if possible kindly share me.
Hi Vijay,
Yes in the java mapping if you set adapter specific message attribute THeaderSUBJECT then you will receive dynamic subject. Check scenario 3 in this blog Stop using Mail Package! © - Simplify your mail receiver adapter scenarios
Regards,
Praveen.
Hi Praveen, Thanks , got it ๐
Hi Praveen
Nice document bro.
Regards,
Anoop Rai
Hi Praveen ,
Can you guide us for getting email notification if the scenario is such that file is not getting successfully delivered to Receiver because of issues in FTP connectivity , server down etc.
Thanks\
Ninad Sane
Hi Ninad,
You can setup alerts for the interface, then any connectivity issues then email will be triggered.
If you have more questions better to open separate discussion.
Regards,
Praveen.