miércoles, 29 de junio de 2011

SALV Set Header Column Text

Hi,

To Set the Text we want to be showed at the column header of one SALV we first need to have been declared some vars:

First our ALV object TYPE REF TO cl_salv_table
Then we need another one to be the column collection TYPE REF TO cl_salv_columns_table
Finally a csingle column var of TYPE REF TO cl_salv_column_table.

After that we now need to create the salv Object using the factory method of cl_salv_table Class, we need to the table that we want the Alv shows data.

Creating the SALV:

cl_salv_table=>factory(
IMPORTING r_salv_table = alv
CHANGING t_table = T_tableView ).

Now we are going to set the column header texts, getting first the column collection from the ALV object created:

g_columns = ALV->get_columns( ).
TRY.
g_columns->set_color_column( 'ROW_COLOUR' ).
g_columns->set_key_fixation( ).
CATCH cx_salv_data_error. "#EC NO_HANDLER
ENDTRY.

at this point we have a collection of columns, now we are going to find an especific column:

executing the get_column method passing the column field name mapped in the alv and saving the result to the column var.

g_column ?= g_columns->get_column( 'MESSAGE' ).

now we can set the header text for the MESSAGE column of the SALV, short,medium and long text:

g_column->set_short_text( value = 'Mensaje' ).
g_column->set_medium_text( value = 'Mensaje' ).
g_column->set_long_text( value = 'Mensaje' ).

hope it helps.

1 comentario: