abap 百分号显示
1、自定义函数
FUNCTION CONVERSION_EXIT_Z0002_OUTPUT. *"-------------------------------------------------------------------- *"*"局部接口: *" IMPORTING *" REFERENCE(INPUT) *" EXPORTING *" REFERENCE(OUTPUT) *"-------------------------------------------------------------------- * IF INPUT IS NOT INITIAL. * WRITE INPUT TO OUTPUT. * OUTPUT = OUTPUT * 100. * CONCATENATE OUTPUT '%' INTO OUTPUT. * CONDENSE OUTPUT NO-GAPS. * ENDIF. "负号及百分比 DATA: OUTPUT1(20) TYPE C, OUTPUT11(30), OUTPUT2(30), OUTDATUM(16) TYPE P DECIMALS 2. IF NOT INPUT IS INITIAL. OUTDATUM = INPUT. * IF INPUT > 0. IF OUTDATUM > 0. OUTDATUM = OUTDATUM * 100. WRITE OUTDATUM TO OUTPUT1 ."RIGHT-JUSTIFIED . OUTPUT11 = |{ OUTPUT1 }%|. ELSE. OUTDATUM = OUTDATUM * ( -1 ) * 100. WRITE OUTDATUM TO OUTPUT1 ."RIGHT-JUSTIFIED. OUTPUT11 = |- { OUTPUT1 }%|. ENDIF. ELSE. CLEAR OUTPUT1. ENDIF. CONDENSE OUTPUT11 NO-GAPS . WRITE OUTPUT11 TO OUTPUT2 RIGHT-JUSTIFIED . OUTPUT = OUTPUT2. CLEAR: OUTPUT2. ENDFUNCTION.
2、可以每次使用函数转换,也可以如果只是ALV显示的话 结合ALV参数使用
但是要注意函数名称格式是固定的,CONVERSION_EXIT_XXXX_OUTPUT,其中XXXX可以自己起名字
结合ALV的参数
wa_fieldcat-edit_mask