cancel
Showing results for 
Search instead for 
Did you mean: 

File Adapter: Run operating system command before processing message

Former Member
0 Kudos

Hi all,

I was wondering whether anyone has ever tried to dig a little deeper into this. Let's say we have a sender file adapter that polls a certain directory for files. If it encounters a match of the file name mask, it should run an OS command, triggering a copy script. So far, simple enough.

However, is it somehow possible to check the output of this script and depending on that output, archive the file or leave it in the folder? I have my doubts. 🙂 If anyone has any ideas on this matter, feel free to post them. (I know I could write the script to check it and do the archiving in case the file was copied correctly - but I'm still curious as to the options in the file adapter when it comes to these OS commands - they seem rather limited).

Looking forward to your ideas!

Regards,

Aerv

Accepted Solutions (1)

Accepted Solutions (1)

former_member184681
Active Contributor
0 Kudos

Hi Aerv,

Here is what SAP Help says about the OS command processing status:

Message processing is independent of any errors that occur during the execution of a configured operating system command.

Based on that, what you're expecting to do is not possible. And yes, this OS command functionality does have some important limitations, which is why people tend to look for workarounds instead of using it.

If you asked me how I would approach your scenario, I would say: create two separate scenarios. One of them will be a simple pass-through with no mapping, only to control the files and copy/move/archive/delete them accordingly, as per your requirement. The other one would read some other directory where the files for processing are moved by the first interface. If you approach it that way, everything stays under PI's control.

Regards,

Greg

Answers (2)

Answers (2)

Former Member
0 Kudos

Thanks all for your helpful replies. I have solved this issue by creating a custom adapter module. However, I have run into another issue. When a message is not suited, I would like to stop processing it. However, if I raise a ModuleException, the processing stops entirely and all further messages are not processed. Is there a way to skip the message and continue processing the others? I was thinking of clearing the file's content and then check the option in the adapter to do nothing with empty files. Would that be an option? Or is the file's content checked before CallSapAdapter module of the File Sender Adapter?

Thanks for your help!

baskar_gopalakrishnan2
Active Contributor
0 Kudos

Yes all things might not be able to make just using os command script. As greg mentioned you can split the task in to two. If you want to handle the archive,copy to the approriate directory with regards to file name, then can be handled using script alone which can run through cron job at specified interval of time.  The second step is just using PI to look the file at the desired folder.