zoukankan      html  css  js  c++  java
  • SAP BDC 调用中 金额格式转换

    在BDC调用中,由于用户设置不同,导致金额、日期等字段的输入格式不正确。此处给出 自创 金额转换FM 并配有 调用方式。

    function zgm_conver_cuur.
    *"----------------------------------------------------------------------
    *"*"Local Interface:
    *"  IMPORTING
    *"     REFERENCE(I_STRIN)
    *"     REFERENCE(I_DECIMALS) TYPE  I
    *"  EXPORTING
    
    
    
    
    
    *"     REFERENCE(E_STROUT)
    *"----------------------------------------------------------------------
      data:l_dcpfm   like usr01-dcpfm,
           l_strin   type char20,
           l_reverse type char20,
           l_strout  type char20,
           l_str1    type string,
           l_str2    type string,
    
           l_mask    type string.
      data:l_lenth type i.
      data:l_lenth2 type i.
      clear l_mask.
      l_str2 = '___'.
      case i_decimals.
        when 2.
          l_str1 = '__'.
        when 3.
          l_str1 = '___'.
        when 4.
          l_str1 = '____'.
        when others.
      endcase.
    
      l_strin = i_strin.
      "remove Punctuation by space
      replace '.' with '' into l_strin.
      condense l_strin no-gaps.
      l_lenth = strlen( l_strin ).
      l_lenth2 = l_lenth - i_decimals.
    
      case l_lenth2.
        when 1 or 2 or 3.
        when 4 or 5 or 6.
        when others.
      endcase.
      "reverse string
      call function 'STRING_REVERSE'
        exporting
          string  = l_strin
          lang    = sy-langu
        importing
          rstring = l_reverse.
    
    
      select single dcpfm into l_dcpfm from usr01 where bname = sy-uname.
    
      case l_dcpfm.
        when ''.
          case l_lenth2.
            when 1 or 2 or 3.
              concatenate l_str1 l_str2 into l_mask separated by ','.
            when 4 or 5 or 6.
              concatenate l_str2 l_str2 into l_mask separated by '.'.
              concatenate l_str1 l_mask into l_mask separated by ','.
            when 7 or 8 or 9.
              concatenate l_str2 l_str2 l_str2 into l_mask separated by '.'.
              concatenate l_str1 l_mask into l_mask separated by ','.
            when 10 or 11 or 12.
              concatenate l_str2 l_str2 l_str2 l_str2 into l_mask separated by '.'.
              concatenate l_str1 l_mask into l_mask separated by ','.
            when others.
          endcase.
        when 'X'.
          case l_lenth2.
            when 1 or 2 or 3.
              concatenate l_str1 l_str2 into l_mask separated by '.'.
            when 4 or 5 or 6.
              concatenate l_str2 l_str2 into l_mask separated by ','.
              concatenate l_str1 l_mask into l_mask separated by '.'.
            when 7 or 8 or 9.
              concatenate l_str2 l_str2 l_str2 into l_mask separated by ','.
              concatenate l_str1 l_mask into l_mask separated by '.'.
            when 10 or 11 or 12.
              concatenate l_str2 l_str2 l_str2 l_str2 into l_mask separated by ','.
              concatenate l_str1 l_mask into l_mask separated by '.'.
            when others.
          endcase.
        when 'Y'.
          case l_lenth2.
            when 1 or 2 or 3.
              concatenate l_str1 l_str2 into l_mask separated by ','.
            when 4 or 5 or 6.
              concatenate l_str2 l_str2 into l_mask separated by space.
              concatenate l_str1 l_mask into l_mask separated by ','.
            when 7 or 8 or 9.
              concatenate l_str2 l_str2 l_str2 into l_mask separated by space.
              concatenate l_str1 l_mask into l_mask separated by ','.
            when 10 or 11 or 12.
              concatenate l_str2 l_str2 l_str2 l_str2 into l_mask separated by space.
              concatenate l_str1 l_mask into l_mask separated by ','.
            when others.
          endcase.
      endcase.
    
      write  l_reverse using edit mask l_mask to l_strout.
    
      if sy-subrc = 0.
        "reverse string
        call function 'STRING_REVERSE'
          exporting
            string  = l_strout
            lang    = sy-langu
          importing
            rstring = e_strout.
      endif.
    endfunction.
      DATA:l_wrbtr LIKE bdcdata-fval.       "BDC Amount
    
        l_wrbtr = <lfs_post>-kwert.
    
        CONDENSE l_wrbtr NO-GAPS.
    
        CALL FUNCTION 'ZGM_CONVER_CUUR'
          EXPORTING
            i_strin    = l_wrbtr
            i_decimals = 2"两位小数,也可三位  四位
          IMPORTING
            e_strout   = l_wrbtr.
  • 相关阅读:
    JPG bufffer转Mat
    cv:Mat MFC上显示 BitMatToWnd
    opencv 版本修改
    2个多边形的关系判断和相交面积计算
    截取图像 opencv
    SQL Server 存储过程的分页方案比拼
    XP系统下数据库文件夹的权限设置
    关于23种设计模式的有趣见解
    一些编程的好习惯
    sql server 2000的数据库还原
  • 原文地址:https://www.cnblogs.com/JackeyLove/p/13191062.html
Copyright © 2011-2022 走看看