EMBEDDED

作者: abapCiCi | 来源:发表于2019-09-25 08:34 被阅读0次

    via embedded expressions.

    |{}|--------- || 中间写文字 {}中间放变量

    ... [WIDTH     = len] 
    [ALIGN     = LEFT|RIGHT|CENTER|(dobj)|expr] 
    [PAD       = c] 
    [CASE      = RAW|UPPER|LOWER|(dobj)|expr] 
    [SIGN      = LEFT|LEFTPLUS|LEFTSPACE|RIGHT|RIGHTPLUS|RIGHTSPACE|(dobj)|expr] 
    [EXPONENT  = exp] 
    [DECIMALS  = dec] 
    [ZERO      = YES|NO|(dobj)|expr] 
    [XSD       = YES|NO|(dobj)|expr] 
    [STYLE     =  SIMPLE|SIGN_AS_POSTFIX|SCALE_PRESERVING 
                 |SCIENTIFIC|SCIENTIFIC_WITH_LEADING_ZERO 
                 |SCALE_PRESERVING_SCIENTIFIC|ENGINEERING 
                 |(dobj)|expr] 
    [CURRENCY  = cur] 
    [NUMBER    = RAW|USER|ENVIRONMENT|(dobj)|expr] 
    [ALPHA     = IN|OUT|RAW|(dobj)|expr] 
    [DATE      = RAW|ISO|USER|ENVIRONMENT|(dobj)|expr] 
    [TIME      = RAW|ISO|USER|ENVIRONMENT|(dobj)|expr] 
    [TIMESTAMP = SPACE|ISO|USER|ENVIRONMENT|(dobj)|expr] 
    [TIMEZONE  = tz] 
    [COUNTRY   = cty] ... 
    

    width align

    DATA(text) =
      |{ 1 WIDTH = 1 ALIGN = LEFT  "  
      }{ 2 WIDTH = 2 ALIGN = RIGHT
      }{ 3 WIDTH = 5 ALIGN = RIGHT }<-|.
    

    width 是指宽度 align 是值的位置

    上面的结果是 1___2_____5 分别是3个空格和5个空格

    case

    "case 控制大小写 下面的是编码
    DATA(text) = 
      |{ cl_abap_codepage=>convert_to( 'Hello World!' ) CASE = LOWER }| . 
    
    "编码
    xstr = cl_abap_codepage=>convert_to(
      source      = '江正军'
      codepage    = `UTF-8` ).
    "解码
    str = cl_abap_codepage=>CONVERT_FROM(
      source      =  xstr
      codepage    = `UTF-8` ).
    

    pad

    此格式选项定义用于填充结果中任何剩余位置的字符。 仅在使用WIDTH定义大于最小所需长度的长度时才应用它。
    DATA(text) = |{ 'X' ALIGN = RIGHT WIDTH = 10 PAD = '_' }|. 
    result is  _________X
    

    DECIMALS = dec

    DATA(text) = |{ 
    - 2 / 3   DECIMALS = 3 },               { 
    CONV decfloat34( - 2 / 3 ) DECIMALS = 3 }, { 
    CONV          f( - 2 / 3 ) DECIMALS = 3 }|.
    
    " result  is  -1.000, -0.667, -0.667 
    

    alpha 去前缀零 或者添加零

    alpha = in 是添加零

    alpha = out 是去前缀零

    相关文章

      网友评论

          本文标题:EMBEDDED

          本文链接:https://www.haomeiwen.com/subject/wevnectx.html