SAP AT EXTRACT ABAP Statements



Get Example source ABAP code based on a different SAP table
  


• AT - extract ABAP Statement

AT, Extract
Short Reference

ABAP_SYNTAX_OBS
LOOP.
$[AT FIRST.
...
ENDAT.$]
$[AT field_groupi $[WITH field_groupj$]
...
ENDAT.$]
$[AT NEW field1.
...
ENDAT.
$[AT NEW field2.
...
ENDAT.
$[...$]$]$]
$[ ... $]
$[$[$[...$]
AT END OF field2.
...
ENDAT.$]
AT END OF field1.
...
ENDAT.$]
$[AT LAST.
...
ENDAT.$]
ENDLOOP.

ABAP Addition
1 ... FIRST
2 ... field_groupi $[WITH field_groupj$]
3 ... ${NEW$}$|${END OF$} fieldi
4 ... LAST

What does it do?
The statement block of a LOOP for extracts can contain control structures for group level processing. The corresponding control statement is AT. The statements AT and ENDAT define statement blocks that are executed at group breaks. Group breaks between group levels are a result of the line structure and the processing order in which the LOOP reads the lines of the extract dataset. Within some of the statement blocks, it is possible to access the automatically created data objects sum(field) and cnt(field).
Apart from the special variants AT FIRST, AT field_group, and AT LAST, group levels are defined using the variant AT NEW and using the consecutive lines of the extract. These are the lines that have the same content in a group key defined in their initial parts. It is possible, from a syntax point of view, to arrange AT control structures in any order and to nest them, however effective group level processing is usually only achieved by the arrangement above. Here, the control structures are specified in accordance with the arrangement of the components in the group key and are not nested.
The statement blocks within the AT-ENDAT control structures are executed if an appropriate group break occurs in the current line. Statements in the LOOP-ENDLOOP control structure that are not listed within an AT-ENDAT control structure are executed in each loop pass.



Latest notes:

In one very common case, the extract dataset is sorted exactly by the group key.
Extracts are obsolete. Internal tables should be used instead.
ABAP_HINT_END
• FIRST AT - extract (obsolete)

ABAP Addition

What does it do?
The group level is defined by the first line of the extract dataset.
• WITH AT - extract (obsolete)

ABAP Addition

What does it do?
A line that was appended to the extract dataset using the statement EXTRACT field_groupi. If the WITH addition is specified, the next line must be defined by the field group field_groupj.
• NEW AT - extract (obsolete)
• END OF AT - extract (obsolete)

ABAP Addition

What does it do?
The group level is defined by the beginning or end of a group of lines with the same content in the component fieldi and in the component left of fieldi. The content of these components determines the group key. The component field must be part of the field group header. Components whose content is hexadecimal 0 are not included as a group break criterion.
For fieldi, a field symbol can also be specified. If a component of field group header is assigned to the field symbol when the statement is executed, this has the same effect as specifying the corresponding component. If no data object is assigned to the field symbol, the specification is ignored. If another data object is assigned to the field symbol, an uncatchable exception is raised.
• LAST AT - extract (obsolete)

ABAP Addition

What does it do?
The group level is defined by the last line of the extraction dataset.

ABAP_EXAMPLE_ABEXA
Extracts, Processing
ABAP_EXAMPLE_END

Return to menu