OO ALV WITH TOP_OF_PAGE EVENT TO DISPLAY HEADER


 DATA : it_spfli TYPE TABLE OF spfli,
wa_spfli TYPE spfli,
o_cust TYPE REF TO cl_gui_custom_container,
o_spli TYPE REF TO cl_gui_splitter_container,
o_ref1 TYPE REF TO cl_gui_container,
o_ref2 TYPE REF TO cl_gui_container,
o_alv TYPE REF TO cl_gui_alv_grid,
o_docu TYPE REF TO cl_dd_document,
ok_code TYPE sy-ucomm.

*———————————————————————-*
CLASS handle_event DEFINITION.
PUBLIC SECTION.

CLASSMETHODS : page_head FOR EVENT  

                   top_of_page OF cl_gui_alv_grid  

                   IMPORTING e_dyndoc_id table_index.


ENDCLASS.                    “HANDLE_EVENT DEFINITION

*———————————————————————-*
CLASS handle_event IMPLEMENTATION.

METHOD page_head.

*—————-try this one———————————*

    DATA : text TYPE sdydo_text_element.
text = ‘FLIGHT DETAILS’.
CALL METHOD o_docu->add_text
EXPORTING
text         = text
sap_color    = cl_dd_document=>list_positive
sap_fontsize = cl_dd_document=>large.

CALL METHOD o_docu->add_picture
EXPORTING
picture_id = ‘HEADER’. ” Object uploaded by OAER Transaction
CALL METHOD o_docu->display_document
EXPORTING
parent = o_ref1.


*———————-or try this ——————————–*

    DATA : text TYPE sdydo_text_element .
DATA : date TYPE char10.
WRITE sy-datum TO date USING EDIT MASK ‘__/__/____’.  CONCATENATE : ‘FLIGHT DETAILS ON ‘ date INTO text SEPARATED BY space.
CALL METHOD o_docu->add_text
EXPORTING
text         = text
sap_style    = cl_dd_document=>heading
sap_color    = cl_dd_document=>list_heading_int
sap_fontsize = cl_dd_document=>large.
CALL METHOD o_docu->new_line.
CLEAR text.
CONCATENATE : ‘BY USER :’ sy-uname INTO text SEPARATED BY space.
CALL METHOD o_docu->add_text
EXPORTING
text         = text
sap_style    = cl_dd_document=>heading
sap_color    = cl_dd_document=>list_heading_int
sap_fontsize = cl_dd_document=>large.
CALL METHOD o_docu->set_document_background
EXPORTING
picture_id = ‘HEADER1’. ” Object uploaded by OAER Transaction
CALL METHOD o_docu->display_document
EXPORTING
reuse_control = ‘X’
parent        = o_ref1.


ENDMETHOD.                    “PAGE_HEAD
ENDCLASS.                    “HANDLE_EVENT IMPLEMENTATION

START-OF-SELECTION.
PERFORM fetch_data_from_spfli.
CALL SCREEN 100.
*&———————————————————————*
FORM fetch_data_from_spfli .
SELECT * FROM spfli INTO TABLE it_spfli.
ENDFORM.                    ” FETCH_DATA_FROM_SPFLI
*&———————————————————————*

MODULE status_0100 OUTPUT.
SET PF-STATUS ‘STATUS’.
SET TITLEBAR ‘TITLE’.
ENDMODULE.                 ” STATUS_0100  OUTPUT

*———————————————————————-*
MODULE split_container OUTPUT.
IF o_cust IS NOT BOUND.
CREATE OBJECT o_cust
EXPORTING
container_name = ‘CONTAINER’.
CREATE OBJECT o_spli
EXPORTING
parent  = o_cust
rows    = 2
columns = 1.
CALL METHOD o_spli->get_container
EXPORTING
row       = 1
column    = 1
RECEIVING
container = o_ref1.
CALL METHOD o_spli->set_row_height
EXPORTING
id     = 1
height = 35.
CALL METHOD o_spli->get_container
EXPORTING
row       = 2
column    = 1
RECEIVING
container = o_ref2.

CREATE OBJECT o_docu
EXPORTING
style = ‘ALV_GRID’.
ENDIF.
ENDMODULE.                 ” SPLIT_CONTAINER  OUTPUT
*———————————————————————-*
MODULE display_alv OUTPUT.
IF o_alv IS NOT BOUND.
CREATE OBJECT o_alv
EXPORTING
i_parent = o_ref2.

SET HANDLER handle_event=>page_head FOR o_alv.

CALL METHOD o_alv->set_table_for_first_display
EXPORTING
i_structure_name = ‘SPFLI’
CHANGING
it_outtab        = it_spfli.

CALL METHOD o_alv->list_processing_events
EXPORTING
i_event_name = ‘TOP_OF_PAGE’
i_dyndoc_id  = o_docu.
ENDIF.
ENDMODULE.                 ” DISPLAY_ALV  OUTPUT
*———————————————————————-*
MODULE user_command_0100 INPUT.
CASE  ok_code.
WHEN ‘BACK’.
LEAVE PROGRAM.
ENDCASE.
ENDMODULE.                 ” USER_COMMAND_0100  INPUT

  SCREEN 100 FLOW LOGIC

PROCESS BEFORE OUTPUT.
MODULE status_0100.
MODULE split_container.
MODULE display_alv.

PROCESS AFTER INPUT.
MODULE user_command_0100.


 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s