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

...Previous  

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

      ENDLOOP.

 

      TRANSLATE g_string USING '| '.

      DO.

        wa_buf = g_string.

        APPEND wa_buf TO g_t_buf.

        SHIFT g_string BY 255 PLACES.

        IF g_string IS INITIAL.

          EXIT.

        ENDIF.

      ENDDO.

 

  1. Appending 255 character data in one variable.

IF g_t_buf[] IS NOT INITIAL.

   LOOP AT g_t_buf INTO wa_buf.

          CONCATENATE

            g_output

            wa_buf

          INTO g_output.

        ENDLOOP.

 

  1. Convert the Binary String to XSTRING

CALL FUNCTION 'SCMS_STRING_TO_XSTRING'

        EXPORTING

          text   = g_output

        IMPORTING

          buffer = g_outputx

 

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

  1. Below is the code required to send the proxy.

TRY-CATCH

* Get attachment protocol

 

        TRY.

            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

              EXPORTING

                output = g_t_header.

          CATCH cx_ai_system_fault INTO lo_sys_exception.

            COMMIT WORK.

        ENDTRY.

CATCH cx_ai_system_fault INTO lo_sys_exception.

  ENDTRY.

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

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