Skip to end of metadata
Go to start of metadata

In order to develop a ABAP Proxy first we need to have a Proxy Configured in SPROXY t Code, this is to be done by  XI person, as a ABAPer you are not concerned with this. We need to Activate this Proxy configured. Although Proxy demands a little more code than IDoc's butu still its a better option to choose.

Author:       Ajay kumar  

Company:       Larsen & Toubro Infotech
Created on:    22 June, 2011
Author(s) Bio
Ajay Kumar is a SAP Consultant with L&T Infotech. 

The Proxy configured in SPROXY will look like.

By Clicking on the structure we can also see the structure of the Proxy, which is in tree structure.

In this case , proxy  have 4 structured to be filled with data and then trigger the proxy to PI.

In order to create the proxy from the namespace given, we need to do following

  1.  Right click on the Message interface(outbound) and click on create.# After clicking on create it will ask for Transport Request no, prefix, proxy class and other details,that we need to give in order to create the proxy and then activate.
  2. We need to create a simple report program using SE38
  3. We need to create a structure that will refer to the proxy structure. We need to populate this in order to send our data.
                               g_t_header TYPE  zintercompany_data _send
  4. Various data declalarions required for Proxy sending and PDF attachment sending are.
                              attch_protocol TYPE REF TO   if_wsprotocol_attachments,
                               g_attachment     TYPE REF TO if_ai_attachment,
                               g_attachments    TYPE prx_attach,       "Internal table for attachment
                               g_attach_xstring TYPE xstring,             "variable of xstring type.
                               g_spool_id TYPE tsp01-rqident,
                               g_pripar TYPE pri_params,
                               g_arcpar TYPE arc_params,
                               g_pdfspoolid TYPE tsp01-rqident,           "SPOOL ID
                               g_jobname TYPE tbtcjob-jobname,        "Jobname parameter for SPOOL
                               g_jobcount TYPE tbtcjob-jobcount,        "Jobcount Paramater for SPOOL
                               g_string TYPE string,                                  "To convert 132 character data into 255 character data.
                *Reference variables exception class
                               lo_sys_exception   TYPE REF TO cx_ai_system_fault,
                *Object declaration for Proxy Class
                              obj_invoice1 TYPE REF TO “Proxy class name”.
             * creating proxy object
                              CREATE OBJECT obj_invoice1.
  5.  If some amount field is involved, we can use FM CONVERSION_EXIT_CUNIT_OUTPUT to put --ve sign on the left side.# Update the main structure with the data required, if some substructures are there,then also finally we need to fill the main structure we only, that will be passed while triggering the proxy.
                                 g_t_header-invoice_details-invoice_line_item[] = g_t_tab_det[].
                                 g_t_header-invoice_properties = wa_inv_pro.
  6. Get all the data required for PDF into a internal table.
  7. In order to send the PDF into the proxy we need to get all the data in a “Xstring” type variable.To do so first we need to create a SPOOL of the data in our internal table.
  8. Use FM 'GET_PRINT_PARAMETERS', if some special format is required. Start the TRY-CATCH Block. To create SPOOL :
                                  NEW-PAGE PRINT ON
                                  PARAMETERS g_pripar
                                  ARCHIVE PARAMETERS g_arcpar
                                  NO DIALOG.
                      “Write your data that need to be printed , with the format required for PDF. Whatever written here will be converted into SPOOL.
                                  g_spool_id = sy-spono.
                                  NEW-PAGE PRINT OFF.

Else than this the steps required are  :
1. Convert the SPOOL into  PDF format.
2. Converting the 132 character data to 255 character data.
3. Append 255 character data in one variable.
4. Convert the Binary String to XSTRING, and concatenate it with data field, which will be sent to proxy.

Below is the code required to complete the remaining part.

1.We need to convert this SPOOL into  PDF format using FM 'CONVERT_ABAPSPOOLJOB_2_PDF'
          src_spoolid                = g_spool_id                 " SPOOL ID
          no_dialog                   = ' '
          pdf_bytecount          = g_size_bytes
          pdf_spoolid               = g_pdfspoolid
          btc_jobname             = g_jobname
          btc_jobcount             = g_jobcount
          pdf                               = g_table                " All the data will be in this Data table
2. Converting the 132 character data to 255 character data
 CLEAR g_string.
      LOOP AT g_table INTO wa_table.
        TRANSLATE wa_table USING ' |'.
        CONCATENATE g_string wa_table INTO g_string.
      TRANSLATE g_string USING '| '.
        wa_buf = g_string.
        APPEND wa_buf TO g_t_buf.
        SHIFT g_string BY 255 PLACES.
        IF g_string IS INITIAL.
3. Appending 255 character data in one variable.
IF g_t_buf[] IS NOT INITIAL.
    LOOP AT g_t_buf INTO wa_buf.
          INTO g_output.
4. Convert the Binary String to XSTRING
          text   = g_output
          buffer = g_outputx
5.Concatenating attach_xstring with the data field.We need to send this field to Proxy.
CONCATENATE g_attach_xstring g_outputx INTO  g_attach_xstring   IN BYTE MODE.
6. Below is the code required to send the proxy.

  • Get attachment protocol
                attch_protocol ?= obj_invoice1->get_protocol( if_wsprotocol=>attachments ).
                g_attachment = attch_protocol->get_attachment_from_binary(
                data = g_attach_xstring
                type = if_ai_attachment=>c_mimetype_pdf
                name = 'PDF Attachment' ).           " Name of PDF to be uploaded
                APPEND g_attachment TO g_attachments.
                attch_protocol->set_attachments( g_attachments ).
    *Sending Proxy fields to XI through EXECUTE ASYNCHRONOUS Method.
                CALL METHOD obj_invoice1->execute_asynchronous
                    output = g_t_header.
              CATCH cx_ai_system_fault INTO lo_sys_exception.
                COMMIT WORK.
    CATCH cx_ai_system_fault INTO lo_sys_exception.
    7. Other Exception Handling can be done as per the requirement.Using the “SXMB_MONI” TCode we can check whether the proxy has been sent successfully or not.

1 Comment

  1. Former Member

    Hi Ajay,


    I am able to send files to PI, correctly when the proxy is asynchronous-outbound.

    But I do not find any files when I use a synchronous outbound proxy.