Dear SAP Community Member,
In order to fully benefit from what the SAP Community has to offer, please register at:
Thank you,
The SAP Community team.
Skip to end of metadata
Go to start of metadata

                                      SAP XI File Adapter OS Command Line Feature

1. Introduction

This document discusses and describes about how to call operating system command using file adapter 'Run Operating System Command Before/After Message Processing' to meet a requirement where file adapter need to place newly created file on two separate target directories instead of only one. The operating system command specified here is executed before or after successful file processing. The default value is an empty character string (no command). When the operating system command is called, the file name currently being processed can be specified with the following placeholders: %f (file name) %F (absolute file name including path). We can specify the maximum runtime of the executing program in seconds. When this time interval is exceeded, the adapter continues processing. The executable program continues to run in the background. There is another feature 'Terminate Program after Timeout'. We can set this indicator if the adapter is to terminate the executing program in the event of a timeout. The adapter writes the output (STDOUT and STDERR) for the operating system command in the system trace  
The requirement is to put the file that file created by receiver adapter on two different directory locations instead of only single directory. The feature of creating file on more than one directory is not available at present. So to achieve the objective we need to think of an alternative solution approach.  

2. Requirement

   As shown below , the data need to flow from JDBC to FTP server. The requirement is that file adapter which is creating a target xml file should put the file on two separate directories ( TestTarget and TestSource ).


3.Solution Approach

We can achieve the requirement using different approaches like developing a custom adapter module, OS System Command line feature etc. Here we will use 'Run Operating System Command after Message Processing' parameter.
We create a script file where we put commands for connecting to FTP server and putting the file on a particular destination directory (TestSource). The code for this logic is given below. We then create a batch file to call the above script file. This batch file is put on XI server. The SAP XI Fileadapter will call this batch file after it has created the target xml file on the directory specified in 'Target Directory' parameter (TestTarget).
At runtime when data goes from SAP XI server to adapter engine, the File adapter create TestData1.xml file on TestTarget. After this activity is over, it call the batch file put on XI server. The batch file call the script file which put the newly created TestData1.xml file on an location 'TestSource' directory

 4. Appendix

        Receiver Adapter Configuration.
         OS Command Line.
       Adapter Audit Log Message

Script File  Batch.txt


cd /TestSource
get TestData1.xml
cd /TestTarget
put TestData1.xml


Batch File Content (File_Copy_Batch.bat)


ftp -s:batch.TXT 

Hi all!!

I would like to add up some stuff to this for the one who use UNIX Operating System at their servers.

At the command line we have to mension shell script instead of batch file when we have UNIX OS on Server as shown below. 

we can specify the input parameters to this shell script as shown in the figure. Here %F is source file path, %f is source file name.
content of the script file                                                                                                                                                                                                                                                                                
#!/bin/sh                                                                                                                                                         cd /TestTarget                                                                                                                                             
cat TestData1.xml >> /TestSource/TestData1.xml                                                                                             

1 Comment

  1. Former Member

    HI Ranjeet,

    Can we use Shell Scripts to put the file on FTP Location?

    Are there any commands required to make FTP connection if we use Runtime OS Command after message processing througth FTP Adpater?

    Please specify those for AIX OS..