Application Development 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: 

Centering Commentary OO

Former Member
0 Kudos

Hi,

I am using ABAP OO to Write and ALV header list. How do we center the commentary written above?

*Write Header Commentary
DATA :
l_oref_grid TYPE REF TO cl_salv_form_layout_grid.

* Add text items for top of page
*CREATE OBJECT l_oref_grid.

perform get_coaddr changing l_tmpstr.
l_oref_grid->create_text(
row = 1 column = 1 text = l_tmpstr ).

l_tmpstr = TEXT-003.
l_oref_grid->create_text(
row = 2 column = 1 text = l_tmpstr ).

How do I modify the elements written to center it instead of the default Left-aligned?

1 ACCEPTED SOLUTION

uwe_schieferstein
Active Contributor
0 Kudos

Hello Mizan

Perhaps the following approach might work:


DATA: lo_column     TYPE REF TO CL_SALV_FORM_GRID_COLUMN.

  lo_column = l_oref_grid->get_column( column = 1 ).

  CALL METHOD lo_column->set_h_align
    EXPORTING
      value = IF_SALV_FORM_C_H_ALIGN=>CENTER.

Regards

Uwe

3 REPLIES 3

uwe_schieferstein
Active Contributor
0 Kudos

Hello Mizan

Perhaps the following approach might work:


DATA: lo_column     TYPE REF TO CL_SALV_FORM_GRID_COLUMN.

  lo_column = l_oref_grid->get_column( column = 1 ).

  CALL METHOD lo_column->set_h_align
    EXPORTING
      value = IF_SALV_FORM_C_H_ALIGN=>CENTER.

Regards

Uwe

0 Kudos

Thank you Uwe,

That was just what I was looking for. was trying to figure out using SET_H_ALIGN from CL_SALV_FORM_LAYOUT_DATA_GRID but was not successful.

Regards,

Mizan.

0 Kudos

Hello Mizan

I have never used these classes before but my instinct told me to search this way because in the new ALV object model virtually everything has become an object:

- centered text => column with this property => found GET_COLUMN method (CL_SALV_FORM_GRID_COLUMN) 
=> and here I could not miss the reqiured method

This is a general approach will should be useful for the new ALV object model as well as other classes where we can expect class composition.

Regards

Uwe