Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

CL_SALV_TABLE - Exception column text change

former_member210252
Contributor
0 Kudos

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_alvgs_alv-lights = '2'.    "Color yellow
   gs_alv-text = 'YELLOW SIGNAL'.
   APPEND gs_alv TO gt_alvgs_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

1 ACCEPTED SOLUTION

Tomas_Buryanek
Active Contributor
0 Kudos

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

-- Tomas --
20 REPLIES 20

Former Member
0 Kudos

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.

0 Kudos

Hi,

Thanks for your reply.

I tried  it, but  it's not working.

Regards,

Mohammed

0 Kudos

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 .

0 Kudos

No luck.

Regards,

Mohammed

gurunathkumar_dadamu
Active Contributor
0 Kudos

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

0 Kudos

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

gurunathkumar_dadamu
Active Contributor
0 Kudos

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

0 Kudos

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

Tomas_Buryanek
Active Contributor
0 Kudos

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

-- Tomas --

0 Kudos

Hi All,

I solved it.

Thanks for your time in posting your comments.

Regards,

Rafi

0 Kudos

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.

0 Kudos

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

0 Kudos

You have posted a document, which is definitely based on this discussion.

Don't you think this question needs to be marked as answered?

matt
Active Contributor
0 Kudos

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.

0 Kudos

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

matt
Active Contributor
0 Kudos

Yeah - wrong space. Try the code gallery.

0 Kudos

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.

-- Tomas --

0 Kudos

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

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

0 Kudos

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.