0

I have a requirement where different documents are saved as a xstring on a database table.
These documents should now be displayed. For this I use the SAP Document Viewer. I got it to work with PDFs, but not with .doc files.

When I try to use it with .doc files, instead of displaying the document I get a download window like in the browser with a zip file containing the content of the word document.

In the example below I skipped the part of reading the xstring from the database and instead tried to display it directly after upload. The problem remains the same.

TYPE-POOLS: soi.
TYPES: ty_daten(2550) TYPE c.

DATA: custom_container TYPE REF TO cl_gui_custom_container,
      document_viewer  TYPE REF TO i_oi_document_viewer.
DATA: t_daten          TYPE STANDARD TABLE OF ty_daten
                       WITH NON-UNIQUE DEFAULT KEY.

DATA: filesize TYPE i.


END-OF-SELECTION.

  CREATE OBJECT custom_container
          EXPORTING container_name = 'CONTAINER100'.

  CALL METHOD c_oi_container_control_creator=>get_document_viewer
           IMPORTING viewer = document_viewer.

  CALL METHOD document_viewer->init_viewer
            EXPORTING parent = custom_container.

  CALL FUNCTION 'UPLOAD'
       EXPORTING
            filename                = 'c:\temp\test.doc'
            filetype                = 'BIN'
       IMPORTING
            filesize                = filesize
       TABLES
            data_tab                = t_daten
       EXCEPTIONS
            conversion_error        = 1
            invalid_table_width     = 2
            invalid_type            = 3
            no_batch                = 4
            unknown_error           = 5
            gui_refuse_filetransfer = 6
            OTHERS                  = 7.
  IF sy-subrc <> 0.
    WRITE:/ 'Fehler',sy-subrc.
    STOP.
  ENDIF.

  CALL METHOD document_viewer->view_document_from_table
    EXPORTING
        type         = soi_type_application
        subtype      = soi_doctype_word_document
        size         = filesize
        show_inplace = 'X'
    CHANGING
        document_table = t_daten
    EXCEPTIONS
        cntl_error = 1
        not_initialized = 2
        dp_error_general = 3
        invalid_parameter = 4
        dp_invalid_parameter = 5.

  CALL SCREEN 100.

  CALL METHOD document_viewer->destroy_viewer.
  CALL METHOD custom_container->free.
  FREE: document_viewer, custom_container.
2
  • 1
    So, you are using the Document Viewer of SAP GUI Desktop Office Integration (DOI). There is also the integration of Microsoft Word, and the display which starts Word "in place" in SAP GUI via Control Framework (methods c_oi_container_control_creator=>get_container_control, init_control, get_document_proxy). The integration may be difficult, there are several SAP Notes to help troubleshooting. Because of that, I prefer the solution to start Word outside SAP GUI. Commented Apr 12 at 16:49
  • Thank you for the insight @SandraRossi, I will look into your suggestion and check if using the Microsoft Word integration is worth it or not. Commented Apr 14 at 7:58

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.