Error: Could not specify the access range automatically. This means that you need a RANGE addition.

Cause: Loops with “VARY” or “VARYING” can cause problems in Unicode environ-ment because, on the one hand, you cannot be sure that you are accessing memory con-tents with the correct type and on the other hand, memory could be inadvertently over-written.

DO … VARYING f FROM f1 NEXT f2 [RANGE f3].
WHILE … VARY f FROM f1 NEXT f2 [RANGE f3].

With these statements, the fields f, f1 and f2 must be type-compatible with one another.

To avoid overwriting memory contents, a RANGE for valid accesses is implicitly or ex-plicitly implemented for these statements.

Solution:

If the RANGE f3 addition is specified, a syntax or runtime error is triggered, should f1 or f2 not be included in f3. For f3, only structures and elementary fields of the types C, N, or X are permitted.

If the RANGE addition is not specified, it is implicitly defined with FROM f1 NEXT f2 as follows:

• If the syntax check recognizes that both f1 and f2 are components of the same structure, the valid RANGE area is defined from the smallest structure containing f1 and f2.
• There is a syntax error if the syntax check recognizes that f1 and f2 are not part of the same structure.
• A valid range must be defined explicitly using RANGE if the syntax check does no recognize that f1 and f2are not together.

If a deep structure is defined as a RANGE addition, the system checks for every loop pass that there are no field references, object references, tables, or strings within the ac-cessed range.

Example:

* DO 10 TIMES VARYING B FROM A+9(1) NEXT A+8(1).
DO 10 TIMES VARYING B FROM A+9(1) NEXT A+8(1) RANGE A+0(1).

Alternative method :

PARAMETERS: P$_TXT01 LIKE SOLISTI1-LINE MODIF ID GRI, “objtxt.
P$_TXT02 LIKE SOLISTI1-LINE MODIF ID GRI.
DATA: W$_TXT00 LIKE SOLISTI1-LINE. “replaces parameter

* DO 3 TIMES VARYING W$_TXT00 FROM P$_TXT01 NEXT P$_TXT02.

** Begin of Changes – 46C To ECC6 – IN9AGARWAL
DATA: BEGIN OF WA_SOLISTI1,
P$_TXT03 TYPE SOLISTI1-LINE,
P$_TXT04 TYPE SOLISTI1-LINE,
END OF WA_SOLISTI1.

WA_SOLISTI1-P$_TXT03 = P$_TXT01.
WA_SOLISTI1-P$_TXT04 = P$_TXT02.

DO 3 TIMES VARYING W$_TXT00 FROM WA_SOLISTI1-P$_TXT03 NEXT WA_SOLISTI1-P$_TXT04 range WA_SOLISTI1.

Leave a comment