健康一贴灵,专注医药行业管理信息化

SAP 控制小数位的长度显示

 

日常使用ALV报表时,如果不想显示指定列的小位,可以通过判断字段名,指定    **-DECIMALS_OUT = '0'. "去掉小数点后的0

 

 

DATA:
 g_line              TYPE slis_fieldcat_alv,
 gt_fieldcat         TYPE slis_t_fieldcat_alv.

*
输出 alv 报表 FORM frm_show_alv . DEFINE append_alv_field. CLEAR g_line. g_line-fieldname = &1. g_line-tabname = 'GT_ALV'. g_line-reptext_ddic = &2. g_line-seltext_l = &2. g_line-seltext_m = &2. g_line-seltext_s = &2. g_line-cfieldname = &3. g_line-ctabname = &4. g_line-no_out = &5. g_line-no_zero = &6. g_line-outputlen = &7. g_line-qfieldname = &8. g_line-just = &9. g_line-ddictxt = 'L'. g_line-do_sum = 'X'. if g_line-fieldname = 'LFIMG'. "如果字段名为LFIMG,则将小数位设置为0,其它的设置为2位 g_line-DECIMALS_OUT = '0'. "去掉小数点后的0 else. g_line-DECIMALS_OUT = '2'. "去掉小数点后的0 endif. APPEND g_line TO gt_fieldcat. END-OF-DEFINITION. **ALV 显示字段 REFRESH:gt_fieldcat. gt_layout-colwidth_optimize = 'X'. " 自适应宽度 append_alv_field 'VKORG' '公司' '' '' '' '' '' '' ''. append_alv_field 'vtweg' '渠道' '' '' '' '' '' '' ''. append_alv_field 'WADAT_IST' '票据日期' '' '' '' '' '' '' ''. append_alv_field 'VBELN' '交货单号' '' '' '' '' '' '' ''. append_alv_field 'RYBH' '业务员号' '' '' '' '' '' '' ''. append_alv_field 'RYXM' '业务员姓名' '' '' '' '' '' '' ''. append_alv_field 'kunnr' '客户号' '' '' '' '' '' '' ''. append_alv_field 'name1' '客户名称' '' '' '' '' '' '' ''. append_alv_field 'matnr' '物料号' '' '' '' '' '' '' ''. append_alv_field 'maktx' '物料描述' '' '' '' '' '' '' ''. append_alv_field 'lfart' '类型' '' '' '' '' '' '' ''. append_alv_field 'LFIMG' '交货数量' '' '' '' '' '' '' ''. append_alv_field 'hsdj' '单价' '' '' '' '' '' '' ''. append_alv_field 'hsje' '金额' '' '' '' '' '' '' ''. append_alv_field 'NETWR' '订单金额' '' '' '' '' '' '' ''. append_alv_field 'KWMENG' '订单数量' '' '' '' '' '' '' ''. append_alv_field 'VTWEG' '行项目' '' '' '' '' '' '' ''. append_alv_field 'DDBH' '订单号' '' '' '' '' '' '' ''. append_alv_field 'vkbur' '销售办公室' '' '' '' '' '' '' ''. append_alv_field 'vkgrp' '销售组' '' '' '' '' '' '' ''. append_alv_field 'bzirk' '销售地区' '' '' '' '' '' '' ''. CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' EXPORTING i_callback_program = sy-repid * i_callback_pf_status_set = 'FRM_STATUS' "GUI指定子程序 * i_callback_user_command = 'FRM_USER_COMM' "客户命令指定子程序 is_layout = gt_layout it_fieldcat = gt_fieldcat[] * it_events = events[] TABLES t_outtab = gt_tab[] "指定要显示的内表名称 EXCEPTIONS program_error = 1 OTHERS = 2. ENDFORM.
**判断字段名称,设置指定字段的小数位
if g_line-fieldname = 'LFIMG'. "如果字段名为LFIMG,则将小数位设置为0,其它的设置为2位 g_line-DECIMALS_OUT = '0'. "去掉小数点后的0 else. g_line-DECIMALS_OUT = '2'. "去掉小数点后的0 endif.
执行效果:

 

 

 
posted @ 2021-11-10 09:35  一贴灵  阅读(1625)  评论(0编辑  收藏  举报
学以致用,效率第一