What does it do? These alternatives specify the lines to be changed using the specification of a line number relating to a table index.
ABAP Alternative 1 ... itab • idx>
ABAP Addition ... USING KEY keyname>
What does it do? Using the addition •>, 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 •> can only be used with index tables> and determines the line to be modified from its primary table index>. If a line specified using •> 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 •>, however, a runtime error occurs only if the value of the component changes.
Latest notes: The addition •> can also be positioned after FROM wa>. NON_V5_HINTS ABAP_HINT_END
ABAP_EXAMPLE_VX5 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>>. ABEXA 00424 ABAP_EXAMPLE_END • USING KEY MODIFY itab •
ABAP Addition
What does it do? 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.
Latest notes: If a sorted secondary key exists, the addition •> can be used for all table types if USING KEY> is used. NON_V5_HINTS ABAP_HINT_END
ABAP_EXAMPLE_VX5 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 >. ABEXA 00425 ABAP_EXAMPLE_END
ABAP Alternative 2 ... itab>
ABAP Addition ... USING KEY loop_key>
What does it do? 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.
Latest notes: The use of this alternative is not recommended. Instead, the addition •> should be used to specify the line number explicitly. NON_V5_HINTS ABAP_HINT_END
ABAP_EXAMPLE_VX5 The internal table contains the numbers 11 to 20 after the loop. Each existing number is raised by 10 in the loop. ABEXA 00426 ABAP_EXAMPLE_END
ABAP Addition
What does it do? 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.
ABAP_EXAMPLE_VX5 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. ABEXA 00427 ABAP_EXAMPLE_END