How to check if a file exists with SAP PRO/SAP PI
Sometimes we have to check if a file has been written on a file system and perform actions based on that. With PI we usually poll a directory using the File Sender Adapter (e.g. in TEST mode if we can not delete the file). Here´s a smarter way:
- Schedule a Trigger that runs the File Check periodically (based on your requirement)
- Read the directory of the NFS/FTP/SFTP using the FileReader Adapter
- Sender: SOAP Message coming from WHINT MessageTrigger Job (of course you can use another trigger like a file sender polling in test mode with channel scheduling)
- Receiver: FileReader Query using WHINT FileReader Adapter
- Both sides use BusinessComponent “FileChecker” here
VOILÁ – here is the message in error (System Error).
If you have defined alerting, an automatic E-Mail is triggered!
In case the file is found, no additional message is being generated. This behaviour can be changed if you change the routing of the Dummy iFlow.