Display right HTML docker container in selection screen

Display right HTML docker container in selection screen

Code example to display a HTML docker container on the right of a selection screen (to display help for instance).



*&---------------------------------------------------------------------*
*& Report  ZTEST_PROGRAM
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZTEST_PROGRAM.

DATA: g_custom_container TYPE REF TO cl_gui_custom_container,
      g_docking          TYPE REF TO cl_gui_docking_container,
      g_html_viewer      TYPE REF TO object.

CONSTANTS c_selection_screen_1900 TYPE sydynnr VALUE 9000. " Used for
                              " navigation in case of several screens.


" Sample of selection screen :
" ============================
SELECTION-SCREEN BEGIN OF SCREEN 9000.
PARAMETERS : p_test TYPE char10.
SELECTION-SCREEN SKIP 2.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT  1(6)  text-001 FOR FIELD testrun. " Test 1
PARAMETERS testrun  RADIOBUTTON GROUP exec.
SELECTION-SCREEN COMMENT 12(83) text-011 FOR FIELD testrun. " Action 1
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT  1(6)  text-002  FOR FIELD update. " Test 2
PARAMETERS update  RADIOBUTTON GROUP exec.
SELECTION-SCREEN COMMENT 12(83) text-012 FOR FIELD testrun. " Action 2
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF SCREEN 9000.


INITIALIZATION.


AT SELECTION-SCREEN OUTPUT.

  PERFORM show_html_docker.



START-OF-SELECTION.

  CALL SELECTION-SCREEN 9000.





**********************************************************************
* FORMS
**********************************************************************

*&---------------------------------------------------------------------*
*&      Form  SHOW_HTML_DOCKER
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM show_html_docker .

  DATA: l_ratio TYPE i VALUE 85.
  IF sy-scols NE 0.
    l_ratio = 100 - ( 60 * 100 / sy-scols ).
  ENDIF.

  IF g_docking IS  INITIAL.

    CREATE OBJECT g_docking
      EXPORTING
        repid                       = sy-repid
        dynnr                       = sy-dynnr
        side                        = cl_gui_docking_container=>dock_at_right
        ratio                       = l_ratio
      EXCEPTIONS
        cntl_error                  = 1
        cntl_system_error           = 2
        create_error                = 3
        lifetime_error              = 4
        lifetime_dynpro_dynpro_link = 5.
    CHECK sy-subrc EQ 0.  "simply leave in case of any problem

    CREATE OBJECT g_html_viewer TYPE ('CL_GUI_HTML_VIEWER')
      EXPORTING
        parent             = g_docking
      EXCEPTIONS
        cntl_error         = 1
        cntl_install_error = 2
        dp_install_error   = 3
        dp_error           = 4.
    CHECK sy-subrc EQ 0.  "simply leave in case of any problem

    CALL METHOD cl_gui_cfw=>flush
      EXCEPTIONS
        cntl_system_error = 1
        cntl_error        = 2.
    CHECK sy-subrc EQ 0.  "simply leave in case of any problem
  ENDIF.


  DATA: lt_html    TYPE STANDARD TABLE OF abaptxt255,
        l_url(255).

  APPEND '<html><body>'                    TO lt_html.      "#EC NOTEXT
  APPEND '<br><br>'                        TO lt_html.      "#EC NOTEXT
  APPEND '<h3>Test HTML :</h3>'            TO lt_html.      "#EC NOTEXT
  APPEND '<ul>'                            TO lt_html.      "#EC NOTEXT
  APPEND '<li>Unordered list element</li>' TO lt_html.      "#EC NOTEXT
  APPEND '<li>2nd item</li>'               TO lt_html.      "#EC NOTEXT
  APPEND '</ul>'                           TO lt_html.      "#EC NOTEXT
  APPEND '</body></html>'                  TO lt_html.      "#EC NOTEXT

  CALL METHOD g_html_viewer->('LOAD_DATA')
    EXPORTING
      type                 = 'text'
      subtype              = 'html'
    IMPORTING
      assigned_url         = l_url
    CHANGING
      data_table           = lt_html
    EXCEPTIONS
      dp_invalid_parameter = 1
      dp_error_general     = 2
      cntl_error           = 3
      OTHERS               = 4.


  CHECK sy-subrc EQ 0.

  CALL METHOD g_html_viewer->('SHOW_URL')
    EXPORTING
      url        = l_url
*     frame      = l_frame
    EXCEPTIONS
      cntl_error = 0.      "simply ignore any problem


ENDFORM.   " SHOW_HTML_DOCKER

About the author

fjourneau administrator

Hi, I'm Florian Journeau, SAP ABAP R3 Freelance, based in Toulouse, France. You want to know more about me, have a look on my CV : cv.fjourneau.net.

Leave a Reply