ABAP 负号前置方法汇总 开发过程中有这样的一个需求,要求指定数字栏位负号前置:
方法一:
PERFORM FRM_MOVE_DATA_MINUS CHANGING L_CHAR20. ” 负号前置
*&———————————————————————*
*& Form FRM_MOVE_DATA_MINUS
*&———————————————————————*
* 负号前置
*———————————————————————-*
FORM FRM_MOVE_DATA_MINUS CHANGING P_VALUE.
DATA : L_NUM(),L_TMP.
DATA : L_LEN TYPE I.
L_NUM = P_VALUE.
L_LEN = STRLEN( L_NUM ).
SEARCH L_NUM FOR ‘-’ STARTING AT L_LEN.
IF SY-SUBRC = .
SPLIT L_NUM AT ‘-’ INTO L_NUM L_TMP.
SHIFT L_NUM LEFT DELETING LEADING SPACE.
CONCATENATE ‘-’ L_NUM INTO P_VALUE.
SHIFT P_VALUE RIGHT DELETING TRAILING SPACE.
ENDIF.
ENDFORM. ” FRM_MOVE_DATA_MINUS 方法二:
IF wa_mbew_out-qty00 < .
CALL FUNCTION ‘CLOI_PUT_SIGN_IN_FRONT’
CHANGING
value = wa_mbew_out-qty00.
ENDIF.