代码之家  ›  专栏  ›  技术社区  ›  Esti

在排序表的附加上进行ABAP短转储

  •  10
  • Esti  · 技术社区  · 16 年前

    为什么我的ABAP程序在将一行附加到已排序的表时会进行短转储?

    ST22节目 ITAB_ILLEGAL_SORT_ORDER

    data: sorted_tab type sorted table of ty_tab with non-unique key key,
          line       type ty_tab.
    
    line-key = 1. 
    append line to sorted_tab.  "works fine" 
    
    line-key = 2. 
    append line to sorted_tab.  "works fine" 
    
    line-key = 1. 
    append line to sorted_tab.  "<==== Short dump here" 
    
    1 回复  |  直到 7 年前
        1
  •  16
  •   Esti    16 年前

    附加排序表时,程序将进行短转储 排序顺序错误

    data: sorted_tab type sorted table of ty_tab with non-unique key key,
          line       type ty_tab.
    
    line-key = 1.
    append line to sorted_tab.  "works fine"
    
    line-key = 2.
    append line to sorted_tab.  "works fine"
    
    line-key = 1.
    append line to sorted_tab.  "<==== Short dump here"
    

    使用插入代替:

    data: sorted_tab type sorted table of ty_tab with non-unique key key,
          line       type ty_tab.
    
    line-key = 1.
    insert line into table sorted_tab.  "works fine"
    
    line-key = 2.
    insert line into table sorted_tab.  "works fine"    
    
    line-key = 1.
    insert line into table sorted_tab.  "works fine"
    

    注释 如果你有 独特的 因为你用同一把钥匙两次,所以你还是会得到一个短的转储。