cancel
Showing results for 
Search instead for 
Did you mean: 

Send second file based on success of first file posting

0 Kudos

Hi All,

I have a requirement - file to file scenario. On successful writing of file to target, PI should write the same file to target2 (actually on source system). This way user makes sure that the transmission was successful. This riquirement need to be done using one interface only in SAP PI 7.3.

I had created a BPM which has a receive step, send step 1 and send step 2. Trying to get an exception for send step 1 when file writing was unsuccessful, so I can come our of the block without writing the second file. Not getting how to use exceptions here.

Please advice here. Also let me know if there is any other simple way to attain this.

Thank you in advance!

Kumaran

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

File adapter supports Transport ack..so in the first send step you can request for Transport ack., and if the ack. is not successful, using deadline step you can throw (after 16 minutes) an exception and then in the exception branch depending upon ur requirement you can throw an alert/cancel the process or using another send step create a error file....but if the ack in first send step is successful then the second send step in series will be executed

so your block will have : 1 normal branch, 1 deadline branch and 1 exception branch

Thanks

Amit Srivastava

Answers (2)

Answers (2)

anupam_ghosh2
Active Contributor
0 Kudos

Hi Kumaran,

                      Are you usinfg FTP or NFS in file receiver adapter? The answer to this question determines how you are actually going to test if the first file has been written completely and correctly. As Amit has mentioned you can ask for ack.

In another way testing of this can be done  using a UDF in message mapping. I am adding a small code snippet which you can use in the UDF in message mapping after send step 1.

String path="C:\\Apps\\hello.pdf";

public static String Function (String path)

{

     String s="";

     java.io.File newFile = new java.io.File (path);

     s=s+newFile.exists();

     System.out.print(s); //prints true if file exists or false if it doesnt exist.

     return s;    

}

The message mapping will be included in transformation step after send step 1.

The output of the UDF will be stored in a target XML field say "STATUS".

Now you need  a branch/switch block where you need to add one condition.

The condition would look like  /p1:MT_MAPPING/RECORDSET/STATUS=true depending on you target message XSD.

After this in the positive branch of the switch add the second send step which you have already designed. In this way you may not need an exception.

Regards

Anupam

rajasekhar_reddy14
Active Contributor
0 Kudos

Hi ,

Amit solution looks promising,

my suggetsion is , perform file look up after send1 step in BPM if file found in FTP then send message to Target 2.

After send step you can use wait step 1 minute then execute mapping 2.

i hope you are clear with my design.

Regards,

Raj