Application Development and Automation 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: 
Read only

Column optimization ALV print

Former Member
0 Likes
2,095

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( ).

6 REPLIES 6
Read only

former_member182010
Active Participant
0 Likes
1,922

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

Read only

Former Member
0 Likes
1,922

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.

Read only

Former Member
0 Likes
1,922

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.

Read only

phillip_manning2
Explorer
0 Likes
1,922

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

Read only

0 Likes
1,922

lr_print->set_column_optimization( 'X' ).

should not be part of your program.

Read only

paulocampos
Explorer
0 Likes
1,922

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