2018 Oct 07 2:52 PM
Hallo Experts ,
I have a requirement to color some Rows based on some conditions although coloring some Columns and cells working well but coloring some Rows is not working at all with me , my coding look like below,
1. Picking up data,
Here i will pick the data with a class
DATA lts_data TYPE zz_ts_data " in this type i have added a field called 'COLOR' type lvc_t_scol.
FIELD-SYMBOLS <ls_data> LIKE LINE OF lts_data
FIELD-SYMBOLS <lt_data_ovrvw> TYPE ANY TABLE.
FIELD-SYMBOLS <ls_data_ovrvw> TYPE data.
zzcl_dd_process=>get_instance( )->get_rprts_by_fsel_rng
(EXPORTING
iv_bukrs = gc_bukrs
it_fsel_rng = lt_fsel_rng
IMPORTING
ets_data = lts_data).
LOOP AT lts_data ASSIGNING <ls_data>.
INSERT INITIAL LINE INTO TABLE <lt_data_ovrvw> ASSIGNING <ls_data_ovrvw>.
MOVE-CORRESPONDING <ls_data> TO <ls_data_ovrvw>.
ENDLOOP.
2. displaying the Data,
DATA ls_color TYPE lvc_s_colo.
DATA lo_not_fin_acr_ov_alv_cols TYPE REF TO cl_salv_columns_table.
DATA lo_not_fin_acr_ov_col TYPE REF TO cl_salv_column_table.
DATA: lt_s_color TYPE lvc_t_scol,
ls_s_color TYPE lvc_s_scol.
DATA ls_color TYPE lvc_s_colo.
CREATE OBJECT go_data
EXPORTING
container_name = 'CON'.
CALL METHOD cl_salv_table=>factoryEXPORTING
r_container = go_data
IMPORTING
r_salv_table = go_alv
CHANGING
t_table = <lt_data_ovrvw>.
ENDIF.
*******Set red color to a column ‚ everything is working ‚**********
ls_color-col = '6'.
lo_not_fin_acr_ov_alv_cols = go_not_fin_acr_ov_alv->get_columns( ).
lo_not_fin_acr_ov_col ?= lo_not_fin_acr_ov_alv_cols->get_column( 'TG_RUN_NO' )
.
lo_not_fin_acr_ov_col->set_color( ls_color ).
*******Set color to a Row, everything is totally not working********
LOOP AT <lt_not_fin_acr_ov> ASSIGNING <ls_not_fin_acr_ov>.
ASSIGN COMPONENT 'BUKRS' OF STRUCTURE <ls_not_fin_acr_ov> TO <lv_bukrs>.
ASSIGN COMPONENT 'COLOR' OF STRUCTURE <ls_not_fin_acr_ov> TO <lv_color>.
if Bukrs = ‘1130‘.
ls_s_color-color-col = cl_gui_resources=>list_col_positive..
ls_s_color-color-int = 0.
ls_s_color-color-inv = 0.
APPEND ls_s_color TO lt_s_color.
endif.
<lv_color> = lt_s_color.
endif.
MODIFY TABLE <lt_not_fin_acr_ov> FROM <ls_not_fin_acr_ov>.
ENDLOOP.
go_alv->display(
As I mentioned coloring the Rows is totally not working, your advices are highly appreciated,
Best Regards,
Jenie
Hallo Experts ,
I have a requirement to color some Rows based on some conditions although coloring some Columns and cells working well but coloring some Rows is not working at all with me , my coding look like below,
1. Picking up data,
Here i will pick the data with a class
DATA lts_data TYPE zz_ts_data " in this type i have added a field called 'COLOR' type lvc_t_scol.
FIELD-SYMBOLS <ls_data> LIKE LINE OF lts_data
FIELD-SYMBOLS <lt_data_ovrvw> TYPE ANY TABLE.
FIELD-SYMBOLS <ls_data_ovrvw> TYPE data.
zzcl_dd_process=>get_instance( )->get_rprts_by_fsel_rng
(EXPORTING
iv_bukrs = gc_bukrs
it_fsel_rng = lt_fsel_rng
IMPORTING
ets_data = lts_data).
LOOP AT lts_data ASSIGNING <ls_data>.
INSERT INITIAL LINE INTO TABLE <lt_data_ovrvw> ASSIGNING <ls_data_ovrvw>.
MOVE-CORRESPONDING <ls_data> TO <ls_data_ovrvw>.
ENDLOOP.
2. displaying the Data,
DATA ls_color TYPE lvc_s_colo.
DATA lo_not_fin_acr_ov_alv_cols TYPE REF TO cl_salv_columns_table.
DATA lo_not_fin_acr_ov_col TYPE REF TO cl_salv_column_table.
DATA: lt_s_color TYPE lvc_t_scol,
ls_s_color TYPE lvc_s_scol.
DATA ls_color TYPE lvc_s_colo.
CREATE OBJECT go_data
EXPORTING
container_name = 'CON'.
CALL METHOD cl_salv_table=>factoryEXPORTING
r_container = go_data
IMPORTING
r_salv_table = go_alv
CHANGING
t_table = <lt_data_ovrvw>.
ENDIF.
*******Set red color to a column ‚ everything is working ‚**********
ls_color-col = '6'.
lo_not_fin_acr_ov_alv_cols = go_not_fin_acr_ov_alv->get_columns( ).
lo_not_fin_acr_ov_col ?= lo_not_fin_acr_ov_alv_cols->get_column( 'TG_RUN_NO' )
.
lo_not_fin_acr_ov_col->set_color( ls_color ).
*******Set color to a Row, everything is totally not working********
LOOP AT <lt_not_fin_acr_ov> ASSIGNING <ls_not_fin_acr_ov>.
ASSIGN COMPONENT 'BUKRS' OF STRUCTURE <ls_not_fin_acr_ov> TO <lv_bukrs>.
ASSIGN COMPONENT 'COLOR' OF STRUCTURE <ls_not_fin_acr_ov> TO <lv_color>.
if Bukrs = ‘1130‘.
ls_s_color-color-col = cl_gui_resources=>list_col_positive..
ls_s_color-color-int = 0.
ls_s_color-color-inv = 0.
APPEND ls_s_color TO lt_s_color.
endif.
<lv_color> = lt_s_color.
endif.
MODIFY TABLE <lt_not_fin_acr_ov> FROM <ls_not_fin_acr_ov>.
ENDLOOP.
go_alv->display(
As I mentioned coloring the Rows is totally not working, your advices are highly appreciated,
Best Regards,
Jenie
2018 Oct 07 7:24 PM
You must also define the name of your color column with the method SET_COLOR_COLUMN.
2018 Oct 07 8:50 PM
2018 Oct 08 9:17 AM
You are confused by the word "column" in SET_COLOR_COLUMN. It doesn't mean the column displayed, but the column in the internal table which is to be used for containing the colors. As you have named your column "COLOR", then you must do
go_alv->get_columns( )->set_color_column( 'COLOR' ).
2018 Oct 08 7:28 AM
2018 Oct 08 8:50 AM
2018 Oct 08 11:50 AM
You are doing assign component but not using anywhere,
Below code will look for bukrs value when equal to 1130, then it will have color row.
LOOP AT <lt_not_fin_acr_ov> ASSIGNING <ls_not_fin_acr_ov>.
ASSIGN COMPONENT 'BUKRS' OF STRUCTURE <ls_not_fin_acr_ov> TO <lv_bukrs>.
if <lv_bukrs> = ‘1130‘.
ls_s_color-color-col = 5.
ls_s_color-color-int = 0.
ls_s_color-color-inv = 0.
APPEND ls_s_color TO <ls_not_fin_acr_ov>-color. <--- append color internal table to the Bukrs field row
endif.
ENDLOOP.
No need to use Modify internal table when using field symbol.
MODIFY TABLE <lt_not_fin_acr_ov> FROM <ls_not_fin_acr_ov>.
Please check again and let me know it is working or not
Thanks a lot !!!...