
The most important news for internal tables are the Table expressions that allow the same single line access as the READ TABLE statement. But soon after those were available, the question arised "What about the system fields?".
We all use the well known patterns
READ TABLE ... TRANSPORTING NO FIELDS.
IF sy-subrc = 0.
...
ENDIF.
READ TABLE ... TRANSPORTING NO FIELDS.
...
Since an expression should be free of side effects it especially should not influence any system field. So what about these patterns?
The answer comes in form of two new built-in functions.
A new predicate function that returns true if a line exists:
IF line_exists( itab[ ... ] ).
...
ENDIF.
Where itab[ ... ] is a table expression that works here like READ TABLE ... TRANSPORTING NO FIELDS.
(Note that we have already some other predicate functions in ABAP: matches and the contains-variants in the context of string processing).
A new table function that returns the number of the line in the index used (primary or secondary index):
DATA(idx)= line_index( itab[ ... ] ).
Where itab[ ... ] is a table expression that works here like READ TABLE ... TRANSPORTING NO FIELDS. If no line is found, the value 0 is returned. For Hash-Tables or hashed secondary keys, always the value -1 is returned.
(Note that this is the second table function in ABAP. The other one is lines).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
7 | |
4 | |
2 | |
2 | |
2 | |
2 | |
1 | |
1 | |
1 | |
1 |