on 06-24-2010 6:25 AM
Hi All,
We want to avoid duplicate files in XI for that we used below code in UDF in mapping
try{
String processedFileDatabase = processedFile[0];
String sourceFileName;
DynamicConfiguration attrib = (DynamicConfiguration)container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey fileKey = DynamicConfigurationKey.create("http:/"+"/sap.com/xi/XI/System/File","FileName");
attrib.put(fileKey,attrib.get(fileKey));
sourceFileName = attrib.get(fileKey);
File fileDB=new File(processedFileDatabase);
if (!(fileDB.exists() && fileDB.canWrite() && fileDB.canRead())){
fileDB.createNewFile();
}
Vector fileNameList = new Vector();
BufferedReader br = null;
br = new BufferedReader(new FileReader(processedFileDatabase));
String name = new String();
//loop and read a line from the file as long as we dont get null
while ((name = br.readLine()) != null)
//add the read word to the wordList
fileNameList.add(name);
br.close();
boolean fileAlreadyProcessed = fileNameList.contains(sourceFileName);
if (!fileAlreadyProcessed) {
Writer output = new BufferedWriter(new FileWriter(new File(processedFileDatabase),true));
output.write(sourceFileName + "\r\n");
output.flush();
output.close();
}
result.addValue("" + !fileAlreadyProcessed);
}catch(java.io.IOException e){
e.printStackTrace();
}
But this is not working ..its unable to Map....
Plz help us in this regard,
You mean to say The logic what you have build it is not working or any other problem with the code??
what is the problem are you facing.
Regards,
Raj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The file name is not going to fileDB and hence it is unable to create the target element.
I followed the below link solution 2
http://wiki.sdn.sap.com/wiki/display/XI/DifferentwaystokeepyourInterfacefromprocessingduplicate+files
I seen that fileDB file is empty ,
User | Count |
---|---|
95 | |
11 | |
11 | |
10 | |
9 | |
8 | |
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.