• ABAP Help Document(25):11.4 Data Cluster


    11.4 Data Cluster

              数据集群,将一组数据存储在storage medium。

    1.EXPORT

    语法:

    EXPORT parameter_list TO medium [COMPRESSION {ON|OFF}].

    COMPRESSION是否压缩形式存储在内存;

    parameter_list:

    {p1 = dobj1 p2 = dobj2 ...} | {p1 FROM dobj1 p2 FROM dobj2 ...} | (ptab) ... .

    建议使用=号传递数据,ptab只有两列的参数表,第一列参数名(必须字符类型),第二列参数值对象;

    medium:

    { DATA BUFFER xstr }
    | { INTERNAL TABLE itab }
    | { MEMORY ID id }
    | { DATABASE  dbtab(ar) [FROM wa] [CLIENT cl] ID id }
    | { SHARED MEMORY dbtab(ar) [FROM wa] [CLIENT cl] ID id }
    | { SHARED BUFFER dbtab(ar) [FROM wa] [CLIENT cl] ID id } ... .

    id为字符型,最长60;

    2.IMPORT

    语法:

    IMPORT parameter_list FROM medium [conversion_options].

    parameter_list:

    {p1 = dobj1 p2 = dobj2 ...}  | {p1 TO dobj1  p2 TO dobj2 ...} | (ptab) ... .

    medium:

    { DATA BUFFER xstr }
      | { INTERNAL TABLE itab }
      | { MEMORY ID id }
      | { DATABASE  dbtab(ar) [TO wa] [CLIENT cl] ID id }
      | { SHARED MEMORY dbtab(ar) [TO wa] [CLIENT cl] ID id }
      | { SHARED BUFFER dbtab(ar) [TO wa] [CLIENT cl] ID id } ... .

    conversion_options:

    { { { {[ACCEPTING PADDING] [ACCEPTING TRUNCATION]}
            | [IGNORING STRUCTURE BOUNDARIES] }
            [IGNORING CONVERSION ERRORS [REPLACEMENT CHARACTER rc]] }
        | [IN CHAR-TO-HEX MODE] }
        [CODE PAGE INTO cp]
        [ENDIAN INTO endian].

    DATA BUFFER,INTERNAL TABLE,DATABASE支持所有options,

    其他仅支持一下options:[ACCEPTING PADDING] [ACCEPTING TRUNCATION]

    [IGNORING STRUCTURE BOUNDARIES]

    [ACCEPTING PADDING]:支持source,target转换结构不同,target结构更复杂;

    [ACCEPTING TRUNCATION]:支持source结构比target结构复杂;

    [IGNORING STRUCTURE BOUNDARIES]:支持INCLUDE结构,不能和上面options同时使用;

    [IN CHAR-TO-HEX MODE]:转换c到x;

    [CODE PAGE INTO cp]:表TCP00,字段CPCODEPAGE,cp值;

    [ENDIAN INTO endian]:大端小端,ABAP_ENDIAN类型,‘B’或‘L’

    3.IMPORT DIRECTORY

    语法:

    IMPORT DIRECTORY INTO itab FROM DATABASE dbtab(ar) [TO wa] [CLIENT cl] ID id.

    itab类型为CDIR,获取字段类型等信息;

    NAME

    CHAR(30)

    Name of the parameter under which a data object was saved.

    OTYPE:

    CHAR(1)

    "F" for elementary, flat data objects,

    "G" for strings,

    "R" for flat structures,

    "S" for deep structures,

    "T" for internal tables with flat row type

    "C" for tables with a deep row type.

    FTYPE

    CHAR(1)

     DESCRIBE FIELD ... TYPE ("a", "b", "C", "D", "e", "F", "g", "I", "N", "P", "s", "T", "X", "y"). v复杂结构,h内表

    TFILL

    INT4

    已保存数据对象长度

    FLENG

    INT2

    已保存数据对象长度或已保存表行长度

    4.FREE MEMORY

    语法:

    FREE MEMORY ID id.

    功能和DELETE FROM MEMORY ID id一致;

    5.DELETE FROM

    语法:

    DELETE FROM { {MEMORY ID id}
                | {DATABASE      dbtab(ar) [CLIENT cl] ID id}
                | {SHARED MEMORY dbtab(ar) [CLIENT cl] ID id}
                | {SHARED BUFFER dbtab(ar) [CLIENT cl] ID id} }.

    示例:

    "数据集群
    FORM f_data_cluster_exp.
      TYPES:BEGIN OF s_tab,
              name TYPE string,
              dobj TYPE string,
            END OF s_tab.
      DATA:lt_tab TYPE TABLE OF s_tab.
      DATA:ls_tab LIKE LINE OF lt_tab.
      DATA:lv_p1 TYPE string.
      DATA:test1 TYPE string VALUE 'hello'.
      ls_tab-name = 'P1'.
      ls_tab-dobj = 'test1'.
      APPEND ls_tab TO lt_tab.
    
      "存储到data buffer
      DATA:lv_xstr TYPE xstring.
      EXPORT (lt_tab) TO DATA BUFFER lv_xstr.
      WRITE:/ lv_xstr.
    
      "存储到internal table
      TYPES:BEGIN OF s_itab,
            col1 TYPE i,
            col2 TYPE x,
            END OF s_itab.
      DATA:lt_itab TYPE TABLE OF s_itab.
      EXPORT p2 = test1 TO INTERNAL TABLE lt_itab.
    
      "存储到memory id
      EXPORT (lt_tab) TO MEMORY ID 'M_ID'.
      "读取
      IMPORT p1 = lv_p1 FROM MEMORY ID 'M_ID'.
      WRITE:/ lv_p1.
    
      "存储到database
      "ar双字符,RELID值;
      "demo_indx_table表必须有RELID,SRTF2字段
      DATA:lt_spfli TYPE TABLE OF spfli.
      DATA:ls_spfli LIKE LINE OF lt_spfli.
      DATA:wa_indx TYPE demo_indx_table.
      SELECT * FROM spfli INTO TABLE lt_spfli.
      EXPORT tab = lt_spfli
      TO DATABASE demo_indx_table(SQ)
      FROM wa_indx
      ID 'TAB'.
      "读取
      IMPORT tab = lt_spfli
      FROM DATABASE demo_indx_table(SQ)
      TO wa_indx
      ID 'TAB'.
      LOOP AT lt_spfli INTO ls_spfli.
        WRITE:/ ls_spfli-carrid.
      ENDLOOP.
    
      "存储到shared memory,burrfer
      "rsdb/esm/buffersize_kb (SHARED MEMORY)
      "rsdb/obj/buffersize (SHARED BUFFER)
      "memory达到最大size,需要使用DELETE FROM SHARED MEMORY
      EXPORT tab = lt_spfli
      TO SHARED MEMORY demo_indx_table(SQ)
      FROM wa_indx
      ID 'TAB_MOMO'.
      "buffer会自动清空,达到最大size
      EXPORT tab = lt_spfli
      TO SHARED BUFFER demo_indx_table(SQ)
      FROM wa_indx
      ID 'TAB_BUFFER'.
    
      "删除
      DELETE FROM MEMORY ID 'M_ID'.
      DELETE FROM DATABASE demo_indx_table(SQ) ID 'TAB'.
      DELETE FROM SHARED MEMORY demo_indx_table(SQ) ID 'TAB_MOMO'.
      DELETE FROM SHARED BUFFER demo_indx_table(SQ) ID 'TAB_BUFFER'.
    ENDFORM

    6.System Class for Data Cluster

    CL_ABAP_EXPIMP_MEM

    CL_ABAP_EXPIMP_SHMEM

    CL_ABAP_EXPIMP_SHBUF

    CL_ABAP_EXPIMP_DB

    CL_ABAP_EXPIMP_CONV

  • 相关阅读:
    Mac Python相关配置操作汇总
    暑假算法练习Day2
    暑假算法练习Day1
    《Min_25筛》
    《Yuchang and Zixiang’s stones》
    《Codeforces Round #732 (Div. 1)》
    《P7842 「PMOI-4」可怜的团主》
    《Codeforces Round #739 (Div. 3)》
    《斜率dp》
    《凸包》
  • 原文地址:https://www.cnblogs.com/tangToms/p/14696762.html
Copyright © 2020-2023  润新知