SAP WHILE VARY ABAP Statements



Get Example source ABAP code based on a different SAP table
  


• VARY FROM NEXT WHILE - obsolete
• RANGE WHILE - obsolete

WHILE, VARY
Short Reference

ABAP_SYNTAX_OBS
WHILE ... VARY dobj FROM dobj1 NEXT dobj2 $[RANGE range$]
$[VARY ...$].
$[statement_block$]
ENDWHILE.

What does it do?
The addition VARY and its addition RANGE have exactly the same effect on a WHILE loop as the other obsolete additions VARYING and RANGE of the statement DO. The addition VARY can be used more than once in a WHILE statement.



Latest notes:

The way the addition VARY works depends on the internal structure of the working memory, which itself can be affected by alignment gaps.
Instead of the addition VARY, the statement ASSIGN should be used in the loop with the addition INCREMENT.
ABAP_HINT_END



Runtime Exceptions


Non-catchable Exceptions
Reason for error:
Invalid access to tables, strings, field references, or object references within the range specified by the addition RANGE.
Runtime error:
DO_WHILE_VARY_ILLEGAL_ACCESS
Reason for error:
Access to data outside the range specified by the RANGE addition.
Runtime error:
DO_WHILE_VARY_NOT_IN_RANGE
ABAP_NONCAT_END

Return to menu