... {TABLE itab}|{itab INDEX idx} FROM wa
[TRANSPORTING comp1 comp2 ...] [result].
1. ... TABLE itab
2. ... itab INDEX idx
3. ... TRANSPORTING comp1 comp2 ...
With these additions, the MODIFY statement assigns a line specified by itab_line to the content of the wa work area. The line can be specified using the table key or the table index. For the variant with the TABLE addition, the line is specified using the table key. For the variant with the INDEX addition, it is specified using the table index. The latter is only possible for index tables.
TRANSPORTING can be used to restrict the comp components to be modified. result can be used when you change an individual line after Release 6.10 to set a reference in the form of a field symbol or a data reference to the changed line.
In the case of access using the table key, index access to
sorted tables and when the TRANSPORTING addition is used, the wa work area must be
compatible with the line type of the internal table. Only in the case of insertion using the table index in
standard tables without the
TRANSPORTING addition can wa be incompatible with the line type of the internal table, and is converted to the line type according to the
conversion rules.
Apart from classes, the FROM wa specification can be left out if the internal table has an itab
header line with the same name. The statement then uses the header line as a work area implicitly.
... TABLE itab
The line to be changed is determined by the fact that the content of the table key matches the content
of the corresponding components in the wa work area. For tables with a key that is not unique, the first entry that is found is changed.
Conversion of the local currency of an airline to Euro using key access in the scarr_tab internal table.
PARAMETERS p_carrid TYPE scarr-carrid.
DATA scarr_tab TYPE SORTED TABLE OF scarr
WITH UNIQUE KEY carrid.
DATA scarr_wa TYPE scarr.
SELECT *
FROM scarr
INTO TABLE scarr_tab.
READ TABLE scarr_tab INTO scarr_wa
WITH TABLE KEY carrid = p_carrid.
scarr_wa-currcode = 'EUR'.
MODIFY TABLE scarr_tab FROM scarr_wa
TRANSPORTING currcode.
... itab INDEX idx
This variant is only possible for standard tables and sorted tables. the line to be changed is specified by its idx table index. For idx, a data object of type i is expected.
The following cases result in an untreatable exception:
Within a LOOP loop,
the INDEX addition can be ommitted. In this case the current
table line of the LOOP loop is changed. If the current line in the same loop pass was deleted, however, the behavior is undefined.
The INDEX addition can also be after FROM wa.
Conversion of the local currency of an airline to Euro in the scarr_tab internal table using index access.
PARAMETERS p_carrid TYPE scarr-carrid.
DATA scarr_tab TYPE SORTED TABLE OF scarr
WITH UNIQUE KEY carrid.
DATA: idx TYPE sy-tabix,
scarr_wa TYPE scarr.
SELECT *
FROM scarr
INTO TABLE scarr_tab.
READ TABLE scarr_tab
WITH TABLE KEY carrid = p_carrid
TRANSPORTING NO FIELDS.
idx = sy-tabix.
scarr_wa-currcode = 'EUR'.
MODIFY scarr_tab INDEX idx FROM scarr_wa
TRANSPORTING currcode.
... TRANSPORTING comp1 comp2 ...
The TRANSPORTING addition has the effect that only the specified comp1 comp2 ... components of the work area are assigned to the corresponding components of the line(s) to be changed. For sorted tables and hashed tables, no table key components may be specified after TRANSPORTING.
The comp1 comp2 ... component specifications are made in accordance with the rules specified in
Component specification, with the constraint that after
TRANSPORTING, no attributes of classes can be addressed using the object component selector.