Skip to Content
There have been many discussions on the XI forum regarding the advantages
of using ABAP Proxy protocol over the RFC protocol. In this weblog I will not provide you
with a direct answer which protocol you should use. Instead I will show how you can use
the new protocol’s function of sending attachments together with the message payload.

Let’s imagine we have to send an invoice (in XML) from our R/3 or ERP system.
If this was our only requirement then we could easily consider using either RFC
or ABAP Proxy communication as in both cases messages will be transfered to XML in the XI
but what if we also have to send the same invoice as a jpg file (or PDF) together
with the XML message and send it in the mail (using mail adapter)? What can we do then?
Is there a simple way of doing it? It turns out that there is 🙂 Since ABAP Proxy protocol
sends a SOAP message we can include the jpg file as an SOAP attachment.

Below you’ll find a code sample that executes a proxy call to the XI. Together with the XML message
we’re sending a jpg file in the attachment.

Now when we post this message we will see both parts in the XI – the XML payload and the attachment part of the SOAP message.

image

If we want to include the jpg file inside the e-mail message all we have to do is to check the “keep attachments” indicator.

image

When we test our flow we will see the jpg attachment in the e-mail message.

image

As you can see the jpg file has content-id name but you can easily change it inside the adapter module
of the mail adapter for example so that it can have the attachment’s name name.

I believe that the scenario I’ve described above could also be done with RFC protocol somehow
but I’m pretty sure we’d have to do a lot more coding to achive the same so why not use the new XI’s possibilities?

To report this post you need to login first.

9 Comments

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

  1. gopal srinivasan
    From my understanding, for most of the proxies you need some kind of coding skill either in Java/ ABAP.. those who hate programming can directly use Adapters, even though there are Pro’s on using Proxies..

    agree?

    (0) 
  2. Se Hun(Dov) Jung
    i am trying p2p connection with Webservice based on your weblog. i think your source tell attached files add proxy and you call method “execute_asynchronous” have on parameter.
    like this.
    it-SOURCE_MT-from = ‘michal’.
    it-SOURCE_MT-to = ‘krawczyk’.

    CALL METHOD prxy->execute_asynchronous
         EXPORTING
            output = it.
    COMMIT WORK.

    i don’t understand why method didn’t have parameter included file info.
    please give me detail codes i will be very big help.

    your short comments make me work out my urgent problem. thanks.

    (0) 
    1. Krishna M
      Hi Se Hun
      Method should not have a parameter for attachment. Attachements like docs or images will be attached as a SOAP attachments but not included in SOAP XML payload. That’s why should not be included as a parameter.

      Protocol object “IF_WSPROTOCOL_ATTACHMENTS” will take care of all these.

      This is how it works.

      Activities
      Sender

             1.      Get a protocol object for the protocol IF_WSPROTOCOL_ATTACHMENTS (see Protocols).

             2.      You must declare the following variables both at the attachment sender and receiver:

      data: lt_attach    type prx_attach,
            l_name       type string,
            l_xstring    type xstring,
            l_string     type string,
            l_type       type string,

            l_attachment type ref to if_ai_attachment.

             3.      At the sender, create attachment objects by using the GET_ATTACHMENT_FROM_BINARY() method and attach them to the lt_attach table. You can use the GET_ATTACHMENT_FROM_TEXT() method for string attachments.

             4.      Transfer the lt_attach table to the ABAP proxy runtime with the SET_ATTACHMENTS() attachment protocol method.

             5.      Call the client proxy (see also: Sending a Message).

      Receiver
             6.      At the receiver, declare the same variables as in step two above and get a protocol object for the IF_WSPROTOCOL_ATTACHMENTS protocol (see Protocols).

             7.      Using the GET_ATTACHMENTS() attachment protocol method, get the attachment table. When reading the attachments, ensure that you use the GET_KIND() method to check the attachment object type before you access the data.

      Hope you are clear.
      Let me know if you have any doubts.

      (0) 
      1. venkata sure

        Hi Krishna,

        I have the senario where i need to send my invoice data from ECC to XI with PDF attachments.

        with your code i can see we can attache the .Jpg or PDF files,but when invoice is going to trigger i need to capture the invoice data(IDOC data) and i need to send both IDOC data and attachement in the same message,how can we approach this functionality

        Please help me i am struggling to get the solution.

        Thanks,

        (0) 
  3. Se Hun(Dov) Jung
    i am trying p2p connection with Webservice based on your weblog. i think your source tell attached files add proxy and you call method “execute_asynchronous” have on parameter.
    like this.
    it-SOURCE_MT-from = ‘michal’.
    it-SOURCE_MT-to = ‘krawczyk’.

    CALL METHOD prxy->execute_asynchronous
         EXPORTING
            output = it.
    COMMIT WORK.

    i don’t understand why method didn’t have parameter included file info.
    please give me detail codes i will be very big help.

    your short comments make me work out my urgent problem. thanks

    (0) 
  4. Peter Jaspers Focks
    How does the other way around works.

    We receive a soap message with a XML-attachment.
    This attachments contains the MessageType it’s all about.
    We try to create an Abap-mapping, using the get_attachment method. Is there an example available?

    Thanks
    -Peter

    (0) 
  5. Thanawin Ratametha
    Hi!,

    I’m facing the problem that, I can attach file (PDF) from Sender PDF using your code, it is very useful.

    But here, my requirement, SOAP <-> XI <-> PROXY
    Where proxy will return something with Attach file (PDF). But I really have no idea how to apply your code in this case.

    Or it not possible to do so?

    Thanks for you suggestion 😀

    terry

    (0) 
  6. sachin arora
    Hi,

    I need some clarification for my scenerio. I am sending PO IDoc from R3 to XI using TRFC port in partner profiles and Idoc is coming in XI as required. Now for attachment if I create ABAP proxy then if I understood correctly I will have to write a program which will trigger this Proxy and send the attachment to XI. How do I combine the attachment part which is coming in XI from proxy call and IDOC xml which is coming in XI from RFC port. Just so you know my PO Idoc is not not atandard and I have entended the ORDERS03 IDoc to match my requirement.

    Thanks for your response.

    BR
    Sac

    (0) 

Leave a Reply