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

ALV Tree- Negative Values are not alligned

karnam344
Newcomer
0 Likes
1,323

Hi All,

I created a custom ABAP report using ALV Tree Layout and I have a problem with numbers in ALV Tree column. Since numbers by default are right hand side aligned and by default negative numbers have the negative sign to the right hand side, when negative and positive values are into the same column on an ALV Tree layout the number alignment includes the sign so the decimal values are never aligned between each others, something like this:

100.00

100.00-

Notice in the image below how the "positive" value is not aligned among the other values.

I am using the class CL_GUI_ALV_TREE.

Thanks in advance

Hi All,

I created a custom ABAP report using ALV Tree Layout and I have a problem with numbers in ALV Tree column. Since numbers by default are right hand side aligned and by default negative numbers have the negative sign to the right hand side, when negative and positive values are into the same column on an ALV Tree layout the number alignment includes the sign so the decimal values are never aligned between each others, something like this:

100.00

100.00-

Notice in the image below how the "positive" value is not aligned among the other values.

I am using the class CL_GUI_ALV_TREE.

Thanks in advance

2 REPLIES 2
Read only

former_member596005
Participant
0 Likes
1,078

As per my understanding from your question i can say change sign from right side to left side ...so that all values are perfectly aligned

Read only

Sandra_Rossi
Active Contributor
0 Likes
1,078

Technically, the ALV tree is an adaptation of the CL_GUI_COLUMN_TREE control (which is not an ALV at all), so the control completely ignores the data types, it handles them all like texts, so the left and right spaces are ignored. If you compare with the CL_GUI_ALV_GRID control, there is a space for the sign for positive numbers because the control considers the data types.

There is a trick but you must change the standard control class (it will recompile all standard programs which use the control), a good place being at the end of method SET_ITEMS_FOR_COLUMN in class CL_ALV_TREE_BASE, add a non-breaking space (U+00A0) :

  IF sy-cprog(1) = 'Z'                            " limit risks - only Z programs
        AND is_fieldcatalog-inttype = 'P'         " packed field (DEC, CURR, QUAN)
        AND is_fieldcatalog-no_sign = abap_false. " only signed numeric fields
    LOOP AT et_items ASSIGNING FIELD-SYMBOL(<zz_item>).
      IF <zz_item>-text np '*-'. " add non breaking space only for positive numbers
        <zz_item>-text = <zz_item>-text && cl_abap_conv_in_ce=>uccpi( 160 ).
      ENDIF.
    ENDLOOP.
  ENDIF.

But at your own risk - side effects unknown !! (personally, I wouldn't do it) It might not work in the Web Gui.