cancel
Showing results for 
Search instead for 
Did you mean: 

ALV Display - Custom Column Name - cl_salv_table

Jose3
Explorer
0 Kudos
523

Hello Everyone,

Any idea on the reason why this is not working. I can't get the custom column name in the report display.

 

 

TYPES: BEGIN OF gty_data,

matnr TYPE matnr, " Material Number

sernr TYPE gernr, " Serial Number

pin TYPE string, " PIN (Assuming PIN as a string)

END OF gty_data,

gty_tab_data TYPE STANDARD TABLE OF gty_data.

 

 

 

 

 

METHOD display_data.

TRY.

cl_salv_table=>factory( IMPORTING r_salv_table = DATA(lr_alv)

CHANGING t_table = ct_data ).

CATCH cx_salv_msg.

ENDTRY.

TRY.

lr_alv->get_layout( )->set_key( VALUE #( report = sy-repid ) ).

lr_alv->get_layout( )->set_default( abap_true ).

lr_alv->get_layout( )->set_save_restriction( if_salv_c_layout=>restrict_none ).

lr_alv->get_functions( )->set_all( abap_true ).

lr_alv->get_columns( )->get_column( 'pin' )->set_long_text( 'PIN' ).

lr_alv->get_columns( )->get_column( 'pin' )->set_medium_text( 'PIN' ).

lr_alv->get_columns( )->get_column( 'pin' )->set_short_text( 'PIN' ).

CATCH cx_salv_not_found.

ENDTRY.

CALL METHOD lr_alv->display.

ENDMETHOD.

 

 


Thanks in advance.

Accepted Solutions (1)

Accepted Solutions (1)

MarcoK
Explorer

First, do yourself and us a favour, and use the insert code feature in the editor (</>).

Second, try to write the column names in uppercase ('PIN')  when you  call the get_column method

 

lr_alv->get_columns( )->get_column( 'PIN' )

 

 

 

Jose3
Explorer
0 Kudos

Hey,

Thanks, Worked.

New to the community,  will use the code feature in the editor (</>) from now on.

Sandra_Rossi
Active Contributor
@Jose3 You may edit your question and fix your code right now, to help future visitors to read your code (I and others).

Answers (0)