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 - Bold/Intensified Text in Cells

kenzo
Participant
0 Kudos

Hi Guys!

I am using CL_SALV_TABLE to generate ALV output.

Has anyone managed to bold the text within a column or cell using the functionalities provided by this class?

I am not interested in changing the program to use CL_GUI_ALV_GRID neither FMs REUSE_ALV_GRID_DISPLAY*...

1 ACCEPTED SOLUTION

Tomas_Buryanek
Active Contributor

It seems there is no easy way to set bold text in SALV cells.

Hard way - get CL_GUI_ALV_GRID object from SALV object, get layout (lvc_s_layo) and set layout-stylefname + style to cell.

Or use colors instead as Simone suggested.

-- Tomas --
11 REPLIES 11

SimoneMilesi
Active Contributor

Hi Carlo,

it's possible to set a colour with all the styling as per Naimesh's wonderful blog http://zevolving.com/2008/10/salv-table-9-apply-colors/

Applying this solution, you can specify which column is intensified aka bold, since it relies on LVC_S_SCOL structure.

LVC_S_SCOL has structure COLOR with field "INT" you can activate (1) or deactivate (0).

0 Kudos

Thanks Simone!

But I'm not talking about colors, I specifically mentioned I would like the text in bold/intensified.

This cannot be achieved by the solution you proposed.

Have you ever managed to achieve BOLD with this?

0 Kudos

As i said

Applying this solution, you can specify which column is intensified aka bold, since it relies on LVC_S_SCOL structure.
LVC_S_SCOL has structure COLOR with field "INT" you can activate (1) or deactivate (0).

The method name is a bit puzzling, but if you just fill the INT field, you got your bold.
Did you read the blog i linked and tried to follow the same path?

0 Kudos

Simone, I have included the sample code and bold cannot be achieved by the proposed solution.

Proof:

This is why I asked if you have managed to achieve this using INT = 1

You can obtain the intensified effect (like on old WRITE LIST ) like this

 DATA: lo_cols_tab TYPE REF TO cl_salv_columns_table,
          lo_col_tab  TYPE REF TO cl_salv_column_table.
    cl_salv_table=>factory( IMPORTING r_salv_table = salv
                            CHANGING t_table = out  ).
  DATA: ls_color TYPE lvc_s_colo.    " Colors strucutre
    lo_cols_tab = salv->get_columns( ).
    INCLUDE <color>.
    TRY.
        lo_col_tab ?= lo_cols_tab->get_column( 'VSTEL' ).
        ls_color-col = 0 .
        ls_color-int = 1.
        ls_color-inv = 0.
        lo_col_tab->set_color( ls_color ).
      CATCH cx_salv_not_found.
    ENDTRY.

0 Kudos

Thanks Simone! That's very helpful!

I know it's not the bold effect, but if you want to stick with basic alv (SALV does that: quick and dirty lists) it's all you can have, i'm sorry 😕

Tomas_Buryanek
Active Contributor

It seems there is no easy way to set bold text in SALV cells.

Hard way - get CL_GUI_ALV_GRID object from SALV object, get layout (lvc_s_layo) and set layout-stylefname + style to cell.

Or use colors instead as Simone suggested.

-- Tomas --

0 Kudos

Simone's solution does not work. I have showed that in the comments.

Could you please further explain your solution using CL_GUI_ALV_GRID with code examples if possible? Thanks!

I meant that instead of making text bold you can color it. So it will be more visible.

For more help on "hard way" - read this nice blog https://blogs.sap.com/2015/06/25/salv-editable-with-single-custom-method/. Cou can find there how to get CL_GUI_ALV_GRID object and then layout. Setting bold text with lvc_s_layo is then no problem to find...

-- Tomas --

0 Kudos

It is indeed a very complicated solution. May not worth it going down that road and just stick to using CL_GUI_ALV_GRID in most cases.

I will advise the business to restrict only to color scheme in this case.

Thanks a lot!