Skip to Content
0
Former Member
Jun 04, 2015 at 07:38 AM

VALUE with LET - is this a bug?

47 Views

Hi,

when trying the following two blocks, they provide different output, while they should not. Only the block #2 provides an expected output. Any idea why block #1 does not work? I am curious why the offset1 is calculated incorrectly (and why is it calculated incorrectly ONLY in 2nd iteration???)...

TYPES:

BEGIN OF struc,

col1 TYPE c,

col2 TYPE i,

END OF struc.

* block #1

DO 3 TIMES.

DATA(struc) = VALUE struc(

LET offset1 = sy-index - 1

IN col1 = sy-abcde+offset1(1)

col2 = sy-index ).

WRITE:/ struc-col1, struc-col2.

ENDDO.

SKIP.

* block #2

DO 3 TIMES.

DATA(offset2) = sy-index - 1.

struc = VALUE struc(

col1 = sy-abcde+offset2(1)

col2 = sy-index ).

WRITE:/ struc-col1, struc-col2.

ENDDO.


Output:

A 1

A 2 "2nd loop: offset1 was not increased, resulting in A instead of B

B 3 "3rd loop: offset1 was increased as expected


A 1

B 2

C 3

Am I missing something?

Thanks, Michal