Whenever we generate a negative value, SAP usually will put the negative sign after the value, now there’s a function module called CLOI_PUT_SIGN_IN_FRONT that could put all the negative sign before or in front of the value.
Here’s the ABAP sample code.
REPORT Z_PUT_NEGATIVE_SIGN_FRONT.
REPORT Z_PUT_NEGATIVE_SIGN_FRONT.
Parameter: p_num1 type i,
p_num2 type i.
p_num2 type i.
Data: d_sum type i,
d_value(10).
d_value(10).
d_sum = p_num1 – p_num2.
d_value = d_sum.
Write:/ ‘Before Function: ‘, d_sum.
CALL FUNCTION ‘CLOI_PUT_SIGN_IN_FRONT’
CHANGING
VALUE = d_value.
SKIP.
CHANGING
VALUE = d_value.
SKIP.
write:/ ‘After Function: ‘, d_value RIGHT-JUSTIFIED.
Run the program and enter value in p_num2 to be greater than p_num1 so that you can get the negative value, as you can see the result before and after the function, where the negative sign is now in front of the number.
Post a Comment