cancel
Showing results for 
Search instead for 
Did you mean: 

Set wrap text property in salv column

Former Member
0 Kudos

Hello. Did anybody encounter how to set up a property of salv to wrap text in some column? I look through the interfaces methods available for customising salv, but didn't find any useful.

Accepted Solutions (1)

Accepted Solutions (1)

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

Do you want to wrap the column header (possible as of NetWeaver 7.01) or the content within the rows of data?

For the column header you would use the following code:

First get access to the ALV Model Object:

data: l_ref_cmp_usage type ref to if_wd_component_usage.
  l_ref_cmp_usage =   wd_this->wd_cpuse_alv( ).
  if l_ref_cmp_usage->has_active_component( ) is initial.
    l_ref_cmp_usage->create_component( ).
  endif.
  data l_salv_wd_table type ref to iwci_salv_wd_table.
  l_salv_wd_table = wd_this->wd_cpifc_alv( ).
  data l_table type ref to cl_salv_wd_config_table.
  l_table = l_salv_wd_table->get_model( ).

Per Column you can control the header text wrapping:

data l_column type ref to cl_salv_wd_column.
 l_column = l_table->if_salv_wd_column_settings~get_column( 'POSTING_DATE' ).
 data l_header type ref to cl_salv_wd_column_header.
  l_header = l_column->get_header( ).
  l_header->set_header_text_wrapping( abap_true ).

If you want to have wrapping within the context of the rows of data, you will need to set propertest of the cell editor for the column:

l_column = l_table->if_salv_wd_column_settings~get_column( 'COMMENTS' ).
  data textview type ref to cl_salv_wd_uie_text_view.
  create object textview.
  textview->set_text_fieldname( 'COMMENTS' ).
  textview->set_wrapping( abap_true ).
  l_column->set_cell_editor( textview ).

Edited by: Thomas Jung on Feb 25, 2010 6:52 PM

Former Member
0 Kudos

Thank you Thomas, your answers are always accurate and correct!

p.s. I wanted to wrap content of the cells, not a header.

Edited by: Konstantin Milutin on Feb 26, 2010 7:42 AM

Answers (1)

Answers (1)

Former Member
0 Kudos

Is it possible to wrap the column header text using the CL_SALV grid outside of Web Dynpro?