SAP Tutorials Blog

 

Modifying Table

MODIFY <itab> [FROM <wa>] [INDEX <idx>] [TRANSPORTING <f1> ... <fn> [WHERE <condition>]].

Modifies the line in the table. For tables with a header line the source area can be omitted. With INDEX option, will be modified the line which has the index <idx>. In this case: SY-SUBRC = 4 if no line with <idx> exists; SY-SUBRC = 0 - success.

Use MODIFY without the INDEX option is allowed only within a LOOP - ENDLOOP loop by modifying the current line (i.e. the line which has the index returned by SY-TABIX).

With the TRANSPORTING option, the system transports only the components <f1> ... <fn> from the work area into the internal table. Strongly recommended suppress unnecessary transports of fields which are internal tables itself. You can specify a component dynamically by writing (<name>). In this case, the system reads the name of the component from field <name> at runtime. An invalid component name leads to a runtime error.

WHERE <condition> with the TRANSPORTING option determines all the lines of the table into which the components <f1> ... <fn> are to be transported. First operand should be a component of the internal table's line structure. WHERE cannot be used together with the INDEX option.

WRITE <f>[+<o1>][(<l1>)] TO <itab>[+<o2>][(<l2>)] INDEX <idx>.

Variant of WRITE TO. Overwrites the section of the line of the <itab> that has index <idx>. Does not affect header line. Does not recognize the structure of table lines. Return codes: SY-SUBRC = 4 - no line with <idx> exists; SY-SUBRC = 0 - success. If <idx> <= 0 - runtime error.


Serkan AKKAVAK

Computer Engineer BSc

SAP Department Manager

Contact : serkurumsal@yandex.com