Documentation View

We are hiring and constantly growing! Have a look through our vacancies to find the right role for you!

ABAPMODIFY_ITAB - MODIFY ITAB

ABAPMODIFY_ITAB - MODIFY ITAB

PERFORM Short Reference   BAL_S_LOG - Application Log: Log header data  
This documentation is copyright by SAP AG.
SAP E-Book

MODIFY itab

Short Reference



MODIFY ${ itab_line $| itab_lines $}.

Effect

This statement changes the content either of a single line itab_line or multiple lines itab_lines, which can be specified using a table key or a table index.

The following restrictions apply with respect to modifications to key fields of the primary and secondary table keys:

  • The key fields of the primary table key of sorted tables and hashed tables are read-only and must not be modified. This would lead to the invalidation of the internal table administration and attempts to do so usually result in untreatable exceptions.

  • In contrast, the key fields of a secondary table key are only read-only when the secondary table key is in use. This is the case in LOOP loops and during the use of the MODIFY statement, in which the secondary key is specified after USING KEY. Otherwise the key fields are not read-only.

The administration of unique secondary keys is updated after the modification of individual rows during the next access to the internal table (delayed update). The administration of non-unique secondary keys is updated during the next explicit use of the secondary key (lazy update). The check of the uniqueness of a secondary key does not take place until the time of the update. It is therefore possible for an internal table to be in an inconsistent state in relation to the secondary key after the modification of individual rows but an exception will not be raised until the next use of the table. If the next use is not directly after the modification, the secondary key can be explicitly updated using methods of the CL_ABAP_ITAB_UTILITIES class to treat possible exceptions on the spot.

The administration of unique secondary keys is updated directly after a modification using MODIFY, and raises a uncatchable exception if duplicate entries would otherwise be produced. The non-unique secondary keys are updated when the secondary table key is next used explicitly (lazy update).

System Fields

sy-subrc Meaning
0 At least one line was changed.
4 No lines were changed, since no suitable line was found in the search using a table key or in the logical expression, or the specified index was greater than the current number of lines for the search using a table index.

The system field sy-tabix is not set.

Notes

  • Apart from using the MODIFY statement, the content of an individual table line can be changed using assignments to field symbols and dereferenced data references that point to the table line.

  • There is no implicit selection of a suitable key or index. The used table key or table index is always specified uniquely. The syntax check issues a warning if there is a suitable secondary table key but this table key is not used. This warning should be removed through using the key. However, in exceptional cases, it can be bypassed using a pragma.

Example

Modification of a line in an internal table using a key access. A line with a specific key value is read to a work area wa and a structure with a different value is then constructed in a non-key component after the addition FROM of the statement MODIFY. The table line with the appropriate key value is then modified.

Exceptions

Catchable Exceptions

CX_SY_ITAB_DYN_LOOP

  • Cause: Error in a dynamic WHERE condition
    Runtime Error: DYN_WHERE_PARSE_ERROR

Non-Catchable Exceptions

  • Cause: Invalid dynamic specification of a line component
    Runtime Error: ITAB_ILLEGAL_COMPONENT
  • A read-only secondary table key would be overwritten
    Runtime Error: ITAB_ACTIVE_KEY_VIOLATION
  • Cause: Memory area violated when TABLES parameter accessed
    Runtime Error: ITAB_STRUC_ACCESS_VIOLATION






General Material Data   BAL Application Log Documentation  
This documentation is copyright by SAP AG.

Length: 7179 Date: 20230206 Time: 100249     sap01-206 ( 103 ms )