Wednesday, April 19, 2017

Splitter container in full screen - two ways

The Goal

is to have fully occupied space of the screen without usage of any tool of screen painter. Just the blank screen is enough, the rest is matter of below coding. In advance let me say, the second solution is much better :)

1) Docking container


The very first way is docking container, which is able to occupy whole screen very easily. See the coding below:


  DATA:
* Reference Variable for Docking Container
  go_dock_container  TYPE REF TO cl_gui_docking_container,
  go_split_container TYPE REF TO cl_gui_splitter_container.

  CREATE OBJECT go_dock_container
    EXPORTING
      repid        sy-repid " Report Name
      dynnr        sy-dynnr " Screen Number
      side                        cl_gui_docking_container=>dock_at_bottom
      extension                   cl_gui_docking_container=>ws_maximizebox

    EXCEPTIONS
      cntl_error                  1
      cntl_system_error           2
      create_error                3
      lifetime_error              4
      lifetime_dynpro_dynpro_link 5
      OTHERS                      6.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

  CREATE OBJECT go_split_container
    EXPORTING
      parent            go_dock_container " Parent Container
      rows              " Number of Rows to be displayed
      columns           " Number of Columns to be Displayed
    EXCEPTIONS
      cntl_error        1
      cntl_system_error 2
      OTHERS            3.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.



The disadvantage of above solution is appearance of side resizing frame border. We need to occupy whole space, split it into two parts, but nothing else. You can not easily disable resizing on docking container.





2) Direct use of Splitter container


The the good message is that by removal of docking container we reach clean fully occupied screen without side resizing frame border.





See whole PBO coding:


  DATAgo_container_top   TYPE REF TO cl_gui_splitter_container,
        go_container_cell1 TYPE REF TO cl_gui_container,
        go_container_cell2 TYPE REF TO cl_gui_container,
        go_salv1           TYPE REF TO cl_salv_table,
        go_salv2           TYPE REF TO cl_salv_table,
        gt_data            TYPE STANDARD TABLE OF tstct,
        gx_msg             TYPE REF TO cx_salv_msg.

  CREATE OBJECT go_container_top
    EXPORTING
      link_dynnr        sy-dynnr " Screen Number
      link_repid        sy-repid " Report Name
      parent            cl_gui_container=>default_screen " Parent Container
      rows              " Number of Rows to be displayed
      columns           " Number of Columns to be Displayed
    EXCEPTIONS
      cntl_error        1
      cntl_system_error 2
      OTHERS            3.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
               WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

*   get part of splitter container for 1st table
  CALL METHOD go_container_top->get_container
    EXPORTING
      row       1
      column    1
    RECEIVING
      container go_container_cell1.

*   get part of splitter container for 2nd table
  CALL METHOD go_container_top->get_container
    EXPORTING
      row       2
      column    1
    RECEIVING
      container go_container_cell2.

  SELECT FROM tstct INTO TABLE gt_data WHERE sprsl 'E'.

  TRY.
      cl_salv_table=>factory(
      EXPORTING
        r_container go_container_cell1
      IMPORTING
        r_salv_table     go_salv1
      CHANGING
        t_table      gt_data ).
    CATCH cx_salv_msg INTO gx_msg.
      MESSAGE gx_msg TYPE 'E'.
  ENDTRY.

  TRY.
      cl_salv_table=>factory(
      EXPORTING
        r_container go_container_cell2
      IMPORTING
        r_salv_table     go_salv2
      CHANGING
        t_table      gt_data ).
    CATCH cx_salv_msg INTO gx_msg.
      MESSAGE gx_msg TYPE 'E'.
  ENDTRY.

  go_salv1->display).
  go_salv2->display).



Valuable hint taken from: http://inmyitkb.blogspot.com/2012/06/container-to-occupy-whole-screen.html 





No comments:

Post a Comment