• SAP 实例 8 HTML from the MIME Repository


    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. 

  • 相关阅读:
    bzoj3926: [Zjoi2015]诸神眷顾的幻想乡 后缀自动机在tire树上拓展
    Codeforces Beta Round #64D
    bzoj2300#2300. [HAOI2011]防线修建
    Codecraft-18 and Codeforces Round #458 (Div. 1 + Div. 2, combined)G. Sum the Fibonacci
    D
    Codeforces Round #503 (by SIS, Div. 1)E. Raining season
    dp优化
    (CCPC-Final 2018)K
    Educational Codeforces Round 48 (Rated for Div. 2)G. Appropriate Team
    Python 匿名函数
  • 原文地址:https://www.cnblogs.com/JackeyLove/p/13489518.html
Copyright © 2020-2023  润新知