cancel
Showing results for 
Search instead for 
Did you mean: 

How to open document from DMS in web dynpro

Former Member
0 Kudos

Hello experts,

     I want to display stored document in web dynpro when we click on the linktoaction  UI element.

    How to do this.

Accepted Solutions (0)

Answers (2)

Answers (2)

kmoore007
Active Contributor
0 Kudos

Try  function 'ARCHIVOBJECT_GET_URI'

Former Member
0 Kudos

Hi Vishal,

I had a same kind of requirement this is how i did it, Please check if it is of any use to you.

method Load_documents.

call function 'CVAPI_DOC_GETDETAIL'

     exporting

       pf_dokar        = i_document_type

       pf_doknr        = i_document_number

       pf_dokvr        = i_document_version

       pf_doktl        = i_document_part

       pf_active_files = 'X' " bring only active files

     tables

       pt_files        = lt_files

     exceptions

       not_found       = 1

       no_auth         = 2

       error           = 3

       others          = 4.

   if sy-subrc eq 0 and

      lt_files is not initial.

       loop at lt_files into l_file.

      clear: lt_req_file.

       " Get the extension of the file

       find first occurrence of regex '\.[^\.]+$' in l_file-filename match offset l_dot_offset.

       add 1 to l_dot_offset.

       " Get the name of the file

       find all occurrences of regex '[^\\]*(\.).{3,4}' in l_file-filename results lt_result_tab.

       " Get the last match

       describe table lt_result_tab lines sy-index.

       read table lt_result_tab into l_result index sy-index.

       if sy-subrc eq 0.

         " File name

         l_original-file_name = l_file-filename+l_result-offset(l_result-length).

       endif.

       l_message-type = 'I'.

       concatenate 'Processing file' l_original-file_name

                   into l_message-message separated by space.

       append l_message to _messages.

       append l_file to lt_req_file.

       if i_with_content eq 'X'.

         clear: l_bin_content,

                l_content,

                lt_content.

         refresh: lt_xdata.

         call function 'CVAPI_DOC_CHECKOUTVIEW'

           exporting

             pf_dokar           = i_document_type

             pf_doknr           = i_document_number

             pf_dokvr           = i_document_version

             pf_doktl           = i_document_part

             pf_content_provide = 'TBL'

           tables

             pt_files           = lt_req_file

             ptx_content        = lt_content.

         if lt_content is not initial.

           loop at lt_content into l_content.

             if lt_xdata is initial.

               perform doc_get_mime_type in program saplcom_cfg_db_tools

                 using    l_content-orblk

                 changing l_original-mime_type.

             endif.

             ls_xdata-line = l_content-orblk.

             append ls_xdata to lt_xdata.

             if lf_size is initial.

               lf_size = l_content-orln.

             endif.

           endloop.

           " Convert binary to xstring

           call function 'SCMS_BINARY_TO_XSTRING'

             exporting

               input_length = lf_size

             importing

               buffer       = l_bin_content

             tables

               binary_tab   = lt_xdata

             exceptions

               failed       = 1

               others       = 2.

           clear: lf_size.

         else.

           l_message-type = 'E'.

           l_message-message = 'File load failed'.

           append l_message to _messages.

         endif.

       endif.

       l_original-file_content = l_bin_content.

       append l_original to et_originals.

     endloop.

endmethod.

method Read.

call method me->load_documents

         exporting

           i_document_type    = i_document_type

           i_document_number  = i_document_number

           i_document_version = i_document_version

           i_document_part    = i_document_part

           i_with_content     = 'X'

         importing

           et_originals       = lt_originals

           et_char_values     = lt_char_values.

       if lt_originals is not initial.

create object l_km_ws_obj.

           loop at lt_originals into l_original.

             loop at lt_directories into l_directory.

               concatenate l_directory-directory '/' l_original-file_name

                               into l_find_resource_in-root_rid.

               concatenate l_directory-directory '/' l_original-file_name

                               into l_lookup_in-rid.

               l_message-type = 'I'.

               concatenate 'KM full path is ' l_lookup_in-rid

                           into l_message-message separated by space.

               append l_message to _messages.

               l_km_ws_obj->lookup( exporting input = l_lookup_in

                                     importing output = l_lookup_out ).

* if the file exists, pass the URL back

               ls_file_details-file_name = l_original-file_name.

* Getting the pth based on the system ID

               select single path from zhs_sysid_path into lv_path where sysid = sy-sysid.

               concatenate lv_path 'irj/go/km/docs/' l_lookup_in-rid

                           into ls_file_details-file_path.

               append ls_file_details to et_files.

               l_message-type = 'I'.

               concatenate 'File' l_original-file_name 'has been read'

                           into l_message-message separated by space.

               append l_message to _messages.

             endloop.

           endloop.

end method.

Thanks

Phani