cancel
Showing results for 
Search instead for 
Did you mean: 

ALV Column width

Former Member
0 Kudos

Hi,

how to set column width in ALV to 10 exactly 10 characters. I know that there is method in cl_salv_wd_column->set_width. What shall I pass in order to get width for 10 characters.

thanks & regards,

Adam

Accepted Solutions (0)

Answers (2)

Answers (2)

uday_gubbala2
Active Contributor
0 Kudos

Hi Adam,

This is possible:

" create an instance of ALV component

DATA: LR_IF_CONTROLLER TYPE REF TO IWCI_SALV_WD_TABLE,

LR_CMP_USAGE TYPE REF TO IF_WD_COMPONENT_USAGE,

LR_CMDL TYPE REF TO CL_SALV_WD_CONFIG_TABLE,

LR_TABLE_SETTING TYPE REF TO IF_SALV_WD_TABLE_SETTINGS.

LR_CMP_USAGE = WD_THIS->WD_CPUSE_ALV( ).

IF LR_CMP_USAGE->HAS_ACTIVE_COMPONENT( ) IS INITIAL.

LR_CMP_USAGE->CREATE_COMPONENT( ).

ENDIF.

" get reference to the ALV model

LR_IF_CONTROLLER = WD_THIS->WD_CPIFC_ALV( ).

LR_CMDL = LR_IF_CONTROLLER->GET_MODEL( ).

LR_TABLE_SETTING ?= LR_CMDL.

" Set column width

DATA LR_COL TYPE REF TO CL_SALV_WD_COLUMN.

LR_COL = LR_CMDL->IF_SALV_WD_COLUMN_SETTINGS~GET_COLUMN( 'PERNR' ).

LR_COL->SET_WIDTH( '70' ) .

LR_COL = LR_CMDL->IF_SALV_WD_COLUMN_SETTINGS~GET_COLUMN( 'ENAME' ).

LR_COL->SET_WIDTH( '100' ) .

LR_TABLE_SETTING->SET_FIXED_TABLE_LAYOUT( ABAP_TRUE ).

You can refer to webdynpro component SALV_WD_TEST_TABLE_PROPS. Go to the view TABLE and look inside the method SET_COLUMN_SETTINGS. I hope this will help you.

Regards,

Uday

0 Kudos

Hi Adam,

You can easily increase the width of the ALV output and columns by specifying the required width. However, to reduce the size, you firstly have to fix the layout of the ALV output. This assigns the same width to all columns. You can then specify the required column width.

For details refer to the below link:

http://help.sap.com/saphelp_erp2005vp/helpdata/en/06/35311b918246d9a0457e5989552916/content.htm

Regards,

Gaurav

Former Member
0 Kudos

Hi Guarav,

Thanks for your answer.

I tried this:

lr_column->set_width( '10' ).

It doesn't work. When I call lr_column->set_width( '60' ) it gives me 10 characters width.

I presume that it might be pixels.

regards,

Adam

Former Member
0 Kudos

I have the same problem:

Have a look at set width...

But nothing happens!!!

Its just same wide as before????

method CONFIG_ALV_COLUMNS .

data: l_ref_interfacecontroller type ref to iwci_salv_wd_table,

lr_config_table type ref to cl_salv_wd_config_table.

data: lr_column_ZPM_META type ref to cl_salv_wd_column,

lr_column_ZPM_ORDER type ref to cl_salv_wd_column,

lr_column_COORDER type ref to cl_salv_wd_column,

lr_column_AUFTXT type ref to cl_salv_wd_column.

data: lr_header type ref to cl_salv_wd_column_header.

************************************************************************

      • Get config model

************************************************************************

l_ref_interfacecontroller = wd_this->wd_cpifc_ALV_ORDER( ).

lr_config_table ?= l_ref_interfacecontroller->get_model( ).

**************************

      • Get rows

**************************

lr_column_ZPM_META = lr_config_table->if_salv_wd_column_settings~get_column( '/BIC/ZPM_META' ).

lr_column_ZPM_ORDER = lr_config_table->if_salv_wd_column_settings~get_column( '/BIC/ZPM_ORDER').

lr_column_COORDER = lr_config_table->if_salv_wd_column_settings~get_column( 'COORDER' ).

lr_column_AUFTXT = lr_config_table->if_salv_wd_column_settings~get_column( 'AUFTXT' ).

**************************************

          • Create header Text

**************************************

lr_header = lr_column_AUFTXT->create_header( ).

lr_header->set_text( '' ).

*****************************************

  • Set witdh

*****************************************

lr_column_AUFTXT->SET_RESIZABLE( ABAP_TRUE ).

lr_column_AUFTXT->set_width( '50' ).

*****************************************

  • Delete rows not used

*****************************************

lr_config_table->if_salv_wd_column_settings~delete_column( '/BIC/ZPM_META' ).

endmethod.