创建函数模块,一进一出,如果不需修改可不创建input
CONVERSION_EXIT_Z001_INPUT
DATA :lw_curr TYPE bnbtr,
lw_str TYPE string.
lw_str = input.
IF lw_str+0(1) EQ '-'.
SHIFT lw_str.
lw_curr = lw_str .
lw_curr = lw_curr * ( -1 ).
CLEAR lw_str .
lw_str = lw_curr .
ENDIF .
output = lw_str .
CONVERSION_EXIT_Z001_OUTPUT
DATA: output1(20) TYPE c,
output2(20),
outdatum TYPE p DECIMALS 3.
IF NOT input IS INITIAL.
outdatum = input.
IF input > 0.
WRITE outdatum TO output1 ."RIGHT-JUSTIFIED .
ELSE.
outdatum = outdatum * ( -1 ).
WRITE outdatum TO output1 ."RIGHT-JUSTIFIED.
CONCATENATE '-' output1 INTO output1.
ENDIF.
ELSE.
CLEAR output1.
ENDIF.
CONDENSE output1 NO-GAPS .
WRITE output1 TO output2 RIGHT-JUSTIFIED .
output = output2.
最后在需要的报表代码中的fieldcat对应的字段加上convexit参数的赋值即可
(Z001与上面两个函数的函数名Z001对应)
展示效果