码迷,mamicode.com
首页 > 其他好文 > 详细

ALV 数值列负号前置 (EDIT_MASK应用)

时间:2015-06-12 14:47:03      阅读:207      评论:0      收藏:0      [点我收藏+]

标签:

1、建立自定义函数

浮点数显示
FUNCTION conversion_exit_zsign_output.
*"----------------------------------------------------------------------
*"*"Local interface:
*"  IMPORTING
*"     REFERENCE(INPUT)
*"  EXPORTING
*"     REFERENCE(OUTPUT)
*"----------------------------------------------------------------------
  DATA: output1(20)   TYPE c,
        output2(20),
        outdatum   TYPE p DECIMALS 6.
  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.
ENDFUNCTION.

2、设置ALV输出格式字段格式
  clear ls_fcat.
  ls_fcat-fieldname = ‘DEC‘.
  ls_fcat-inttype   = ‘P‘.
  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 = ‘==ZSIGN‘.
  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.

    这种方式同样可以实现相对复杂的显示效果,如财务凭证中S表示借,H表示贷,我们在显示的时候要显示“”或“贷”,也可以写一个类似的函数来实现。

 

http://blog.163.com/arhao_h/blog/static/125169020103191200252/ 

ALV 数值列负号前置 (EDIT_MASK应用)

标签:

原文地址:http://www.cnblogs.com/caizjian/p/4571495.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!