cancel
Showing results for 
Search instead for 
Did you mean: 

ALV cell alignment

Former Member
0 Kudos

Hi,

I want to make cell alignment in ALV.

I could able to do left and center alignment but not right alignment.

How to do the right alignment??

I'm using the below code:

data lr_salv_column type ref to cl_salv_wd_column.

lr_salv_column->SET_H_ALIGN( value = 1 ). "0 - right/ 1- center

Thankx,

Suba

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Please check these code:


DATA: LR_IF_CONTROLLER  TYPE REF TO IWCI_SALV_WD_TABLE,
      LR_CMDL           TYPE REF TO CL_SALV_WD_CONFIG_TABLE,
      LR_COL            TYPE REF TO CL_SALV_WD_COLUMN.

* get reference to the ALV model
  LR_IF_CONTROLLER = WD_THIS->WD_CPIFC_ALV( ).
  LR_CMDL = LR_IF_CONTROLLER->GET_MODEL( ).

* get column
  LR_COL = LR_CMDL->IF_SALV_WD_COLUMN_SETTINGS~GET_COLUMN( 'ENDDA' ).

* set h.alignment
  LR_COL->SET_H_ALIGN( '06' ).
  
    

Notes:

'06' = FORCED RIGHT

'05' = END OF LINE

Regards,

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

>

> Hi,

>

> .....

> * set h.alignment

> LR_COL->SET_H_ALIGN( '06' ).

>

>

>


> Notes:
> '06' = FORCED RIGHT
> '05' = END OF LINE
> 
> Regards,{quote}

Just a word of warning.  You should avoid coding the values directly.  SAP can change these values at any time and we won't applogize if that breaks your application. 🙂  You should always use the class constants.  This also makes your coding much more readable and maintainable.  It also makes it easy to forward navigate and find all the possible values.  For this example the class constants are CL_WD_TABLE_COLUMN=>E_H_ALIGN

Type defintion from CL_WD_TABLE_COLUMN:
 

begin of e_h_align,

auto type wdy_uie_library_enum_type value '00', " TableColumnHAlign.auto

center type wdy_uie_library_enum_type value '01', " TableColumnHAlign.center

forced_left type wdy_uie_library_enum_type value '04', " TableColumnHAlign.forcedLeft

end_of_line type wdy_uie_library_enum_type value '05', " TableColumnHAlign.endOfLine

forced_right type wdy_uie_library_enum_type value '06', " TableColumnHAlign.forcedRight

begin_of_line type wdy_uie_library_enum_type value '07', " TableColumnHAlign.beginOfLine

end of e_h_align .




So your coding should be:
   

LR_COL->SET_H_ALIGN( CL_WD_TABLE_COLUMN=>E_H_ALIGN-FORCED_RIGHT ).

Answers (0)