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: 

Adding Traffic Lights to CL_SALV_TABLE (didn't find solution over here)

Former Member
0 Kudos

Hi,

I need to display traffic lights in a certain column in a report with some logic.

The problem is - through 90% of the tutorials I've looked into a field catalog is used while

I'm using the gel_salv_table to display the report and need to implement that into it.

I tried another option that was presented in a sap technical tutorial though I have an error saying the method

"set_exception_column" can't be found, private or protected.

10 REPLIES 10

raymond_giuseppi
Active Contributor
0 Kudos

To set exception column use method SET_EXCEPTION_COLUMN of class CL_SALV_COLUMNS_LIST (inherit from CL_SALV_COLUMNS)

(Ref: ALV Object Model, Areas of the ALV Output, Columns (General), Columns with Special Technical Meaning in SAP online help...)

Regards,

Raymond

former_member201275
Active Contributor
0 Kudos

Have a look at some of the Sap standard demo programs, for example: BCALV_GRID_04, which does what you require.

former_member201275
Active Contributor
0 Kudos

actually what might be better is program BCALV_TEST_COLORS.

0 Kudos

It's kinda hard for me to understand what's going on in there and I don't see the use of

the class cl_salv_table which I'm using to display the ALV.

Please take into account I'm a newbie, so I know you don't have the time to teach me ABAP here,

but if you could elaborate more I'd be thankful.

0 Kudos

Have especially a look for the column icon in structure gs_vtref:

DATA:

       BEGIN OF gs_vtref,

         vtref TYPE vvscpos-vtref,

         gpart_new TYPE vvscpos-gpart,

         gpart_old TYPE vvscpos-gpart,

        icon TYPE icon_d,

       END OF gs_vtref,


       gt_vtref LIKE TABLE OF gs_vtref,


       gr_table  TYPE REF TO cl_salv_table.


* Fill the table somehow

   gs_vtref-icon = icon_red_light.

   append gs_vtref to gt_vtref.

* ...

CALL METHOD cl_salv_table=>factory

     IMPORTING

       r_salv_table = gr_table

     CHANGING

       t_table      = gt_vtref.

   gr_table->display( ).


Regards,

Ulrich



0 Kudos

I think then it is best you have a look at the second program i mentioned i.e. BCALV_TEST_COLORS. If you debug this you can get an idea of how this works, set a breakpoint in FORM DISPLAY_FULLSCREEN at the row "perform select_data", here you can then see how the internal table gt_outtab_om is filled. After this in row 207 is the call to the factory method of this class.

When you run the program, execute from SE38, and on the selection screen select the Tick for "Object Model", this then will stop at your breakpoints.

I don't have time to go into more detail than that but hopefully debugging will give you a more clear idea on this class.

There is also a useful pdf for this class which may help you: http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/eac1fa0b-0e01-0010-0990-8530de490...

Hope this helps.

0 Kudos

thanks that seems a bit more clear.

How do I reference to a certain field in the table and where can I insert logic for that field?

0 Kudos

I'm not sure what you mean exactly. Do you fill the internal table yourself or do you get its content from somewhere else?

If the table is already filled you must define a copy of the table definition with an additional field icon. Then you must modify each line by setting the appropriate value for the icon e.g. depending from another field in the line.

This could look like:

loop at t_your_table into s_your_table.

  if s_your_table-field1 = 'XYZ'.

    s_your_table-icon =icon_red_light.

  else.

   s_your_table-icon = icon_green_light.

endif.

  modify t_your_table from s_your_table.

endloop.

rosenberg_eitan
Active Contributor
0 Kudos

Hi,

This program is using traffic lights

Regards.

Former Member

Hi,

Try this sample code.

type-pools icon.
TYPES: BEGIN OF ty_alv,
         lights(4) 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.

START-OF-SELECTION.
   gs_alv-lights = icon_led_red. "'1'.    "Color red
   gs_alv-text = 'RED SIGNAL'.
   APPEND gs_alv TO gt_alv.

   gs_alv-lights = icon_led_yellow. ".'2'.    "Color yellow
   gs_alv-text = 'YELLOW SIGNAL'.
   APPEND gs_alv TO gt_alv.

   gs_alv-lights = icon_led_green. "'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' ).

   CALL METHOD gr_alv->display.


hopes this helps u.


Thanks,

Ashok.