关于 ABAP 的运行时错误 ITAB_ILLEGAL_ORDER
一个朋友在我的知识星球里提问:
Jerry 您好!请教一个问题,在生成物料凭证的时候,有个比较奇怪的问题,在函数MARD_MD_ARRAY_READ,第154行的时候会提示运行时错误:ITAB_ILLEGAL_ORDER,内表中的排序不正确;
跟着查看是在132行的时候读取v_mard_md的数据未排序,然后后面按照取出来的数据插入到内表MARD_TAB_MD之后,也是未排序的,然后在154行的时候就提示报错了。但是同样的数据有时候就能过,请问一下这种问题我应该怎么去入手进行解决.
以下是ST22的部分内容:
短文本
Incorrect sorting of the rows in an internal table.
发生了什么?
Error in the ABAP application program.
The current ABAP program "SAPLMG26" had to be terminated because it found a
statement that could not be executed.
错误分析
In the ABAP Debugger, the switch for monitoring the sorting of internal
tables before statements with the form "READ ... BINARY SEARCH" was
activated.
In this case, rows 5 and 6 in table "\FUNCTION=MARD_MD_ARRAY_READ\DATA=???"
are not sorted
according to the key specified for the READ statement.
The "READ ... BINARY SEARCH" statement works on the assumption that the
table is correctly sorted. An incorrect entry will normally be
localized.
我们逐一分析。
In the ABAP Debugger, the switch for monitoring the sorting of internal
tables before statements with the form “READ … BINARY SEARCH” was
activated.
在 ABAP 调试器里,有个菜单 Change Debugger Profile/ Settings
:
在 Specific Settings 选项区域,有个 Check Sorting Before BINARY SEARCH
:
如果勾上这个选项,在 ABAP 调试器里单步调试到 READ TABLE BINARY SEARCH 关键字时,如果 READ TABLE 操作的 内表,没有提前进行排序,比如不是一个 sorted table
,就会出现运行时异常 ITAB_ILLEGAL_ORDER.
但是同样的数据有时候就能过,请问一下这种问题我应该怎么去入手进行解决.
代码第 154 行的语义是:从有序表 MARD_TAB_MD 里采用二分查找的方式,检查 TMARD 指定的 key 对应的数据是否存在。如果不存在,将这个 key 对应的记录,通过 APPEND,添加到 MARD_TAB_MD 的尾部。注意第 154 行是在 DO 循环里执行的。如果当前 APPEND 操作执行后,破坏了 MARD_TAB_MD 里的有序状态,则 DO 下一次循环时,READ TABLE BINARY SEARCH 就会出错。
SAP ABAP 帮助文档里,对于使用 APPEND 添加记录到 sorted table 里的行为是这样描述的:
Lines are appended to sorted tables only if they match the sort order and do not create duplicate entries if the primary table key is unique.
仅当行与排序顺序匹配时,它们才会附加到已排序的表中,并且如果表的主键是唯一的话,则不会创建重复的条目。
也就是说,APPEND 后面指定的待插入的 TMARD 内容,插入到 MARD_TAB_MD 之后,必须保证整张表仍然有序。
相关文章
- 孙鑫XML视频教程中关于DOM例子的一点错误
- 关于【ExecuteReader: Connection 属性尚未初始化】的错误提示解决方案「建议收藏」
- 关于socket通信bind()返回值错误:10049
- 关于 SAP Spartacus SSR 请求 OCC API 遇到 403 错误的解决办法
- 【说站】python错误类型捕获的方法
- mysql workbench 1142,Mysql Workbench错误1142“错误查询安全信息”;关于数据导出「建议收藏」
- err 错误使用场景
- C#-GDI+中发生一般性错误的解决办法
- mysql 5.5.1 关于datetime的错误
- 【错误记录】Kotlin 1.5.0 编译报错 ( 1.5.0 中 Float 不能直接转 Byte 类型 )
- 【错误记录】Google Play 上架报错 ( 此版本不符合 Google Play 关于提供 64 位版本应用的要求。| 如果提供 x86 架构动态库则必须提供 x86_64 架构的动态库 )
- MySQL错误日志分析:解决故障的重要步骤(mysql错误日志分析)
- 解决Oracle 01407错误的绝招(oracle01407)
- MSSQL记录插入发生错误(插入mssql记录错误)
- 揭露Redis中的误解纠正错误的说法(关于redis说法错误)
- 谬误谬论关于Redis的错误理解(redis说法不正确的是)
- SQL"不能为新插入的行确定标识"错误的解决方法
- PHPsyntaxerror,unexpected$end错误的一种原因及解决
- phpsession_start()关于Cannotsendsessioncachelimiter-headersalreadysent错误解决方法
- mysql常见的错误提示问题处理小结