09-01-2021 7:51 AM
I have an OO ALV, in that the quantity and netprice field is editable and there is some color based on some conditions.
Now, I have requirement to change the color of the cells after editing the value , based on conditions.
Thanks in advance.
09-01-2021 7:54 AM
Welcome to the SAP Community! We wanted to give you the opportunity to take the tutorial to get started in SAP Community, as it provides tips for preparing questions that draw responses from our members.
Additionally, by adding a picture to your profile you encourage readers to respond to your question. Learn more about your profile using Profile Tutorial
Thank you!
09-01-2021 8:02 AM
This is your requierment, not a technical question. So what is your question ?
09-01-2021 9:48 AM
Did you even tried to search for help before posting this question? I have a fish memory for some things, like the one you are asking for, and I'm able to fast find the way to do it without having to post the question again and again.
As you can edit, I assume you are using the "deprecated" CL_GUI_ALV_something... check for program samples, or just search this place for
CL_GUI_ALV_something cell color
09-01-2021 10:26 AM
The term "OO ALV" is confusing, are you talking about CL_GUI_ALV_GRID or about "OM ALV" (Object Model ALV A.K.A. CL_SALV_* classes)?
The question has been asked so many times how to set a color in a cell. If you tried one of the many solutions, could you precise what your issue is?
09-02-2021 10:05 AM
Yea, I am using CL_GUI_ALV_GRID
I have a requirement like i have to change the color of a cell after edit based on some condition
for example suppose if the after edit the Net price is more than 1000 so the colour of the cell will be red.
I want to know how to add colours to the cells after editing the value .
09-02-2021 12:44 PM
So you know how to set the color of a given cell, but you want to know how to change it after you press a button in the toolbar, right?
So, during the processing of the function code, based on condition, you change the color in the field catalog, you transfer it to the frontend (SET_FRONTEND_FIELDCATALOG) and you refresh the ALV (REFRESH).
EDIT after raymond.giuseppi comment: sorry, I am full wrong here. You just need to update the color in the ALV internal table and call REFRESH_TABLE_DISPLAY.
09-03-2021 11:54 AM
Perform some search, you could add a column in your table, type lvc_t_scol, so for each record you can add in this itab a record per column with a color attribute
09-03-2021 6:22 PM
METHOD HANDLE_DATA_CHANGED.
loop at er_data_changed->mt_MOD_cells into is_cells.
check is_cells-fieldname eq 'NETPR'.
CALL METHOD rg1->get_frontend_layout
IMPORTING
es_layout = IS_LAYO1.
CASE IS_CELLS-FIELDNAME.
WHEN 'NETPR'.
REPLACE ALL OCCURRENCES OF ',' IN IS_CELLS-VALUE WITH '.'.
MESSAGE IS_CELLS-VALUE TYPE 'I'.
IF IS_CELLS-VALUE >= 100000 AND IS_CELLS-VALUE <= 200000.
MESSAGE 'HIGH' TYPE 'I'.
ls_color-fname = 'NETPR'.
ls_color-color-col = 3.
ls_color-color-int = 0.
ls_color-color-inv = 0.
APPEND ls_color TO <fs>-color.
ELSE .
MESSAGE 'LOW' TYPE 'I'.
ls_color-fname = 'NETPR'.
ls_color-color-col = 4.
ls_color-color-int = 0.
ls_color-color-inv = 0.
APPEND ls_color TO <fs>-color.
ENDIF.
ENDCASE.
ENDLOOP.
is_layo1-ctab_fname = 'COLOR1'.
CALL METHOD rg1->set_frontend_layout
EXPORTING
is_layout = is_layo1.
CALL METHOD rg1->refresh_table_display
EXPORTING
* is_stable =
i_soft_refresh = 'X'
* EXCEPTIONS
* finished = 1
* others = 2
.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
ENDMETHOD.
09-03-2021 6:27 PM
Can anyone tell me what I am doing wrong ?
when I am pressing enter after editing the value no colors are coming even the old colors are also vanished.
09-03-2021 8:12 PM
I am concerned about <FS>. Is it the line of the ALV internal table, of which you want to update the color in one of the cells? If yes, then its color column seems to be named COLOR, but you indicate the name COLOR1 in the layout.
Moreover, you need to call SET_FRONTEND_LAYOUT once for all, before SET_TABLE_FOR_FIRST_DISPLAY, you don't need to call it while you handle user events.