为什么我的 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"
最佳答案
以错误的排序顺序附加已排序的表时,程序会进行短转储
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"
使用 INSERT 代替:
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"
注意如果你有一个 UNIQUE 键,你仍然会得到一个简短的转储,因为你使用了两次相同的键
关于附加排序表时的 ABAP 短转储,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1518465/