COLLECT only. For hashed tables, all prerequisites are fulfilled
automatically.
If a standard table is still filled using COLLECT , it should
not be edited using any other statement, with the exception of
MODIFY . If the latter is used with the
addition TRANSPORTING , no primary key fields can be changed. This
is the only way to ensure that the table entries are always unique and
compressed, and that the COLLECT statement runs efficiently. The
function module ABL_TABLE_HASH_STATE
can be used to check whether a standard table is suitable for
editing using COLLECT .
Example ABAP Coding Compressed insertion of data from the database table
sflight into the internal table seats_tab . The rows in
which the primary key components carrid and connid are
identical are compressed by adding the number of occupied seats to the
numeric component seatsocc .
DATA: BEGIN OF seats,
carrid TYPE sflight-carrid,
connid TYPE sflight-connid,
seatsocc TYPE sflight-seatsocc,
END OF seats.
DATA seats_tab LIKE HASHED TABLE OF seats
WITH UNIQUE KEY carrid connid.
SELECT carrid connid seatsocc
FROM sflight
INTO seats.
COLLECT seats INTO seats_tab.
ENDSELECT.
Runtime Exceptions
Catchable Exceptions
CX_SY_ARITHMETIC_OVERFLOW
Reason for error: Overflow in integer field when creating totals
Runtime error: COLLECT_OVERFLOW
Reason for error: Overflow in type p field when creating totals
Runtime error: COLLECT_OVERFLOW_TYPE_P
Non-catchable Exceptions
Reason for error: COLLECT used for non-numeric fields
Runtime error: TABLE_COLLECT_CHAR_IN_FUNCTION
Reason for error: Memory area
violated when TABLES parameter accessed
Runtime error: ITAB_STRUC_ACCESS_VIOLATION
Documentation extract taken from SAP system, � Copyright SAP AG. All rights reserved