on 02-27-2011 7:36 AM
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
You will get null pointer exception if you will test in message mapping.
Please test your mapping scenario in operation mapping.
Thanks
Nidhi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
79 | |
9 | |
9 | |
7 | |
7 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.