Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

GOS read/save from one doc to another

Manohar2u
Active Contributor
0 Kudos

We have a requirement to download and upload URL link from GOS from one document to another i.,e from purchase req to purchase order etc.

Is there any standard function module/method available to retrieve from one document update/save into new document? So I can place in a bdi of purchase order.

Cheers

Manohar

2 REPLIES 2

former_member156446
Active Contributor
0 Kudos

This message was moderated.

Former Member
0 Kudos

Here is a small example how you can get the GOS from a VC01N_M document....

Maybe that will help you ?


*---1) Get GOS attachments for VC01N_M document
      refresh: ta_srgbtbrel.
      select * from srgbtbrel into table ta_srgbtbrel
                      where instid_a = p_vbeln
                        and typeid_a = 'BUS1051'
                        and catid_a  = 'BO'.

      check sy-subrc eq 0.
      sort ta_srgbtbrel by instid_a typeid_a catid_a.
      delete adjacent duplicates from ta_srgbtbrel
                      comparing instid_a typeid_a catid_a.

      loop at ta_srgbtbrel into wa_srgbtbrel.

        clear: gs_lpor.
        gs_lpor-instid = wa_srgbtbrel-instid_a.
        gs_lpor-typeid = wa_srgbtbrel-typeid_a.
        gs_lpor-catid  = wa_srgbtbrel-catid_a.

        ls_option-sign   = 'I'.
        ls_option-option = 'EQ'.
        ls_option-low    = 'ATTA'.
        append ls_option to lt_options.

        ls_option-low = 'NOTE'.
        append ls_option to lt_options.

        ls_option-low = 'URL'.
        append ls_option to lt_options.

        try.
            call method cl_binary_relation=>read_links_of_binrels
              exporting
                is_object           = gs_lpor
                it_relation_options = lt_options
                ip_role             = 'GOSAPPLOBJ'
                ip_no_buffer        = 'X'
              importing
                et_links            = lt_links.
            .
            loop at lt_links into ls_link.
              document_id = ls_link-instid_b.

*-------------Get all information on a document
              clear: document_data.
              refresh: object_content, object_content.

              call function 'SO_DOCUMENT_READ_API1'
                exporting
                  document_id                = document_id
                importing
                  document_data              = document_data
                tables
                  object_content             = object_content
                  contents_hex               = contents_hex
                exceptions
                  document_id_not_exist      = 1
                  operation_no_authorization = 2
                  x_error                    = 3
                  others                     = 4.

              attdoctype = document_data-obj_type.
              atttitle   = document_data-obj_descr.
              attsize    = document_data-doc_size.
*             attsize    = xstrlen( fp_formoutput-pdf ).

*-------------Binary_tab must be in SOLIX table format
              refresh: binary_tab.
              binary_tab[] = contents_hex[].
*             binary_tab = cl_document_bcs=>xstring_to_solix(
*                          ip_xstring = fp_formoutput-pdf ).


*-------------2) Add attachment to email
              document->add_attachment( exporting i_attachment_type = attdoctype
                                                  i_attachment_subject = atttitle
                                                  i_attachment_size = attsize
                                                  i_attachment_language = sy-langu
                                                  i_att_content_hex = binary_tab ).
            endloop.