Preface – This post is part of the ABAP Beginner series.
Control Break statements in SAP ABAP are the are statements enclosed between AT and ENDAT. These statements help us to control a loop according to our requirement. In this article we will discuss about the four control break statements provided by SAP ABAP.
Table of Contents
In ABAP, there are times where we need to perform some group level processing operations only upon certain set of data. For that purpose, we can take all data from a table to an internal table and push that data into a loop [LOOP … END LOOP]. In that loop we will need something called control break statements which are enclosed between statements AT and ENDAT.
To utilize these control break statements in ABAP, we will also need some mathematical statements such as SUM, which can be used to total the numeric components of a table.
***Note: If inside a Loop you are using INTO wa, then it cannot be modified as it is overwritten with the old one when the AT-ENDAT control structure is entered. In this case use another work area to save your changes.
Types of Control Break statements in SAP ABAP
|AT FIRST …. ENDAT
|· This is triggered for the first row of internal table or the first iteration of loop (both are same).
· As soon it is hit (AT FIRST), the value of work area are filled by ‘*’. And as soon as it hit –ENDAT, the work area is restored.
|AT NEW <field_name> …. ENDAT
|· This is triggered for First row of a group with the same content of internal table based on a field (here <field_name>).
|AT END OF <field_name> …. ENDAT
|· This is triggered for Last row of a group with the same content of internal table based on a field (here <field_name>).
|AT LAST …. ENDAT
|· This is triggered for the last row of internal table or the last iteration of loop (both are same).
*** We will update it soon