cancel
Showing results for 
Search instead for 
Did you mean: 

File adapter - How to pass File name and path at runtime

Former Member
0 Kudos

Hi gurus,

We want to use PI 7.0 as an ftp server and expose the config as a webservice where the service consumer can pass one or more file names and the path to pick them and drop them on a fixed ftp server.

So precisely, I need to be able to set the file name, target directory parameters in both sender and receiver file/ftp adapters at runtime. is this possible at all ?

I am aware of passing Adapter specific parameters from sender file adapter to receiver file adapter to create the same folder structure and file names. But my requirement is different. I hope I am clear.

Could I please get some advise on this .

Thanks & Kind Regards,

Jhansi.

Accepted Solutions (0)

Answers (7)

Answers (7)

Former Member
0 Kudos

Hi in proxy to file scenerio i have problem that , there is one file created per Crew location Currently there are approximately 95 crew locations The file naming for the crew interface files is MMA_PPPP_MMDDYYYY.xml, where PPPP is the Crew (PAR) location number and MMDDYYYY is the current date. Therefore there is one file per crew location so how i have to do it receiver file directory is same so can any body help me for each crew location a file to be created in xml format target system same

Regards

sravan

Edited by: dsravan on Mar 29, 2011 5:43 AM

Former Member
0 Kudos

Hi in proxy to file scenerio i have problem that , there is one file created per Crew location Currently there are approximately 95 crew locations The file naming for the crew interface files is MMA_PPPP_MMDDYYYY.xml, where PPPP is the Crew (PAR) location number and MMDDYYYY is the current date. Therefore there is one file per crew location so how i have to do it receiver file directory is same so can any body help me

Regards

sravan

Former Member
0 Kudos

Hi Sravan,

U did'nt state what u want to do with each file for Crew. Do u want them to be placed in a seperate directory according to crew number??

Regards,

Rakesh

Former Member
0 Kudos

hi rakesh for each crew location a seperate file to be created target system same and we have 95 crew locations help me if possible rakesh

regards

sravan

Former Member
0 Kudos

Hi Guys,

Thanks very much for all your instant advise.

However, I am not very sure whether you understood my requirement completely. let me explain again.

At the moment have configured this ftp-xi-ftp scenario without IR objects. So at the moment, all the files are pulled in from a particular folder and ftp'ed to another folder as I have specified the file name as .

But what I want to be able to do is, to create an interface where the user can specify:

1) one or more file names that need to be pulled.

2) the folder structure from where they need to be pulled, source folder structure

3) specify the filename/filenames as which these files should be saved on the target folder structure.(this could be same as source file names or he can chose different file names for each file)

4) the target folder structure.

These are all the possibilities I want to provide. However what I need to know is which of these are possible and how.

thanks again and it would be great if you guys take few mins to give me end to end example with steps please.

Kind Regards

Jhansi.

Edited by: jhansi kodali on Nov 29, 2010 10:00 AM

Former Member
0 Kudos

Hi Jhansi,

1) one or more file names that need to be pulled.

It is not possible. When the adapter tends to pick the file, will pick all the messages in single shot.

2) the folder structure from where they need to be pulled, source folder structure

Not possible. As it need to be defined.

3)specify the filename/filenames as which these files should be saved on the target folder structure.

This can be achieved. You can specify the target filename in the receiver adapter and can send the file accordingly.( Using either variable substitution or dynamic configuration)

4) the target folder structure.

Target message need to be defined in IR ie Message Mapping.

Thanks,

Former Member
0 Kudos

Hi Jhansi,

Either you can go ahead with dynamic configuration as said by other SDN'ers. Else can go with Java Mapping:

Here is the code for Java Mapping:



import com.sap.aii.mapping.api.*;
import java.io.*;
import java.text.*;
import java.util.*;

public class GetDynamicConfiguration implements StreamTransformation {


private Map param;


public void setParameter(Map map1) {
this.param = map1;
}


public void execute(InputStream inputstream, OutputStream outputstream) throws StreamTransformationException {
try {
AbstractTrace trace = null;
// a) Set ouput File name
String directory=null;
trace = (AbstractTrace)param.get(StreamTransformationConstants.MAPPING_TRACE );
param.put(DynamicConfigurationKey.create("http://sap.com/xi/XI/Dynamic", StreamTransformationConstants.DYNAMIC_CONFIGURATION), "");
DynamicConfiguration conf = (DynamicConfiguration) param.get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File", "FileName");
DynamicConfigurationKey key1 = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File", "Directory");
String filename =conf.get(key);
conf.put(key, filename);
trace.addInfo("File name is "+filename);
if(filename.equals("in.txt"))
directory = "/home/ftpxi/in";


if(filename.equals("test.txt"))
directory = "/home/ftpxi/in/test";
if(filename.equals("shweta27.txt"))
directory = "/home/ftpxi/in/test";


trace.addInfo("Directory name is "+directory);
conf.put(key1, directory);
// b) Just copy input file to output file
byte[] b = new bytehttp://inputstream.available();
inputstream.read(b);
outputstream.write(b);


} catch (Exception exception) {
exception.printStackTrace();
}
}
}

Former Member
0 Kudos

Hi

Choose the Adapter Specific message attributes in Advanced option of Communication Channel.

Use the following udf for file name identification

public String getFileName(Container container) throws StreamTransformationException{

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

//For getting filename

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

// Retrieve the filename

String FileName = conf.get(key);

return FileName;

}

former_member472138
Active Contributor
0 Kudos

Hello Kodali,

Look at this thread, you can achieve.

Regards

Pothana

Former Member
0 Kudos

I am not that clear about your requirement. Could you please explain in detail.

If the receiver directory path is fixed, then you can define that in the Target directory path. And if you would like to change the name of the file in runtime then you need to go ahead with ASMA.

Thanks,