Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 3354

Re: Attaching attachments in custom module pool program

$
0
0

Hi Siva,

 

First, when you work with attach document, we are talking about GOS Service, so, all document saved in SAP that use GOS service is stored in SRGBTBREL table.

 

For do your goal, try to do this:

 

1.- Use GUI_UPLOAD FM like this:

 

    CALL FUNCTION 'GUI_UPLOAD'

      EXPORTING

        filename                = g_filename

        filetype                = 'BIN'

      IMPORTING

        filelength              = g_attsize

      TABLES

        data_tab                = gt_bin

      EXCEPTIONS

        file_open_error         = 1

        file_read_error         = 2

        no_batch                = 3

        gui_refuse_filetransfer = 4

        invalid_type            = 5

        no_authority            = 6

        unknown_error           = 7

        bad_data_format         = 8

        header_not_allowed      = 9

        separator_not_allowed   = 10

        header_too_long         = 11

        unknown_dp_error        = 12

        access_denied           = 13

        dp_out_of_memory        = 14

        disk_full               = 15

        dp_timeout              = 16

        OTHERS                  = 17.

 

The goal here, is just upload the file.

 

2.- Use macro and BINARY_RELATION_CREATE_COMMIT FM, like this

 

      swc_container lt_message_container.

      swc_container l_cont.

      swc_create_object  l_obj  'MESSAGE'       ''.

      swc_set_element    l_cont 'NO_DIALOG'     'X'.

      swc_set_element    l_cont 'DOCUMENTTITLE' g_filename.

      swc_set_table      l_cont 'Content_Hex'   gt_bin.

      swc_set_element    l_cont 'DOCUMENTTYPE'  lv_ext.

      swc_set_element    l_cont 'DOCUMENTSIZE'  g_attsize.

      swc_refresh_object l_obj.

      swc_call_method    l_obj  'CREATE'        l_cont.

      swc_get_object_key l_obj  gs_objb-objkey.

 

      gs_objb-objtype = gc_msg.

      gs_obja-objtype = gc_bus.

      gs_obja-objkey  = p_ebeln.

 

      CALL FUNCTION 'BINARY_RELATION_CREATE_COMMIT'

        EXPORTING

          obj_rolea      = gs_obja

          obj_roleb      = gs_objb

          relationtype   = 'ATTA'

        IMPORTING

          binrel         = gs_binrel

        TABLES

          binrel_attrib  = gt_binatt

        EXCEPTIONS

          no_model       = 1

          internal_error = 2

          unknown        = 3

          OTHERS         = 4.

 

The goal here, is store the document in SAP, so, check SRGBTBREL table and find your document. It's important store the values(INSTID_B, TYPEID_B, CATID_B) in Z table, because after that the user will check the file again.

 

3.- If you want display the file attached doing click or double click

 

DATA: obj_display TYPE REF TO cl_gos_document_service.

  READ TABLE git_addoc INTO gst_addoc WITH KEY flag = gc_x.

  IF sy-subrc = 0.

 

 

    CREATE OBJECT obj_display.

 

 

    CALL METHOD obj_display->display_attachment

      EXPORTING

        ip_attachment = gst_addoc-instid_b.

 

 

    FREE obj_display.

 

I hope will be useful for you.

 

Regards,


Viewing all articles
Browse latest Browse all 3354

Trending Articles



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