Skip to Content

Recently I worked on one required where I want to download /send files to FTPS server, standard PI File adapter will not support implicit FTPS calls, so I decided to use OS commands (shell scripts) to achieve the same.

 

This is very common requirement where you want to perform Archiving, Logging and changing the file name using Shell script. If you have a prior experience  executing scripts using PI, Logging is not possible, when ever we call script using communication channel it gives only stats message shell script is called or not in communication channel monitoring.

 

If any syntax error occurred or no files found in FTP server or any other exception occurrs it is very difficult to find the root cause, so if you perform logging then you can easily solve above issues.

 

Refer below wiki, it gives basic idea how to write and call OS commands in XI/PI.

 

http://wiki.sdn.sap.com/wiki/display/XI/SAP+XI+File+Adapter+OS+Command+Line+Feature

 

 

 image

If you see above image there was a scripting code where I am downloading files from FTPS server and putting in to local XI NFS.

 

Logging :

 

Below statement will generate log file in FTP location with end to end status.

 

exec &> /usr/sap/interfaces/xd5ftp/xxxxxbank/EBS.log

 

image>

Changing the File Name:

 

I want to add the time stamp to file before placing in to target directory, below two lines code required, time stamp format you can change whet ever format you want.

 

 

TSTAMP=`date +%Y%m%d%H%M%S`

DSTFILE=XXXXXbankEBS.$TSTAMP.txt

 

Below statement will download all files from source system and copies in to Target directory with time stamp.

 

get *,byparm $DSTFILE

 

 Archiving:

 

If you want to archive the messages in FTP directory add below code in script, this will move files in to Archive directory.

 

# Archive directory

ARCDIR=/usr/sap/interfaces/ftpus/DEV/BackOffice/Bank/Archive

# Move transferred file to archive directory $ARCDIR

 mv $File $ARCDIR

To report this post you need to login first.

Be the first to leave a comment

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

Leave a Reply