SAP MODIFY ITAB TABLE KEY ABAP Statements

Get Example source ABAP code based on a different SAP table
  



MODIFY itab - table_key

Short Reference
• USING KEY MODIFY TABLE itab
• TABLE MODIFY itab


ABAP Syntax ... TABLE itab [USING KEY
keyname] ... .
ABAP Code Snippet

What does it do? For wa, a work area compatible to the row type of the internal table must be specified. This concerns functional operand positions. The first row of the internal table found, whose values in the columns of the table key used match those of the corresponding components of wa , is processed. If the key fields in wa are empty, no entries are processed.

If the USING KEY addition is not specified, the primary table key is used. If the USING KEY addition is specified, the table key specified in keyname is used.
ABAP Code Snippet

The same applies when searching for a row to be modified as to key access using the statement READ.

If the primary table key is used to access a standard table and the key is empty, then the first row of the internal table is deleted. If this is statically identifiable, the syntax check produces a warning.



Latest notes:When using the primary table key, note that this key can be
the standard key, which can also have unexpected consequences: For structured row types, the standard key covers all character-like and byte-like components. The standard key of a standard table can be empty.



Example ABAP Coding
Converts the local currency of an airline using primary
key access to the internal table scarr_tab. 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.

scarr_wa = scarr_tab[ KEY primary_key carrid = p_carrid ].

scarr_wa-currcode = 'EUR'.

MODIFY TABLE scarr_tab FROM scarr_wa
TRANSPORTING currcode.

...More SAP MODIFY Examples

Return to menu