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!
Showing results for 
Search instead for 
Did you mean: 
Active Contributor
0 Kudos


The requirement is create a zip file in the target server but we need to create same file name in inside the zip file we are creating. File adapter we can only set the name of the zip file name not the inside file in Zip file, Using message transform bean we can set the static file name but not the dynamic file name, we need to write adapter module to set the file name dynamically.

I want to show how we can implement this in PI/PRO.


Create the sender data type as below.

Create receiver data type like below.

Create two message types using above data types and create below two service interfaces.

Create message mapping for above sender message type to receiver message type.

fileName variable mapping:

I used reusable dynamic configuration UDF's as shown in below blog.
Reuse FunctionLibrary for DynamicConfiguration and Message Header Attributes

Create operation mapping for above message mapping.


Create the below IFLOW in NWDS.

Sender channel configuration:

Enable File Name attribute in adapter specific message attributes.

Receiver channel configuration:

Enable File Name attribute in adapter specific message attributes.

Maintain below modules in the receiver file channel.

I have used custom adapter module to change the content type.
import javax.ejb.CreateException;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;

public class DynamicContentTypeBean implements SessionBean, Module {
private static final long serialVersionUID = 1L;
private SessionContext myContext;
public ModuleData process(ModuleContext moduleContext, ModuleData inputModuleData) throws ModuleException {
String CLASS_NAME = getClass().getSimpleName();
try {
Message msg = (Message) inputModuleData.getPrincipalData();
MessageKey key = new MessageKey(msg.getMessageId(), msg.getMessageDirection());
AuditAccess audit = PublicAPIAccessFactory.getPublicAPIAccess().getAuditAccess();
audit.addAuditLogEntry(key, AuditLogStatus.SUCCESS, CLASS_NAME + ": Module Called");
String source = moduleContext.getContextData("source");
if (source == null) {
throw new ModuleException("Parameter source is missing");
audit.addAuditLogEntry(key, AuditLogStatus.SUCCESS, "Read parameter source: " + source);
String target = moduleContext.getContextData("target");
if (target == null) {
throw new ModuleException("Parameter target is missing");
audit.addAuditLogEntry(key, AuditLogStatus.SUCCESS, "Read parameter newString: " + target);
MessagePropertyKey KEY_FILENAME = new MessagePropertyKey("FileName", "");
String fileName = msg.getMessageProperty(KEY_FILENAME);
audit.addAuditLogEntry(key, AuditLogStatus.SUCCESS, "FileName read successfully. fileName: " + fileName);
fileName = fileName.replace(source, target);
String contentType = "text/plain;charset=\"utf-8\";name=\"" + fileName + "\"";
audit.addAuditLogEntry(key, AuditLogStatus.SUCCESS, "ContentType was set to: " + contentType);
} catch (Exception e) {
throw new ModuleException(e.getClass() + ": " + e.getMessage());
return inputModuleData;
public void ejbRemove() {
public void ejbActivate() {
public void ejbPassivate() {
public void setSessionContext(SessionContext context) {
public void setMyContext(SessionContext myContext) {
this.myContext = myContext;
public SessionContext getMyContext() {
return myContext;
public void ejbCreate() throws CreateException {


I placed the below XML file in the source directory.

The content type was changed as we expected and Zip file was created in target directory.

Target ZIP file was created in the target folder.

Zip file contains the same file name inside.

The content of the file inside the zip file.


Using above custom adapter module we can create a zip file and create the same file name inside the zip file. I hope this helps to the community.
Labels in this area