Skip to content

ABAP Keyword Documentation →  ABAP - Reference →  User Dialogs →  Dynpros →  Screen and Screen Elements →  Screen Elements - Examples 

Dynpros, HTML from the MIME Repository

This example demonstrates how a HTML file is displayed from the MIME repository.

Other versions: 7.31 | 7.40 | 7.54

Source Code

REPORT demo_html_from_mime.

CLASS mime_demo DEFINITION.
  PUBLIC SECTION.
    CLASS-METHODS main.
  PRIVATE SECTION.
    TYPES: mime_line(1022) TYPE x,
           mime_tab        TYPE STANDARD TABLE OF mime_line
                                WITH EMPTY KEY.
    CLASS-METHODS get_mime_obj
      IMPORTING
        mime_url        TYPE csequence
      RETURNING
        VALUE(mime_tab) TYPE mime_tab.
ENDCLASS.

CLASS mime_demo IMPLEMENTATION.
  METHOD main.
    DATA html_url TYPE c LENGTH 255.

    DATA(custom_container) = NEW
      cl_gui_custom_container( container_name = 'CUSTOM_CONTAINER' ).
    DATA(html_control) = NEW
     cl_gui_html_viewer( parent = custom_container ).

    DATA(pict_tab) = get_mime_obj(
      mime_url = '/SAP/PUBLIC/BC/ABAP/mime_demo/ABAP_Docu_Logo.gif' ).
    html_control->load_data(
      EXPORTING
        url          = 'picture_url'
        type         = 'image'
        subtype      = '.gif'
      CHANGING
        data_table   = pict_tab ).

    DATA(html_tab) = get_mime_obj(
      mime_url = '/SAP/PUBLIC/BC/ABAP/mime_demo/demo_html.html' ).
    html_control->load_data(
      IMPORTING
        assigned_url = html_url
      CHANGING
        data_table   = html_tab ).

    html_control->show_url(
       EXPORTING
         url = html_url ).
  ENDMETHOD.

  METHOD get_mime_obj.
    cl_mime_repository_api=>get_api( )->get(
      EXPORTING i_url = mime_url
      IMPORTING e_content = DATA(mime_wa)
      EXCEPTIONS OTHERS = 4 ).
    IF sy-subrc = 4.
      RETURN.
    ENDIF.
    mime_tab =
      VALUE #( LET l1 = xstrlen( mime_wa ) l2 = l1 - 1022 IN
               FOR j = 0 THEN j + 1022  UNTIL j >= l1
                 ( COND #( WHEN j <= l2 THEN
                                mime_wa+j(1022)
                           ELSE mime_wa+j ) ) ).
  ENDMETHOD.
ENDCLASS.

START-OF-SELECTION.
  mime_demo=>main( ).
  CALL SCREEN 100.

Description

An API is used to load a HTML file and an image from the MIME repository and save them in internal tables. The method LOAD_DATA of the class CL_GUI_HTML_VIEWER is used to associate the data with the HTML control of CFW and the HTML file is displayed. The name of the image in the HTML file is the same as the URL passed to the method LOAD_DATA for the image. LOAD_DATA is given a URL for the image in the internal table and is used on the HTML page.

See also the example for direct access to objects from the MIME repository using ICF.