cancel
Showing results for 
Search instead for 
Did you mean: 

cl_gui_alv_grid HEADER

Former Member
0 Kudos

Hello All,

I need to print user name, date and time on the header. I am using the class <b>cl_gui_alv_grid</b>. I tried events top_of_list but it dint work. can somebody please help me with this?

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi,

Try the event PRINT_TOP_OF_LIST

First add a handler method in your handler class definition as:

e.g. METHOD handle_print_top_of_list FOR EVENT <b>print_top_of_list OF cl_gui_alv_grid</b> .

Then implement the method in the implementation part of your local class.

e.g. METHOD handle_print_top_of_list .

WRITE:/ 'Flights Made on ', sy-datum .

ENDMETHOD .

And register this method as the handler.

e.g. SET HANDLER gr_event_handler->handle_print_top_of_list FOR gr_alvgrid .

The output of these events can be examined at the print preview or in the printing.

Hope it helps u.

Thanks&Regards,

Ruthra

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi,

Just try the sample.Kindly reward points by clicking the star on the left of reply,if it helps.

CLASS lcl_event_receiver DEFINITION.
  PUBLIC SECTION.
    CLASS-METHODS:
...
      handle_print_top_of_page
            FOR EVENT print_top_of_page OF
                      cl_gui_alv_grid,

      handle_top_of_page
           FOR EVENT top_of_page OF
                      cl_gui_alv_grid.
ENDCLASS.
* Implementation
CLASS lcl_event_receiver IMPLEMENTATION.
...
  METHOD handle_print_top_of_page.
    IF sy-pagno = 1.
      PERFORM f9803_top_of_page.
    ENDIF.
  ENDMETHOD.
  METHOD handle_top_of_page.
    PERFORM f9803_top_of_page.
  ENDMETHOD.
ENDCLASS.

FORM f9803_top_of_page.
* List heading
      WRITE:/ v_text01.
ENDFORM.                    " f9803_top_of_page

FORM f9000_objects_create.

  IF cl_gui_alv_grid=>offline( ) IS INITIAL.
    CREATE OBJECT o_dockingcontainer
      EXPORTING
        ratio                       = '95'
      EXCEPTIONS
        cntl_error                  = 1
        cntl_system_error           = 2
        create_error                = 3
        lifetime_error              = 4
        lifetime_dynpro_dynpro_link = 5
        others                      = 6.
    IF sy-subrc NE 0.
      MESSAGE i001 WITH text-e01."Error in creating Docking container
      LEAVE LIST-PROCESSING.
    ENDIF.
    CREATE OBJECT v_split
         EXPORTING
           parent            = o_dockingcontainer
*          ORIENTATION       = 0
           sash_position     = 25
           with_border       = 0
         EXCEPTIONS
           cntl_error        = 1
           cntl_system_error = 2
           others            = 3.
    IF sy-subrc NE 0.
      MESSAGE i000 WITH text-e01."Error in creating Docking container
      LEAVE LIST-PROCESSING.
    ENDIF.
*   Get the containers of the splitter control
    v_contnr_top = v_split->top_left_container.
    v_contnr_bot = v_split->bottom_right_container.

    CREATE OBJECT o_alvgrid
   EXPORTING
     i_parent = o_dockingcontainer.

*   Create an instance of alv control
    CREATE OBJECT o_alvgrid
         EXPORTING i_parent = v_contnr_bot.

*   Object for display of selection parameters in HTML top container
    CREATE OBJECT v_html
         EXPORTING
           style = 'ALV_GRID'.


*   Must be after the SET HANDLER for TOP_OF_PAGE and foreground only
    CALL METHOD o_alvgrid->list_processing_events
                     EXPORTING i_event_name = 'TOP_OF_PAGE'
                               i_dyndoc_id  = v_html.
    CLEAR v_text01.
    IF rb_man      = c_checked
       AND rb_fi   = ' '
       AND rb_pofi = ' '.
      v_text01     = text-063.
    ELSEIF rb_user = c_checked
       AND rb_fi = ' '
       AND rb_pofi = ' '.
      v_text01     = text-064.
    ELSEIF rb_fi   = c_x.
      v_text01     = text-074.
    ELSEIF rb_pofi = c_x.
      v_text01     = text-086.
    ENDIF.
    v_font = 'HEADING'.
    CALL METHOD v_html->add_gap
                EXPORTING
                  width         = 120.
    CALL METHOD v_html->add_text
           EXPORTING
             text           = v_text01
             sap_style      = v_font.

    CALL METHOD v_html->new_line.
* Display the data
    CALL METHOD v_html->display_document
      EXPORTING
         parent             = v_contnr_top.

*   Handle the event
    CALL METHOD o_alvgrid->list_processing_events
                        EXPORTING i_event_name = 'PRINT_TOP_OF_PAGE'.
  ENDIF.

* IF Program Running in Background, place a container.
  IF sy-batch = 'X'.
    CREATE OBJECT o_alvgrid
 EXPORTING
   i_parent = o_dockingcontainer.
  ENDIF.

ENDFORM.                    " f9000_objects_create


MODULE  status_9001 OUTPUT.

  IF o_dockingcontainer IS INITIAL.
.....
*   Creating Object
    PERFORM f9000_objects_create.
...
SET HANDLER o_eventreceiver->handle_print_top_of_page FOR o_alvgrid.
  SET HANDLER o_eventreceiver->handle_top_of_page FOR o_alvgrid.

ENDMODULE.                 " STATUS_9001  OUTPUT

Karan_Chopra_
Active Participant
0 Kudos

Hi Expert,

I have this same problem as above, used the above method but I want to get print of header also with the ALV , please let me know how to do it using Grid Control (container-module pool) - cl_gui_alv_grid.

I can see the header with data but no print button ?

Former Member
0 Kudos

Hi ,

It is possible with Top_of_page event . You have to use function REUSE_ALV_COMMENTARY_WRITE . For refernce just see the program DD_SIMPLE_ALV_TOP.

This program uses FM REUSE_ALV_LIST_DISPLAY but I think its possible with class CL_GUI_ALV_GRID.

Cheers.

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

I was under the impression that this does not work if you are using the CL_GUI_ALV_GRID. I know that it works if you are using the function module.

Regards,

Rich HEilman

Former Member
0 Kudos

Hi,

I don't think REUSE*COMMENTARY will work if you are using the grid controls. The way we do is to split the container into two, have HTML control in the top portion and use that to write whatever you want on the top.

Regards,

Ravi

Former Member
0 Kudos

If you are using WRITE statement after the event then it does not work unless you use ALV_LIST instead of GRID.

GRID is displayed using Module Pool, and write statement does not work, unless you submit to the Spool.

To display Username, date etc. on the screen, where the control is, you need to create fields on the screen, as you would in any Module pool screen, and set the values to the fields from the program.

Hope this is helpful. Let me know.