cancel
Showing results for 
Search instead for 
Did you mean: 

Adding date and time as the first line of the output file

Former Member
0 Kudos

Dear Experts ,

Here i have the requirement as follows:

There is a requirement to add the date time details as the first line of the output file and the logic used to achieve this is as follows:

•Extract the date time information from the filename

•Add the above extracted date time as the first line in all the output files ftp’ed to AIM(Business System)

Could any body direct me how to achieve this ,as this is my current requirement?

it would be pleasant ,if i get this ASAP

Thanks&Regards

Shoukath

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

you can select adapter specfic identifiers (filename) in the sender file adapter, this will allow you to access the file name in the mapping. you can use the piece of code mentioned below to access the filename in your user defined function.

you will have to map this UDF to the first element (dummy element to display the data and time) in your Target file structure.

String sourceFileName="";

DynamicConfiguration conf = (DynamicConfiguration) getParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

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

sourceFileName=conf.get(key);

Cheer's

Former Member
0 Kudos

U can use this javacode to get the current time.

Calendar cal = new GregorianCalendar();

int intHour24 = cal.get(Calendar.HOUR_OF_DAY); // 0..23

int intMin = cal.get(Calendar.MINUTE); // 0..59

int intSec = cal.get(Calendar.SECOND); // 0..59

String strTime = intHour24":"intMin":"intSec;

return strTime;

For date u can use this..

import java.util.Date;

Date d = new Date();

return d.toString();

The format returned will be like this "Mon 11 17:15:24 IST 2007"

Regards,

Anoop

prateek
Active Contributor
0 Kudos

U can create ur receiver file structure in the following manner. One header segment and one trailer segment containing the required date field. In the middle would be ur rest of the payload. The values of date could be easily extracted during message mapping.

Regards,

Prateek

Former Member
0 Kudos

Hi,

1. Use variable substitution to extract date from your input file.

2. Create your target file structure such that it will have header to contain time.

Map it in your File Content Conversion.

Regards,

Akshay Jamgaonkar.

**Reward points if find useful.

justin_santhanam
Active Contributor
0 Kudos

Shoukath,

Are u gng to use File content conversion in receiver File adapter? Do u have any fields in the target structure so that we can map the date to the target field..

raj.