cancel
Showing results for 
Search instead for 
Did you mean: 

ABAP Proxy attachment

DG
Active Contributor
0 Kudos

Hi,

I need to send a flat file (a file which has been encrypted) from ERP via PI to a partner.

Is it possible to create an attachment with the flatfile in a proxy interface or even better can I just have the flat file as payload to my proxy.

regards

Daniel

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Proxy with attachements..

/people/michal.krawczyk2/blog/2006/04/19/xi-rfc-or-abap-proxy-abap-proxies-with-attachments

DG
Active Contributor
0 Kudos

Hi Sarvesh,

It seems to work. It only seems to work with the file as an attachment and not as a main documenent.

/Daniel

Answers (1)

Answers (1)

Former Member
0 Kudos

Hello,

Yes, it is very well possible. Here is the link for coding proxies:

http://help.sap.com/saphelp_nw70/helpdata/en/a7/3b2a2d45a34a23b75e3b18745c63bc/content.htm

And here is some example code:

*&----


*

*& Report ZPI_P_PROXY_ATTACH_BINARY

*& Author: S. Gökhan Topçu

*&----


*

*&

*&

*&----


*

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.