on 02-02-2011 2:49 AM
if i have one source file, i m able to pass the file name directly to the target through the udf below:
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;
But i have 2 files from different location. Now both files has dates at the end. how can i pass AAA for File1.txt and BBB for File2.txt. .
after the above code, i have included below code too, but not working(*-for date n timestamps):
if(ourSourceFileName.equals("ABC*.txt"))
return "FILE1";
else if(ourSourceFileName.equals("XYZ*.txt"))
return "FILE2";
please suggest
Hi Rajib,
Try this:
if(ourSourceFileName.contains("ABC"))
return "FILE1";
else if(ourSourceFileName.contains("XYZ"))
return "FILE2";
Regards,
Aravind
Edited by: ajnayak on Feb 2, 2011 5:10 AM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi,
am getting error on activating object with this code u provided ...
Source code has syntax error: /usr/sap/DXI/DVEBMGS31/j2ee/cluster/server0/./temp/classpath_resolver/Map430093802ee311e08d0700144f1e71f0/source/com/sap/xi/tf/_MM_ZBAPI_.java:840: cannot resolve symbol
symbol : method contains (java.lang.String) location: class java.lang.String if(ourSourceFileName.contains("ABC*.txt")) ^
cannot resolve symbol
symbol : method contains (java.lang.String) location: class java.lang.String else if(ourSourceFileName.contains("XYZ2*.txt"))
Hi Basker,
Error in activating object in IR - heres the total code i have used for this purpose. plz help in getting this.
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;
if(ourSourceFileName.equals("SOURCE_1*.txt"))
return "File1";
else if(ourSourceFileName.equals("SOURCE_2*.txt"))
return "File2";
Source code has syntax error: /usr/sap/DXI/DVEBMGS31/j2ee/cluster/server0/./temp/classpath_resolver/Map27461f402eff11e0898d00144f1e71f0/source/com/sap/xi/tf/_MM_UPDATE_.java:839: unreachable statement if(ourSourceFileName.equals("SOURCE1_*.txt")) ^ /usr/sap/DXI/DVEBMGS31/j2ee/cluster/server0/./temp/classpath_resolver/Map27461f402eff11e0898d00144f1e71f0/source/com/sap/xi/tf/_MM_UPDATE_.java:844: missing return statement } ^ 2 errors
The error is due to function doesnt return any values. you need to change the condition statement in the UDF. Try use the below,
Instead of equals use "startswith" Method.
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;
if(ourSourceFileName.startswith("SOURCE_1"))
return "File1";
else if(ourSourceFileName.startswith("SOURCE_2"))
return "File2";
else
return "";
Regards
Ramg
same kinda error on activating IR:
Source code has syntax error: /usr/sap/DXI/DVEBMGS31/j2ee/cluster/server0/./temp/classpath_resolver/Map54bc18702f0511e0c01b00144f1e71f0/source/com/sap/xi/tf/_MM_UPDATE_.java:840: cannot resolve symbol symbol : method startswith (java.lang.String) location: class java.lang.String if(ourSourceFileName.startswith("source1")) ^ /usr/sap/DXI/DVEBMGS31/j2ee/cluster/server0/./temp/classpath_resolver/Map54bc18702f0511e0c01b00144f1e71f0/source/com/sap/xi/tf/_MM_UPDATE_.java:842: cannot resolve symbol symbol : method startswith (java.lang.String) location: class java.lang.String else if(ourSourceFileName.startswith("source2")) ^ 2 errors
am i missing on the import parameter or anywher?
same error baskar, u gotta help me man..tried many options but failed in activating only.
Source code has syntax error: /usr/sap/DXI/DVEBMGS31/j2ee/cluster/server0/./temp/classpath_resolver/Mape9cb9d202f1c11e0c90800144f1e71f0/source/com/sap/xi/tf/_MM_UPDATE_.java:840: unreachable statement if(ourSourceFileName.startsWith("ABC")) ^ 1 error
the problem is the 2 file names from diff locations are not constant - they are coming with the date n timestamps. so in the condition I have to give ABC_.txt then File1 else if XYZ.txt then File2.
can someone plz suggest?
the udf got the file name and i am putting If Then Else. it is working for constant file names but is i put *.txt , not going thru the condition
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
25 | |
12 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.