附加排序表时的 ABAP 短转储

标签 abap

为什么我的 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/

相关文章:

abap - 在 ABAP 中格式化时间,删除秒

abap - 为什么ABAP将字符串截成一个字符?

odata - 如何实现 ABAP OData 服务为公共(public)服务?

reflection - 如何发现abap开发对象的属性?

abap - FOR ALL ENTRIES 通过空 itab 从数据库中选择所有记录

abap - 将对象实例传递给 RFC 功能模块

parallel-processing - 开始新任务的并行处理 - 前端屏幕超时

db2 - 为什么 `FOR ALL ENTRIES` 会降低 DB6 上 CDS View 的性能?

abap - 单击按钮调用屏幕?

abap - 如何使用 WHERE 条件中的关联值从 ABAP SQL 消费 CDS?