2007 Oct 01 11:00 AM
The following segment of my code has no syntax error. Trying to change the color dynamically of a cell.
But the grid table has no change in the color of the targeted cell. Is there
something i miss out?
MODULE build_struct_9000 OUTPUT.
Create dynamic Internal Table
CREATE DATA o_table TYPE TABLE OF (p_table) .
ASSIGN o_table->* TO <fs_table>.
Create dynamic work area
CREATE DATA o_line LIKE LINE OF <fs_table>.
ASSIGN o_line->* TO <fs_warea>.
CREATE DATA o_color TYPE lvc_t_scol.
ASSIGN o_color->* TO <t_cellcolors>.
Field Catalogue
CALL FUNCTION 'NAMETAB_GET'
EXPORTING
langu = sy-langu
tabname = p_table
TABLES
nametab = i_nametab.
LOOP AT <fs_table> INTO <fs_warea>.
ASSIGN COMPONENT 'T_CELLCOLORS'
OF STRUCTURE <fs_warea> TO <t_cellcolors>.
LOOP AT i_nametab INTO w_nametab .
CLEAR wa_cellcolors.
wa_cellcolors-fname = w_nametab-fieldname.
wa_cellcolors-color-col = '3'.
wa_cellcolors-color-int = '1'.
wa_cellcolors-color-inv = '1'.
APPEND wa_cellcolors TO <t_cellcolors>.
ENDLOOP.
MODIFY <fs_table> FROM <t_cellcolors>.
ENDLOOP.
ASSIGN COMPONENT 'T_CELLCOLORS'
OF STRUCTURE <fs_warea> TO <t_cellcolors>.
LOOP AT i_ED INTO wa_ED.
READ TABLE <fs_table> INTO <fs_warea> INDEX wa_ED-RECORDNO.
IF sy-subrc EQ 0.
READ TABLE <t_cellcolors> INTO wa_cellcolors
WITH KEY fname = wa_ED-ERRORFIELD.
IF sy-subrc EQ 0.
wa_cellcolors-fname = wa_ED-ERRORFIELD.
wa_cellcolors-color-col = '6'.
wa_cellcolors-color-int = '0'.
wa_cellcolors-color-inv = '0'.
MODIFY <t_cellcolors> FROM wa_cellcolors.
ENDIF.
MODIFY <fs_table> FROM <t_cellcolors> INDEX wa_ED-RECORDNO.
endif.
ENDLOOP.
LOOP AT i_nametab INTO w_nametab .
w_fcat-col_pos = w_nametab-position.
w_fcat-fieldname = w_nametab-fieldname .
w_fcat-coltext = w_nametab-fieldname .
w_fcat-datatype = w_nametab-datatype.
w_fcat-inttype = w_nametab-inttype.
w_fcat-intlen = w_nametab-intlen.
w_fcat-decimals = w_nametab-decimals.
IF w_nametab-keyflag NE 'X'.
w_fcat-edit = 'X'.
ENDIF.
APPEND w_fcat TO i_fcat.
ENDLOOP.
ENDMODULE. " build_struct_9000 OUTPUT
have u added in the layout field
assume ur layous is ls_layout
then ls_layout-coltab_fieldname = 'T_CELLCOLORS'.
please reward if useful.
2007 Oct 01 11:31 AM
have u added in the layout field
assume ur layous is ls_layout
then ls_layout-coltab_fieldname = 'T_CELLCOLORS'.
please reward if useful.
2007 Oct 02 2:48 AM
Yes... I've added in the following module:
MODULE display_in_grid_9000 OUTPUT.
SELECT * FROM (p_table) INTO TABLE <fs_table>.
s_layo-edit = 'X'.
<b> s_layo-ctab_fname = 'T_CELLCOLORS'.</b>
IF sy-subrc EQ 0.
CALL METHOD o_grid->set_table_for_first_display
EXPORTING
i_save = 'A'
i_default = 'X'
is_layout = s_layo
CHANGING
it_outtab = <fs_table>
it_fieldcatalog = i_fcat
it_sort = i_sort
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.
ENDIF.
CALL METHOD o_grid->refresh_table_display.
CALL METHOD o_grid->set_ready_for_input
EXPORTING
i_ready_for_input = 0.
ENDMODULE. " display_in_grid_9000 OUTPUT
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |