cancel
Showing results for 
Search instead for 
Did you mean: 

Regarding Variable Substitition

Former Member
0 Kudos

Hi Gurus,

I have a requirement that the File Name should be generated as

shown below .

“File name scheme + <YYYYMMDDThhmmss> + GMT + extension”

I am able to accomplish the task using Module at the Receiver side.

My question is will it be possible to do using variable substitution with using the reference from PAYLOAD (is that i can use refernce from some other than payload and do it)

thanks

Rams

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Ramamurthy,

I presume you want to create a file with the following name scheme.

File name scheme + <YYYYMMDDThhmmss> + GMT + extension

Where YYYYMMDDThhmmss contains the timestamp during file creation.

Am I right?

I had a similar requirement in file to file scenario but in my case the timestamp to be written in the filename was not when the file was created but when my file sender adapter polls the file.

or Is this what you are looking for?

You can achieve this by variable subsitution.

http://help.sap.com/saphelp_nw04/helpdata/en/bc/bb79d6061007419a081e58cbeaaf28/content.htm

Regards,

Pritish

justin_santhanam
Active Contributor
0 Kudos

Ram,

<b><i>File name scheme + <YYYYMMDDThhmmss> + GMT + extension</i></b>

Can you give example o/p u needed. One more thing the value for YYYYMMDDThhmmss must be current time or its from payload?

Also let me know from the above which of the fields you are getting from payload.

Best regards,

raj.

Former Member
0 Kudos

Dear Raj,

I am sorry , I dont want to take values from payload but need to name the file with current date and time in the format mentioned below.

thanks

rams

justin_santhanam
Active Contributor
0 Kudos

Ram,

you can solve this by using dynamic configuration.

Please follow the below blog for reference.

/people/michal.krawczyk2/blog/2005/11/10/xi-the-same-filename-from-a-sender-to-a-receiver-file-adapter--sp14

Implement the below code to achieve the same.

Create UDF with Date(pre-defined function) as input parameter.

Map the UDF to the root node level of the target message.

<b>//Get Current time</b>

Calendar cal =new GregorianCalendar();

int hour = cal.get(Calendar.HOUR);

if(cal.get(Calendar.AM_PM) != 0)

hour+=12;

int min=cal.get(Calendar.MINUTE);

int sec=cal.get(Calendar.SECOND);

String cur_time=hour""min""sec;

<b>//Get Input Date in the reqd format</b>

String Datetime= Date""cur_time+"GMT";

<b>//I hope file name is constant</b>

String Filename ="ABC";

String extension =".txt"

String dynaname = FilenameDatetimeextension

DynamicConfiguration conf = (DynamicConfiguration) container

.getTransformationParameters()

.get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

DynamicConfigurationKey key = DynamicConfigurationKey.create(

“http://sap.com/xi/XI/System/File”,

“FileName”);

conf.put(key,dynaname);

return "";

If you have any doubt reply back.

Best Regards,

raj.

Former Member
0 Kudos

Hi Raj,

File name & Extension should be what ever given in the File Name Scheme.

thanks

Rams

justin_santhanam
Active Contributor
0 Kudos

Ram,

<i>File name & Extension should be what ever given in the File Name Scheme.</i>

Is it the file name must be same from sender comm channel. File Name scheme, where you are getting this i/p from, can you explain it.

Best regards,

raj.

justin_santhanam
Active Contributor
0 Kudos

Ram,

Did you solved the issue, do let us know.

best regards,

raj.

Former Member
0 Kudos

Dear Raj,

well , I was not able to ......In the ID - Receiver we will be giving the File Name Schema right from that we should take the file name and extension

i.e from Receiver ...

thanks for the tips so for I am trying on this

Rams

justin_santhanam
Active Contributor
0 Kudos

Ram,

In Receiver Communication Channel the File Name Scheme, will always be constant. Am I right? Hence from the above UDF I mentioned just give the same name as in the receiver comm. channel instead of "ABC".

Best regards,

raj.

prateek
Active Contributor
0 Kudos

<i>My question is will it be possible to do using variable substitution with using the reference from PAYLOAD </i>

Yes. It is possible

Variable substitution allows you to name your target file dynamically with some value in the msg payload.

/people/sameer.shadab/blog/2005/09/23/an-interesting-usage-of-variable-substitution-in-xi

/people/sravya.talanki2/blog/2005/08/11/solution-to-the-problem-encountered-using-variable-substitution-with-xi-sp12

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

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

Although u have another of option of trying Adapter specific message attributes (ASMA)

/people/michal.krawczyk2/blog/2005/11/10/xi-the-same-filename-from-a-sender-to-a-receiver-file-adapter--sp14

Regards,

Prateek

Former Member
0 Kudos

Hi Prateek ,

I am sorry my question was wrong in the forum ... Actually I don't want to take it from msg payload at all ....I don't want to use payload but need to solve this ....is there any way using variable substitution with out taking from payload

thanks

rams