on 10-22-2007 7:58 AM
Hi Experts,
I am doing JDBC to File Scenario, sender side i got the company name field receiver side i got company code field.
There is a file in the XI server it contains list of all company name and copany codes.
i need to take the company code from the file based on company name from sender side during the mapping.
Can anybody suggest me how can i achieve this?
Kind Regards,
Kiran.
Hi, kiran,
You need to write a java code which will parse the file and retrieve the data. The methods of this java class should be called during mapping whici would rteturn you the company code...
If you can be more specific about the data paresent in the file, then it'd be more helpful
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Kiran,
Sprry for late reply, had gone 4 lunch
Pl add this in ur UDF..The input to UDF would be company name..
Change the location of your file accordingly in the code
The imports are
java.io.BufferedReader;
java.io.FileReader;
java.io.InputStreamReader;
java.util.HashMap;
String companyCode = "";
HashMap fileMap = new HashMap();
BufferedReader reader = new BufferedReader(new FileReader("C:
ROOT
MyFolder\file.txt"));
String line = "";
while((line = reader.readLine())!=null)
{
String<i>[]</i> lineArray = line.split(",");
fileMap.put(lineArray<i>[1]</i>, lineArray<i>[0]</i>);
}
companyCode = (String) fileMap.get(companyName);
return companyCode;
Hi Kiran,
About the file not found exception, I think i need to make the code generic...
The code i gave was for windows machines...
Please use this code. Also find out the JAVA.HOME folder in your XI server..
Usually it would be C:\j2sdk1.4.2_12\jre.
Place your file here and name it file.txt.
String companyCode = "";
String filePath = System.getProperty("java.home");
filePath = filePath + java.io.File.separator + "file.txt":
HashMap fileMap = new HashMap();
BufferedReader reader = new BufferedReader(new FileReader(filePath));
String line = "";
while((line = reader.readLine())!=null)
{
String<i>[]</i> lineArray = line.split(",");
fileMap.put(lineArray<i>[1]</i>, lineArray<i>[0]</i>);
}
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
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.