ABAP Short Dump on append of a sorted table

31,121

The program short dumps when appending a sorted table in the wrong 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"

Use INSERT in stead:

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"

Note If you had a UNIQUE key you would still get a short dump because you're using the same key twice

Share:
31,121

Related videos on Youtube

user2568701
Author by

user2568701

SAP ABAP Developer

Updated on July 09, 2022

Comments

  • user2568701
    user2568701 almost 2 years

    Why does my ABAP program short dump when I append a line to a sorted table?

    ST22 Shows 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" 
    
    • Thorsten
      Thorsten over 14 years
      please include the declaration of your sorted table!

Related