Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
former_member182412
Active Contributor

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 :wink: .

7 Comments
Labels in this area