08-17-2013 9:32 AM
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
08-17-2013 11:30 AM
Hi,
First if you optimise SAP will set the output length automatically
so remove
lo_columns->set_optimize('x').
Now to set the required width for each column set the width like this.
LO_COLUMN->SET_OUTPUT_LENGTH('15').
Regards
08-17-2013 11:20 AM
Hi,
you can use method SET_OUTPUT_LENGTH to fix the column width.
~priyaranjan
08-17-2013 11:30 AM
Hi,
First if you optimise SAP will set the output length automatically
so remove
lo_columns->set_optimize('x').
Now to set the required width for each column set the width like this.
LO_COLUMN->SET_OUTPUT_LENGTH('15').
Regards
08-17-2013 11:39 AM
08-17-2013 11:50 AM
hi,
you can use the each fieldcatlog what is each field length can you give input.
PERNR this field length is 10 can you give the input of this fieldcatlog is 10
lo_column2->SET_OUTPUT_LENGTH('10')..