SAP INSERT ITAB ABAP Statements
Get Example source ABAP code based on a different SAP table
Standard SAP Help for INSERT_INTO_ITAB
INSERT
• INSERT itab ABAP Statement
• INTO INSERT itab
ABAP Syntax
What does it do? This statement adds one or more rows
When the row is in inserted, all existing unique table keys are checked. These can be a
RESET M2 If attempting to insert a single row using a primary key would result in duplicates with respect to the unique primary key, no row is inserted and
If attempting to insert a single row using the key or the index would result in duplicates with respect to a unique secondary key, a handleable exception of the class
If the attempt to insert a single row (using an index) or multiple rows (as a block) would result in duplicates (in terms of a unique primary or secondary key), a runtime error occurs.
The system field
Latest notes:The administration of an unique secondary table key is updated immediately (
Example ABAP Coding
Inserts single rows in a
DATA: int_tab TYPE STANDARD TABLE OF i,
ref_tab TYPE HASHED TABLE OF intref
WITH UNIQUE KEY table_line.
DO 10 TIMES.
INSERT sy-index
INTO int_tab • 1
REFERENCE INTO DATA(dref).
INSERT dref
INTO TABLE ref_tab.
ENDDO.
cl_demo_output=>begin_section( `Integer Table` ).
LOOP AT int_tab INTO DATA(int).
cl_demo_output=>write( |{ int }| ).
ENDLOOP.
cl_demo_output=>next_section( `Reference Table` ).
LOOP AT ref_tab INTO dref.
cl_demo_output=>write( |{ dref->* }| ).
ENDLOOP.
cl_demo_output=>display( ).
Runtime Exceptions
Catchable Exceptions
Reason for error:
Duplicate key values in unique secondary key Runtime error:
Non-catchable Exceptions
Reason for error:
When inserting a set of rows, entries with an identical key were produced (the target table is defined by Runtime error:
Reason for error:
Sort order violated when using an Runtime error:
Reason for error:
Invalid index value (<(><<)>= 0) when Runtime error:
Return to menu