cancel
Showing results for 
Search instead for 
Did you mean: 

How to change the column length in the ALV Grid.

Former Member
0 Kudos

Hai All,

I am developing a ALV application.

in the table it have five columns, I want to set the column width to only 5 character length.

how can i make this.

Thanks,

Sreevathsava.G.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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' ).
Regards, Radhika.

Former Member
0 Kudos

Hai radhika ,

i tried with the code what you sent,

but it shows error lr_cmdl is not exist.

can u provide the solution for that.

Former Member
0 Kudos

Hi,

lr_cmdl type ref to cl_salv_wd_config_table. "Model object for ALV

Regards,

Lekha.

Former Member
0 Kudos
* Instantiate the used component
  DATA lo_cmp_usage TYPE REF TO if_wd_component_usage.

  lo_cmp_usage =   wd_this->wd_cpuse_usg_alv( ).
  IF lo_cmp_usage->has_active_component( ) IS INITIAL.
    lo_cmp_usage->create_component( ).
  ENDIF.

* Get Model
  DATA lo_interfacecontroller TYPE REF TO iwci_salv_wd_table .
  lo_interfacecontroller =   wd_this->wd_cpifc_usg_alv( ).

  DATA lo_value TYPE REF TO cl_salv_wd_config_table.
  lo_value = lo_interfacecontroller->get_model(
  ).

DATA LR_COL TYPE REF TO CL_SALV_WD_COLUMN.
 
LR_COL = lo_value->IF_SALV_WD_COLUMN_SETTINGS~GET_COLUMN( 'PERNR' ).
LR_COL->SET_WIDTH( '70' ).
Former Member
0 Kudos

hai lekah while trying with the code

DATA lr_cmdl type ref to cl_salv_wd_config_table.

DATA LR_COL TYPE REF TO CL_SALV_WD_COLUMN.

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

LR_COL->SET_WIDTH( '10' ).

it shows runtime error "ACCESS VIA NULL IS NOT POSSIBLE".

Former Member
0 Kudos

You will have to instantiate the ALV, check the code in my previous reply. You can use the code wizard for generating the same. Radhika.

Former Member
0 Kudos

Hi,

Check in ST22 where the Null reference error is pointed to.

DATA lr_cmdl type ref to cl_salv_wd_config_table.

DATA LR_COL TYPE REF TO CL_SALV_WD_COLUMN.

if lr_cmdl is not initial.

LR_COL = LR_CMDL->IF_SALV_WD_COLUMN_SETTINGS~GET_COLUMN( 'STATUS' ). "Is this column name correct

endif.

if lr_col is not intiial.

LR_COL->SET_WIDTH( '10' ).

endif.

Where have you written this piece of code.

If you have written in any method of view, then check wether this ALV is under the component usages tab of PROPERTIES tab of that view.

Now instantiate the ALV then try touse the above code of RADHIKA's.

Regards,

Lekha.

Answers (0)