on 06-28-2007 1:45 PM
Hello Friends,
My scenario is I have an xyz.xml file coming and i need to have the same file name in the receiver but with a different extension as xyz.csv and the source file name will not be the same, it will be changing.
Can you please help me on this.this is a bit urgent to me.
Thanks in advance.
Regards,
Kumar
I believe the only option for you to do this is thru File adapter module where you dynamically set the file name based on the input file name
regards
krishna
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
>>I have set the adapter specific message attributes in both the sender and the receiver channel to File Name
This wont do the trick.
What you have to do is to get the file name in the receiver File adapter module and change the extension to whatever you want and the push the file from the Module by using a ftp library like apache commons.
regards
krishna
Hi
Follow the "how to guide to create adapter modules"
Within the adapter module , read the source file name with a code like
obj = inputModuleData.getPrincipalData();
String filename = "";
msg = (Message) obj;
XMLPayload xmlpayload = msg.getDocument();
Channel ch = new Channel(moduleContext.getChannelID());
filename = ch.getValueAsString("file.sourceFileName");
and then later set the name of the file for the receiver
regards
krishna
Kumar,
Write <b>UDF</b> with <b>no input</b> parameters.
DynamicConfiguration conf = (DynamicConfiguration) container
.getTransformationParameters()
.get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key = DynamicConfigurationKey.create(
http://sap.com/xi/XI/System/File,
FileName);
String fname = conf.get(key);
StringTokenizer st = new StringTokenizer(fname,".");
String[] name = new String[2];
while(st.hasMoreElements())
{
for(int i=0;i<1;i++)
{
name<b>[</b>i<b>]</b>=st.nextElement();
}
}
String finalname = name[0]+".csv";
conf.put(key,finalname);
<b>Mapping Logic</b>
UDF -
> Target Rootnode.
Make sure that u checked the Adapter specific message attributes in both comm.channel.
If you have doubts reply back.
Best regards,
raj.
Message was edited by:
Raj
Hello Raj,
Thanks for the help. I have created the UDF and when i test my mappings i am getting an error as
Source code has syntax error: /usr/sap/DXI/DVEBMGS01/j2ee/cluster/server0/./temp/classpath_resolver/Map39000520257b11dc82766685770b97b3/source/com/sap/xi/tf/_MM_COAL_LABSAMPLE_.java:249: illegal character: \8220 ?http://sap.com/xi/XI/System/File?, ^ /usr/sap/DXI/DVEBMGS01/j2ee/cluster/server0/./temp/classpath_resolver/Map39000520257b11dc82766685770b97b3/source/com/sap/xi/tf/_MM_COAL_LABSAMPLE_.java:250: illegal character: \8220 ?FileName?); ^ /usr/sap/DXI/DVEBMGS01/j2ee/cluster/server0/./temp/classpath_resolver/Map39000520257b11dc82766685770b97b3/source/com/sap/xi/tf/_MM_COAL_LABSAMPLE_.java:250: illegal character: \8221 ?FileName?); ^ /usr/sap/DXI/DVEBMGS01/j2ee/cluster/server0/./temp/classpath_resolver/Map39000520257b11dc82766685770b97b3/source/com/sap/xi/tf/_MM_COAL_LABSAMPLE_.java:250: ')' expected ?FileName?); ^ 4 errors
Please let me know what mistake i have done.
Regards,
Chaitanya
Kumar,
Try the below.
DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
String fname = conf.get(key);
StringTokenizer st = new StringTokenizer(fname,".");
String[] name = new String[2];
while(st.hasMoreElements())
{
for(int i=0;i<1;i++)
{
name<b>[</b>i<b>]</b>=(String)st.nextElement();
}
}
String finalname = name[0]+".csv";
conf.put(key,finalname);
return "";
Hello Raj,
I have checked the above line but still the issue is same.
/usr/sap/DXI/DVEBMGS01/j2ee/cluster/server0/./temp/classpath_resolver/Mapedb3fac0257c11dc8ade6685770b97b3/source/com/sap/xi/tf/_MM_COAL_LABSAMPLE_.java:248: illegal character: \8220 DynamicConfigurationKey key = DynamicConfigurationKey.create(?http://sap.com/xi/XI/System/File?,?FileName?); ^ /usr/sap/DXI/DVEBMGS01/j2ee/cluster/server0/./temp/classpath_resolver/Mapedb3fac0257c11dc8ade6685770b97b3/source/com/sap/xi/tf/_MM_COAL_LABSAMPLE_.java:249: ')' expected String fname = conf.get(key); ^ 2 errors
Please help.
regards,
Kumar
Kumar,
Please try the below.
DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
String fname = conf.get(key);
StringTokenizer st = new StringTokenizer(fname,".");
String finalname = (String)st.nextElement()+".csv";
conf.put(key,finalname);
return "";
Best regards,
raj.
User | Count |
---|---|
84 | |
24 | |
11 | |
9 | |
7 | |
6 | |
5 | |
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.