• 2019.11.10【每天学点SAP小知识】Day3


    1.语法为 CONV dTYPE|#(...)

    # 代表任意类型

    "7.40之前表达式 
    DATA text   TYPE c LENGTH 255.
    DATA helper TYPE string.
    DATA xstr   TYPE xstring.
    helper = text.
    xstr = cl_abap_codepage=>convert_to( source = helper ).
    "7.40之后

    DATA text TYPE c LENGTH 255.
    text 'zhujx'.
    DATA(xstr1= cl_abap_codepage=>convert_to( source = CONV stringtext ).
    *OR
    DATA(xstr2= cl_abap_codepage=>convert_to( source = CONV #text ).
    "转化为16进制

    2.新语法:操作值

    "操作值
    *   Variables:    VALUE dtype|#( )
    *
    *   Structures:  VALUE dtype|#( comp1 = a1 comp2 = a2 … )
    *
    *   Tables:         VALUE dtype|#( ( … ) ( … ) … ) …
    
    TYPES:BEGIN OF ty_mara,
            matnr TYPE mara-matnr,
            matkl TYPE mara-matkl,
          END OF ty_mara.
    
    TYPES:BEGIN OF ty_makt,
            maktx TYPE makt-maktx,
            mara1 TYPE ty_mara,
          END OF ty_makt.
    
    "1 给变量赋值
    DATA(lv_matnr) = 'AT001'.
    "2 给结构赋值
    DATA(ls_makt1) = VALUE ty_makt( maktx = 'TEST MATERIAL'
                               mara1-matnr = lv_matnr
                               mara1-matkl = 'Z001').
    "3 给内表赋值
    "(1)标准的内表
    TYPES: ty_t_makt TYPE STANDARD TABLE OF ty_makt WITH EMPTY KEY.
    
    DATA(lt_makt) = VALUE ty_t_makt(
    ( maktx = 'MATERIAL 1' mara1-matnr = 'AT001' mara1-matkl = 'Z001')
    ( maktx = 'MATERIAL 2' mara1-matnr = 'AT002' mara1-matkl = 'Z001')
    ( maktx = 'MATERIAL 3' mara1-matnr = 'AT003' mara1-matkl = 'Z001')

    结果为:

    -TAB 热爱技术 享受生活

  • 相关阅读:
    Qt自定义一个事件类型
    Qt正则表达式限制输入
    QtQuick随笔
    右值引用示例
    虚函数习题复习
    实现基于IOCP的回声服务器端
    以纯重叠I/O方式实现回声服务器端(windows)
    使用事件对象(重叠I/O)
    pipe mmap
    ubuntu下压缩和解压缩的命令用法
  • 原文地址:https://www.cnblogs.com/jxzhu/p/11830807.html
Copyright © 2020-2023  润新知