Sie sind auf Seite 1von 5

REPORT ytest LINE-COUNT 10 LINE-SIZE 20.

CLASS lcl_event_handler DEFINITION DEFERRED.


TYPES : BEGIN OF ty_type.
INCLUDE STRUCTURE ytest_emp.
TYPES : dept_name TYPE zdept_name.
TYPES : END OF ty_type.
TYPES : t_data TYPE STANDARD TABLE OF ty_type.
DATA : lt_data TYPE t_data,
wa_data LIKE LINE OF lt_data.
DATA : gv_container_name TYPE scrfname VALUE 'CUSTOM_CONTAINER'.
DATA : go_custom_container TYPE REF TO cl_gui_custom_container,
** TO implement top of page event, we need to container object,
** and a splitter container which will be splitted into top and bottom container
s
** one fo display top of page data and second is for alv display
go_splitter_container TYPE REF TO cl_gui_splitter_container,
go_container_top TYPE REF TO cl_gui_container,
go_container_bottom TYPE REF TO cl_gui_container,
go_alv TYPE REF TO cl_gui_alv_grid,
go_event_handler TYPE REF TO lcl_event_handler,
go_dd_document TYPE REF TO cl_dd_document,
go_html TYPE REF TO cl_gui_html_viewer.
DATA : lt_fcat TYPE lvc_t_fcat,
wa_fcat TYPE lvc_s_fcat,
layout TYPE lvc_s_layo.
DATA : lt_exclude_toolbar TYPE UI_FUNCTIONS,
wa_exclude_toolbar LIKE LINE OF lt_exclude_toolbar.
DATA : lv_cntr TYPE i,
ok_code LIKE sy-ucomm.
INCLUDE ytest_class.
**======================================================================
*
INITIALIZATION
*
**======================================================================
**======================================================================
*
START-OF-SELECTION
*
**======================================================================
START-OF-SELECTION.
SELECT * FROM ytest_emp
INTO CORRESPONDING FIELDS OF TABLE lt_data.
**======================================================================
*
END-OF-SELECTION
*
**======================================================================
END-OF-SELECTION.
CHECK NOT lt_data IS INITIAL.
CALL SCREEN 100.
*&---------------------------------------------------------------------*
*&
Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
SET PF-STATUS 'YTEST_EMP'.

* SET TITLEBAR 'xxx'.


IF NOT go_custom_container IS BOUND.
CREATE OBJECT go_event_handler.

*
*
*

*
*
*
*
*
*
*
*
*

*
*

CREATE OBJECT go_custom_container


EXPORTING
parent
=
container_name
= gv_container_name
style
=
lifetime
= lifetime_default
repid
= sy-repid
dynnr
= sy-dynnr.
CREATE OBJECT go_splitter_container
EXPORTING
link_dynnr
=
link_repid
=
shellstyle
=
left
=
top
=
width
=
height
=
metric
= cntl_metric_dynpro
align
= 15
parent
= go_custom_container
rows
= 2
columns
= 1
no_autodef_progid_dynnr =
name
=
.
CALL METHOD go_splitter_container->set_row_height
EXPORTING
id
= 1
" means top container
height = 20.
CALL METHOD go_splitter_container->get_container
EXPORTING
row
= 1
column
= 1
RECEIVING
container = go_container_top.
CALL METHOD go_splitter_container->get_container
EXPORTING
row
= 2
column
= 1
RECEIVING
container = go_container_bottom.

*
*
*
*
*
*

CREATE OBJECT go_alv


EXPORTING
i_shellstyle
i_lifetime
i_parent
i_appl_events
i_parentdbg
i_applogparent
i_graphicsparent

= 0
=
= go_container_bottom
= space
=
=
=

*
*

i_name
i_fcat_complete

=
= space

.
SET
SET
SET
set

HANDLER
HANDLER
HANDLER
HANDLER

go_event_handler->handle_top_of_page FOR go_alv.


go_event_handler->handle_toolbar FOR go_alv.
go_event_handler->handle_user_command FOR go_alv.
go_event_handler->handle_double_click FOR go_alv.

CREATE OBJECT go_dd_document


