Skip to Content
0
Jun 08, 2009 at 03:24 AM

Setting the default text to be displayed in ALV columns (via cl_salv_table)

2435 Views

Dear forumers,

I would like to set the heading texts of all ALV columns to be displayed by default in the resulting ALV table. For this, I am using the CL_SALV_TABLE way as well.

In my codes, I have tried using these methods:

set_long_text

set_medium_text

set_short_text

set_text_column

All of these methods failed with a runtime error, except for set_long_text.

However, with set_long_text, the user will need to extend the column width using the mouse cursor to be able to view the long text that have been set in my codes.

What can I do here to have the column text that I have set to be displayed by default? Any inputs are appreciated.

Codes:-


DATA:
o_table      TYPE REF TO cl_salv_table,
o_functions  TYPE REF TO cl_salv_functions_list,
o_selections TYPE REF TO cl_salv_selections.

CLASS lcl_handle_events DEFINITION DEFERRED.
DATA:
o_handle_events TYPE REF TO lcl_handle_events,
o_events        TYPE REF TO cl_salv_events_table.

DATA:
o_columns TYPE REF TO cl_salv_columns_table,
o_column  TYPE REF TO cl_salv_column_table.

...


    TRY.
        CALL METHOD cl_salv_table=>factory
          IMPORTING
            r_salv_table = o_table
          CHANGING
            t_table      = i_ro_assets.
      CATCH cx_salv_msg.
    ENDTRY.

    o_functions = o_table->get_functions( ).
    o_functions->set_all( abap_true ).

    o_columns = o_table->get_columns( ).
    o_columns->set_optimize( abap_true ).

    TRY.
        o_column ?= o_columns->get_column( 'BUKRS' ).
        o_column->set_long_text( text-008 ).
      CATCH cx_salv_not_found.
    ENDTRY.

    TRY.
        o_column ?= o_columns->get_column( 'ANLN1' ).
        o_column->set_long_text( text-009 ).
        o_column->set_cell_type( cl_salv_column_table=>if_salv_c_cell_type~hotspot ).
      CATCH cx_salv_not_found.
    ENDTRY.

    TRY.
        o_column ?= o_columns->get_column( 'TXT50' ).
        o_column->set_long_text( text-010 ).
      CATCH cx_salv_not_found.
    ENDTRY.

        ...

    o_table->display( ).