zoukankan      html  css  js  c++  java
  • ABAP的一些常用函数用法

    1、ABS 绝对值

    2、ROUD:

      除了调用函数外,还有另一个用法:

      round( val = arg {dec = n}|{prec = n} [mode = m] )

    3、SUBSTRING:

       SUBSTRING( VAL = GS_STRING OFF = GI_FLAG - 1  LEN = 1 ) 

      1.  substring(  val = text [off = off] [len = len] ) ...

      2.  substring_from( val = text {sub = substring}|{regex = regex} 
                          [case = case ] [occ = occ] [len = len]  ) ...

      3.  substring_after( val = text {sub = substring}|{regex = regex} 
                           [case = case ] [occ = occ] [len = len]  ) ...

      4.  substring_before( val = text {sub = substring}|{regex = regex} 
                            [case = case ] [occ = occ] [len = len]  ) ...

      5.  substring_to( val = text {sub = substring}|{regex = regex} 
                            [case = case ] [occ = occ] [len = len]) ...

    Example

      The return codes of the following function calls are: "CD", "CDEFGH"., "EFGH"., "AB"., and "ABCD".

      DATA  result TYPE string. 

      result = substring( val = 'ABCDEFGH' off = 2 len = 2 ). 

      result = substring_from( val = 'ABCDEFGH' sub = 'CD' ). 

      result = substring_after( val = 'ABCDEFGH' sub = 'CD' ). 

      result = substring_before( val = 'ABCDEFGH' sub = 'CD' ). 

      result = substring_to( val = 'ABCDEFGH' sub = 'CD' ). 

    ROUND  详细说明:

    Effect

    This function rounds a decimal floating point number declared as an argument for the parameter val. A data object specified for arg is converted to the data type decfloat34 before the function is executed, if necessary.

    • If the parameter dec is given a value, the value entered is rounded to the number of decimal places specified in n and returned. Data objects of type i is expected for n. The value of these data objects cannot be less than -6144. If a negative value is given, the relevant whole number place is rounded.

    • If the parameter prec is given a value, the value entered is rounded to the  specified in n and returned. Data objects of type i are expected for n. The value of these data objects must be greater than 0.

    A rounding can reduce  and  but cannot increase them. If dec is specified, the mantissa of the return code does not contain any zeros after the position where the rounding applies. If prec is specified, the input value is returned without being changed, if the specified precision is greater than or equal to the input value.

    You can use the mode parameter (optional) to set the rounding type. For m it is only possible to specify values that exist as ROUND_... constants in class . The following table shows the possible rounding rules. If mode is not given a value, commercial rounding is used.

    SUBSTRING 的详细使用说明:

    In the argument , the substring functions determine a substring and return it.

    The substring is determined as follows:

    • The function substring uses the offset  and the length  to return a certain subrange. At least one of the two arguments off or len must be specified.

    • The function substring_from scans text for the match (specified in ) with the character string specified in  or with the  specified in  and returns the subrange of the length  from the offset of the found location. If len is not specified, the substring is returned to the end of the character string. If substring is empty, an exception from the class CX_SY_STRG_PAR_VAL is raised. The search is case-sensitive by default, but you can override this with the parameter case. If no substring is found, the return code is empty.

    • The function substring_after works in the same way as substring_from, but the subrange plus the length of the substring found is returned, from the offset of the found location.

    • The function substring_before works in the same way as substring_from, but the subrange of the length  is returned, before the offset of the found location. If len is not specified, the subrange is formed from the start of the character string.

    • The function substring_to works in the same way as substring_before, but the subrange before the offset of the found location plus the length of the substring found is returned.

    The return code has the type string accordingly.

    Note

    The performance of the substring functions is not as good as a direct . They do, however, allow you to use  in all operand positions. 

    路漫漫其修遠兮,唔將上下而求索!
  • 相关阅读:
    根据输入参数,判定时间范围CheckTimeSpan
    C#登出系统并清除Cookie
    MySQL中使用group_concat遇到的坑
    MySQL中group by 与 order by 一起使用排序问题
    使用VMware安装CentOS 7
    VMware安装Linux提示此主机支持 Intel VT-x,但 Intel VT-x 处于禁用状态
    Yii2处理密码加密及验证
    Yii2 的安装及简单使用
    git merge的使用
    PHP中上传文件打印错误,错误类型
  • 原文地址:https://www.cnblogs.com/yanglikun/p/4078701.html
Copyright © 2011-2022 走看看