• FM四舍五入_从小数点最后一位进位


    原贴地址:http://jiahongguang12.blog.163.com/blog/static/334665720071060551591/

       输入参数12.5445,因此FM从小数点最后一位进位,FM参数 CONV_DEC =2 为精确到第2位小数   ,

       打印结果:12.55;                     

      REPORT  Z_TEST_007.

    DATA : DAT TYPE P DECIMALS 9  VALUE '12.5445' ,
           DAT1 TYPE P DECIMALS 9 .

    *       MOVE DAT TO DAT1.

    CALL FUNCTION 'HR_NZ_ROUNDING_DECIMALS'
      EXPORTING
        VALUE_IN                       = DAT                      " Input field with decimals

       CONV_DEC                       = 2                         " i    Number of desired decimals for conversion

     IMPORTING
       VALUE_OUT                      = DAT1.                  " Output field with rounded decimals

    * EXCEPTIONS
    *   NO_ROUNDING_REQUIRED             = 1        " No rounding required. (CONV_DEC > VALUE_IN dec)

    *   DECIMALS_GREATER_THAN_10       = 2        " Conversion only possible with decimals <= 10

    *   ROUNDING_ERROR                          = 3        " An error occurred during the decimal conversion

    *   OTHERS                                           = 4.

    "  HR_NZ_ROUNDING_DECIMALS

    WRITE DAT1.

    注:处理的数据必须是数值类型,SAP默认四舍五入,如果是P类型可以直接定义小数位来限制

  • 相关阅读:
    lsblk命令详解
    lspci命令详解
    numastat命令详解
    lsscsi命令详解
    lscpu命令详解
    linux内核模块相关命令:lsmod,depmod,modprobe,modinfo,insmod,rmmod 使用说明
    elk收集tomcat的日志
    npm安装
    centos7.5 解决缺少libstdc++.so.6库的原因及解决办法
    linux下正确卸载rpm包
  • 原文地址:https://www.cnblogs.com/ruingy/p/3392104.html
Copyright © 2020-2023  润新知