cancel
Showing results for 
Search instead for 
Did you mean: 

Target file name using Dynamic Configuration

Former Member
0 Kudos

Hi,

Currently we have requirement Idoc to File interface.In this scenario if one field exists infile then we have to check and we need to create update directory and if it is not exist then we should create one more directory and upload files over there there files should create with timestamp. Since,File system using Sql database so we have used JDBC lookup to check that particaluar field and if it exists we are passing update to UDF if it is not then we are passing constant Create to that. If we use Adapter Specific Message Attributes then in reciever side file Communication Channel addtimestap will it consider or do we have to write anything in Udf it self? Could anybody explain on this?Please provide some sample udf .

Thanks ,

Aparna.

Edited by: aparna_karnam on Dec 24, 2011 11:44 AM

Edited by: aparna_karnam on Dec 24, 2011 11:52 AM

Accepted Solutions (1)

Accepted Solutions (1)

rajasekhar_reddy14
Active Contributor
0 Kudos

>

> Currently we have requirement Idoc to File interface.In this scenario if one field exists infile then we have to check and we need to create update directory and if it is not exist then we should create one more directory and upload files over there there files should create with timestamp. Since,File system using Sql database so we have used JDBC lookup to check that particaluar field and if it exists we are passing update to UDF if it is not then we are passing constant Create to that. If we use Adapter Specific Message Attributes then in reciever side file Communication Channel addtimestap will it consider or do we have to write anything in Udf it self? Could anybody explain on this?Please provide some sample udf .

>

>

If you select ASMA for only directory then you can add time stamp by selecting add time stamp option in receiver file adapter, if you are maniluplating File name and directory using Dynamic Config UDF then it wont effect, hence you need to write code .

Former Member
0 Kudos

Thank you Rajashekar. Here my Doubt is like,

Please find below Udf , in this suppose 'a' value is update file name has to be 'update user_date(timestamp).txt'. But whethere file type txt automatically it will take or do we have to give in udf it self ? If you want to give in UDF then how it will consider timestamp because when you give filename=a" ""User_";( in this how i can give file extension .txt).

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

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

conf.put(key,"/sap-dev/" +a);

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

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

string filename=conf1.get(key1);

filename=a" ""User_";

conf1.put(key1,filename);

And also in Reciver Communication Channel under Adapter Specific Message attributes we have option of file type how it works?

return" ";

anupam_ghosh2
Active Contributor
0 Kudos

Hi,

I have added little changes to the code you have written, to meet your expectations

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

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

conf.put(key,"/sap-dev/" +a); 

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

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

string filename=conf1.get(key1); 
final String DATE_FORMAT_NOW = "dd-MM-yyyy_HH-mm-ss"; 
String s; 
java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat(DATE_FORMAT_NOW); 
java.util.Calendar cal = java.util.Calendar.getInstance(); 
s=sdf.format(cal.getTime()); 
filename=a+" "+"User_"+s+".txt"; 

conf1.put(key1,filename); 


return " "; 

So if value of input variable "a" is "update" then the target directory will be "/sap-dev/update" and the file formed will have name "update User_26-12-2011_01-20-50.txt", of course the date and time values will change depending on server settings. I just showed a sample. one more point, the directory will not be created, you have to create the directories before you run the scenario, only the final directory will be decided depending on value of variable "a". In case you wanna create new directory if directory is not pre-existing then try ticking on "Create Target Directory" option under "file access parameters" in communication channel. (I have never used this option u can have a try. )

Now coming to your queries

1. But whether file type txt automatically it will take or do we have to give in udf it self ?

ans) You have to put the value in UDF as I have done in code.

2. how it will consider timestamp ?

ans) This has been generated in UDF itself.

3. how i can give file extension .txt?

ans) same as ans 1

4. And also in Receiver Communication Channel under Adapter Specific Message attributes we have option of file type how it works?

ans) File type determines is the file you are going to write is of type "text" or "binary". From "Processing Parameters" tab you can select this from drop down menu in communication channel or you can set it through ASMA properties in similar manner as you have done for file name and directory name. For more details refer to http://help.sap.com/saphelp_nw04/helpdata/en/bc/bb79d6061007419a081e58cbeaaf28/content.htm

http://help.sap.com/saphelp_nwpi71/helpdata/en/44/6830e67f2a6d12e10000000a1553f6/content.htm

Finally few more points I would like to add

1) you have not mentioned the operating system of the server where file is going to form. In case its UNIX/LINUX you are not allowed to use space in the filename. you can consult these links before you decide on file name and directory name in the UDF mentioned above

http://www.med.nyu.edu/rcr/rcr/nyu_vms/unixfileanddirectorynames.htm (UNIX)

http://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx#naming_conventions (WINDOWS)

2) you can alter the string "DATE_FORMAT_NOW" as per your requirement so that the timestamp appears in the way you want. I have just showed a sample.

3) Plesae do not forget to tick on the options "Use Adapter-Specific Message Attributes indicator", "Fail If Adapter-Specific Message Attributes Missing", indicators "File Name" and "Directory" under "Define Adapter-Specific Message Attributes." in receiver communication channel.

Hope this solves your problem.

Wish my dear forum members and users of SDN

Merry Christmas and Happy new year (in advance)

Regards

Anupam

N.B:- I initially forgot to add the ".txt" part to the file name. I made necessary corrections in code now.

Former Member
0 Kudos

Thanks Anupam,

I have to test this Interface using UDF which you have sent then will let you know.

Thanks,

Aparna.

Answers (0)