负号显示
最简单的一种:
CALL FUNCTION 'CLOI_PUT_SIGN_IN_FRONT'
CHANGING
value = value.
还有就是自己写函数等了
构建ALV的FIELDCATE时,设置 edit_mask = '==XXXXX',建立函数CONVERSION_EXIT_XXXXX_OUTPUT设置输出为负号提前,之后调用ALV显示函数,系统会自动调用函数CONVERSION_EXIT_XXXXX_OUTPUT FUNCTION CONVERSION_EXIT_ZMENGE_OUTPUT. *"---------------------------------------------------------------------- *"*"Local interface: *" IMPORTING *" REFERENCE(INPUT) TYPE ANY *" EXPORTING *" REFERENCE(OUTPUT) TYPE ANY *"---------------------------------------------------------------------- OUTPUT = INPUT. CALL FUNCTION 'CLOI_PUT_SIGN_IN_FRONT' CHANGING VALUE = OUTPUT. ENDFUNCTION. 1、建立自定义函数 1.1 整数显示 FUNCTION CONVERSION_EXIT_Z0002_OUTPUT. *"---------------------------------------------------------------------- *"*"Local interface: *" IMPORTING *" REFERENCE(INPUT) *" EXPORTING *" REFERENCE(OUTPUT) *"---------------------------------------------------------------------- DATA: OUTPUT1(12) TYPE C, OUTDATUM TYPE INT4. IF INPUT <> SPACE. OUTDATUM = INPUT. if input > 0. move OUTDATUM TO OUTPUT . else. OUTDATUM = OUTDATUM_*( -1 ). move OUTDATUM TO OUTPUT1 . CONCATENATE '-' output1 into output. CONDENSE output NO-GAPS . endif. ELSE. OUTPUT = SPACE. ENDIF. ENDFUNCTION. 1.2 浮点数显示 FUNCTION conversion_exit_zsign_output. *"---------------------------------------------------------------------- *"*"Local interface: *" IMPORTING *" REFERENCE(INPUT) *" EXPORTING *" REFERENCE(OUTPUT) *"---------------------------------------------------------------------- DATA: output1(19) TYPE c, output2(19), outdatum TYPE p DECIMALS 2. IF not input is initial. outdatum = input. IF input > 0. WRITE outdatum TO output1 ."RIGHT-JUSTIFIED . CONCATENATE ' ' output1 INTO output1. ELSE. outdatum = outdatum_*( -1 ). WRITE outdatum TO output1 ."RIGHT-JUSTIFIED. CONCATENATE '-' output1 INTO output1. ENDIF. ELSE. * output = '0.00'. CLEAR output1. ENDIF. CONDENSE output1 NO-GAPS . WRITE output1 TO output2 RIGHT-JUSTIFIED . output = output2. ENDFUNCTION. 2、设置ALV输出格式字段格式 clear ls_fcat. ls_fcat-fieldname = 'INT4'. ls_fcat-inttype = 'I'. ls_fcat-intlen = 10. ls_fcat-col_pos = l_lin. ls_fcat-seltext_s = ls_fcat-fieldname. ls_fcat-seltext_m = ls_fcat-fieldname. ls_fcat-seltext_l = ls_fcat-fieldname. ls_fcat-edit_mask = '==Z0002'. append ls_fcat to ct_fcat. 3、调用函数就可达到负数符号前显的效果。 call function 'REUSE_ALV_GRID_DISPLAY' exporting it_fieldcat = lt_fcat tables t_outtab = gt_outtab exceptions program_error = 1 others = 2. 2. 方法1:把字段设置为CHAR型,拼接字符串负号自然可以提前显示。 方法2:构建ALV的FIELDCATE时,设置 edit_mask = '==XXXXX',建立函数CONVERSION_EXIT_XXXXX_OUTPUT设置输出为负号提前,之后调用ALV显示函数,系统会自动调用函数CONVERSION_EXIT_XXXXX_OUTPUT FUNCTION CONVERSION_EXIT_ZMENGE_OUTPUT. *"---------------------------------------------------------------------- *"*"Local interface: *" IMPORTING *" REFERENCE(INPUT) TYPE ANY *" EXPORTING *" REFERENCE(OUTPUT) TYPE ANY *"---------------------------------------------------------------------- OUTPUT = INPUT. CALL FUNCTION 'CLOI_PUT_SIGN_IN_FRONT' CHANGING VALUE = OUTPUT. ENDFUNCTION. 1、建立自定义函数 1.1 整数显示 FUNCTION CONVERSION_EXIT_Z0002_OUTPUT. *"---------------------------------------------------------------------- *"*"Local interface: *" IMPORTING *" REFERENCE(INPUT) *" EXPORTING *" REFERENCE(OUTPUT) *"---------------------------------------------------------------------- DATA: OUTPUT1(12) TYPE C, OUTDATUM TYPE INT4. IF INPUT <> SPACE. OUTDATUM = INPUT. if input > 0. move OUTDATUM TO OUTPUT . else. OUTDATUM = OUTDATUM_*( -1 ). move OUTDATUM TO OUTPUT1 . CONCATENATE '-' output1 into output. CONDENSE output NO-GAPS . endif. ELSE. OUTPUT = SPACE. ENDIF. ENDFUNCTION. 1.2 浮点数显示 FUNCTION conversion_exit_zsign_output. *"---------------------------------------------------------------------- *"*"Local interface: *" IMPORTING *" REFERENCE(INPUT) *" EXPORTING *" REFERENCE(OUTPUT) *"---------------------------------------------------------------------- DATA: output1(19) TYPE c, output2(19), outdatum TYPE p DECIMALS 2. IF not input is initial. outdatum = input. IF input > 0. WRITE outdatum TO output1 ."RIGHT-JUSTIFIED . CONCATENATE ' ' output1 INTO output1. ELSE. outdatum = outdatum_*( -1 ). WRITE outdatum TO output1 ."RIGHT-JUSTIFIED. CONCATENATE '-' output1 INTO output1. ENDIF. ELSE. * output = '0.00'. CLEAR output1. ENDIF. CONDENSE output1 NO-GAPS . WRITE output1 TO output2 RIGHT-JUSTIFIED . output = output2. ENDFUNCTION. 2、设置ALV输出格式字段格式 clear ls_fcat. ls_fcat-fieldname = 'INT4'. ls_fcat-inttype = 'I'. ls_fcat-intlen = 10. ls_fcat-col_pos = l_lin. ls_fcat-seltext_s = ls_fcat-fieldname. ls_fcat-seltext_m = ls_fcat-fieldname. ls_fcat-seltext_l = ls_fcat-fieldname. ls_fcat-edit_mask = '==Z0002'. append ls_fcat to ct_fcat. 3、调用函数就可达到负数符号前显的效果。 call function 'REUSE_ALV_GRID_DISPLAY' exporting it_fieldcat = lt_fcat tables t_outtab = gt_outtab exceptions program_error = 1 others = 2.