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: 

Color Header cl_salv_table

raul_sap_cl
Explorer
0 Kudos
922

Hi experts,
I'm trying to change the color of the header title using cl_salv_display_settings.
I haven't found a way to change the color.

Do you think it is possible?

DATA: gr_table TYPE REF TO cl_salv_table,
lr_display TYPE REF TO cl_salv_display_settings.

lv_title TYPE lvc_title.
lv_title = 'TEST'.
lr_display = gr_table->get_display_settings( ).
lr_display->set_list_header( lv_title ).

Thank you so much!

6 REPLIES 6

raymond_giuseppi
Active Contributor
825

(Paste code in plain text)

Sandra_Rossi
Active Contributor
825

Please edit your question (Actions>Edit), select your code and press the button [CODE], which makes the code appear colored/indented, it'll be easier for people to look at it. Thanks!

Sandra_Rossi
Active Contributor

raul_sap_cl
Explorer
825

Thanks for replies!
Finally, I solved the requirement with 2 containers in dynpro and cl_dd_document class


I post my source code, maybe it's useful for someone.

DATA: gr_container   TYPE REF TO cl_gui_custom_container,
      dd TYPE REF TO cl_dd_document,
      o_split TYPE REF TO cl_gui_splitter_container,
      o_alv TYPE REF TO  cl_gui_container.
      gr_table       TYPE REF TO cl_salv_table.


IF cl_salv_table=>is_offline( ) EQ if_salv_c_bool_sap=>false.
    CREATE OBJECT dd. "Global

    CREATE OBJECT gr_container
      EXPORTING
ENDIF.

" Split Object
  CREATE OBJECT o_split
    EXPORTING
      parent  = gr_container "Text/Title
      rows    = 1
      columns = 1.

  CALL METHOD o_split->get_container
    EXPORTING
      row       = 1
      column    = 1
    RECEIVING
      container = o_alv.  "Our ALV

  TRY.
      CALL METHOD cl_salv_table=>factory
        EXPORTING
          r_container    = o_alv 
        IMPORTING
          r_salv_table   = gr_table
        CHANGING
          t_table        = lt_data. "Our data
    CATCH cx_salv_msg.
  ENDTRY.

"ADD  TITLE
  CALL METHOD dd->add_text
    EXPORTING
      text          = 'Text with red font colour'.
      sap_emphasis = 'STRONG'
*     sap_style    = cl_dd_area=>list_negative_inv "bold
      sap_color    = cl_dd_area=>list_negative_inv "red color
      sap_fontsize  = cl_dd_document=>large
      sap_fontstyle = cl_dd_area=>list_negative_inv
      style_class   = cl_dd_document=>list_negative_inv.


  CALL METHOD dd->display_document
    EXPORTING
      container = 'HEADER'.

  CALL METHOD gr_table->display.

825

Thank you very much for sharing! And not writing just: "Solved" 🙂

-- Tomas --

0 Kudos
227

Hello guys,

I hope is everything going well.
Thank you very much for this insight and for sharing the code @raul_sap_cl.
I was trying to implement the code, but I have a question. I need to implement two different containers in the screen painter to be able to achieve this? 

I would kindly like to ask for some additional info or prints about the containers if possible.


Thank you,
Have a great day,
Best Regards