cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic file name (Date) in Receiver File Adapter

Former Member
0 Kudos

Hi,

can any one tell me how to create outbound file name with receiver file adapter in format like Name_22-08-2006.dat. I need from a current Date in the name of the message (without any other information). In message payload I don’t have that date. Is it possible to use variable from user defined function in message mapping for that name?

Regards,

Naycho

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Have you tried the "Add time stamp" option in receiver file adapter?

Regards,

Jai Shankar.

Former Member
0 Kudos

Hi Jai,

yes I have tried it but then I have name like Name_20060821-125049-925.dat and I need from Name_22-08-2006.dat

Regards,

Naycho

Former Member
0 Kudos

Hi Naycho,

Do add the field in your target structure as a separate node and then populate the date in the required format in between your mapping.

Now in your receiver file adapter make that node value used in the variable substitution and then in the file content conversion you can use the 'Cut' option so that it wont get in the data of the file which you are writing.

Cheers

JK

Former Member
0 Kudos

Hi Jai,

thanks for your answer but in Documentation for File Content Conversion - Cut means that a value is shortened to the maximum permitted length.

Are you sure that I can remove that additional field with cut?

Regards,

Naycho

henrique_pinto
Active Contributor
0 Kudos

Naycho,

that's exactly what I've managed to perform using DynamicConfiguration. Check these links:

http://help.sap.com/saphelp_nw2004s/helpdata/en/43/03612cdecc6e76e10000000a422035/frameset.htm

http://help.sap.com/saphelp_nw2004s/helpdata/en/43/09b16006526e72e10000000a422035/frameset.htm

http://help.sap.com/saphelp_nw2004s/helpdata/en/43/03fe1bdc7821ade10000000a1553f6/frameset.htm

Particularly, I've created a Java API for using setDirectory and setFileName methods through mappings. I use XSLT with java enhancement because it's a million times easier to parse and get node values with XSL than pure java.

I'm writing a blog on the subject, if you don't resolve the problem until it's out, let me know.

Regards,

Henrique.

Former Member
0 Kudos

I am looking for a method of appending date and time to an inbound text file. I have tried the File constructiono mode = add time stamp but the results did not give the needed .txt extension. What would be the sytax of FILE NAME SCHEMA to give filenameyyymmddhhmmdd.txt

Regards,

Connie

Message was edited by: connie wiggins

henrique_pinto
Active Contributor
0 Kudos

connie,

the "Add timestamp" function adds it before the extension. So, if the File Name Scheme of your adapter is filename.txt, after adding the timestamp, it will become filename<timestamp>.txt.

Regards,

Henrique.

Answers (2)

Answers (2)

former_member189519
Participant
0 Kudos

1. why dont you close the thread when its solved?

2. what are the message properties for the mail adapter?

Former Member
0 Kudos

Naycho, can you please post how you resolved this problem? I have encountered the same questions.

Henrique, did you ever finish your blog on this problem

and can you please provide a link?

henrique_pinto
Active Contributor
0 Kudos

I didn't.

But just make a simple java mapping which gets current time and appends it to original file name (using dynamic configuration).

Regards,

Henrique.

bhavesh_kantilal
Active Contributor
0 Kudos

Hi,

Check this blog by Michal,

/people/michal.krawczyk2/blog/2005/11/10/xi-the-same-filename-from-a-sender-to-a-receiver-file-adapter--sp14

All you will have to do is change the filename in the Mapping using an UDF( code is also available in the blog.)

Regards,

Bhavesh

Former Member
0 Kudos

Hi,

I solved the problem with use of the following function in my message mapping.

DynamicConfiguration conf = (DynamicConfiguration) container

.getTransformationParameters()

.get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

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

conf.put(key, a);

return a;

As a source parameter for the function you can put the needed output file name.

In receiver File communication channel I've selected Use Adapter Specific Message Properties and File Name.

In field File Name Scheme I've defined 'FileName' (like in my function).

As a result I'm receiving in outbound directory files with the name defined in my Mapping.

Cheers

Naycho