Using OfficeControl

Use

This simple example describes how you can use OfficeControl to integrate a Microsoft Office document into a Web Dynpro application. You can find a description of the OfficeControl in the UI element referenve of this documentation.

OfficeControl is implemented in a Web Dynpro application that is used by a defined user community, since the installation of the respective Office program must be installed on the client.

Prerequisites

  • Web Dynpro Component, Window, and View for your application

  • In this example a file is read that is called test.doc, and is kept in the MIME repository.

Define Context

  1. Go to the context of your view and define a context node with a context element of type XSTRING, which is to be used for saving the content.

  2. Define a further context element for the visibility, for example, VISIBLE of type WDUI_VISIBILITY.

  3. To store your Office file in the context, use the WDDOMODIFYVIEW method.

    METHOD wddomodifyview.
    
      DATA:
        mime_repository TYPE REF TO if_mr_api,
        content TYPE xstring,
        url TYPE string VALUE
    '/SAP/BC/WebDynpro/SAP/PUblic/BC/ssr/uuielibs/office_integration' &
    '/test.doc'.
    
    * just do it once
      CHECK first_time = abap_true.
    
      mime_repository ?= cl_mime_repository_api=>get_api( ).
    
      CALL METHOD mime_repository->get
        EXPORTING
          i_url     = url
        IMPORTING
          e_content = content.
    
      wd_context->set_attribute( name = 'DATAS' value = content ).
    
      wd_context->set_attribute( name = 'visible'  value =
    cl_wd_office_control=>e_visible-visible ).
    ...
    endmethod.
                      
  4. Save your entries.

Integrate OfficeControl into the Layout

  1. Add a OfficeControl UI element to your view.

  2. Bind property OfficeControl.dataSource to the context attribute for the content.

  3. Bind property OfficeControl.visible to the context node for the visibility.

  4. Save your entries.