Step-by-Step guide to develop Outbound ABAP Proxy from SAP with PDF attachment

By Ajay Kumar

In order to develop a ABAP Proxy first we need to have a Proxy Configured in the transaction SPROXY, this is to be done by PI or XI consultant, as a ABAPer you are not concerned with this.

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
  2. 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.
  3. We need to create a simple report program using SE38 .
  4. 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 .

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

  1. If some amount field is involved, we can use FM CONVERSION_EXIT_CUNIT_OUTPUT to put –ve sign on the left side.
  2. 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.

  1. Get all the data required for PDF into a internal table.
  2. 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.
  3. Use FM 'GET_PRINT_PARAMETERS', if some special format is required. Start the TRY-CATCH Block. To create SPOOL :


 PARAMETERS g_pripar



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


  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

Click here to continue...

Please send us your feedback/suggestions at webmaster@SAPTechnical.COM 

HomeContribute About Us Privacy Terms Of Use • Disclaimer • SafeCompanies: Advertise on SAPTechnical.COM | Post JobContact Us  

Graphic Design by Round the Bend Wizards

footer image footer image