[ABAP] ITS: HTML aus einem Dynpro generieren

* Paket: SITS_ABAP

* SE11 - Report
DATA: lv_prog TYPE d020s-prog VALUE 'SAPLSD_ENTRY'.
* Dynpro 1000
DATA: lv_dynnr TYPE d020s-dnum VALUE '1000'.
* '' / C - Classic, B - HTML-Business, W - WebGUI
DATA: lv_style TYPE w3style VALUE 'B'.

DATA: lv_html_xstr TYPE xstring.
DATA: it_html TYPE STANDARD TABLE OF w3html WITH DEFAULT KEY.

* Template von Dynpro generieren
CALL FUNCTION 'ITS_GENERATE_HTML_FROM_DYNPRO'
  EXPORTING
    progname                       = lv_prog
    dynnr                          = lv_dynnr
    style_2006                     = lv_style
  IMPORTING
    source_stream                  = lv_html_xstr
  TABLES
    meta_html                      = it_html
  EXCEPTIONS
    style_not_valid                = 1
    dynnr_or_programname_not_valid = 2
    css_not_valid                  = 3
    xsl_not_valid                  = 4
    placeholder_not_valid          = 5
    no_card_identifiers_used       = 6
    error_occured                  = 7
    OTHERS                         = 8.

IF sy-subrc = 0.
  cl_demo_output=>write_data( it_html ).
  DATA(lv_html) = cl_demo_output=>get( ).

* Daten im Inline-Browser im SAP-Fenster anzeigen
  cl_abap_browser=>show_html( EXPORTING
                                title        = 'HTML'
                                html_string  = lv_html
                                container    = cl_gui_container=>default_screen ).

* cl_gui_container=>default_screen erzwingen
  WRITE: space.
ENDIF.

[ABAP] Informationen zu einem Dynpro lesen

* Dynproheaderstruktur
DATA: lv_header LIKE d020s.
* Dynprofeldtabelle
DATA: it_ftab TYPE STANDARD TABLE OF d021s WITH DEFAULT KEY.
* Tabelle für Dynproablauflogik
DATA: it_pltab TYPE STANDARD TABLE OF d022s WITH DEFAULT KEY.

* Dynproloadinformationen mit ABAP-Mitteln
* request:
*  - 'A' - Dynproheader u. Felder
*  - 'F' - Dynprofelder
*  - 'C' - Dynproablauflogik
*  - 'G' - Generiere
*  - 'H' - Dynproheader
*  - 'T' - Testharms
CALL FUNCTION 'RS_IMPORT_DYNPRO'
  EXPORTING
    dylang               = sy-langu       " Dynprogenerierungssprache
    dyname               = 'SAPLSD_ENTRY' " Name des Dynpros (SE11)
    dynumb               = '1000'         " Nummer des Dynpros
    suppress_checks      = abap_true
*    request              = 'A'
  IMPORTING
    header               = lv_header
  TABLES
    ftab                 = it_ftab
    pltab                = it_pltab
  EXCEPTIONS
    button_error         = 1
    dylanguage_invalid   = 2
    dylanguage_not_inst  = 3
    dyname_invalid       = 4
    dynproload_not_found = 5
    dynpro_old           = 6
    dynumb_invalid       = 7
    ftab_invalid         = 8
    gen_error            = 9
    gen_ok               = 10
    header_invalid       = 11
    internal_error       = 12
    no_dynpro            = 13
    no_ftab_row          = 14
    no_memory            = 15
    no_processlogic      = 16
    pltab_invalid        = 17
    request_invalid      = 18
    OTHERS               = 19.

IF sy-subrc = 0.
  cl_demo_output=>write_data( lv_header ).
  cl_demo_output=>write_data( it_ftab ).
  cl_demo_output=>write_data( it_pltab ).

*   HTML-Code vom Demo-Output holen
  DATA(lv_html) = cl_demo_output=>get( ).

*   Daten im Inline-Browser im SAP-Fenster anzeigen
  cl_abap_browser=>show_html( EXPORTING
                                title        = 'Dynpro'
                                html_string  = lv_html
                                container    = cl_gui_container=>default_screen ).

*   cl_gui_container=>default_screen erzwingen
  WRITE: space.
ENDIF.