cancel
Showing results for 
Search instead for 
Did you mean: 

Proxy to SOAP with file attachment

Former Member
0 Kudos

Hi,

Before I describe the requirement I would like to say that I did search on scn before posting this query

I have a scenario where in an ABAP Proxy with File Name and Date_Time in it's structure would send a flat file as an attachment.

PI is required to drop this flat file in target server using SOAP adapter.

For some reasons FTP or SFTP connectivity is not recommended.

Kindly suggest how to proceed with this design.

Regards,

Vishal

Accepted Solutions (0)

Answers (6)

Answers (6)

Former Member
0 Kudos

Hi,

We are working on similar scenario. PI [7.11] receives SRM Purchase Orders with any binary attachment. I have gone though various blogs to understand how to read this attachment. But i have not got any concrete result.

I have to read these attachment and further convert them to BASE64 format. I have to generate MIME file with PO XML payload and Base64 attachment data.

Kindly help on reading these attachment.

0 Kudos

HI Vishal ,

Are you sending the attachement through the proxy? i mean using the class .If not please use the following code in ABAP sidee.

REPORT  ZPI_P_PROXY_ATTACH_BINARY.

  •   Adapters supporting attachments:
  •     File/FTP(Sender)
  •     SOAP
  •     Marketplace
  •     Mail(XIPAYLOAD)
  •     RNIF20
  •     XI

*

*

  •   Methods of Protocol IF_WSPROTOCOL_ATTACHMENTS

*

  •   GET_ATTACHMENT_FROM_TEXT - Returns an attachment object for a parameter of type STRING.
  •   GET_ATTACHMENT_FROM_BINARY - Returns an attachment object for a parameter of type XSTRING.
  •   SET_ATTACHMENTS - Attaches one or more attachment objects to the output message by using a table.
  •   GET_ATTACHMENTS - Returns a table with attachment objects at the receiver.
  •   RESET_ATTACHMENTS - Deletes the attachment table for the output message.

*

*

  •   Attachment objects implement the IF_AI_ATTACHMENT interface. This interface specifies a
  •   selection of constants, for example IF_AI_ATTACHMENT=>C_MIMETYPE_TEXT_HTML to help specify
  •   the attachment type. You must specify this constant when you want to create an attachment object.

*

  •   Methods of Interface IF_AI_ATTACHMENT

*

  •   GET_KIND - Returns the type of attachment as either
  •              IF_AI_ATTACHMENT=>C_ATTACH_TYPE_BINARY or
  •              IF_AI_ATTACHMENT=>C_ATTACH_TYPE_TEXT
  •   GET_CONTENT_TYPE - Returns the attachment type.
  •   GET_TEXT_DATA - Only use for attachment objects of type IF_AI_ATTACHMENT=>C_ATTACH_TYPE_TEXT
  •                   Returns the attachment data as STRING.
  •   GET_BINARY_DATA - Returns the attachment data as XSTRING. You can use this method for both
  •                     types of attachments.
  •   GET_DOCUMENT_NAME - Returns the attachment name.

DATA:

* Reference variables for proxy and exception class

  lo_ClientProxy          TYPE REF TO ZCO_MIOA_MSG,

* Structures to set and get message content

  ls_request              TYPE ZMT_REQUEST,

  •   Protocol variables

  lo_attachment_protocol  TYPE REF TO IF_WSPROTOCOL_ATTACHMENTS,

  l_attachment            TYPE REF TO if_ai_attachment,

  lt_attach               TYPE prx_attach,

  l_xstring               TYPE xstring,

  l_string                TYPE string,

  l_type                  TYPE string,

  l_name                  TYPE string,

* Exception variables

* lo_oref                 TYPE REF TO cx_root,

  lo_text                 TYPE STRING,

  lo_sys_exception        TYPE REF TO cx_ai_system_fault,

  lo_app_exception        TYPE REF TO cx_ai_application_fault

  .

  •   Get the attachment text file

DATA: input_set    TYPE STRING,

      msg          TYPE STRING.