EXPORTING
style = 'GO_ALV'
*
background_color =
*
bds_stylesheet =
*
no_margins =
.
*
CALL METHOD go_dd_document->initialize_document
*
EXPORTING
**
first_time
=
**
style
=
*
background_color = cl_dd_area=>col_textarea
*
bds_stylesheet =
*
no_margins
=
.

*
*
*
*
*

CALL METHOD go_alv->list_processing_events


EXPORTING
i_event_name
= 'TOP_OF_PAGE'
i_dyndoc_id
= go_dd_document
is_subtottxt_info =
ip_subtot_line
=
i_table_index
=
CHANGING
c_subtottxt
=
.
PERFORM display_alv.

ENDIF.
ENDMODULE.
" STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
*&
Form DISPLAY_ALV
*&---------------------------------------------------------------------*
FORM display_alv .
PERFORM build_fcat.
PERFORM define_layout.
PERFORM exclude_toolbar.
CALL METHOD go_alv->set_table_for_first_display
EXPORTING
*
i_buffer_active
=
*
i_bypassing_buffer
=
*
i_consistency_check
=
*
i_structure_name
=
*
is_variant
=
*
i_save
= 'X'
*
i_default
= 'X'
*
is_layout
=
*
is_print
=
*
it_special_groups
=

*
*
*
*

*
*
*
*
*
*
*

it_toolbar_excluding
= lt_exclude_toolbar
it_hyperlink
=
it_alv_graphics
=
it_except_qinfo
=
ir_salv_adapter
=
CHANGING
it_outtab
= lt_data
it_fieldcatalog
= lt_fcat.
it_sort
=
it_filter
=
EXCEPTIONS
invalid_parameter_combination = 1
program_error
= 2
too_many_lines
= 3
others
= 4

.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM.
" DISPLAY_ALV
*&---------------------------------------------------------------------*
*&
Form BUILD_FDAT
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
FORM build_fcat .
PERFORM fcat USING : 'EMPID'
text-004 '' '' '',
'EMP_NAME'
text-005 '' '' '',
'QUALIFICATION'
text-006 '' '' '',
'DEPT_ID'
text-007 '' '' '',
'SALARY'
text-008 '' '' ''.
ENDFORM.
" BUILD_FDAT
*&---------------------------------------------------------------------*
*&
Form FCAT
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*
FORM fcat USING
value(fname)
value(desc)
value(key)
value(value)
value(len).
ADD 1 TO lv_cntr.
wa_fcat-col_pos
= lv_cntr.
wa_fcat-row_pos
= 1.
wa_fcat-fieldname = fname.
* w_fcat-fieldname = f_desc.
" Does not work in OOPs
wa_fcat-scrtext_l
= desc.
" field description has to be passed like th
is for Column Heading, -- using OOPs
wa_fcat-key
= key.
wa_fcat-key_sel
= key.
wa_fcat-fix_column = key.
wa_fcat-hotspot
= value.
wa_fcat-outputlen = len.
wa_fcat-col_opt = 'X'.

APPEND wa_fcat TO lt_fcat.


CLEAR wa_fcat.
ENDFORM.
" FCAT
*&---------------------------------------------------------------------*
*&
Form DEFINE_LAYOUT
*&---------------------------------------------------------------------*
FORM define_layout .
layout-cwidth_opt = 'X'.
layout-zebra = 'X'.
ENDFORM.
" DEFINE_LAYOUT
*&---------------------------------------------------------------------*
*&
Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
MODULE user_command_0100 INPUT.
CASE ok_code.
WHEN 'BACK' OR 'EXIT' OR 'CANCEL'.
LEAVE TO SCREEN 0.
ENDCASE.
ENDMODULE.
" USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
*&
Form EXCLUDE_TOOLBAR
*&---------------------------------------------------------------------*
form EXCLUDE_TOOLBAR .
wa_exclude_toolbar = cl_gui_alv_grid=>MC_FC_PRINT.
APPEND wa_exclude_toolbar to lt_exclude_toolbar.
wa_exclude_toolbar = cl_gui_alv_grid=>MC_FC_GRAPH.
APPEND wa_exclude_toolbar to lt_exclude_toolbar.
endform.

" EXCLUDE_TOOLBAR

Das könnte Ihnen auch gefallen