cancel
Showing results for 
Search instead for 
Did you mean: 

Move original file to another folder on SFTP server in case of exception

former_member537554
Participant

Hi all,

In CPI we connect to an SFTP environment with folders input, output and error. The files needed processing are set in the input folder and upon succesful processing we replace them to the output folder. However, in case of an exception we would like move the file to the error folder.

My question is whether this is possible: the SFTP adapter only has a post-processing action and lacks a post-exception action.

The only solution I can come up with is to load the file with a separate flow in a datastore,remove it from the input folder and output it again based on the processing results. But I'd rather move the original file so that the system behind the SFTP environment can check that there is a locked file in the input folder.

Thanks for helping out!

Bram

Accepted Solutions (1)

Accepted Solutions (1)

bhalchandraswcg
Contributor

The path where file is moved Post-Processing can have dynamic constituents. Using this you can determine where file is moved based on property, let's call the property "archiveDirectory". You can set property "archiveDirectory" initially for successful processing to 'output'. For failed processing, set the property "archiveDirectory" in Exception Subprocess ending with Message End.

Your path to move the file post processing could be \${property.archiveDirectory}\${file:name}.

The solution is explained in the blog: Dynamic Setting of Archive Directory for Post Processing in SFTP Sender Adapter

Hope it helps,

Bala

former_member537554
Participant

Thanks for helping out! This is what we were looking for.

Great blog as wel!

Best,

Bram

former_member688311
Discoverer
0 Kudos

> the SFTP adapter only has a post-processing action and lacks a post-exception action.

I feel that this is a serious flaw and should be patched by SAP. I've seen multiple people, myself included, dancing around this problem. In my opinion, the "Error end" -process step should have a checkbox for "Trigger adapter post-processing". I need to see failed messages in CPI monitoring but I also need the erroneous file to go away after the first failed attempt to prevent a flood of error messages.

Does the CPI dev team have a suggestion box?

Answers (5)

Answers (5)

Rich_S
Explorer
0 Kudos

Hi,

Has anyone found a better way to do this? I believe in PI you can sent a separate post processing to run on the SFTP connector as a result of an exception as opposed to a normal run but this isn't available in CPI.

We want to move the file to an archive folder if successful and exception folder if unsuccessful as the process will be a scheduled process and we don't want the same file processed twice. We also need to finish the flow with an error end point as we want ALM to be able to identify interface runs that have run in error and if you use an error end point no post processing currently runs.

Does anyone have a solution to the above (or is anyone aware of any CPI developments to allow separate post processing of FTP files on exception like in PI?)

Many Thanks

Rich

0 Kudos

Hi All,

Did anyone found a better way to delete source file through existing adapter. I am also facing the same issue where my schedule keeps picking the same file and keeps erroring out continuously as my polling frequency is every 5 minutes and my file size is usually huge with 10k CSV records.

Regards,

Appasab

n_rvsavinashvarma
Participant
0 Kudos

Hi Bram,

Hope you are doing good.

Could you please explain how did you solve this scenario.I am facing same issue.Below is my iflow.

Able to move files to success,archive and error directories but unable to delete file from source when iflow is failed.

Thanks,

Avinash

dghammer
Explorer
0 Kudos

Hi Bram,

Did you figure this out? I have the same requirement and am looking at some different options. I would love to know what your solution was. I believe the delete can be done using a Groovy script but am wondering if there is another way or design that would accomplish this.

Thank you,
Doug

former_member537554
Participant
0 Kudos

Hi Doug,

Only for the separate IFlow scenario: so first pick up + delete file, then process and push file accordingly.

I think there no other option with current SFTP adapter than this.

Best,

Bram

Sriprasadsbhat
Active Contributor
0 Kudos

Hello Bram,

Below might help you.

1) Copy the content of file and file into Properties ( Say P_FileContent and P_FileName).

2) In case of exception use Send Step inside Exception with SFTP receiver adapter and set the file name & filecontent stored in property.

Regards,

Sriprasad Shivaram Bhat

former_member537554
Participant
0 Kudos

Hello Sriprasad,

The problem then is that the file is still in the input folder as well, while I would like it to be only in the error folder.

So I think in this case the datastore operation is best then, since you cannot delete files with the SFTP adater (only after processing).

Best,

Bram