Why does nested LOOP AT SCREEN cause infinite loop/recursion?

情到浓时终转凉″ 提交于 2019-12-23 09:56:40

问题


Here is one for you. Although such a language construction does not make much sense I would like to know why the nested LOOP AT SCREEN cause infinite loop (recursion?).

Let us take the following simple program.

REPORT yyy.

PARAMETERS:
  p_x1 TYPE abap_bool.

AT SELECTION-SCREEN OUTPUT.
  LOOP AT SCREEN.
    BREAK-POINT.
  ENDLOOP.

The BREAK-POINT statement will be executed only 4 times. This leads to an assumption that such a nested loop would run 16 times. Instead the below mentioned program runs forever and ends with a timeout exception.

REPORT yyy.

PARAMETERS:
  p_x1 TYPE abap_bool.

AT SELECTION-SCREEN OUTPUT.
  LOOP AT SCREEN.
    LOOP AT SCREEN.
      ASSERT 1 = 1.
    ENDLOOP.
  ENDLOOP.

It looks like nesting LOOP AT SCREEN causes either an infinite loop or some kind of an infinite recursion.

Why is it so? Is it documented somewhere? The extended check does not report anything regarding the loop. The same applies to Code Inspector as well.

EDIT

I have also checked whether this is a general problem for internal tables with a header line. It seems not.

REPORT YYY.

DATA: gt_t000 TYPE t000 OCCURS 10 WITH HEADER LINE.

START-OF-SELECTION.
  SELECT * FROM t000
    INTO TABLE gt_t000[].

  LOOP AT gt_t000.
    LOOP AT gt_t000.
      WRITE / gt_t000-mandt.
    ENDLOOP.
  ENDLOOP.

来源:https://stackoverflow.com/questions/56748140/why-does-nested-loop-at-screen-cause-infinite-loop-recursion

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!