cancel
Showing results for 
Search instead for 
Did you mean: 

How to include the file name as an XML field

Former Member
0 Kudos

Hi,

I'm using a file adapter for process a flat file and convert it into an XML. Does anybody knows how to include the file name into an XML field.

Ex.

I process the file named <b>XXIMN21022007.txt</b> and I need an XML like:

<MT_FILE>

<field1></field1>

<field2></field2>

<field3></field3>

<filename><b>XXIMN21022007.txt</b></filename>

</MT_FILE>

Regards

Gonzalo

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Gonzalo,

I think from SP14 you are able to get the file name from the dynamic configuration.

If your issue is to have the same name in source system and in the target system, you can follow the Michal Krawczyk blog.

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

I hope this help, if not, let me know I will suggest you other ways to sort it out.

Saludos.

Eduardo M.

henrique_pinto
Active Contributor
0 Kudos

Just go for dynamic configuration.

Check the sender file adapter to write the filename in the header (as explained in Michal's blog) and then read that header in some mapping.

U can use that even in simple message mappings.

http://help.sap.com/saphelp_nw2004s/helpdata/en/43/03612cdecc6e76e10000000a422035/frameset.htm

Your code for the filename tag would be something like:

<i>DynamicConfiguration conf = (DynamicConfiguration) container

.getTransformationParameters()

.get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

DynamicConfigurationKey key = DynamicConfigurationKey.create(

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

“FileName”);

return conf.get(key);</i>

Regards,

Henrique.

Answers (1)

Answers (1)

Former Member
0 Kudos

It worked as you said, thank you both.

Regards

Gonzalo