No File ? Send Email : Send Target System
This blog topic has been a very common integration requirement in SAP XI/PI integration world and unfortunately there is no simple solution for this requirement. Some solutions were provided by forum experts such as run OS script (not actually using XI), using extra administrative scenario and checking for time stamp, using script with extra administrative scenario etc. The below discussions and blog will explain sample such requirements and solutions.
I started thinking if this requirement can be achieved in a better way but yet with only classical configuration (no BPM & no extra administrative scenario). After some deep thinking, I came up with two ideas. One option is to use very simple alert to send email to business Admin user for failing sender channel indicating no business data for the day (ah, how sender channel can fail?). The second option is to configure an end to end scenario and send either actual business data or email accordingly (again how?). The below steps will explain my solutions.
- Obviously, we need a trigger file(.txt) which should be pooled in TEST mode by a scheduled Sender File channel as per business requirement.
- The trigger file should have same structure as main business payload (.xml), but however with only one field 🙂 . The field value will be very useful in evaluating conditions either in Receiver determination or in multi-mapping, to decide the actual receiver i.e., Target (or) an email to Target system business owner/administrator e.g., If Business data payload has <MT xmlns:ns0=”abc.com”><f1/><f2/><f3/>…<fn/></MT>, then trigger file can have data <MT xmlns:ns0=”abc.com”><f1>SendEmail</f1></MT>.
- Two solutions,
- First simple solution:- Use “Additional files” option in sender file channel to pick up business data as a MANDATORY attachment. i.e., the file channel will fail with error if there is no attachment (actual business Data). Note:- With this solution, step2 trigger file can be empty or can have any dummy data
- Second Solution:- Use the same “Additional files” option in sender file channel to pick up business data but as an OPTIONAL attachment. i.e., the file channel will never fail with error when there is no attachment.
- For solution 3a,
- Failure Case: configure a simple alert and send alert to the subscribed business user as an email indicating that there is no file for actual business data for the day
- Successful Case: Configured PayloadSwapBean will treat attachment (actual business data) as main payload and then the rest the configured scenario will take care of sending actual business data to target system
- For Solution3b,
- – Configured PayloadSwapBean will treat attachment (business data) as main payload, if the business data file exists
- – With simple routing conditions (details as explained in step-2), now XI can decide the actual receiver. Obviously, when there is no attachment for business data, the “SendEmail” condition will match.
5. Since File sender channel is configured in TEST mode, use script in the channel under “Run OS command after message processing” to archive the business data(.xml) to ARCHIVE folder. Step 5 is common for both 3 a&b successful case solutions.
I tested both the solutions and they are working like a charm for File NFS protocol. The solution can be extended to File FTP protocols as well but with a custom adapter module. The custom adapter module for FTP protocol should have functionality similar to “Additional Files” option in Sender File channel with NFS protocol. i.e., the custom adapter module should be able to attach actual business data and then it should archive after processing.
updated on 08/13/2013: Few corrections for Step4 content
Hope this new solutions helps.