ABAP顾问
分类:
2007-11-12 20:57:30
*&---------------------------------------------------------------------*
*& Report Z_BARRY_ALV_CL_COLOR2 *
*& *
*&---------------------------------------------------------------------*
*& *
*& *
*&---------------------------------------------------------------------*
REPORT Z_BARRY_ALV_CL_COLOR2 .
TYPES: BEGIN OF ilist_s ,
name1(10),
name2(10),
name3(10),
END OF ilist_s.
DATA: ilist TYPE STANDARD TABLE OF ilist_s WITH HEADER LINE .
DATA: BEGIN OF list OCCURS 0.
INCLUDE STRUCTURE ilist .
DATA: rowcolor(4) TYPE c ,
cellcolors TYPE lvc_t_scol ,
cellstyles TYPE lvc_t_styl ,
celltext TYPE alv_t_dtv .
DATA: END OF list.
DATA: ok_code LIKE sy-ucomm.
DATA: l_valid(1) TYPE c.
DATA: go_grid TYPE REF TO cl_gui_alv_grid.
DATA: gt_fieldcat TYPE lvc_t_fcat,
gs_fieldcat TYPE lvc_s_fcat,
sla TYPE lvc_s_layo.
DATA: ls_fieldcat TYPE lvc_s_fcat.
DATA ls_style TYPE lvc_s_styl .
DATA ls_cellcolor TYPE lvc_s_scol .
DATA ls_celltext TYPE alv_s_dtv .
*---------------------------------------------------------------------*
* CLASS lcl_event_receiver DEFINITION
*---------------------------------------------------------------------*
CLASS lcl_event_receiver DEFINITION.
PUBLIC SECTION.
METHODS handle_button_click
FOR EVENT button_click OF cl_gui_alv_grid
IMPORTING es_col_id
es_row_no.
ENDCLASS. "lcl_event_receiver DEFINITION
*---------------------------------------------------------------------*
* CLASS lcl_event_receiver IMPLEMENTATION
*---------------------------------------------------------------------*
CLASS lcl_event_receiver IMPLEMENTATION.
METHOD handle_button_click.
PERFORM test USING es_col_id
es_row_no.
ENDMETHOD. "handle_f4
ENDCLASS. "lcl_event_receiver IMPLEMENTATION
DATA: event_receiver TYPE REF TO lcl_event_receiver.
DATA: ii TYPE i .
START-OF-SELECTION.
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'NAME1'.
ls_fieldcat-scrtext_l = 'NAME1'.
APPEND ls_fieldcat TO gt_fieldcat.
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'NAME2'.
ls_fieldcat-scrtext_l = 'NAME2'.
* ls_fieldcat-emphasize = 'C610'.
APPEND ls_fieldcat TO gt_fieldcat.
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'NAME3'.
ls_fieldcat-scrtext_l = 'NAME3'.
APPEND ls_fieldcat TO gt_fieldcat.
list-name1 = 'A'.
list-name2 = 'ARE'.
ls_cellcolor-fname = 'NAME1' .
ls_cellcolor-color-col = '5' .
ls_cellcolor-color-int = '1' .
ls_cellcolor-color-inv = '1' .
APPEND ls_cellcolor TO list-cellcolors .
APPEND list.
list-name1 = 'AA'.
list-name2 = 'BB'.
ls_cellcolor-fname = 'NAME2' .
ls_cellcolor-color-col = '3' .
ls_cellcolor-color-int = '1' .
ls_cellcolor-color-inv = '1' .
APPEND ls_cellcolor TO list-cellcolors .
APPEND list.
list-name1 = 'HOW'.
list-name2 = 'ARE'.
list-rowcolor = 'C410'.
ls_style-fieldname = 'NAME3' .
ls_style-style = cl_gui_alv_grid=>mc_style_button .
* ls_style-style = cl_gui_alv_grid=>MC_STYLE_HOTSPOT.
APPEND ls_style TO list-cellstyles .
ls_celltext-buttoncell = 'TEST'.
APPEND ls_celltext TO list-celltext.
APPEND list.
sla-stylefname = 'CELLSTYLES'.
sla-ctab_fname = 'CELLCOLORS'.
sla-info_fname = 'ROWCOLOR'.
WRITE 'a'.
CREATE OBJECT go_grid
EXPORTING
i_parent = cl_gui_container=>screen0.
CREATE OBJECT event_receiver.
SET HANDLER event_receiver->handle_button_click FOR go_grid.
CALL METHOD go_grid->set_table_for_first_display
EXPORTING
* is_variant = gs_variant
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.
*&---------------------------------------------------------------------*
*& Form test
*&---------------------------------------------------------------------*
FORM test USING p_es_col_id TYPE lvc_s_col
p_es_row_no TYPE lvc_s_roid.
MESSAGE i899(fi) WITH p_es_col_id-fieldname p_es_row_no-row_id .
ENDFORM. " test