cancel
Showing results for 
Search instead for 
Did you mean: 

Receiver File Name with date

Former Member
0 Kudos

Hi @,

I have a requirement where I wanted to genereate the recevier file name as TestYYYYMMDD.txt format.

Note that in Receiver target structure date is not coming and output file also we dont require date data.

I tried to put the Date root node and date field in target structure and in Receiver FCC i have not put the Date root node name but still date data is generated in output file.

Since its a Comma separated file hence I can not use CUT option which is applicable for Fixed length file.

I used the time stamp option but it is giving HH.MM.SS details which i dont want.

Is there any other options available.

chirag

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

As prateek said, use Dynamic Configuration in Mapping.

Date-UDF--testField(disable).

Map the system date in UDF. Override the File name with that date. Map the UDF output in target field, disable the field (testField) in the target message.

Regards,

Farooq

Former Member
0 Kudos

Dear All,

I tried with all the options-

For example: I have only three field values in my file which are Bike Model,BikeInformation and BikeDescription.

Probem is if i use dynamic then in target structure i have to use FilenameDate field and when I will do the FCC that value will also be available in my file which I dont want.

Thnx

chirag

former_member200962
Active Contributor
0 Kudos

When doing Dynamic Config you dont need to use any of the fields from the Target....means that you dont need to put any value in the target structure from the dynamic config UDF....so you can remove any additional field that you have included in the target structure.

Your UDF output can be mapped even to the Root node of your Target structure and the UDF need not have any value in the return statement.....just return""; will do

Regards,

Abhishek.

former_member200962
Active Contributor
0 Kudos

CurrentDate ---> DateTransform ---> UDF ---> Any node on the target (even root node will do)

UDF:

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

DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File", "FileName");
fileName = "Test"+currentDate(input to the UDF)+".txt";
conf.put(key, fileName);
return "";

Regards,

Abhishek.

Former Member
0 Kudos

Hi,

My root node is repeating as many times my source node so i can not make use of that root node. Any other options

Chirag.

Shabarish_Nair
Active Contributor
0 Kudos

use dynamic configuration and map the output of your logic / udf to the upper most node of your target message i.e the MT itself.

ref: /people/shabarish.vijayakumar/blog/2009/03/26/dynamic-configuration-vs-variable-substitution--the-ultimate-battle-for-the-file-name

prateek
Active Contributor
0 Kudos

Probem is if i use dynamic then in target structure i have to use FilenameDate field and when I will do the FCC that value will also be available in my file which I dont want.

Incorrect. For DynamicConfiguration, you don't have to use payload field.

Any other options

Map it to any node which has no other mapping. Only important thing is that node should be created in mapping.

Regards,

Prateek

Former Member
0 Kudos

You can add a node 'TRAIL' with 'FILENAME' sub-node; Your target format is like this:

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

<ns0:MT_FILE_STRING_OUT xmlns:ns0="HTTP://WWW.XXX.COM">

<Recordset>

<Row>3</Row>

</Recordset>

<Trail>

<Filename>DFS-XXX-20090804173307</Filename>

</Trail>

</ns0:MT_FILE_STRING_OUT>

When mapping, the UDF can be:

(imports: java.text.SimpleDateFormat;)

   
 SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
  String ds = sdf.format(new Date(System.currentTimeMillis()));
  String filename = "DFS-ADSFCL-" + ds;
 
return filename; 

In file adapter, you can use the adapter attributes to get the file name and the conversion to cut the trail node in the file...

Done!

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi Chirag,

If you are facing problem in renaming the filename in Mapping, then try to develop the Custom Adapter module and rename the file as per your requirement. Use Getter and Setter message property methods.

Regards,

Chandra Shekhar.

former_member200962
Active Contributor
0 Kudos

As an input to your UDF you can have the standard mapping function (currentDate)...you can do transform to have the date in desired format

while building your FileName have a similar statement:

fileName = "Test"+"currentDate"+".txt";
conf.put(Key, fileName);

Regards,

Abhishek.

Former Member
0 Kudos

Chirag,

You can create a udf and can put this filename to Filename and can just map it to one of the target node and tehn you can use this in your reciever comm. channel. Just do a search for udf on SDN.

Regards,

---Satish

prateek
Active Contributor
0 Kudos

Can't you set the date as filename using DynamicConfiguration and use ASMA?

Regards,

Prateek