cancel
Showing results for 
Search instead for 
Did you mean: 

Problem When Pushing Files Into Target Folder Using UDF

lokeshwar
Explorer
0 Kudos

Hi All,

We are writing an UDF to put a file into a folder based on some conditions over SFTP. Based on the file name, we'll decide in which folder to put those files into. The folder path will be determined inside the Java code. There is no need to change the file name or content of the files. Scenario is a Java program receives the file, checks the file name, decides on the folder it needs to place and put it into it.

What is happening is, if we specify the destination folder in the parameters, it is picking from the source folder and placing all the files (even for the files which doesnt pass the condition ) in the folder. Instead if we put * in there for Filepath, files are going missing.

Below are the screen shots of configurations

Below is the Java code we use:


try

{

String currDateMinusOneFilesPath = "/interface/DMS/AMT/CORRECTFILES";

String otherFilesPath = "/interface/DMS/AMT/WRONGFILES";

final DateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");

final Calendar fileDate = Calendar.getInstance();

DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/Files", "FileName");

DynamicConfigurationKey key1 = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/Files", "Directory");

String filename=conf.get(key);

String splitValue = filename.substring(filename.length()-8, filename.length());



Calendar calendar = Calendar.getInstance();

fileDate.setTime(dateFormat.parse(splitValue));

if(fileDate.get(Calendar.YEAR) == calendar.get(Calendar.YEAR) && fileDate.get(Calendar.MONTH) == calendar.get(Calendar.MONTH))

{

  if(calendar.get(Calendar.DATE) - fileDate.get(Calendar.DATE) == 1)

  {

  conf.put(key,filename);

  conf.put(key1,currDateMinusOneFilesPath);

  }

  else

  {

  conf.put(key,filename);

  conf.put(key1,otherFilesPath);

  }

}

else

{

  conf.put(key,filename);

  conf.put(key1,otherFilesPath);

}

}

catch(Exception e)

{

  throw new StreamTransformationException(e.toString());

}

finally

{

  return  "";

}

Your help is highly appreciated.

Thanks,

Lokesh

Accepted Solutions (1)

Accepted Solutions (1)

former_member186851
Active Contributor
0 Kudos

Change the Files in your namespace to file in channel configuration.

lokeshwar
Explorer
0 Kudos

Hi Raghuraman,

We have changed the namespace to file but we are facing the same issue

former_member186851
Active Contributor
0 Kudos

Hello Goud,

sorry it should be File not file,Try with this and let us know.

change it in the code and as well in the channel,

I guess the dyanmic parameters are not set correct because of wrong namespace.

lokeshwar
Explorer
0 Kudos

Hi Raghu,

We have changed to File itself but we are facing the same issue.

former_member186851
Active Contributor
0 Kudos

Hello,

Then the only possibility could be the file name not satisfying any condition.

lokeshwar
Explorer
0 Kudos

Hi Raghu,

Issue have been solved.

We have changed the file to File and refreshed the cache then it's working.

Thanks and Regards,

Lokesh.

former_member186851
Active Contributor
0 Kudos

Great Lokesh..:)

Answers (2)

Answers (2)

Former Member
0 Kudos

H Lokesh,

have you checked the message monitor? It will definetely tell you what happened with each file.

I could only imagine two things:

  1. The UDF runs into a exception and the message is not delivered
  2. One file is overwriting another

br,

Heiko

markangelo_dihiansan
Active Contributor
0 Kudos

Hi,


What is happening is, if we specify the destination folder in the parameters, it is picking from the source folder and placing all the files (even for the files which doesnt pass the condition ) in the folder. Instead if we put * in there for Filepath, files are going missing.

Are you using archiving? If yes, make sure that the addTimeStamp option is checked.

Regards,

Mark

lokeshwar
Explorer
0 Kudos

Hi,

No we are not using archiving.

Regards,

Lokesh.