Skip to Content
Author's profile photo Praveen Gandepalli

Pick Up The Files From Dynamic Directory Using Sender File Adapter


The requirement is to pick the files from dynamic directory using sender file adapter as mentioned in below question
Move Folders containing multiple file with File adapter

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


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.

Since file is non XML so select the interface pattern to Stateless (XI30-Compatible) forSenderData_Out service interface then we no need to remove the software component in ICO.


Create below java mapping to set the file name and directory using dynamic configuration.


public class SetFileNameDirectoryJavaMap
  extends AbstractTransformation
  private static final String NAMESPACE = "";
  public void transform(TransformationInput transformationInput, TransformationOutput transformationOutput)
    throws StreamTransformationException
      DynamicConfiguration dynConfig = transformationInput.getDynamicConfiguration();
      DynamicConfigurationKey FILE_NAME = DynamicConfigurationKey.create("", "FileName");
      String fileName = dynConfig.get(FILE_NAME);
      String[] parts = fileName.split("/");
      dynConfig.put(FILE_NAME, parts[1]);
      dynConfig.put(DynamicConfigurationKey.create("", "Directory"), "/usr/sap/intf/test/FileData/In/" + parts[0]);
      IOUtils.copy(transformationInput.getInputPayload().getInputStream(), transformationOutput.getOutputPayload()
    catch (Exception e)
      throw new StreamTransformationException(e.getMessage());

Create imported archive and import the above java mapping.

I am using IOUtils class from commons IO, so you need to import this jar in common software component then create the dependency for your original software component then this jar will be available.




Create the below IFLOW in NWDS.


Configure the sender channel like below,

Enable FileName under adapter specific message attributes.

Maintain below values in FileName and Directory in receiver file channel.

Enable FileName and Directory under adapter specific message attributes.


Files are placed in the source directory.

The file name comes with folder and the file name, The file successfully written to the dynamic target directory with source file name.

The folder and files are placed in the target FTP server.

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      Hello Praveen,

      I'm trying your approach but I need to create dynamic target directories. Is this possible with the File Adapter?


      Author's profile photo Long Nham Duc
      Long Nham Duc

      Hi Preaveen,

      I am facing exactly same the problem need to be resolved. Thanks for your post so much! But in theĀ  sender directory you only put http://usr/sap/intf/test/FileData/Out/, and file is *. And actually in this folder contains subfolder is 18102016. Then how in runtime it understands the file is /18102016/File1.txt? Normally Sender channel looking file in parent folder, if there is not any file, it doesn't looking in child folder right?

      Thanks you so much!