cancel
Showing results for 
Search instead for 
Did you mean: 

Source Filename to XML with File Adapter

Former Member
0 Kudos

Hi,

I need to insert the filename in the XML structure when the file is read by File Sender Adapter (FTP).

Example

<document>
  <filename>file_200602081000.dat</filename>
  <record>
    <row>
      <line>Line 1</line>
      <line>Line 2</line>
    </row>
  </record>
</document>

It's possible?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

If you are giving a single filename in the File adapter configuration then you can easily get the filename using the Module.

The code to get the filename is

Channel channelid = moduleContext.getChannelID();

String file = channelid.getValueAsString("file.sourceFileName");

Then you can add this to your XML structure in that module itself.

regards,

P.Venkat

Former Member
0 Kudos

I don't know anything about module. You can help me?

Former Member
0 Kudos

Hi Evandro,

Module comes into play whenever you want to change the input XML before going to Mapping.

check this thread for creating and deploying module.

use my code in the previous post in the module to get the file name.

Hope this solves your problem.

regards,

P.Venkat

Answers (4)

Answers (4)

Former Member
0 Kudos

Answered

Former Member
0 Kudos

Hi Evandro,

please go through the link. This may help you.

http://help.sap.com/saphelp_nw2004s/helpdata/en/e2/e13fcd80fe47768df001a558ed10b6/frameset.htm

Thanks and Regards

Vishal Kumar

Former Member
0 Kudos

Hi Evandro,

Its possible using the extended source file option where you can send it and receive it using the same option in the receiver file adapter and write it with the same name which is possible from SP14 onwards.

But if you want it in the payload you need to use it by modifying the payload using adapter module.

Cheers

JK

moorthy
Active Contributor
0 Kudos

Hi,

If you are using XI SP14, you have inbuilt options to retrieve the file name in the File Sender Adapter. Once you choose that option in the Adapter configuration , in Mapping you can access the file name.

For more info refer to /people/sap.user72/blog/2005/10/01/xi-new-features-in-sp14

Following link tells about Release Notes:

http://help.sap.com/saphelp_nw04/helpdata/en/43/161682de3c04bae10000000a11466f/frameset.htm

If XI is below SP14, then you need to use Module Processor to retrieve the File Name.

regards,

Moorthy

Former Member
0 Kudos

My XI is in SP13. It's possible in SP13?

MichalKrawczyk
Active Contributor
0 Kudos

Hi,

yes very easily (few lines of code)

you can do it inside an adapter module:

SAP note

819761 - XI 3.0 File Sender: Accessing source file name from a module

Regards,

michal

-


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

moorthy
Active Contributor
0 Kudos

There is no inbuilt options available in SP13.

So in this case you need to write Java Module code and you need to deploy it in the Sender file Adapter.

You have How to Create Adapter Modules guide from SAP itself. You can refer the same.

You can go thru following blog for more details in SP14.

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

(in SP14)

Hope this helps,

Regards,

Moorthy

bhavesh_kantilal
Active Contributor
0 Kudos

Hi Evandro,

This link contains a list of all standard functions available in XI. Just go through them and check if it helps,

http://help.sap.com/saphelp_nw04/helpdata/en/43/c4cdfc334824478090739c04c4a249/content.htm

Regards,

Bhavesh