cancel
Showing results for 
Search instead for 
Did you mean: 

Process files (SFTP) based on Filename

markbernabe
Active Participant
0 Kudos

Hi,

I have a scenario wherein I have to poll and pick up files (SFTP) at certain times of the day (i.e. 12pm, 3pm, 4pm, 9pm) and I've implemented ATP to achieve this. The filename indicates the time that it needs to be processed. For instance, 'Filename_HH.xml' where HH is the processing time (i.e. Filename_12, Filename_15). So at 12pm, I only need to pick up Filename_12, then at 3pm, get Filename_15 and so on. How can I instruct the channel to do this?

Thanks!

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Why not use the "Run Operating System Command Before Message Processing" to run a script that will determine what hour it is and then change the file name based on that. Then have your CC channel look for the changed name

So if it is 3:00PM (1500 hours) the script will notice it is 15, change Filename_15 to Filename_PROCESSNOW and the channel will only look for Filename_PROCESSNOW.

Hope that helps.

markbernabe
Active Participant
0 Kudos

Hi Dave,

Thanks a lot. Do you know any guide that explains how to access the FTP in the shell script?

Former Member
0 Kudos

No I am sorry I don't. What you can do is create a .bat file in a folder and place your scripts in that file. Then in the "Run Operating System Command Before Message Processing" field, place the path to that .bat file.

For example \\localPIMachine\FileRename.bat

Where FileRename.bat contains Windows Scripting to look for all files in a certain folder with a certain name and rename them. You will probably have to map a drive from the PI server to the FTP server so you can access the folder on the FTP server by drive letter. i.e. G:\.

Hope this helps

anupam_ghosh2
Active Contributor
0 Kudos

Hi Mark,

                do you need SFTP or FTP??

what is the operating system of your Pi server?

Regards

Anupam

markbernabe
Active Participant
0 Kudos

Hi Anupam,

I'm using SFTP and it's in Unix so I created shell scripts (.sh).

Answers (5)

Answers (5)

psierrag
Member
0 Kudos

Hi ,

Use Regular Expressions:

Ej. 

FileName.*\.xml 

View this document Configuration Guide SAP® Secure File Transfer Protocol Adapter Using SAP NetWeaver Process Integration

iaki_vila
Active Contributor
0 Kudos

Hi 

vedrankubelka
Explorer
0 Kudos

Hm, yes. That is not good solution for this. That wouldnt solve problem to take file at exactly time. And my answer is for totally different question.

Sorry

gagandeep_batra
Active Contributor
0 Kudos

Hi Mark

As vedran said you can do this with mapping with date function

plz see below:

& i use following code:

---------------------------------------------------------

DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");

String SourceFileName = conf.get(key)

String fname = SourceFileName + var1;

conf.put(key,fname) ;

return "" ;

------------------------------------------

and remember also to select ASMA parameter at sftp side also

Regards

gAgan

markbernabe
Active Participant
0 Kudos

Hi Gagandeep,

Can you re-upload the image again? It's not getting displayed. Thank you.

gagandeep_batra
Active Contributor
0 Kudos

You can check it in another browser

vedrankubelka
Explorer
0 Kudos

Hi, in mapping you can define what is file name.

Something like this with time function

DynamicConfiguration conf = (DynamicConfiguration) container

.getTransformationParameters()

.get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

String fname = "your file name";

DynamicConfigurationKey key = DynamicConfigurationKey.create( "http://sap.com/xi/XI/System/File", "FileName");

// set up file name for receiver adapter

String SourceFileName = conf.get(key);

conf.put(key, fname);

return " ";

This function is mapped on top element. And in communication channel put "*" as File name

iaki_vila
Active Contributor
0 Kudos

Hi Mark,

I dont know if your SFTP adapter if it is from SAP in 7.3 version or an external one. I think that you could do two scenario SFTP - FILE and FILE-XXXX. The first one you get all the files in the SFTP server and they will be downloaded in filesystem availabe via NFS by PI . In the second one scenario you could get the files by date in the name with:

1. OS system command as Dave said. Check this thread: http://scn.sap.com/thread/1725145

2. Via directoy api. I havent done this, and i dont know 100% secure that it will works. Check the remarkable William Li's document: http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/c0487ced-f537-2d10-249d-f6c7323c2...

Regards.