SAP FOR COND



Get Example source ABAP code based on a different SAP table
  


• WHERE FOR
• USING KEY FOR
• TO FOR
• FROM FOR
• STEP FOR

FOR, cond

ABAP_SYNTAX
... $[USING KEY keyname$]
$[FROM idx1$] $[TO idx2$] $[STEP n$]
$[WHERE ( log_exp )$|(cond_syntax)$] ...

What does it do?
As with LOOP AT itab, the following is possible for each expression FOR ... IN itab and FOR GROUPS ... OF of a constructor expression:
USING KEY can be used to specify the table key with which the table is evaluated.
FROM and TO can be used as upper and lower limits to restrict the lines in the table index used.
STEP can be used to define the step size and loop order for processing the internal table.
WHERE can be used to specify static or dynamic conditions for column content.
The syntax and semantics are exactly the same as in LOOP AT itab, apart from the fact that a statically specified logical expression log_exp in the WHERE condition must always be placed in parentheses.
In the expression FOR ... IN GROUP group , only static WHERE conditions can be specified for cond.



Latest notes:

The local auxiliary variables of the expression visible in this position can be used for idx1, idx2, and in the logical expression of the WHERE condition.
The pseudo component table_line can be used in the logical expression of the WHERE condition.
NON_V5_HINTS
ABAP_HINT_END

ABAP_EXAMPLE_VX5
The example shows how the same result can be achieved with a WHERE condition in an iteration expression and the filter operator FILTER. The shorter filter expression is usually more suitable in this case.
ABEXA 01032
ABAP_EXAMPLE_END