Программа для демонстрации цветов:
TYPES: BEGIN OF ty_s_data, text TYPE text10, linecolor TYPE lvc_t_scol, END OF ty_s_data. DATA: lv_index TYPE i, ls_color TYPE lvc_s_scol, lt_color TYPE lvc_t_scol, lt_data TYPE TABLE OF ty_s_data, ls_data LIKE LINE OF lt_data, lr_alv TYPE REF TO cl_salv_table, lr_layout TYPE REF TO cl_salv_layout, ls_key TYPE salv_s_layout_key, lr_functions TYPE REF TO cl_salv_functions_list, lr_columns TYPE REF TO cl_salv_columns_table. * empty row with default color APPEND ls_data TO lt_data. * rows with possible colors DO 7 TIMES. ls_color-color-col = sy-index. " 1-7 DO 2 TIMES. lv_index = sy-index - 1. ls_color-color-int = lv_index. " 0-1 DO 2 TIMES. lv_index = sy-index - 1. ls_color-color-inv = lv_index. " 0-1 APPEND ls_color TO lt_color. * ls_data-col = ls_color-color-col. * ls_data-int = ls_color-color-int. * ls_data-inv = ls_color-color-inv. ls_data-text = 'C' && ls_color-color-col && ls_color-color-int && ls_color-color-inv. ls_data-linecolor = lt_color. APPEND ls_data TO lt_data. CLEAR lt_color. ENDDO. ENDDO. ENDDO. CLEAR ls_data. APPEND ls_data TO lt_data. cl_salv_table=>factory( IMPORTING r_salv_table = lr_alv CHANGING t_table = lt_data ). lr_layout = lr_alv->get_layout( ). ls_key-report = sy-repid. ls_key-handle = 'ALV1'. lr_layout->set_key( ls_key ). lr_layout->set_default( abap_true ). lr_layout->set_save_restriction( ). lr_functions = lr_alv->get_functions( ). lr_functions->set_all( abap_true ). lr_columns = lr_alv->get_columns( ). lr_columns->set_optimize( abap_true ). lr_columns->set_color_column( 'LINECOLOR' ). lr_alv->display( ).
Комментариев нет:
Отправить комментарий