Ansicht
Dokumentation

ABAPMODIFY_ITAB_INDEX - MODIFY ITAB INDEX

ABAPMODIFY_ITAB_INDEX - MODIFY ITAB INDEX

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

MODIFY itab, index

Short Reference



...   ${ itab INDEX idx $[USING KEY keyname$] $}
    $| ${ itab $[USING KEY loop_key$]$} ...


Alternatives:

1. ... itab INDEX idx $[USING KEY keyname$]

2. ... itab $[USING KEY loop_key$]

Effect

These alternatives specify the lines to be changed using the specification of a line number relating to a table index.

Alternative 1

... itab INDEX idx


Addition:

... USING KEY keyname

Effect

Using the addition INDEX, the statement MODIFY modifies the line in the line number specified in idx in a table index. idx is a numeric expression position with the operand type i. If idx contains the value 0 or less, an uncatchable exception is raised.

If the addition USING KEY is not used, the addition INDEX can only be used with index tables and determines the line to be modified from its primary table index.

If a line specified using INDEX is modified without the addition TRANSPORTING, all components of the line are transported. If it is known statically that write-protected secondary table keys would be overwritten by this, a syntax error occurs. If it can only be determined at runtime, the corresponding runtime error occurs.

If the components of a primary sorted table key are modified in a line specified using INDEX, however, a runtime error occurs only if the value of the component changes.

Note

The addition INDEX can also be positioned after FROM wa.

Example

Conversion of the local currency of an airline in the internal table scarr_tab by accessing the index. The addition TRANSPORTING ensures that only the component currcode is modified and only this component is filled in the structure constructed by the value operator VALUE.

Addition

... USING KEY keyname

Effect

The addition USING KEY can be used to specify a table key in keyname to specify the table index to be used explicitly.

If the table has a sorted secondary key, this can be specified in keyname. The line to be modified is then determined from its secondary table index. A secondary hash key cannot be specified.

If the primary table key is specified under its name primary_key, the table must be an index table, and the behavior is the same as if USING KEY were not specified.

Note

If a sorted secondary key exists, the addition INDEX can be used for all table types if USING KEY is used.

In this example, the letter "D" is replaced by "X" in the fourth line, since this line has the index value 1 in the sorted key skey.

Alternative 2

... itab


Addition:

... USING KEY loop_key

Effect

This variant is only possible within a LOOP across the same internal table. The current table line of the LOOP is modified implicitly. If the addition USING KEY is specified in LOOP, the addition USING KEY loop_key must be specified for this variant.

If the current lines were already deleted in the same loop pass, the behavior is undefined.

This variant is not allowed outside of LOOP statements. A syntax check warning occurs if it cannot be known statically whether the variant is specified in a loop.

Note

The use of this alternative is not recommended. Instead, the addition INDEX should be used to specify the line number explicitly.

The internal table contains the numbers 11 to 20 after the loop. Each existing number is raised by 10 in the loop.

Addition

... USING KEY loop_key

Effect

This addition is required if the table key used by the LOOP is specified explicitly in the statement LOOP. It states explicitly that the current table line of the LOOP is modified. No other key can be specified apart from the predefined name loop_key. If no explicit table key is specified for LOOP, the addition USING KEY loop_key is optional.

Example

In this example, the letters of the first column are replaced by the letters whose position in sy-abcde is given by the value sy-tabix. The table is processed in the order of the secondary index, which produces the same order with respect to this index in the first column as in the second column.






Vendor Master (General Section)   rdisp/max_wprun_time - Maximum work process run time  
This documentation is copyright by SAP AG.

Length: 7124 Date: 20240419 Time: 085821     sap01-206 ( 89 ms )