Skip to Content
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.

image

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.

image

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….

image

…which is being populated with some values.

image

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

image

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.

image

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

To report this post you need to login first.

27 Comments

You must be Logged on to comment or reply to a post.

  1. Sravya Talanki
    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.
    (0) 
      1. Chris Chris
        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 …..

        (0) 
        1. Michal Krawczyk Post author
          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

          Regards,
          Michal

          (0) 
          1. Elmar Fritz

            Hello Michal!

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

            Mapping “http://ewe.at/best_foeger/OM_FILE_TO_MAIL_FOEGER” konnte nicht ausgeführt werden: MappingException: Runtime Exception when executing application mapping program com/sap/xi/tf/_MM_FILE_TO_MAIL_FOEGER_; Details: com.sap.aii.utilxi.misc.api.BaseRuntimeException; 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

            (0) 
      2. Rajesh PS

        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

        (0) 
      1. Rajesh PS

        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

        UDF3.jpg

        (0) 
  2. Kian Hin Ngan
    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.

    (0) 
    1. Sravya Talanki
      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.
      (0) 
    2. Diana Singleton
      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?
      (0) 
      1. Alok Sarawat
        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
        (0) 
  3. Arvind Ravindran
    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

    Thx
    Arvind

    (0) 
    1. Bhavesh Kantilal
      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

      Regards
      Bhavesh

      (0) 
  4. Sumit Oberoi
    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.

    Thanks
    Sumit

    (0) 
  5. jeevan k
    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.

    %filename%.

    Can you help me….

    (0) 
  6. jeevan k
    Hi,
    If possible can you place the Adapter Configuration SCREEN SHOTS for Sender and Receiver ADAPTERS.
       Facing problem in configuration
    (0) 
  7. XI trigger
    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

    srini

    (0) 
  8. Rajesh PS

    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

    (0) 

Leave a Reply