‎2010 Jan 28 7:30 PM
I am using CL_SALV_TABLE for my ALV report and I need to optimize the columns when the report is printed. I tried the following but it doesnt seem to do the trick. What am I missing.
lr_print = gr_table->get_print( ).
lr_print->set_column_optimization( 'X' ).
gr_table->display( ).
‎2010 Jan 28 7:36 PM
Hello Megan,
Try the following code.
TRY.
CALL METHOD cl_salv_table=>factory
IMPORTING
r_salv_table = gr_table
CHANGING
t_table = gt_output_list.
CATCH cx_salv_msg.
ENDTRY.
DATA: lr_columns TYPE REF TO cl_salv_columns_table.
DATA: lr_column TYPE REF TO cl_salv_column_table.
lr_columns = gr_table->get_columns( ).
lr_columns->set_optimize( abap_true ).
Regards,
Rae Ellen Woytowiez
‎2010 Jan 28 7:39 PM
I already have my columns optimized. But when printing it doesnt optimize the report, when displaying on screen it does. So I added CL_SALV_PRINT to the mix but it doesnt seem to work either.
‎2010 Jan 28 8:14 PM
When I look at program SALV_TEST_TABLE, it is doing exactly what I require. The print out of the report has column's optimized. If in the display I shorten the length of the columns, this is reflected in the print preview. But I cant figure out what changes in the settings are needed to get to this.
‎2010 Apr 21 8:59 AM
Hi,
I'm having kind of the opposite problem. I don't want my columns to be optimised when printing, but they are.
The program SALV_TEST_TABLE behaves as I would want as well.
I see you have this question as answered - did you find the difference between your program and SALV_TEST_TABLE?
Cheers,
Phil
‎2010 Apr 23 8:41 PM
lr_print->set_column_optimization( 'X' ).
should not be part of your program.
‎2014 Jun 17 3:01 PM
My Friend,
First, use the method GET_COLUMNS of de class CL_SALV_TABLE.
DATA: lo_salv_table TYPE REF TO cl_salv_table,
lo_columns TYPE REF TO cl_salv_columns_table.
cl_salv_table=>factory( IMPORTING r_salv_table = lo_salv_table
CHANGING t_table = YOUR INTERNAL TABLE ).
lo_columns = lo_salv_table->get_columns( ).
lo_columns->set_optimize( abap_true ).
lo_salv_table->display( ).
Here it worked.
Att
Paulo Campos
Consultor ABAP