Skip to Content
0
Former Member
Aug 17, 2013 at 08:32 AM

How to make fixed column width of ALV Report

2611 Views

Dear Guys,

I need your help, i use class method for displaying alv report. Needed things is i want to make the column width fix, but i dont know type of parameter i should add.

these is the logic that i used to make alv report.

FORM f_display_data1 .

* ALV Property

DATA: ob_salv TYPE REF TO cl_salv_table,

l_gr_functions TYPE REF TO cl_salv_functions,

lo_display TYPE REF TO cl_salv_display_settings,

lo_table TYPE REF TO cl_salv_table,

lo_events TYPE REF TO cl_salv_events_table,

lo_columns TYPE REF TO cl_salv_columns_table,

lo_column2 TYPE REF TO cl_salv_column,

gr_layout TYPE REF TO cl_salv_layout,

key TYPE salv_s_layout_key.

TRY.

CALL METHOD cl_salv_table=>factory

* EXPORTING

* LIST_DISPLAY = IF_SALV_C_BOOL_SAP=>FALSE

* R_CONTAINER =

* CONTAINER_NAME =

IMPORTING

r_salv_table = ob_salv

CHANGING

t_table = it_report.

lo_events = ob_salv->get_event( ).

CATCH cx_salv_msg.

ENDTRY.

lo_columns = ob_salv->get_columns( ).

lo_columns->set_optimize('x').

* Standard ALV Functions

l_gr_functions = ob_salv->get_functions( ).

l_gr_functions->set_all( abap_true ).

** Save Layout/Variant

gr_layout = ob_salv->get_layout( ).

key-report = sy-repid.

gr_layout->set_key( key ).

gr_layout->set_save_restriction( if_salv_c_layout=>restrict_none ).

gr_layout->set_default( abap_true ).

* Report Title

lo_display = ob_salv->get_display_settings( ).

lo_display->set_list_header( 'Program Upload Payment' ).

* change column capton

* lo_columns2 = ob_salv->get_columns( ).

lo_column2 = lo_columns->get_column( 'NUMBER' ).

lo_column2->set_long_text( 'Number' ).

lo_column2->set_medium_text('Number').

lo_column2->set_short_text('Number').

lo_column2 = lo_columns->get_column( 'PERNR' ).

lo_column2->set_long_text( 'Personal Number' ).

lo_column2->set_medium_text('Personal Number').

lo_column2->set_short_text('Number').

lo_column2 = lo_columns->get_column( 'LGART' ).

lo_column2->set_long_text( 'WAGE TYPE' ).

lo_column2->set_medium_text( 'WAGE TYPE' ).

lo_column2->set_short_text( 'TYPE' ).

lo_column2 = lo_columns->get_column( 'STATUS' ).

lo_column2->set_long_text( 'STATUS' ).

lo_column2->set_medium_text( 'STATUS' ).

lo_column2->set_short_text( 'STATUS' ).

* Display Report

ob_salv->display( ).

ENDFORM.

anybody can help?

for admin, thanks 😀