TRY.

  •   create proxy client

    CREATE OBJECT lo_ClientProxy.

  •   get protocol for attachments

    lo_attachment_protocol ?= lo_ClientProxy->get_protocol( if_wsprotocol=>ATTACHMENTS ).

  •   fill attachment data and get the attachment object

    l_name    = 'Ibanez'.

    l_type    = if_ai_attachment=>C_MIMETYPE_JPEG.

    CALL METHOD lo_attachment_protocol->GET_ATTACHMENT_FROM_BINARY

      EXPORTING

        DATA       = l_xstring

        TYPE       = l_type

        NAME       = l_name

      RECEIVING

        ATTACHMENT = l_attachment

        .

  •   Add the attachment to the attachments table

    APPEND l_attachment TO lt_attach.

  •   Set the attachments

    lo_attachment_protocol->SET_ATTACHMENTS( lt_attach ).

  CATCH cx_ai_system_fault INTO lo_sys_exception.

*   lo_text = lo_sys_exception->errortext.

    lo_text = lo_sys_exception->get_text( ).

    MESSAGE lo_text TYPE 'A'.

    LEAVE PROGRAM.

ENDTRY.

*******************     FILL REQUEST DATA   **************************

ls_request-mt_request-name   =  SY-UZEIT.

ls_request-mt_request-age    =  '40'.

*******************    END OF REQUEST DATA  ***************************

TRY.

CALL METHOD lo_ClientProxy->EXECUTE_ASYNCHRONOUS

      EXPORTING

        OUTPUT = ls_request.

    COMMIT WORK.

    WRITE: / 'Request sent'.

  CATCH cx_ai_system_fault INTO lo_sys_exception.

    lo_text = lo_sys_exception->get_text( ).

    MESSAGE lo_text TYPE 'A'.

    LEAVE PROGRAM.

  CATCH cx_ai_application_fault INTO lo_app_exception.

    lo_text = lo_sys_exception->get_text( ).

    MESSAGE lo_text TYPE 'A'.

    LEAVE PROGRAM.

ENDTRY.

Then once you send it to PI in Runtime workbech you check in the payload eaither you are receiving the attachment or not.

Thnaks,

Mohan

Former Member
0 Kudos

Hi All,

Any idea how to resolve this in PI 7.0?

Regards,

Vishal

Former Member
0 Kudos

Could someone help here?

Regards,

Vishal

0 Kudos

HI Vishal,

Have you tried to enable the option in operation mapping Read attachments.This will read the attachments if you are sending the attachment with proxy.

Thanks

Mohan

Former Member
0 Kudos

Hi Mohan,

I am using PI 7.0. There is no option to read attachments in interface mapping.

Regards,

Vishal

ambrish_mishra
Active Contributor
0 Kudos

HI Vishal,

Hope you have checked the link http://scn.sap.com/thread/3250774

SOAP Attachments - PI 7.1.1

Are you going to send the file as attachment in ABAP proxy ? then check http://scn.sap.com/thread/3250774 as well.

Ambrish

Former Member
0 Kudos

Hi Ambrish,

Thanks for your response. I am on PI 7.0.

The scenario is the ABAP proxy would send file as an attachment and I need to send that file as an attachment to target using SOAP adapter.

Is it possible to do without any UDF or java mapping? Are there any standard adapter modules available to read and write attachments?

Regards,

Vishal

ambrish_mishra
Active Contributor
0 Kudos

Hi Vishal,

Have you taken a look at:

http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/404ee507-3fbc-2e10-00bc-be90ab28d...

and

http://scn.sap.com/thread/3250774.

I think you should be able to work out the scenario with these 2.

hope it helps!

Ambrish

rajasekhar_reddy14
Active Contributor
0 Kudos

SOAP adapter doesnot support FTP protocol connectivty hence not possible to place file on FTP /SFTP.

Former Member
0 Kudos

I agree that SOAP adapter does not support FTP protocol, but we need to send that file as an attachment using SOAP adapter.