cancel
Showing results for 
Search instead for 
Did you mean: 

Error in Duplicate file Handling

Former Member
0 Kudos

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,

Accepted Solutions (1)

Accepted Solutions (1)

rajasekhar_reddy14
Active Contributor
0 Kudos

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

Former Member
0 Kudos

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 ,

Answers (0)