cancel
Showing results for 
Search instead for 
Did you mean: 

Configuring FTP channel to pickup based on Filename

Former Member
0 Kudos

Hello Experts,

I have a requirment to pick up the file from NFS, only when the first 7 postions of the filename is Numerics and next two are alphabets .Else, Ignore.

Actual scenario :

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

Pick up any files ( .pdf ) , and post them to an FTP ( Creating Dynamic directory ).

I have used File sender adapter to pickup the file and delete it when the file gets processed .

And, I have written Java mapping with the following condition to process only when the condition is satisfied  ( when first 7 postions of the filename are numerics and next two are alphabets ).

       String store = oldFileName.substring(0,7);

       String state = oldFileName.substring(7,9);

       Pattern p = Pattern.compile( "([0-9]*)" );

       Matcher str = p.matcher(store);

       Pattern p1 = Pattern.compile( "([A-Z]*)" );

       Matcher st = p1.matcher(state);

      

       if(str.matches())

           if(st.matches()){

       conf.put(KEY_FILEPATH, dir);

       conf.put(KEY_FILENAME, FileName);

Therefore, when filename condition doesn't matches the file from the source is note getting deleted. however, the file is getting copied into the Destination with wrong directory path.

To avoid this I would like to check if there is any condition in File Sender Adapter to check the filename conditions and then process the request .

Thanks for your valuable inputs

Regards,

Ram

Accepted Solutions (1)

Accepted Solutions (1)

former_member184720
Active Contributor
0 Kudos

>>>Therefore, when filename condition doesn't matches the file from the source is note getting deleted. however, the file is getting copied into the Destination with wrong directory path.

Destination folder is getting created as you are not throwing exception when the file name condition is not satisfied.

If you want to throw exception and fail the message try using below method

throw new StreamTransformationException


Former Member
0 Kudos

Thanks Hareesh

this worked

Answers (3)

Answers (3)

iaki_vila
Active Contributor
0 Kudos

Hi Rama,

SFTP supports regex, but like Vishnu said  FTP adapter doesn't. The only ways, to develop a module bean or run OS are not the better ones either. If i was i will continue with the java mapping and if you have enough time i would try to do a module bean.

Regards.

pvishnuvardan_reddy
Active Contributor
0 Kudos

Hi Ram,

I don't think file adapter supports regex in the filename patterns. It will support only placeholders * and ?.

Defining Placeholders, File Name Masks, and Exclusion Masks - Advanced Adapter Engine - SAP Library

Still if you want to handle this in the channel level itself, then you need to check for OS command possibility.

Former Member
0 Kudos

Try Run Operating System Command Before Message Processing option

You can write Unix commands for checking file name and place files in respective directory if it matches your requirement.