‎2009 Sep 22 12:48 PM
Hi All,
We are going for upgrade from 4.6 to ECC 6.0. In 4.6 below code is written with Do statement,but gives syntex error like 'use range addition'.
SELECT SINGLE *
FROM ZCS_WARS
INTO ZCS_WARS
WHERE WERKS = XRLDRI-WERKS
AND LGNUM = XRLDRI-LGNUM.
DO 7 TIMES VARYING V_P_FIELD FROM ZCS_WARS-SDIR1 NEXT ZCS_WARS-SDIR2
VARYING V_H_FIELD FROM ZCS_WARS-SORT1 NEXT ZCS_WARS-SORT2
VARYING V_D_FIELD FROM V_DF00 NEXT V_DF01
VARYING V_A_FIELD FROM V_AF00 NEXT V_AF01.
*IS THE SORT FIELD IS ASCENDING OR DESCENDING
IF V_P_FIELD = C_CON_X.
V_D_FIELD = V_H_FIELD. "DESCENDING
ELSE.
V_A_FIELD = V_H_FIELD. "ASCENDING
ENDIF.
ENDDO.
Please let me know how to use range with do statement.
Thanks and Regards,
Mohit
‎2009 Sep 22 12:53 PM
See the std help for the issue:
Loops with the VARY or VARYING addition are also problematic in Unicode, since a type-a access to memory contents cannot be ensured and memory can be overwritten inadvertently.
DO ... VARYING f FROM f1 NEXT f2.
For this statement, the fields f, f1, and f2 must be type-compatible with each other. To prevent memory contents being overwritten, a RANGE for valid accesses is introduced implicitly or explicitly for the following statements:
DO ... TIMES VARYING f FROM f1 NEXT f2 [ RANGE f3 ].
WHILE ... VARY f FROM f1 NEXT f2 [ RANGE f3 ].
A syntax or runtime error is caused if f1 or f2 are not included in f3. If the RANGE addition is missing, it is defined implicitly from FROM f1 NEXT f2 as follows:
If both f1 and f2 are statically recognizable components of the same structure, the valid RANGE area is defined from the smallest structure that comprises f1 and f2.
A syntax error is triggered if it is recognizable statically that f1 and f2 are not part of the same structure.
A valid area must be defined explicitly using the RANGE addition if the connection between f1 and f2 is not recognizable statically.
If you specify a deep structure as the RANGE addition, the system checks for every loop pass that there are no field references, object references, tables, or strings in the area read.
‎2009 Sep 22 12:55 PM
the use of varying is now obsolete..
so why dont you do it with a LOOP-ENDLOOP?