on 09-27-2006 5:51 PM
My scenario is to get Target Directory Name based on part of Filename. How can I do that using UDF. I will select adapter specific parametrs and like to change using UDF. TO achive this I will create a dummy field names in the target structure. Can someone let give me UDF code?.
For Example: Source FileName : SD00123456Prod.csv
Target Directory Should be /Sales/
Target File: Prod.csv
Thanks for any help.
HI,
Have a look into this blog-
/people/michal.krawczyk2/blog/2005/11/10/xi-the-same-filename-from-a-sender-to-a-receiver-file-adapter--sp14
Regards.
Moorthy
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Moorthy,
Do I have to Import any for this UDF? and Name of the UDF can be anything right? Thanx a lot for quick reply.
When I do check in the message mapping of the function its showing lot of erros. So Do I have to import anything into function ?
Here is the Function I created.
public String SourceFileName(Container container){
DynamicConfiguration conf = (DynamicConfiguration) container
.getTransformationParameters()
.get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key = DynamicConfigurationKey.create(
http://sap.com/xi/XI/System/File,
FileName);
String valueOld = conf.get(key);
if (valueOld != null) {
String valueNew = valueOld.replaceAll(input,output);
conf.put(key, valueNew);
}
}
Hi,
I hope you have posted only the part in bold in the editor
public String SourceFileName(Container container){
<b>DynamicConfiguration conf = (DynamicConfiguration) container
.getTransformationParameters()
.get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key = DynamicConfigurationKey.create(
http://sap.com/xi/XI/System/File,
FileName);
String valueOld = conf.get(key);
if (valueOld != null) {
String valueNew = valueOld.replaceAll(input,output);
conf.put(key, valueNew);
}</b>
}
HI,
What is the error ?
<i>String valueOld = conf.get(key);
if (valueOld != null) {
String valueNew = valueOld.replaceAll(input,output);
conf.put(key, valueNew);
}</i>
I think the error may be because of some problem with syntax etc. You did not write <i>return</i> Statement..check carefully with the blog.
Regards,
Moorthy
I changed function this time. I took exact coy of Michals Blog.
Function:
public String SourceFileName(Container container){
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;
}
Now the error when activate message mapping:
Activation of the change list canceled Check result for Message Mapping Source_2_Target | http://test.com: Starting compilation Source code has syntax error: /usr/sap/DPI/DVEBMGS01/j2ee/cluster/server0/./temp/classpath_resolver/Map36d73f104e5e11db977f001125a56eca/source/com/sap/xi/tf/_Source_2_Target_.java:55: cannot resolve symbol symbol : variable conf location: class com.sap.xi.tf._Source_2_Target_ String ourSourceFileName = conf.get(key); ^ 1 error
Prakash, Moorthy you got it. the Declaration has paroblem. I donno but I just did cut and paste. I appreciate all your help. Though you both answered almost at exact times I flagged Prakash solved problem. I hope Moorthy understands me and appreciate his prompt response by being one one the top contributors in the forum and thanks a lot guys.
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
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.