cancel
Showing results for 
Search instead for 
Did you mean: 

File Name

former_member581827
Participant
0 Kudos

Hi All,

Can I create file name like tes1.txt.TimeStamp.pgp.

TimeStamp should be Dyanamic and I think we can get from Add Time stamp option in Reciever File adapter.

I normally see if we go for option Add Time Stamp, this timestamp will be added at the last of file name like test1.txt.pgp timestamp. If I want to get time stamp in middle of .txt and .pgp in file, How can we proceed?

Regards,

Chandra.

Accepted Solutions (0)

Answers (2)

Answers (2)

rajasekhar_reddy14
Active Contributor
0 Kudos

Hi Chandra,

Try this UDF,it will work for you

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

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

SimpleDateFormat dateformat = new SimpleDateFormat("yyyyMMdd");

String timestamp = dateformat.format(new Date());

String filename="test1.txt.pgp "+timestamp;

conf.put(key, filename);

return "";

Regards,

Raj

former_member581827
Participant
0 Kudos

Hi Raj,

What do we need to pass input for this UDF and do I need to have a field in target structure for it.

I am using time stamp which we have option in Processing tab of reciever File adapater and its comming as 20090820-020227-160.txt, Is there any possiblity where i can get Time stamp as 20090820020227160.txt it means no '-' in time stamp.

Regards,

Chandra.

rajasekhar_reddy14
Active Contributor
0 Kudos

Create one UDF and map this one to root element of your receiver message,in this case no nned to select any option in File Adapter,if you want to change the date time format change in UDF.

Regards,

Raj

Former Member
0 Kudos

HI,

I think you just go through this wiki which will help you to solve your problem. Just modify the UDF code as per your need.

http://wiki.sdn.sap.com/wiki/display/XI/CombiningthreedifferentaspectsofPIinoneshot

Regards,

Sarvesh

former_member581827
Participant
0 Kudos

Hi Sarvesh,

Thanks for your quick reply.

I need the time when the file will be created attached to the file name in the middle of .txt and .pgp.

How can i get date and time which has to be passed in middle of txt and pgp in file name?

Regards,

Chandra.

Former Member
0 Kudos

Chandra,

What you can do is

A)

enable Use Adapter Specific Message attributes in the file adapter.

Check Option File Name.

B)

In the mapping set the file name according to your requirements.

i.e modifty String str = "ORDERS" + a + ".xml" according to your requirements.

rest of the code as copied from the link given by Sarvesh.

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

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

conf.put(FileName, str);

return "";

That should be all.

Regards,

Sumit

Former Member
0 Kudos

>

> Hi Sarvesh,

>

> Thanks for your quick reply.

>

> I need the time when the file will be created attached to the file name in the middle of .txt and .pgp.

>

> How can i get date and time which has to be passed in middle of txt and pgp in file name?

>

> Regards,

> Chandra.

You need to pass the timestamp in your mapping to this UDF and then concatenate it with your file at desired location.

former_member581827
Participant
0 Kudos

HI Sarvesh,

I have tried using option ADD TIME STAMP in processing tab of Reciever communication channel, the time stamp which the file is getting generated is 20090820-020227-160.txt and the customer is requesting for no '-' in time stamp.

How can we do this?

Regards,

Chandra.

former_member200962
Active Contributor
0 Kudos
customer is requesting for no '-' in time stamp

It is not possible to change the format of Timestamp feature of the channel.

You can add Timestamp in the Dynamic Config UDF itself and then create the filename as per your requirement.

What do we need to pass input for this UDF and do I need to have a field in target structure for it.

If you are intending to use the CurrentTime function in mapping then input to your UDF will be this function.

If you are implementing the logic in UDF itself, then the input can be any source node (even root node of source.....you wont be refering this node anywhere in the UDF then)

Similarly the O/P of the UDF can be mapped to any node on the target (even to target root node) as your UDF is not giving any value in return statement

Regards,

Abhishek.

Edited by: abhishek salvi on Dec 16, 2009 10:09 AM