cancel
Showing results for 
Search instead for 
Did you mean: 

Dyanamic Configuration at receiver file adapter determine target directory

Former Member
0 Kudos

Hi Experts,

I have a requirement to determine the target directory during runtime.

From the source side one particular field determine the Target directory where you need to place file

ECC - PI - File adapter - this is the scenario

In target side 3 directories in the same server . but the directory should determine from source fields - werks

As I am new to PI Please describe the procedure in detail.

Thanks in advance.

Kevin

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

You will get null pointer exception if you will test in message mapping.

Please test your mapping scenario in operation mapping.

Thanks

Nidhi

Former Member
0 Kudos

Hi Kevin,

Use the below UDF and map to the rootnode in the message mapping.

public String GetFileName(Container container){
DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

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

String ourSourceFileName = conf.get(key);

return  ourSourceFileName;  
}

In the Advanced tab of the File adapter, check the option Adapter Specific Message Attributes. Under that, check the Filename option.

This would get the fieldname in the target filename.

Check the below link:

/people/madanmohan.agrawal/blog/2009/05/20/combining-three-different-aspects-of-pi-asma-af-module-and-variable-substitution-in-one-shot

http://help.sap.com/saphelp_nw04/helpdata/en/43/0a7d1be4e622f3e10000000a1553f7/frameset.htm

/people/shabarish.vijayakumar/blog/2007/07/26/troubleshooting-the-file-adapter-last-updated-on-02-july10

Thanks,

Former Member
0 Kudos

Hi Kevin,

The complete code of the UDF is as follows:

The code takes a single String array input[ ] as input and returns a ResultList item result as output.


//Where input[] is the input parameter in your UDF which contains the directory name from your source file.

public void dynamicDir(String[] input,ResultList result,Container c)
{
DynamicConfiguration conf (DynamicConfiguration)container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
 
DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","Directory");
 
conf.put(key, input[0]);
 
result.addValue(" ");
}
 

Map the output of this UDF to any node in the target side.

Hope it helps you buddy!!!!

Thanks

Biswajit

Edited by: 007biswa on Feb 28, 2011 11:46 AM

Former Member
0 Kudos

In your message mapping create one UDF with below code and map it do any root node..

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

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

conf.put(key, target_dir);

return "";  

//Where target_dir is the input parameter in your UDF which you will map with directory name from your source file.

Apart from this in your receiver CC, you have to select the check box "Directory" under Adapter Specific Message Attributes in Advanced Tab.

Former Member
0 Kudos

Hi ,

When compiling the Message Mapping I am getting Null point exception error because I mapped to the the target root node

help me

Kevin

Former Member
0 Kudos

Hi,

if you are using Dynamic Configurations in UDF you cannot test Message Mapping...

Need to do end to end testing for the same..

Better search SDN for these ...as this has been discussed lot of times..

HTH

Rajesh

Edited by: Rajesh on Mar 2, 2011 11:11 AM

Former Member
0 Kudos

When compiling the Message Mapping I am getting Null point exception error because I mapped to the the target root node

Dynamic Configuration cannot be tested in message mapping. In order to test it you have to do end to end testing.