04-18-2014 11:38 AM
Hi Experts,
I am using CL_SALV_TABLE class for displaying data in ALV.
Traffic lights are displayed in ALV. For traffic lights column the text displayed by default is 'Exception'. I tried to set the custom text for it using below code but it is not working.
Below is the code for reference.
REPORT ZMDR_SALV_TEST.
TYPES: BEGIN OF ty_alv,
lights(1) TYPE c, "Exception, Holding the value of the lights
text(20) TYPE c, "some text
END OF ty_alv.
DATA: gs_alv TYPE ty_alv,
gt_alv TYPE TABLE OF ty_alv,
gr_alv TYPE REF TO cl_salv_table,
gr_columns TYPE REF TO cl_salv_columns_table,
gr_column TYPE REF TO cl_salv_column_table.
START-OF-SELECTION.
gs_alv-lights = '1'. "Color red
gs_alv-text = 'RED SIGNAL'.
APPEND gs_alv TO gt_alv. gs_alv-lights = '2'. "Color yellow
gs_alv-text = 'YELLOW SIGNAL'.
APPEND gs_alv TO gt_alv. gs_alv-lights = '3'. "Color green
gs_alv-text = 'GREEN SIGNAL'.
APPEND gs_alv TO gt_alv.
CALL METHOD cl_salv_table=>factory
IMPORTING
r_salv_table = gr_alv
CHANGING
t_table = gt_alv.
gr_columns = gr_alv->get_columns( ).
gr_columns->set_exception_column( value = 'LIGHTS' ).
TRY.
gr_column ?= gr_columns->get_column( 'EXCEPTION' ). "Exception Column
gr_column->set_medium_text( 'STATUS' ).
gr_column->set_long_text( 'STATUS' ).
gr_column->set_short_text( 'STATUS' ).
CATCH cx_salv_not_found. "#EC NO_HANDLER
ENDTRY.
CALL METHOD gr_alv->display.
Please share if any ideas on it.
Regards,
Mohammed
04-18-2014 3:35 PM
Hi,
it seems like that exception column have fixed and unchangeable header text.
Why don't you use another field of char4 and put your lights in it?
Without setting: gr_columns->set_exception_column( value = 'LIGHTS' ).
Values would be from table ICON field ID (like @01@ etc..) and you can change header text of column
04-18-2014 12:19 PM
Hi, may be
TRY.
gr_column ?= gr_columns->get_column( 'LIGHTS' ). "Exception Column
gr_column->set_medium_text( 'STATUS' ).
gr_column->set_long_text( 'STATUS' ).
gr_column->set_short_text( 'STATUS' ).
CATCH cx_salv_not_found. "#EC NO_HANDLER
ENDTRY.
04-18-2014 12:24 PM
Hi,
Thanks for your reply.
I tried it, but it's not working.
Regards,
Mohammed
04-18-2014 12:35 PM
Hi, one more variant
DATA: lr_column TYPE REF TO cl_salv_column.
TRY.
lr_column = lr_columns->get_column( 'LIGHTS' ).
lr_column->set_long_text( 'STATUS').
lr_column->set_medium_text( 'STATUS').
lr_column->set_short_text( 'STATUS' ).
CATCH cx_salv_not_found. "#EC NO_HANDLER
ENDTRY .
04-18-2014 1:02 PM
04-18-2014 12:56 PM
Hi Rafi,
Try the below code it will works fine.
gr_columns = gr_alv->get_columns( ).
*remove this line from your code
gr_columns->set_exception_column( value = 'LIGHTS' ).
add the following code.
TRY.
gr_column ?= gr_columns->get_column( 'LIGHTS' ). "Exception Column
gr_column->set_medium_text( 'STATUS' ).
gr_column->set_long_text( 'STATUS' ).
gr_column->set_short_text( 'STATUS' ).
CATCH cx_salv_not_found. "#EC NO_HANDLER
ENDTRY.
Let me know if you have any issues.
Regards,
Gurunath D
04-18-2014 1:04 PM
Hi Guru,
Thanks for your reply.
I tried this code, I am able to change the column text but traffic signals in color like RED, YELLOW, GREEN are replaced with 1,2,3.
Regards,
Mohammed
04-18-2014 2:41 PM
Hi Rafi,
Please check the below link and saying that this is not possible.
http://abap-explorer.blogspot.in/2009/07/traffic-lights-in-alv-reports.html
Regards,
Gurunath D
04-18-2014 3:12 PM
Hi Guru,
The link refers to displaying ALV using Function Modules, but my requirement is displaying ALV using
CL_SALV_TABLE.
This is possible when we are building field catalog for ALV.
If the layout for ALV is LVC_S_LAYO then we can use the below code
gs_layout-ESCP_ROLLN = 'J_STATUS'.
Here Data Element is J_STATUS with field label as 'STATUS' so when applied this layout to ALV then text from 'EXCEPTION' to 'STATUS' will change.
Regards,
Mohammed
04-18-2014 3:35 PM
Hi,
it seems like that exception column have fixed and unchangeable header text.
Why don't you use another field of char4 and put your lights in it?
Without setting: gr_columns->set_exception_column( value = 'LIGHTS' ).
Values would be from table ICON field ID (like @01@ etc..) and you can change header text of column
04-18-2014 5:51 PM
Hi All,
I solved it.
Thanks for your time in posting your comments.
Regards,
Rafi
04-18-2014 7:19 PM
I see that you have posted a document just before reply to this thread.
What is more important, posting the working code here and marking the question as correct?
OR, posting a document?
Your document title is exception column text change, but you are not changing the text of exception column at all. You are using a normal column instead that has traffic lights. The title is misleading.
04-19-2014 3:14 PM
Hi Manish,
Thanks for your suggestion.
Now that I have changed the title of the document posted.
Actually I was trying to work on changing the exception column text as TRAFFIC LIGHTS are shown in it, but it is a standard output text displayed when used ALV for EXCEPTION column.
So, I used another column and set TRAFFIC LIGHTS for it.
Regards,
Rafi
04-19-2014 5:42 PM
You have posted a document, which is definitely based on this discussion.
Don't you think this question needs to be marked as answered?
04-21-2014 3:50 PM
I have rejected your document. Documents that consist of just program listing are just not good documents. You can maybe add it to the wiki, in which case post a link in this thread, or post the answer directly here.
This is for the good of anyone who might find this thread and be disappointed at not finding the answer.
04-21-2014 5:04 PM
Hi Matthew,
Thanks for your suggestion.
Now I posted the same document in Wiki. Below is the link for reference.
CL_SALV_TABLE - Traffic Lights Column Text Change - Application Server Infrastructure - SCN Wiki
Regards,
Rafi
04-21-2014 6:07 PM
04-22-2014 8:28 AM
Here is proper way of setting ICON column in SALV:
displaying icons in alv using class cl_salv_table - Code Gallery - SCN Wiki
By the way to original problem - set_exception_column method sets "coltext" field in fieldcatalog. Which is not modifiable any easy way in SALV and I couldnt filnd "hard" way yet. And it bypass short,medium and long texts.
So I wouldn't recommend use set_exception_column If you don't have special reason for it.
04-22-2014 10:20 AM
HI Tomas,
Actually in CL_SALV_TABLE one way of showing Traffic lights are using the column SET_EXCEPTION_COLUMN with which we cannot change the column name.
So the alternative way is to take a separate column into which traffic lights are to be shown. The way how we proceed using SET_EXCEPTION_COLUMN for displaying traffic lights will not help in showing traffic lights in other normal columns. So for this reason,
I tried with WRITE icon_red_light TO gs_alv-lights.
Regards,
Rafi
04-22-2014 10:29 AM
Hi Matthew,
Thanks again for your suggestion.
Finally I posted the in the code gallery.
CL_SALV_TABLE - Traffic Lights Column Text Change - Code Gallery - SCN Wiki
Hope this should be fine now.
Regards,
Rafi
08-28-2019 1:10 PM
Use CHAR01 type for exception column
TYPES: BEGIN OF ty_alv,
lights TYPE char01, "Exception, Holding the value of the lights
text(20) TYPE c, "some text
END OF ty_alv.