Control Break statements in SAP ABAP

by | Jan 14, 2019 | ABAP Beginner

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.

Introduction

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

StatementDescription
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).

Image Illustration

Control Break statements in SAP ABAP: At First

Control Break statements in SAP ABAP: At First

Control Break statements in SAP ABAP: At New

At New

Control Break statements in SAP ABAP: At End

At End

Control Break statements in SAP ABAP: At Last

At Last

Example

*** We will update it soon

Author

1 Comment

  1. Govardana Reddy

    Very good explanation.

    Reply

Submit a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.