cancel
Showing results for 
Search instead for 
Did you mean: 

Updated Filename in File Receiver

Former Member
0 Kudos

I need to append today's date to the file name when outputting a file. The date isn't available in the outbound XML so I can't use variable substitution. Does anyone have any suggestions?

Accepted Solutions (0)

Answers (9)

Answers (9)

Former Member
0 Kudos

Hi, Perhaps I should explain a little more about the interface I'm trying to build. It's iDoc to File. I don't have access to a date or time in the outbound XML file so I can't use variable substitution. I can't add additional fields to the outbound message as the partner would reject them. I need to rename the outbound file including the date and a sequence number.

I'm not a JAVA programmer and know nothing about user defined functions but am more than willing to learn. I see that I need to create a mapping to the root node, using my date and including a userdefined function to put this value somewhere I can get it later. Can someone please explain how I reference this value from the receiver comms channel?

former_member189441
Active Participant
0 Kudos

Hi,

I don't have access to a date or time in the outbound XML file so I can't use variable substitution. I can't add additional fields to the outbound message as the partner would reject them.

To Map the Date function you no need any field in the source structure.The Date function is the standard function.and it wont take any input from sourece.it simply returns the current date in the specifies format.

I see that I need to create a mapping to the root node, using my date and including a userdefined function to put this value somewhere I can get it later

generally u specify your file name in Receiver communincation channel.So the same file name you have to concate with the Date (by usind predefined function Concat) and give the new string that means(ex:Filename = XYZ and Date :20080914 then new concated string whould be "XYZ20080914")

you have to create one new UDF and copy the code that have specified and give the new String (for ex:XYZ20080914) as input.map it to root node.

In ID you have to enable Adapter specific message attributes and also Filename in that.(Give * or any string in the place of File name) Because of this in the receiver file adapter it wont take the static filename which we have specified in the fiels FileName,instead it will take the File name which we have specified in Mapping UDF.

SudhirT
Active Contributor
0 Kudos

Hi ,

Check this discussion similar problem solved here

Thanks!

dharamveer_gaur2
Active Contributor
0 Kudos

use this thread will realy help

SudhirT
Active Contributor
0 Kudos

Hi

Use variable substitution for filename check the code for UDF getFileName

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

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

String ourSourceFileName = conf.get(key);

result.addValue(""+ourSourceFileName);

Edit the SourceFileName with some string manipulation (SubString) with your requirement.

Also check the thread for more detail.

Thanks!

Former Member
0 Kudos

Thanks

If I use variable substitution then the tag will appear in the outbound XML document. The partner that is receiving the XML would reject the document if it has any more tags than required.

Former Member
0 Kudos

Better try doing this with variable substitution.

Insert the timeStamp in a XML tag (using Message Mapping) and use the Variable Substitution. For Example:

Create a "filename" tag

File Name Schema = %fileName%

Variable Substitution (Table)

... add a Line

Variable name = fileName

Reference = payload:myXml,1,filename,1

Edited by: malini balasubramaniam on Sep 15, 2008 1:05 PM

Former Member
0 Kudos

Hi,

You can give addtimestamp option in Receiver file adapter.

So that you can achieve the same what you want.

Thanks,

Kalyan.

Former Member
0 Kudos

By default I appear to get YYYYMMDD-HHMMDD-SSS where SSS is some sort of sequence number. This is more than I actually need.

former_member189441
Active Participant
0 Kudos

Use the Date function in mapping to get the required date in what ever format you want by using change format option in it and then concat this Date with the required FileName ex:file1 and give this new String to the Below UDF.

Map the output of this UDF to root node of target structure in Mapping so that it wont effect any target structure.

check Adapter specific parameters in your Receiver File Adapter

write this UDF


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

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

String ourSourceFileName = conf.get(key);

return  ourSourceFileName;  



use these links for ur reference

https://sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/2664

http://help.sap.com/saphelp_nw04/helpdata/en/43/03612cdecc6e76e10000000a422035/content.htm

Former Member
0 Kudos

use std date functions and a UDF

currentDate> TransformDate>UDF ---> Root node

in currDate specify your date format..if it is not existing type it there..

Time field should be blank as you are not interested in time..

For UDF refer..

By default I appear to get YYYYMMDD-HHMMDD-SSS where SSS is some sort of sequence number.

--->

to resolve this,in rec file adapter File construction Mode = Add counter

counter Mode =After first file

so that sequence no will not be written at the end.... it will appear in case more than one file comes at same time and this will hardly happen

Former Member
0 Kudos

Hi,

By default u get tat format oly.

former_member192295
Active Contributor
0 Kudos

Hi,

Add time stamp option at receiver end, by default u can get format yyyymmdd

Former Member
0 Kudos

Hi,

Use Addtimestamp option in the receiver file channel.

Former Member
0 Kudos

Thanks, I just want the date, formatted as YYYYMMDD. Sorry, I should have made that clear.