Skip to Content

XI: The same filename from a sender to a receiver file adapter – SP14

Finally πŸ™‚

Finally (from SP14) we can receive a file do something with it inside XI
and send it back with the same name. No need for writing adapter modules,
no need for variable substitution – SAP gave us a new, easy solution to this issue.
From XI 3.0 SP14 we can use Adapter Specific Message Properties.
Now not only can we use the filename of the received file but we can also change it
inside our mapping (using graphical mapping for example).

Let’s see how the scenario works:

Step 1

Inside your file/FTP adapter we can now set “Adapter Specific Message Properties”
which tell the adapter to include those properties inside the SOAP message sent to XI
from the adapter. Because we want to see the whole example we can start by setting all of them.


Step 2

The file/FTP receiver adapter must also know that he has to use those new properties
so we also have to set them on the receiver’s side.


Step 3

Because we also want to get the filename inside our mapping we have to create a user defined function
which will return the filename and map it to one of our XML tags.

The code shown above just takes the filename so we can map it, if you’d like to change it
have a look at the code provided by SAP: Accessing Adapter-Specific Properties

When we run our file to file scenario we can now see that there’s a new section called DynamicConfiguration….


…which is being populated with some values.


When we take a look at our outbound message we can see that one of our tags has the filename value.


Later on we can check our FTP folder to find out that the created file has exacly the same name
as the file from the sender adapter.


Easy wasn’t it? This example just shows that SAP listens to us (developers)
to make our lives a little bit easier πŸ™‚

You must be Logged on to comment or reply to a post.
  • During the migration process problems have been reported for this blog. The blog content may look corrupt due to not supported HTML code on this platform. Please adjust the blog content manually before moving it to an official community.
      • Hi,
        why dont you answer for the queries which other users facing issues with your blog?

        I always see you just replying only to those who thank to you but not to whom who got some problems while implementing your blog.

        It would be great if you can .....

        • Hi Chris Chris,

          did you read my comment below all of my blogs - - "if you have futher..." ?
          there is a place where all those questions
          can be answers in less then 5 min as they are in 99% that simple - but blog comments is not that place πŸ™‚

          hope you know why I don't answer them here now πŸ™‚
          nothing wrong with me I just want to learn people
          to post questions in a correct place


          • Hello Michal!

            I tried your solution here in 2014 πŸ˜‰ But, it always fails with this error; we are on SAP PI 7.40!

            Mapping "" konnte nicht ausgeführt werden: MappingException: Runtime Exception when executing application mapping program com/sap/xi/tf/_MM_FILE_TO_MAIL_FOEGER_; Details:; Content is not allowed in prolog.

            Do you have any idea, what could be wrong? My scenario is File Sender -> PI -> Mail Receiver, without any mapping. I just want to bring a .pdf to e-mail, and this with the original filename!

            BR, EF

      • Hi Michael,

        Basically my requirement to get Filename in idoc segments in order to validate the posting at month end.

        Its an File to idoc scenario- GL Posting.

        Please check attached UDF and it gives error. Kindly help. Thanks/wp-content/uploads/2015/03/udf1_662969.png

      • Hi Michael,

        Basically my requirement to get Filename in idoc segments in order to validate the postings at month end.

        Its an File to idoc scenario- GL Posting.

        Please check attached UDF and it gives error. Kindly help. Thanks


  • Great article michal!  I guess a lot of people have been waiting to do this.  However, I have a slightly different scenario.  In this case, XI is used as a medium to transfer a PDF file from one directory to another directory.  There is not transformation or mapping involved. 

    The message is send by File Sender Adapter and received by File Receiver Adapter.  Message type is created as a simply type hexBinary.  The file is supposed to be picked up as a PDF and received as a PDF, retaining the same file name.  As such, the file name is neither stored in the source structure nor the target structure.

    Once the PDF file is transfered into target directory, it should be able to be open by using Acrobat directly without further conversion.

    We might add a file name file into the target structure but would that rendered the PDF non-readable upon being received by the File Receiver Adapter?

    Any idea is highly appreciated.

    • He and his articles..Both are great..:)
      We can use file with attachhments option.Check the blog posted by sudhir porumilla.You can execute a OS command in the reciever adapter for making it non readable.
    • Have you received a resolution to your scenario?  I want to use the Seeburger AS2 Adapter to send a text file to XI, then utilize the file adapter in XI to place the same text file in the target directory, using the original file name, on a SFTP Server.  Any ideas?
      • In my scenario I am picking the file using File Adapter and sending it as attachment by Mail Adapter. I want to retain the same file name of attachment. Plz help me
  • Hi Michal,
              Can you please elaborate on step 3. I want to get the Filename into my Payload so that it can be modified. where exactly should I run the Java code u posted? ...

    am a newbie so pls explain it in layman term pls


    • It will work with both XI and PI.
      As long as you SP 14 or higher.

      Also, do not test the code in your message mapping , this will work only during run time


  • Hi Michal,
               I have the following scenario :
    I have a file sender adapter sending a hex:binary file to a file receiver.
    There is another receiver which is a Web Service(SOAP) which needs the name of the file.

    Is this possible? If yes then please give any clue.


  • Can I call this method of File handling as
    variable Substitution..

    I came to know thatthere is method like giving the file name like below.


    Can you help me....

  • Hi Michel,

    I have followed the same and could not see the filename element in the XML ,

    I did following steps:

    1) Checked  : Adapter Specific Confi and Filename

    Since i need the filename in the XML tag , how could i do that , now in the SXMB_moni i see in inbound displaying the content of file as flat file with no tags arounds,

    strange error


  • Hi Michael,

    Basically my requirement to get Filename in idoc segments in order to validate the postings at month end.

    Its an File to idoc scenario- GL Posting.

    Please check attached UDF and it gives error. Kindly help. Thanks/wp-content/uploads/2015/03/udf1_662903.png