cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic Filename doubt!!!

Former Member
0 Kudos

Hi Experts

I have a bypass scenario where I need not do any transformation to the file but need to change the filename scheme.

The sourcefile name is XYZ.txt whereas the target needs to be <IDOCNUM>_X_Y.DAT

As of now we have used a java mapping to achieve this but I was looking out for something simpler.

I mean can we straighaway catch the IDOCNUM(comes in source payload) and use it for filename scheme?

Regards

Soumen...

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Use this as a sample

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 = filename.replaceAll( ".xml" ,"_" );

filename = filenametimestamp".xml";

conf1.put(key1,filename);

return filename;

}

catch(Exception e)

{

String exception = e.toString();

return exception;

}

Regards,

Nithiyanandam

Former Member
0 Kudos
 Without mapping its not possible i think(looking for simple sol),even we can achieve this requirement using message mapping using Dynamic Configuration UDF,by passing DOCNUM as input to the UDF.

Simple is a wrong word that I used. What I meant is can we twitch the file channels(some kinda parameters or something) to get this done.

Message mapping is not there atall and hence we didn't want to add one just for this.

I think you have used dynamic configuration code in JAVA Mapping...

Exactly!!!

Use this as a sample

@Nithiyanandam A.U : Prolly you missed my query. We already have done teh code. All i want to know is an alternative way to achieve this w/o using a mapping.

Regards

Soumen...

rajasekhar_reddy14
Active Contributor
0 Kudos

Hi,

As i said already without maping not possible,we can use variable sustitution in Receiver communication channel,but i am not sure this will work for you,

because we have to read docnum from message,and need to append in to file name.

Regards,

Raj

Former Member
0 Kudos

Hi ,

You can achieve this requirement by usinh the variable substitution.

in variable substitution specify the variable...

seqno payload:(give the whole path of the IDOC number)

if FCC ,for the file name use

abc_%seqno%.txt.

.................................

I think this is the only way u can solve this issue without mapping.

Babu

Shabarish_Nair
Active Contributor
0 Kudos

>

>

> @Nithiyanandam A.U : Prolly you missed my query. We already have done teh code. All i want to know is an alternative way to achieve this w/o using a mapping.

>

> Regards

> Soumen...

to answer your question, the simplest way is what you are already doing

without a mapping or a module, it is not possible to cache the dynamic configuration parameters

Former Member
0 Kudos

Ok!!! slight change in the requirement. Now I just need to change the extension.

For example : Input is XYZ.txt and required output is XYZ.dat is it possible w/o any mapping. The scenario is same bypass one. And hence I dont have any XML structure. Its flatfile @ both source & target. With change of extension.

How can we change the extension without changing teh filename?

rajasekhar_reddy14
Active Contributor
0 Kudos

Hi,

I dont think so its possible,Using variable substitution we can change the name of the file,but the variable here is Source message element,we have to provide the XPath for the element.

Regards,

Raj

Former Member
0 Kudos
I dont think so its possible,Using variable substitution we can change the name of the file,but the variable here is Source message element,we have to provide the XPath for the element.

Yeah...

@ALL : Any inputs??

balaji_pichaimuthu
Active Participant
0 Kudos

Hii

Set the Adapter specific attributes in sender and receiver communication channel.. in receiver channel creat a Module program which can catch source file name and modify the filename name scheme there..

Regards,

Balaji

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

Think i got the solution for you..

Do what it says in this:

http://wiki.sdn.sap.com/wiki/display/XI/CombiningthreedifferentaspectsofPIinoneshot

Just ignore the stuff about UDF...

And check the File Name option under Adapter-Specific Message Attribute on your senderchannel.

Then you will get the original filename..

I just tried it out and it works

Former Member
0 Kudos

Step by step..

Sender Channel:

1. put a checkmark in File Name under Adapter-Specific Message Attribute

Receiver Channel:

1. Add the following line to Module as the first entry

1 AF_Modules/DynamicConfigurationBean Local Enterprise Bean 0 
2 CallSapAdapter Local Enterprise Bean 0

2. Add the following lines to Module Configuration

0 key.0 write http://sap.com/xi/XI/System/File FileName
0 value.0 message.interface

3. Enable variable substitution under Advanced parameters

Variable Name = filename 
Reference = message:interface_name

4. File Name Scheme = Output_%filename%

If you do above your result will be the following:

Input file = XYZ.xml

Output file = Output_XYZ.xml

Former Member
0 Kudos

Darn!!! The filename comes but the extension doesn't... Any idea why??

former_member187339
Active Contributor
0 Kudos

Hi Soumen,

>>The filename comes but the extension doesn't.

Give it explicitly in the File name eg :

>>%FileName%.xml

Regards

Suraj

Former Member
0 Kudos

Suraj bro

Hi !!! Gud to see you here

I already tried that. I used %filename%.DAT but when i get the file at target side it come without the extension.

Anyways, for the time being have settled down with the java mapping.

Regards

Soumen...

Former Member
0 Kudos

@ALL : Got teh issue for extension not coming. We should not be checking Use Adapter specific message attributes in receiver file channel. This worked.

Former Member
0 Kudos

Hello,

I am facing similar issue but with time stamp format. can you please guide me in this.

I am usinf Integrated configuaration for File to file scenario ( no IR objects)

I need the target file name to be XYZ.ddmmyyyy but when I am using Add time Stamp option output file is coming as XYZ.ddmmyyyy-ssssss.

I need to eliminate the milli seconds part. How can I do that.

Thanks .

rajasekhar_reddy14
Active Contributor
0 Kudos

Hi,

Without mapping its not possible i think(looking for simple sol),even we can achieve this requirement using message mapping using Dynamic Configuration UDF,by passing DOCNUM as input to the UDF.

I think you have used dynamic configuration code in JAVA Mapping,the same code we can use as UDF also.

Regards,

Raj