Quantcast
Channel: SCN : All Content - ABAP Development
Viewing all articles
Browse latest Browse all 8332

CL_SALV_TABLE - Exception column text change

$
0
0

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


Viewing all articles
Browse latest Browse all 8332

Trending Articles