cancel
Showing results for 
Search instead for 
Did you mean: 

Filename required with Timestamp and without '-' in between the Timestamp

santosh_k3
Active Participant
0 Kudos

Hi All,

I have a requirement were the file name along with time stamp should be as,

FileNameyyyyMMddHHmmSS.txt

But if i use File Construction mode as TimeStamp in receiver channel

i am getting the file name as shown below

FileName20110908-055553-153

My requirement is to get the file name as

FileName20110908055553153

ie.. i dont want '-' in between the Time stamp.

Can anybody suggest me the solution for this.

Thanks

Sai

Accepted Solutions (1)

Accepted Solutions (1)

former_member463616
Contributor
0 Kudos

Hi,

You have to write UDF for achieve your requirement.

Please see the below link, it might be useful to you.

[TimeStamp|;

Hope this helps.

Regards,

P.Rajesh

santosh_k3
Active Participant
0 Kudos

Hi All,

I have created mapping as

CurrentDate---->UDF--->rootnode

Currentdate set to : yyyyMMddHHmmSS

UDF code : No imports

String fileName ="DataAuditNewCustomer" + CurrentDate + ".txt";

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

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

conf.put(key,fileName);

return fileName;

In sender Comm channel as:

*i did not select ASMA*

In receiver Comm channel i set the parameters as

Filename schema : *

fileConstruction mode : Create

*ASMA attributes : fileName*

The file is being picked up but showing an error

In MONI its showing an error message as :

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>

- <!-- Request Message Mapping

-->

- <SAP:Error xmlns:SAP="http://sap.com/xi/XI/Message/30" xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" SOAP:mustUnderstand="">

<SAP:Category>Application</SAP:Category>

<SAP:Code area="MAPPING">EXCEPTION_DURING_EXECUTE</SAP:Code>

<SAP:P1>com/sap/xi/tf/_MM_NewCustomer_</SAP:P1>

<SAP:P2>com.sap.aii.utilxi.misc.api.BaseRuntimeException</SAP:P2>

<SAP:P3>RuntimeException in Message-Mapping transformatio~</SAP:P3>

<SAP:P4 />

<SAP:AdditionalText />

<SAP:ApplicationFaultMessage namespace="" />

<SAP:Stack>During the application mapping com/sap/xi/tf/_MM_NewCustomer_ a com.sap.aii.utilxi.misc.api.BaseRuntimeException was thrown: RuntimeException in Message-Mapping transformatio~</SAP:Stack>

<SAP:Retry>M</SAP:Retry>

</SAP:Error>

Thanks

Sai

Edited by: sai_SHA on Sep 9, 2011 2:09 PM

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi Sai,

If you want to use File Construction Mode as Timestamp, then we cannot remove the '-' from the filename. As this is the standard module functionality which is performed after the ASMA.

We can create the filename without '-' in 2 ways.

1. In the Message mapping using Dynamic Configuration, create filename based on the system timestamp. Limitation, if your server is slow or receiver system is down and later some time back i.e. when server gets up; if you restart the message from AE, the filename will be placed with the old timestamp when the mapping is performed and this is not cirrect time stamp. In order to ignore this concern, try using 2nd way

2. Create Adapter Module, which will give very close time with the standard adapter module Timestamp when file placed on the Reciever system.

Regards,

Chandra Shekhar.

monicabhosale
Active Participant
0 Kudos

Hello,

Create an UDF and include the piece of code that captures the Filename and Timestamp from source side via ASMA.

Modify them according to our requirement by adding the <Timestamp> at the end of <filename> with ''.

Map the UDF to any of the top level node so that the modified filename will be available for the target communication channel

UDF Code is:

try {

String filename = "";

String timestamp = "";

DynamicConfiguration conf1 = (DynamicConfiguration) container

.getTransformationParameters()

.get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

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

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

filename = conf1.get(key1);

timestamp = conf1.get(key2);

filename = filenametimestamp".xml";

filename = filename.replaceAll( "-" ,"" );

conf1.put(key1,filename);

return filename;

}

catch(Exception e)

{

String exception = e.toString();

return exception;

}

I hope this will work.

Monica

Former Member
0 Kudos

Use dynamic configuration (UDF) to set the file name by providing one input parameter for time stamp using currentDate / Time function in your specified format.

Regards

Raj

Former Member
0 Kudos

in ur tartet data type , add another structure

lets say ur target DT is

DT_output
Records
...f1
...

.....
 fn

Now add the following in the DT

File
...FileName

so it will look like

DT_output
Records
...f1
...
.....
.. fn
File
...FileName

from mesage mapping u create the timestamp and pass it to FilName

Use variable substitution and get the filename and supress the strcuture

File.fieldFixedLengths = 0
File.endSeparator ='0'
File.fixedLengthTooShortHandling = Cut

Regards

Biplab Das

Former Member
0 Kudos

Hi,

you have to write a UDF for this.

You can use function CurrentDate to set timestamp format, and then use it in a UDF function to set filename

Fabio

public String SetFileName(String zTimeStamp,Container container){

String fileName = " ";

fileName = "XXXX""zTimeStamp"".xml"; (consider plus sign between fixed strings and fields)

}

return fileName;

or you can add a field in target structure. Use function CurrentDate directly in this field and use the field to build filename in CC.

santosh_k3
Active Participant
0 Kudos

Hi Fabio,

Thanks for u r inputs.

The Timestamp is working fine with u r suggestions,

one concern is that I am trying to pick the two files ,

Files consists of small amount of data, so while placing the files i am getting the same TimeStamp for both the files

one file is placed in the directory and the other is not placed because fo the same Timestamp.

Error:

Attempt to process file failed with java.lang.Exception: Overwriting file '/staging/INTERFACE/SAP/cais/xxxx20110909112743.txt' not allowed due to configuration flag

Even i cannot override the file existing file.

Can anybody suggest me for further

Thanks

Sai.

former_member194786
Active Contributor
0 Kudos

Hi Sai,

Could you please check what is the file construction mode that is selected in the reciever channel. In case you want the files to be appended, use the mode as Append.

Regards,

Sanjeev.