首页 文章

在将记录插入内部表时抑制不可压制的警告

提问于
浏览
1

我正在循环内的已排序内部表中添加一个新条目 . 由于循环I 'm in has a sort order that'与排序表的循环不同,我必须使用 INSERT INTO 语句而不是 APPEND TO ,因为后者有可能违反导致转储的排序顺序 .

但是,当我添加该代码时,我会在内部消息代码“ MESSAGE GJK ”中收到语法检查警告,在EPC中它说:

Program: ZCL_CLASS Method METHOD_NAME Row: 301
Syntax check warning.

In the table "LT_TABLE_NAME" a row was to be changed, 
deleted or inserted. It is not possible
to determine statically if a LOOP is active over "LT_TABLE_NAME"

Internal message code: MESSAGE GJK
Cannot be hidden using a pragma.

但是“不能使用pragma隐藏”只是没有't work for me. I understand the reason for the warning but I know at build time with 100% certainty that no loop will be active on the internal table that I' m插入新记录 . 但我不能隐瞒这个警告 . 除了在开发过程中导致无用的警告之外,在某些环境中,我无法传输带有语法检查警告的代码!

Is there any way to suppress this insuppresible warning?

Failing that, is there any way to avoid it? 我可以通过使用临时未排序的表作为中间件然后将行附加到排序表中来实现,但我不愿意创建一个无用的(百万行)内部表,只是为了绕过似乎是一个明显的疏忽 .

2 回答

  • 2

    这个消息不能被压制,因为它已经被陈述in your previous question . 但是,我们可以摆脱问题的最初原因,这是在这里做的唯一正确的方法 . 此错误报告内部表上的某些操作是使用隐式索引规范执行的,如详细消息中所述:

    在程序流程中,使用当前的LOOP行,这意味着使用INDEX sy-tabix . 如果此时表上没有LOOP处于活动状态,则会发生运行时错误TABLE_ILLEGAL_STATEMENT . 对于这种隐式操作的当前情况,可以静态地找到该表的包含LOOP语句(使用语法检查) .

    由于某种原因,编译器没有看到你的循环,因此无法找到循环索引 . 在这种情况下可以做些什么:

    • 使用 INSERT wa INTO TABLE 而不是 INSERT 的缩写形式 .

    • 为您 INSERT 语句使用显式索引

    INSERT wa INTO itab INDEX loopIdx.
    

    ABAP documentation for INSERT wa INTO itab 语法变体确认此语法需要LOOP:

    此变量仅在同一个表中的LOOP内可用,并且如果未在LOOP中指定添加USING KEY . 要插入的每一行都可以在LOOP中的当前行之前插入 .

    附:可以使用 DOCU_CALL FM传递消息代码 TRMSG_MESSAGE_GJK 来获取此消息的全文 . 所有消息代码都存储在 DOKIL 表中 .

  • 2

    获得此警告的最可能原因实际上是语法错误!只要您收到如下声明,就会发生这种情况:

    INSERT [work area] INTO [internal table].
    

    插入itab的实际语法需要 INTO TABLE

    INSERT [work area] INTO TABLE [internal table].
    

    警告's description doesn'似乎与这里实际发生的情况相符 . 据推测,'s considering that the table might have a header area (which is not the case). If you run this code, you'将获得带有更具描述性的错误消息的 TABLE_ILLEGAL_STATEMENT 转储:

    尝试在内部表“[internal table]”中更改,删除或添加行 . 但是,该表没有有效的游标 .

    这实际上是我第二次发生这样一个令人困惑的消息,当我发布这个消息时我没有打算自我回答,但是当我得到转储时我意识到了我的错误 . 我'm guessing the main problem is relying on syntax errors to tell me when I' m使用了不正确的语法:语法检查显然不认为这是一个彻头彻尾的错误,即使它可能应该 .

相关问题