zoukankan      html  css  js  c++  java
  • BW转换例程中去掉非法字符

    * result value of the routine
       RESULT = COMM_STRUCTURE-txtmd.
      CALL FUNCTION 'Z_ZH_REMOVE_INVLID_CHARARCTER'
        CHANGING
          c_string = RESULT.
    * if abort is not equal zero, the update process will be canceled


    .....
    FUNCTION z_zh_remove_invlid_chararcter.
    *"----------------------------------------------------------------------
    *"*"Local Interface:
    *"  CHANGING
    *"     REFERENCE(C_STRING) TYPE  ANY
    *"----------------------------------------------------------------------

      DATA: l_count TYPE i,
           l_oldpos TYPE i,
           l_str(40) TYPE c,
           l_strlen TYPE i,
           l_maxcount TYPE i.

      FIELD-SYMBOLS: <fs> TYPE x.

      l_count = 0.
      l_str = c_string.
      l_strlen = STRLEN( l_str ).
      l_maxcount = l_strlen - 1.

      DO.
        IF ( l_count > l_maxcount ).
          EXIT.
        ENDIF.

        ASSIGN l_str+l_count(1) TO <fs> CASTING TYPE x.
        IF <fs> <= 127.
          l_count = l_count + 1.  "go to the next
        ELSE.                     "Chinese character
          l_count = l_count + 1.
          IF l_count > l_maxcount.
            "Wrong
            l_oldpos = l_count - 1.
            l_str+l_oldpos(1) = space.
          ELSE.
            ASSIGN l_str+l_count(1) TO <fs> CASTING TYPE x.
            IF <fs> <= 127.
              "  Wrong.
              l_oldpos = l_count - 1.
              l_str+l_oldpos(1) = space.
            ELSE.                      "Correct
              l_count = l_count + 1.   "go to the next
            ENDIF.
          ENDIF.
        ENDIF.
      ENDDO.

      c_string = l_str.
    *  BREAK-POINT.


    ENDFUNCTION.


    以下为网上的例程。

      l_strlen = STRLEN( c_text ).

      DO l_strlen TIMES.
        IF c_text+l_offset(1) < ' '.
          c_text+l_offset(1) = ' '.
        ENDIF.

        ADD 1 TO l_offset.
      ENDDO.

  • 相关阅读:
    免费公共dns推荐
    vm10 mac 序列号
    sublimetext 序列号
    操作系统第6次实验报告:使用信号量解决进程互斥访问
    操作系统第5次实验报告:内存管理
    操作系统第4次实验报告:文件系统
    操作系统第3次实验报告:管道
    操作系统第2次实验报告:创建进程
    OS第1次实验报告:熟悉使用Linux命令和剖析ps命令
    第四次实验报告:使用Packet Tracer理解RIP路由协议
  • 原文地址:https://www.cnblogs.com/Beewolf/p/1436194.html
Copyright © 2011-2022 走看看