SAP APPEND ABAP Statements
Get Example source ABAP code based on a different SAP table
Standard SAP Help for APPEND
APPEND
• APPEND ABAP Statement
• TO APPEND
ABAP Syntax
ABAP Addition
What does it do? This statement appends one or more rows
If
For the individual table types, appending is done as follows: To standard tables, rows are appended directly and without checking the content of the internal table.
Rows are appended to
No rows can be appended to
Exceptions are raised in the following cases: If a row to be appended would produce a duplicate entry in a unique primary table key, a non-handleable exception is raised.
If a row to be appended would produce a duplicate entry in a unique secondary table key, a handleable exception of the class
If a block of rows to be appended would produce a duplicate entry in a unique secondary table key, a non-handleable exception is raised.
If the row being appended would destroy the sort order of sorted tables, a non-handleable exception is raised (the secondary index of a sorted secondary key, however, is updated before it is used again).
Latest notes:The administration of a unique secondary table key is updated immediately; the administration of a non-unique key is not updated until the secondary table key is next used explicitly (
• SORTED BY APPEND
ABAP Addition
What does it do? Used correctly, this addition can produce ranking lists in descending order. This only works if a value greater than 0 is specified in the declaration of the internal table in the addition
The addition
As long as the declaration of the internal table for
If the number of rows before the statement is executed is greater than or equal to the number specified in the declaration of the internal table in the addition
When using only the statement
ABAP_PGL
Example ABAP Coding
Creates a ranking of the three flights of a connection showing the most free seats. PARAMETERS: p_carrid TYPE sflight-carrid,
p_connid TYPE sflight-connid.
DATA: BEGIN OF seats,
fldate TYPE sflight-fldate,
seatsocc TYPE sflight-seatsocc,
seatsmax TYPE sflight-seatsmax,
seatsfree TYPE sflight-seatsocc,
END OF seats.
DATA seats_tab LIKE STANDARD TABLE OF seats
INITIAL SIZE 3.
SELECT fldate seatsocc seatsmax
FROM sflight
INTO seats
WHERE carrid = p_carrid AND
connid = p_connid.
seats-seatsfree = seats-seatsmax - seats-seatsocc.
APPEND seats TO seats_tab SORTED BY seatsfree.
ENDSELECT.
Runtime Exceptions
Catchable Exceptions
Reason for error:
Duplicate key values in unique secondary key Runtime error:
Non-catchable Exceptions
Reason for error:
Row with identical key inserted (target table defined using Runtime error:
Reason for error:
Sort order violated after an Runtime error:
Reason for error:
Invalid index value (<(><<)>= 0) when Runtime error:
Reason for error:
Runtime error:
Return to menu