Skip to Content
0
Oct 15, 2011 at 12:48 PM

TOP_OF_PAGE: Not getting displayed for OOPS ALV

65 Views

Hi All,

I am trying to get TOP_OF_PAGE in my OOPS ALV. But unable to get it.

I have used 2 ALV grids in the screen (using CL_GUI_EASY_SPLITTER_CONTAINER).

Please find the code for ready reference.

*&---------------------------------------------------------------------*
*& Report  ZTEST_ALV
*&---------------------------------------------------------------------*

REPORT  ztest_alv.

TABLES : scarr, sflight.

DATA : it_scarr TYPE TABLE OF scarr,
             it_sflight TYPE TABLE OF sflight .

DATA : ob_custom   TYPE REF TO cl_gui_custom_container ,
        ob_split1   TYPE REF TO cl_gui_easy_splitter_container ,
       ob_split2   TYPE REF TO cl_gui_easy_splitter_container ,
       ob_grid1    TYPE REF TO cl_gui_alv_grid ,
       ob_grid2    TYPE REF TO cl_gui_alv_grid ,
       ob_grid3    TYPE REF TO cl_gui_alv_grid,
       ob_document TYPE REF TO cl_dd_document,
       ob_grid     TYPE REF TO cl_gui_alv_grid,
       ob_top_container TYPE REF TO cl_gui_container,
       gs_layout   TYPE lvc_s_layo.

DATA w_variant TYPE disvariant.

SELECT-OPTIONS : s_carrid FOR scarr-carrid.

START-OF-SELECTION .

  SELECT * INTO TABLE it_scarr FROM scarr WHERE carrid IN s_carrid .
  SELECT * INTO TABLE it_sflight FROM sflight.

  CALL SCREEN 1001 .

*&---------------------------------------------------------------------*
*&      Module  STATUS_1001  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE status_1001 OUTPUT.
  SET PF-STATUS 'ZTEST'.
*  SET TITLEBAR 'xxx'.

* This will create a container
  CREATE OBJECT ob_custom
    EXPORTING
      container_name = 'GRID'.

  CREATE OBJECT ob_split1
    EXPORTING
      parent      = ob_custom
      orientation = cl_gui_easy_splitter_container=>orientation_vertical.

  CREATE OBJECT ob_grid1
    EXPORTING
      i_parent = ob_split1->top_left_container.

  CREATE OBJECT ob_grid2
    EXPORTING
      i_parent = ob_split1->bottom_right_container.

  PERFORM fill_top_of_page.

  w_variant-report = sy-repid.

* Set a titlebar for the grid control
  gs_layout-grid_title = 'Learning OOPS ALV'(100).

  CALL METHOD ob_grid1->set_table_for_first_display
    EXPORTING
      is_variant       = w_variant
      i_save           = 'A'
      i_structure_name = 'SCARR'
      is_layout        = gs_layout
    CHANGING
      it_outtab        = it_scarr.

  CALL METHOD ob_grid2->set_table_for_first_display
    EXPORTING
      is_variant       = w_variant
      i_save           = 'A'
      i_structure_name = 'SFLIGHT'
    CHANGING
      it_outtab        = it_sflight.

ENDMODULE.                 " STATUS_1001  OUTPUT

*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_1001  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE user_command_1001 INPUT.

  IF sy-ucomm = 'BACK' OR
     sy-ucomm = 'EXIT' .
    FREE : ob_grid1 ,
           ob_grid2 ,
           ob_grid3 ,
           ob_split1 ,
           ob_split2 ,
           ob_custom .
    LEAVE TO SCREEN 0 .
  ENDIF.

ENDMODULE.                 " USER_COMMAND_1001  INPUT

*&---------------------------------------------------------------------*
*&      Form  FILL_TOP_OF_PAGE
*&---------------------------------------------------------------------*
FORM fill_top_of_page .

*   Creating the document
  CREATE OBJECT ob_document
    EXPORTING
      style = 'ALV_GRID'.

* Calling the methods for dynamic text
  CALL METHOD ob_document->add_text
    EXPORTING
      text = 'This is TOP_OF_PAGE'.
*
* Adding Line
  CALL METHOD ob_document->new_line.
*
  CALL FUNCTION 'REUSE_ALV_GRID_COMMENTARY_SET'
    EXPORTING
      document = ob_document
      bottom   = space.

* Display the data
  CALL METHOD ob_document->display_document
    EXPORTING
      parent = ob_custom. "ob_top_container.

  CALL METHOD ob_document->initialize_document.

* Calling the method of ALV to process top of page
  CALL METHOD ob_grid1->list_processing_events
    EXPORTING
      i_event_name = 'TOP_OF_PAGE'
      i_dyndoc_id  = ob_document.

ENDFORM.                    " FILL_TOP_OF_PAGE