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.

/wp-content/uploads/2016/09/filedata_1035253.png

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.

serviceInterface.png

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.

/wp-content/uploads/2016/09/xi30_1035348.png

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.

importedArchive.png

Create a operation mapping between SenderData_Out and MailReceiverData_In

opearionMapping.png

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.

IFLOW2.png

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.

interfaceSplit.pngmaintainOrder.png

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.

mailConfig.png

Maintain below module configuration in the mail channel.

moduleConfiguration.png

Testing

Place the file in source directory.

outFile.png

The file delivered successfully and the mail also sent successfully. The order also maintained at runtime according to our configuration.

sequenceNumber.png

The file placed in the target directory.

inboundFile.png

The email sent to the respective person.

emailConfirm.png

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 😉 .

To report this post you need to login first.

7 Comments

You must be Logged on to comment or reply to a post.

  1. Ninad Sane

    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

    (0) 
    1. Praveen Gandepalli Post author

      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.

      (0) 

Leave a Reply