Quantcast
Channel: SCN : All Content - Process Integration (PI) & SOA Middleware
Viewing all articles
Browse latest Browse all 7030

Outbound Proxy..... Attaching multiple attachments

$
0
0

Hi Gurus,

 

I want to attach multiple files with my ABAP outbound proxy for Purchase Requisitions. I have done the single attachment but unable to attach multiple files. I am using the following code for attachment.

 

TYPES:
    BEGIN OF gty_file_data,
      entry TYPE x LENGTH 255,
      END OF gty_file_data.

 

DATA:

  gr_consumer_proxy     TYPE REF TO   zco_consumer_proxy,

  gr_proto_attachment   TYPE REF TO   if_wsprotocol_attachments,

  gr_attachment         TYPE REF TO   if_ai_attachment,
  gt_attachments        TYPE          prx_attach,

  gt_file_data          TYPE TABLE OF gty_file_data,

  gv_attachment_xstring TYPE          xstring.

 

FIELD-SYMBOLS:

  <gfs_file_data> TYPE gty_file_data.

 

TRY.

    CALL FUNCTION 'GUI_UPLOAD'

      EXPORTING
        filename =
'D:\Temp\TestDoc.pdf'
        filetype = 'BIN'
      TABLES
        data_tab = gt_file_data.

 

    IF sy-subrc NE 0.

        " Error handling logic

      ENDIF.

 

    LOOP AT gt_file_data ASSIGNING <gfs_file_data>.
      CONCATENATE gv_attachment_xstring

                  <gfs_file_data>-entry

             INTO gv_attachment_xstring

             IN BYTE MODE.
      ENDLOOP.

 

   CREATE OBJECT gr_consumer_proxy.

 

    gr_proto_attachment ?=

      gr_consumer_proxy->get_protocol( if_wsprotocol=>attachments ). 

  

    gr_attachment =

      gr_proto_attachment->get_attachment_from_binary(

                             data = gv_attachment_xstring

                             type = if_ai_attachment=>c_mimetype_pdf

                             name = 'AttachmentDocument' ).
   
APPEND gr_attachment TO gt_attachments.
    gr_proto_attachment->set_attachments( gt_attachments ).

  CATCH cx_ai_system_fault INTO gx_system.

    " Exception handling logic

  ENDTRY.

 

Actually in FM Gui_upload, if give specific location to input parameter file name, it works.

 

CALL FUNCTION 'GUI_UPLOAD'

      EXPORTING
        filename =
'D:\Temp\TestDoc.pdf'
        filetype = 'BIN'
      TABLES
        data_tab = gt_file_data.

But if i want to pass multiple files locations inside loop, it gives error "File is not available". Like this

 

loop at ftab into waf.

   CALL FUNCTION 'GUI_UPLOAD'

       EXPORTING

         filename waf-filename    

         filetype = 'BIN'

       TABLES

         data_tab = gt_file_data.

 

     IF sy-subrc NE 0.

         " Error handling logic

endloop.

       ENDIF.

 

can anybody tell me how can i use this FM for multiple attachment or is there any other wau to attach multiple files in outbound abap proxy.

 

Thanks

 

Regards


Viewing all articles
Browse latest Browse all 7030

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>