DATA: * Reference to document dg_dyndoc_id TYPE REF TO cl_dd_document, * Reference to split container dg_splitter TYPE REF TO cl_gui_splitter_container, * Reference to grid container dg_parent_grid TYPE REF TO cl_gui_container, * Reference to html container dg_html_cntrl TYPE REF TO cl_gui_html_viewer, * Reference to html container dg_parent_html TYPE REF TO cl_gui_container.
*---------------------------------------------------------------------* * CLASS ZALV_EVENT_RECEIVER DEFINITION *---------------------------------------------------------------------* * ........ * *---------------------------------------------------------------------* CLASS zalv_event_receiver DEFINITION. PUBLIC SECTION. METHODS handle_total_txt FOR EVENT subtotal_text OF cl_gui_alv_grid IMPORTING es_subtottxt_info ep_subtot_line e_event_data. METHODS handle_double_click FOR EVENT double_click OF cl_gui_alv_grid IMPORTING e_row e_column es_row_no. METHODS handle_top_of_page FOR EVENT top_of_page OF cl_gui_alv_grid IMPORTING e_dyndoc_id. ENDCLASS. "ZALV_EVENT_RECEIVER DEFINITION *---------------------------------------------------------------------* * CLASS ZALV_EVENT_RECEIVER IMPLEMENTATION *---------------------------------------------------------------------* * ........ * *---------------------------------------------------------------------* CLASS zalv_event_receiver IMPLEMENTATION. METHOD handle_total_txt. ENDMETHOD. "handle_total_txt
TYPE-POOLS: slis. DATA: go_grid TYPE REF TO cl_gui_alv_grid. DATA: event_receiver TYPE REF TO zalv_event_receiver. DATA: gt_fieldcat TYPE lvc_t_fcat, gs_fieldcat TYPE lvc_s_fcat. DATA:info TYPE STANDARD TABLE OF x031l. DATA: info_tab TYPE x031l . DATA: ls_fieldcat TYPE lvc_s_fcat. DATA: it_fcat TYPE slis_t_fieldcat_alv, is_fcat LIKE LINE OF it_fcat. DATA: it_fieldcat TYPE lvc_t_fcat, is_fieldcat LIKE LINE OF it_fieldcat. DATA:v_html TYPE REF TO cl_dd_document, v_html_view TYPE REF TO cl_gui_html_viewer. DATA: v_split TYPE REF TO cl_gui_easy_splitter_container.
*********
SELECT-OPTIONS: lname FOR usr02-bname.
START-OF-SELECTION. CREATE OBJECT event_receiver. TYPES: BEGIN OF list_t. TYPES vd(1). TYPES logon_name TYPE usr02-bname. TYPES name(10). TYPES create_time TYPE d. TYPES devclass(20). TYPES t1 TYPE i. TYPES t2 TYPE i. TYPES: END OF list_t. DATA: tab TYPE list_t. DATA: list TYPE TABLE OF list_t. SELECT erdat devclass name_last t1~bname INTO (tab-create_time,tab-devclass,tab-name,tab-logon_name) FROM usr02 AS t1 INNER JOIN usr21 AS t2 ON t2~bname = t1~bname INNER JOIN tdevc ON t1~bname = tdevc~as4user INNER JOIN user_addr ON user_addr~bname = t1~bname WHERE t1~bname IN lname. tab-t1 = tab-t1 + 1. tab-t2 = tab-t2 + 1. APPEND tab TO list. ENDSELECT.
REPORT yclass_alv_header_print2.
TABLES: usr02,tdevc.
DATA:
* Reference to document
dg_dyndoc_id TYPE REF TO cl_dd_document,
* Reference to split container
dg_splitter TYPE REF TO cl_gui_splitter_container,
* Reference to grid container
dg_parent_grid TYPE REF TO cl_gui_container,
* Reference to html container
dg_html_cntrl TYPE REF TO cl_gui_html_viewer,
* Reference to html container
dg_parent_html TYPE REF TO cl_gui_container.
*---------------------------------------------------------------------*
* CLASS ZALV_EVENT_RECEIVER DEFINITION
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
CLASS zalv_event_receiver DEFINITION.
PUBLIC SECTION.
METHODS handle_total_txt
FOR EVENT subtotal_text OF cl_gui_alv_grid
IMPORTING
es_subtottxt_info
ep_subtot_line
e_event_data.
METHODS handle_double_click
FOR EVENT double_click OF cl_gui_alv_grid
IMPORTING
e_row
e_column
es_row_no.
METHODS handle_top_of_page
FOR EVENT top_of_page OF cl_gui_alv_grid
IMPORTING e_dyndoc_id.
ENDCLASS. "ZALV_EVENT_RECEIVER DEFINITION
*---------------------------------------------------------------------*
* CLASS ZALV_EVENT_RECEIVER IMPLEMENTATION
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
CLASS zalv_event_receiver IMPLEMENTATION.
METHOD handle_total_txt.
ENDMETHOD. "handle_total_txt
METHOD handle_double_click.
ENDMETHOD. "handle_DOUBLE_CLICK
METHOD handle_top_of_page.
PERFORM event_top_of_page USING e_dyndoc_id.
ENDMETHOD. "handle_TOP_OF_PAGE
ENDCLASS. "ZALV_EVENT_RECEIVER IMPLEMENTATION
TYPE-POOLS: slis.
DATA: go_grid TYPE REF TO cl_gui_alv_grid.
DATA: event_receiver TYPE REF TO zalv_event_receiver.
DATA: gt_fieldcat TYPE lvc_t_fcat,
gs_fieldcat TYPE lvc_s_fcat.
DATA:info TYPE STANDARD TABLE OF x031l.
DATA: info_tab TYPE x031l .
DATA: ls_fieldcat TYPE lvc_s_fcat.
DATA: it_fcat TYPE slis_t_fieldcat_alv,
is_fcat LIKE LINE OF it_fcat.
DATA: it_fieldcat TYPE lvc_t_fcat,
is_fieldcat LIKE LINE OF it_fieldcat.
DATA:v_html TYPE REF TO cl_dd_document,
v_html_view TYPE REF TO cl_gui_html_viewer.
DATA: v_split TYPE REF TO cl_gui_easy_splitter_container.
*********
SELECT-OPTIONS: lname FOR usr02-bname.
START-OF-SELECTION.
CREATE OBJECT event_receiver.
TYPES: BEGIN OF list_t.
TYPES vd(1).
TYPES logon_name TYPE usr02-bname.
TYPES name(10).
TYPES create_time TYPE d.
TYPES devclass(20).
TYPES t1 TYPE i.
TYPES t2 TYPE i.
TYPES: END OF list_t.
DATA: tab TYPE list_t.
DATA: list TYPE TABLE OF list_t.
SELECT erdat
devclass
name_last
t1~bname
INTO (tab-create_time,tab-devclass,tab-name,tab-logon_name)
FROM usr02 AS t1
INNER JOIN usr21 AS t2 ON t2~bname = t1~bname
INNER JOIN tdevc ON t1~bname = tdevc~as4user
INNER JOIN user_addr ON user_addr~bname = t1~bname
WHERE t1~bname IN lname.
tab-t1 = tab-t1 + 1.
tab-t2 = tab-t2 + 1.
APPEND tab TO list.
ENDSELECT.
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'LOGON_NAME'.
ls_fieldcat-scrtext_l = 'LOGON_NAME'.
APPEND ls_fieldcat TO gt_fieldcat.
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'NAME'.
ls_fieldcat-scrtext_l = 'NAME'.
APPEND ls_fieldcat TO gt_fieldcat.
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'DEVCLASS'.
ls_fieldcat-scrtext_l = 'DEVCLASS'.
APPEND ls_fieldcat TO gt_fieldcat.
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'CREATE_TIME'.
ls_fieldcat-scrtext_l = 'CREATE_TIME'.
APPEND ls_fieldcat TO gt_fieldcat.
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'T1'.
ls_fieldcat-scrtext_l = 'T1'.
ls_fieldcat-do_sum = 'X'.
APPEND ls_fieldcat TO gt_fieldcat.
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'T2'.
ls_fieldcat-scrtext_l = 'T2'.
* ls_fieldcat-DO_SUM = 'X'.
APPEND ls_fieldcat TO gt_fieldcat.
END-OF-SELECTION.
CALL SCREEN 100.
*&---------------------------------------------------------------------*
*& Form EVENT_TOP_OF_PAGE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->DG_DYNDOC_ID text
*----------------------------------------------------------------------*
FORM event_top_of_page USING dg_dyndoc_id TYPE REF TO cl_dd_document.
CALL METHOD dg_dyndoc_id->add_text
EXPORTING
text = 'Test Report'
sap_style = cl_dd_area=>heading.
CALL METHOD dg_dyndoc_id->add_text
EXPORTING
text = '2 line'
sap_fontsize = cl_dd_document=>small.
PERFORM html.
ENDFORM. "EVENT_TOP_OF_PAGE
*&---------------------------------------------------------------------*
*& Form HTML
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM html.
DATA : dl_length TYPE i, " Length
dl_background_id TYPE sdydo_key VALUE space. " Background_id
* Creating html control
IF dg_html_cntrl IS INITIAL.
CREATE OBJECT dg_html_cntrl
EXPORTING
parent = dg_parent_html.
ENDIF.
* Reuse_alv_grid_commentary_set
CALL FUNCTION 'REUSE_ALV_GRID_COMMENTARY_SET'
EXPORTING
document = dg_dyndoc_id
bottom = space
IMPORTING
length = dl_length.
* Get TOP->HTML_TABLE ready
CALL METHOD dg_dyndoc_id->merge_document.
* Set wallpaper
CALL METHOD dg_dyndoc_id->set_document_background
EXPORTING
picture_id = dl_background_id.
* Connect TOP document to HTML-Control
dg_dyndoc_id->html_control = dg_html_cntrl.
* Display TOP document
CALL METHOD dg_dyndoc_id->display_document
EXPORTING
reuse_control = 'X'
parent = dg_parent_html
EXCEPTIONS
html_display_error = 1.
ENDFORM. " HTML
*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
SET PF-STATUS '0100'.
* SET TITLEBAR 'xxx'.
CREATE OBJECT dg_dyndoc_id
EXPORTING
style = 'ALV_GRID'.
* Create Splitter for custom_container
CREATE OBJECT dg_splitter
EXPORTING
parent = cl_gui_container=>screen0
rows = 2
columns = 1.
* Split the custom_container to two containers and move the reference
* to receiving containers g_parent_html and g_parent_grid
"i am allocating the space for grid and top of page
CALL METHOD dg_splitter->get_container
EXPORTING
row = 1
column = 1
RECEIVING
container = dg_parent_html.
CALL METHOD dg_splitter->get_container
EXPORTING
row = 2
column = 1
RECEIVING
container = dg_parent_grid.
CALL METHOD dg_splitter->set_row_height
EXPORTING
id = 1
height = 5.
CREATE OBJECT go_grid
EXPORTING
i_parent = dg_parent_grid.
SET HANDLER event_receiver->handle_total_txt FOR go_grid.
SET HANDLER event_receiver->handle_double_click FOR go_grid.
SET HANDLER event_receiver->handle_top_of_page FOR go_grid.
DATA: sla TYPE lvc_s_layo.
DATA: ls_vari TYPE disvariant.
ls_vari-report = sy-repid.
ls_vari-handle = space.
ls_vari-log_group = space.
ls_vari-username = space.
ls_vari-variant = space.
ls_vari-text = space.
ls_vari-dependvars = space.
CALL METHOD go_grid->set_table_for_first_display
EXPORTING
is_variant = ls_vari
i_save = 'A'
is_layout = sla
CHANGING
it_outtab = list[]
it_fieldcatalog = gt_fieldcat[]
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
* Initializing document
CALL METHOD dg_dyndoc_id->initialize_document.
* Processing events
CALL METHOD go_grid->list_processing_events
EXPORTING
i_event_name = 'TOP_OF_PAGE'
i_dyndoc_id = dg_dyndoc_id.
"end }
ENDMODULE. " STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE user_command_0100 INPUT.
CASE sy-ucomm.
WHEN 'BACK'.
SET SCREEN 0.LEAVE SCREEN.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT