Skip to Content
author's profile photo Former Member
Former Member

how to make a column a key using CALL METHOD cl_salv_table=>factory

hy guys

i have gotten everything right but cannot make a column of my internal table a key column

done this so far for columns:

DATA: alv_columns_list TYPE REF TO cl_salv_columns_list.

DATA: alv_column TYPE REF TO cl_salv_column.

alv_columns_list = alv_table->get_columns( ).

alv_columns_list->set_optimize( 'X' ).

alv_columns_list->SET_KEY_FIXATION( 'X' ).


alv_column = alv_columns_list->get_column( 'BNAME' ).

catch cx_salv_NOT_FOUND.

message e000(zz) with 'Element not found'.


alv_column->SET_SHORT_TEXT( 'User' ).

alv_column->SET_MEDIUM_TEXT( 'User' ).

alv_column->SET_LONG_TEXT( 'User' )

found class cl_salv_column_list with method set_key

but how do i get to it. if it is even the right one

please help


Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Posted on Apr 04, 2008 at 02:56 PM

    Yes CL_SALV_COLUMN_LIST is the right one to use.

    After the following code:

    alv_column = alv_columns_list->get_column( 'BNAME' ).

    Add the following:

    alv_column_list ?= alv_column.
    alv_column_list->set_key( ).

    Don't forget to add the data definition for alv_column_list.

    Hope this helps.



    Edited by: Jonathan Bourne on Apr 4, 2008 3:01 PM

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      That cast won't work. Try this:


      *& Form SET_KEY_COLUMN


      * text


      FORM set_key_column USING pr_columns TYPE REF TO cl_salv_columns_table

      p_colname TYPE lvc_fname.

      DATA lr_coltab TYPE REF TO cl_salv_column_table.


      lr_coltab ?= pr_columns->get_column( p_colname ).

      CATCH cx_salv_not_found.


      CATCH cx_sy_move_cast_error.



      lr_coltab->set_key( abap_true ).


Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.