cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic Filename with TimeStamp

Former Member
0 Kudos

Hi Guys,

i'd like to post a file on a ftp with following structure:

yyyyddmmhhmmssMatNr

Well the TimeStamp is a given function from XI. Reading the payload for getting the matNr is also given with variable Substitution.

But getting both together didn't work for me. When i chose "Add Tme Stamp" and the variable Substitution in Receiver Adapter the output-file looks like:

MatNryyyyddmmhhmmss

9111111220070629-153110-012

which is not the way i wanted it :). So does somebody have an idea on this?!

And for the timestamp: is it possible to get rid of "-"?!

br Jens

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi;

Refer these for more help

Dynamic File Name Part 1

/people/jayakrishnan.nair/blog/2005/06/20/dynamic-file-name-using-xi-30-sp12-part--i

Dynamic File Name Part 2

/people/jayakrishnan.nair/blog/2005/06/28/dynamic-file-namexslt-mapping-with-java-enhancement-using-xi-30-sp12-part-ii

Mudit

justin_santhanam
Active Contributor
0 Kudos

Jens,

As Michal suggested , the best way is ASMA.

Please write the below code in UDF with <b>two i/p parameters</b>

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

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

String inputdate = <b>yourInputdate</b>;

String fname = <b>MATNR</b>;

String finalname = inputdate""fname;

conf.put(key,finalname);

return "";

The logic is

Take two input -


>UDF------->Root Node[target]

Best regards,

raj.

Former Member
0 Kudos

Hi Raj, its me again.

Ok i will try this UDF but where to get my inputDate from?! this i got from the option to add a timestamp to the outputfile-name - as given in the configuration of the CC. But where to get the date/time now?!

br Jens

Former Member
0 Kudos

Hi Jens,

you can take the current date from the standard date function in msg mapping....double-click it to change the format of date.........then input this along with MATNR into a UDF and take output of UDF to the topmost header node.....

Thanks,

Rajeev Gupta

Shabarish_Nair
Active Contributor
0 Kudos

try using;

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

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

Date now1 = new Date();

SimpleDateFormat formatter = new SimpleDateFormat ("yyyyddmmhhmmss");

String dateString1 = formatter.format(now1);

String final = a + dateString1;

conf.put(key,final);

return (final);

Former Member
0 Kudos

Ok, i took yout code - after customizing it it works fine so far.

But i still have to use the Variable Substitution (VS) - or don't I?

Therefore its not working. In my mapping i map to the very root node of my target MT. In VS i made the Varibale name "var1" with the Reference to the MT "payload:MT_XYZ,1".

What is wrong?

br Jens

Former Member
0 Kudos

>>But i still have to use the Variable Substitution (VS) - or don't I?

You dont need to use Variable substitution. Just use the UDF shown by Shabz and populate what ever value you want to the file Name. Just ensure, you have selected ASMA in receiver File adapter. In the File Name column in adapter, just fill any dummy name(this will be replaced by the value you fill in mapping).

Regards,

Jai Shankar

Former Member
0 Kudos

Hi Jai,

well that's it. First ASMA is running - thx to all!!

br Jens

MichalKrawczyk
Active Contributor
0 Kudos

Hi Jens,

I cannot imagine an easier way

then shown in this blog:

/people/william.li/blog/2006/04/18/dynamic-configuration-of-some-communication-channel-parameters-using-message-mapping

it's a standard, no need to use this never working variable Substitution

and it's exactly what you need

so just go and do it

<b>this solution works like a charm - trust me</b>

Regards,

michal

-


<a href="/people/michal.krawczyk2/blog/2005/06/28/xipi-faq-frequently-asked-questions"><b>XI / PI FAQ - Frequently Asked Questions</b></a>

Former Member
0 Kudos

Hi,

well i already tried this appoach, even ur former blog to dynamic configuaration - but it didn't work out for me.

Just to make it clear. Again i have an IDoc2File Scenario with integrated FCC. Because of chosing the Adapter-Specific Message Attributes there are no Header Fields offered in the FTP-Receiver. (i am using NW04s, PI 7.0)

But the variable substitution really works for me - i only have to change the structure of the output-name.....

Former Member
0 Kudos

I'd recomment that when you are doign the message mapping, make a UDF that does all this and writes it to the payload, then use variable substitution, you can make the time stamp in your UDF using the java engine.