cancel
Showing results for 
Search instead for 
Did you mean: 

Validation of file name in BPM: Need help for requirement

manikandan_shanmugam3
Active Participant
0 Kudos

Dear All,

Scenario:File to File (pass through ,no mapping is involved)

Source is sending the two file and these two files are related and having the Same file name with different extension(ex:.zip and .txt).PI should validate the file name for the files and transfer if files are present

Requirement: PI should transfer the files if both are present in the source else nothing should be transfer.

i have planned to use BPM to validate the File name and kindly help me to achieve this with your valuable Ideas and reference Links.

Regards,

Manikandan

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi,

One of the possible way to acheive this is

1) Pick .zip and .txt file

2) Place .txt file in folder1 of XI by receiver file adapter

2) Change filename of .zip file to .txt file and place it in folder2 of XI

Now use 2 file sender channels where 1st channel will poll for folder1 and second channel will poll for folder2. And both the files in folder1 and folder2 are of same name. And you can use corelation based on filename.

Thanks and Regards

Suma S

anupam_ghosh2
Active Contributor
0 Kudos

Hi Manikandan,

what is the operating system your PI server? Assuming its UNIX ,this can be easily tested with shell script.

Here is the algo of the script.

1. Check whether there are exactly two files in the source directory from where communication channel is picking up the files.If the files are not posted simultaneously wait for sometime that you can set the parameter for sleep command .

2. Check whether there is one file of type Zip and other of type txt.

3. incase above requirements are not met delete both the files.

4. end the script.

The script needs to be called before the channel picks up any file. The script is to be called from the option " Run operating system command before message processing". There is an option called "command line" there you can mention the absolute path of the script such as "sh myscript.sh "

I can suggest the coding will look something like this but since I have no access to UNIX server command line right now you might have to do necessary corrections and use it. The script here waits 60 secs for two times i.e. in total for 2 minutes for both files to arrive. If still it does not find any one of the files or both, it deletes the .txt and .zip files in the directory. Thus PI is never able to read the files at all. If only both files are present the script ends and PI server picks it up for processing.

 
count=`expr $2 + 0` 
while [ $count -gt 0 ] 
do    
                   a=`ls  -l  *.txt 2>/dev/null | wc - l` 
                   b=`ls  -l  *.zip 2>/dev/null | wc - l` 
                   a=`expr $a + 0` 
                   b=`expr $b + 0` 
                   if [ $a -eq 1 ]; then 
                             if [ $b -eq 1 ]; then 
                                      break; 
                             fi 
                   fi 
                   sleep 60 
                   count=`expr $count - 1` 
done 

if [ $a -ne 1  -o  $b -ne 1]; then 
                  rm  -f  *.txt   *.zip 
fi 

Hope this helps. In my view if you use scripts, you may not require an BPM at all.

I just read your response that scripts are not to be used. Please ignore this post.

This is going to be difficult without scripts it seems.

Regards

Anupam

Edited by: anupamsap on May 23, 2011 12:44 PM

Former Member
0 Kudos

Hi,

If you can include the filename as part of your payload, you can do the correlation based on that. But please bear in mind that even then, you would need to convert the files to xml format as otherwise, the correlation can not be defined.

Regards

Former Member
0 Kudos

HI,

ccBPM can't do correlation on ASMAs so try using a script that would be called before polling that does the test and then renames the file to the right pattern.

manikandan_shanmugam3
Active Participant
0 Kudos

Hi,

We are not allowed to use scripts in My company.

Note: this is a pass through interface and we are passing the zip files which contains the multiple files.