Friday, March 11, 2011

OOP ALV splitter screen

Custom container can be divided into parts by a splitter screen class. Usually, developers can create different panel within a custom container to separate its selection screen header or the ALV data itself.


STEPS:

  Prerequisite: You should define first your custom container

  Code:

      DATA: G_GRID TYPE REF TO CL_GUI_ALV_GRID.

  IF at_custom_container IS INITIAL.
*     Create TOP-Document
    CREATE OBJECT O_DYNDOC_ID
    EXPORTING STYLE = 'ALV_GRID'.

    CREATE OBJECT at_custom_container  "type ref CL_GUI_CUSTOM_CONTAINER
    EXPORTING CONTAINER_NAME = at_container.  "type SCRFNAME

*     Create Splitter for custom_container
    CREATE OBJECT O_SPLITTER
    EXPORTING PARENT  = at_custom_container
    ROWS    = 2 "header(1) and grid(2) part only = count of 2 screen
    COLUMNS = 1.
*    Assigning Part 1 for TOP_OF_PAGE
      CALL METHOD O_SPLITTER->GET_CONTAINER
        EXPORTING
        ROW = 1   "cause 1st part of container (look at the container as a grid with col, row etc)
        COLUMN = 1
        RECEIVING
        CONTAINER = O_PARENT_TOP. "type ref to CL_GUI_CONTAINER
*     *Assigning the Part 2 to GRID
      CALL METHOD O_SPLITTER->GET_CONTAINER
        EXPORTING
        ROW = 2  "meaning the below part of the custom container
        COLUMN = 1
        RECEIVING
        CONTAINER = O_PARENT_GRID.

*     Set height for Top of page
      CALL METHOD O_SPLITTER->SET_ROW_HEIGHT
        EXPORTING
        ID = 1  "meaning the first row of the container or o_splitter
        HEIGHT = 20.


"instantiate the grid container or the row 2 or the container
      CREATE OBJECT at_GRID1
      EXPORTING I_PARENT = O_PARENT_GRID. "type ref to CL_GUI_CONTAINER

  endif.


NOTE: To put text to your header ( this is done through an event) please see this topic.


Sample output:



Other related links: saparticle

No comments:

Post a Comment