How to shift negative sign from right to left in ABAP?

By default negative signs will get displayed in the right side of the field in ABAP. We can display the negative sign to the left while displaying the values in a report by using a function module ‘CLOI_PUT_SIGN_IN_FRONT’. But this FM will work only with character fields, So first copy the currency or quantity fields to a text field, do the conversion and then display the text field in the report.

DATA: gv_amount type konp-kbetr.
  DATA: gv_amount_text(15)  type c. 

gv_amount = 100.
  WRITE:/ 'Positive Value : ', gv_amount. 

gv_amount = gv_amount * -1. 

WRITE:/ 'Negative Value : ', gv_amount. 

gv_amount_text = gv_amount. 

CALL FUNCTION 'CLOI_PUT_SIGN_IN_FRONT'
    CHANGING
      value         = gv_amount_text. 

WRITE:/ 'After Shifting : ', gv_amount_text RIGHT-JUSTIFIED.

Output

Negative-sign-1


2 Comments

Comments are closed.