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: 

how to build field catalog and pass to CL_SALV_TABLE?

Former Member
0 Kudos

Hello SDN Community, I have researched this extensively both on the internet and in SDN forums. It seems like a common thing to do, but I cannot seem to connect the dots from what I have read. I have done this using the function module, but am now needing to code for new CL_SALV_TABLE class.

Does anyone have an example coding of how to build a field catalog and pass it to CL_SALV_TABLE? (with data definitions of all structures)

Thank you,

Dean Atteberry.

1 ACCEPTED SOLUTION

naimesh_patel
Active Contributor

In SALV model, system creates the Field cataloge automatically based on the structure of the table. Yes, you need to get the COLUMNS objects to be able to work with it.

Try like this:


* Get the column object
  DATA: lo_cols      TYPE REF TO cl_salv_columns.
  lo_cols = me->wo_salv->get_columns( ).

* modify individual properties
  DATA: lo_column    TYPE REF TO cl_salv_column.
  TRY.
      lo_column = lo_cols->get_column( 'AVAILDATE' ).
      lo_column->set_long_text( 'Avl Date' ).               "#EC NOTEXT
      lo_column->set_medium_text( 'Avl Date' ).             "#EC NOTEXT
      lo_column->set_short_text( 'Avl Date' ).              "#EC NOTEXT
      lo_column->set_output_length( 10 ).
    CATCH cx_salv_not_found.                            "#EC NO_HANDLER
  ENDTRY.

Explore class CL_SALV_COLUMN for different methods to change the properties of the column.

See program SALV_DEMO_TABLE_COLUMNS

You can also check: [SALV Table Display - Column Properties|http://help-abap.blogspot.com/2008/09/salv-model-7-changing-column-settings.html]

Regards,

Naimesh Patel

3 REPLIES 3

Former Member
0 Kudos

Never fails - post a question - find your answer. At least I think I did.

What I found... For CL_SALV_TABLE there is no field catalog. This functionality is now handled by the R_COLUMNS attribute.

Would appreciate verification of what I found and if this is how the world now looks, any coding examples would be appreciated.

Thank you,

Dean Atteberry.

0 Kudos

Try this way


   DATA: l_cols_tab TYPE REF TO cl_salv_columns_table,
              l_col_tab  TYPE REF TO cl_salv_column_table.
    l_cols_tab = co_alv->get_columns( ).     "  fetch Columns object
    TRY.
        l_col_tab ?= l_cols_tab->get_column( 'VBELN' ).
      CATCH cx_salv_not_found.
    ENDTRY.

naimesh_patel
Active Contributor

In SALV model, system creates the Field cataloge automatically based on the structure of the table. Yes, you need to get the COLUMNS objects to be able to work with it.

Try like this:


* Get the column object
  DATA: lo_cols      TYPE REF TO cl_salv_columns.
  lo_cols = me->wo_salv->get_columns( ).

* modify individual properties
  DATA: lo_column    TYPE REF TO cl_salv_column.
  TRY.
      lo_column = lo_cols->get_column( 'AVAILDATE' ).
      lo_column->set_long_text( 'Avl Date' ).               "#EC NOTEXT
      lo_column->set_medium_text( 'Avl Date' ).             "#EC NOTEXT
      lo_column->set_short_text( 'Avl Date' ).              "#EC NOTEXT
      lo_column->set_output_length( 10 ).
    CATCH cx_salv_not_found.                            "#EC NO_HANDLER
  ENDTRY.

Explore class CL_SALV_COLUMN for different methods to change the properties of the column.

See program SALV_DEMO_TABLE_COLUMNS

You can also check: [SALV Table Display - Column Properties|http://help-abap.blogspot.com/2008/09/salv-model-7-changing-column-settings.html]

Regards,

Naimesh Patel