cancel
Showing results for 
Search instead for 
Did you mean: 

SAP PI 7.31 - File to File Scenario Challenge

arkesh_sharma
Active Participant
0 Kudos

Hi Experts,

I have a file to file scenario in which the Sender system places a file on FTP Directory at source side. PI picks up the file, generates a "FileName" from the contents of the source file and is suppose to pick up a file from another SFTP directory with the same "FileName" and send it to the Source System.

For example, If "Sender A" sends a file "SourceFile.TXT" which has fields "abc" and "def" then I have form a file name "abcdef.TXT" and pick "abcdef.TXT" from the "SFTP Server" and send it back to "Sender A" system.

Initially I thought the scenario is simple but I ended up creating outbound interfaces for both Sender A and the SFTP Server as I need to pick files from both the systems. Also, how should I pass the name abcdef.TXT to the Sender SFTP File channel? Will Dynamic configuration UDF work for this case?

It would be helpful if some helpful suggestions/approach can be provided for this scenario.

Thanks,

Arkesh

Accepted Solutions (1)

Accepted Solutions (1)

udo_martens
Active Contributor
0 Kudos

Hi Arkesh,

the described scenario is not easy to implement because the file sender works only asynchronous. You cant influence the file name to be picked during runtime.

What you can do is to use Directory API (have a look to http://scn.sap.com/community/pi-and-soa-middleware/blog/2012/10/12/using-pi-73-s-directory-api or http://scn.sap.com/community/pi-and-soa-middleware/blog/2008/10/20/directory-api-development--part-1...) to change the second channel's file name and start/stop the channel.

1. Message: Pick a file, execute a mapping, inside the mapping use of Directory's API influencing the other channel

2. The changed channel will pick the file with the dynamic name.

/Udo

arkesh_sharma
Active Participant
0 Kudos

Hi Udo,

Thank You so much for your help and guidance!

I am new to Directory API and I went through the links that you mentioned and I also referred to the blog (http://scn.sap.com/thread/2034141) where the experts are discussing about reading the communication channel properties and then changing them but I do not understand which methods should I use in my code to get the channel, get the channel into edit mode, change the file name property, saving the change list and activating the list.

Could you please guide me a bit more in this regard?

Thanks,

Arkesh

Answers (2)

Answers (2)

Bhargavakrishna
Active Contributor
0 Kudos

Hi,

you can proceed as suggested by udo and pavan..

Regards

Bhargava krishna

former_member200386
Active Participant
0 Kudos

Hi Arkesh,

As Udo said File sender adapter works only asynchronous, better you can split the scenario into 2.

1) Pick the file from Sender A and generate the file name based upon Input fields(File to SFTP)

2)Send the the same file back to receiver(SFTP to File).

Thanks & Regards,

Pavan

arkesh_sharma
Active Participant
0 Kudos

Hi Pavan,

I can generate the file name using Mapping but how should I pass that particular file name to the Sender SFTP Channel ? I need to dynamically update the SFTP channel with that particular file name each time.

Thanks,

Arkesh

former_member200386
Active Participant
0 Kudos

Hi Arkesh,

You can achieve your requirement my small UDF. Please use this below UDF code for your refernece and chang

public String setFileName(String filename_in, Container container) throws StreamTransformationException{

String i_str = filename_in;

try {

DynamicConfiguration config = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

DynamicConfigurationKey FileNameX = DynamicConfigurationKey.create("http:/"+"/sap.com/xi/XI/System/File","FileName");

config.put(FileNameX, i_str);

}

catch (Exception ex)

{

}

  return "";

udo_martens
Active Contributor
0 Kudos

Pavan,

we are talking here about a sender adapter.

/Udo