* Konvertierungsklasse HTML-String nach HTML-itab
CLASS lcl_html_str_to_itab DEFINITION FINAL.
PUBLIC SECTION.
* Zeilenlänge für HTML-itab
CONSTANTS: co_html_length TYPE i VALUE 1024.
* HTML-itab
TYPES: ty_html_line TYPE c LENGTH co_html_length.
TYPES: ty_it_html TYPE STANDARD TABLE OF ty_html_line WITH DEFAULT KEY.
CLASS-METHODS:
convert
IMPORTING
i_html_str TYPE string
RETURNING VALUE(rv_it_html) TYPE ty_it_html.
ENDCLASS.
CLASS lcl_html_str_to_itab IMPLEMENTATION.
**********************************************************************
* Konvertiert HTML-String nach HTML-itab
**********************************************************************
* i_html_str -> HTML-String
* rv_it_html <- HTML-itab
**********************************************************************
METHOD convert.
DATA(lv_right) = i_html_str.
WHILE strlen( lv_right ) >= co_html_length.
* linker Teil
DATA(lv_left) = substring( val = lv_right off = 0 len = co_html_length ).
APPEND lv_left TO rv_it_html.
* Rest
lv_right = substring( val = lv_right off = co_html_length len = strlen( lv_right ) - co_html_length ).
ENDWHILE.
* Rest anfügen
IF strlen( lv_right ) > 0.
APPEND lv_right TO rv_it_html.
ENDIF.
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
* Daten holen
SELECT * FROM tnapr INTO TABLE @DATA(it_tnapr).
* HTML-Daten aus itab generieren
DATA(lv_html) = cl_demo_output=>get( it_tnapr ).
* HTML-String nach HTML itab konvertieren
DATA(it_html) = lcl_html_str_to_itab=>convert( lv_html ).
* HTML-Viewer
DATA(o_hv) = NEW cl_gui_html_viewer( parent = cl_gui_container=>default_screen ).
* URL holen
DATA: lv_url type swk_url.
o_hv->load_data( IMPORTING
assigned_url = lv_url
CHANGING
data_table = it_html ).
* Daten anzeigen
o_hv->show_url( url = lv_url
in_place = abap_true ). " im SAP-Fenster (abap_true) oder im Externen Browser (abap_false) anzeigen
* cl_gui_container=>default_screen erzwingen
WRITE: space.