Control Break Statements in SAP ABAP
Control Break Statements in SAP ABAP
Control break statements are like events inside the loop. There are 5 control break statements in
ABAP. These are used within loop.(Except ON CHANGE OF which can be used outside the loop
as well)
AT FIRST - ENDAT
AT NEW - ENDAT
AT END OF - ENDAT
AT LAST - ENDAT
ON CHANGE OF
Explanation:
The below 3 events are normally used when the table is sorted.
AT END OF : When we use At end for a field, it will trigger whenever there is any change in any
of the fields from the left to that of the particular field. The trigger point will be the at the
last occurrence of the same value for the field.
AT NEW: When we use At new for a field, it will trigger whenever there is any change in any of
the fields from the left to that of the particular field.The trigger point will be the at the
first occurrence of the new value for the field.
ON CHANGE OF: On change of it triggers only when there is any change in the particular field.
On change of can be used outside the loop too
Example Program:
Here is an example program which gives you the practical understanding of all control break
statements.
*&---------------------------------------------------------------------*
*& Report ZAU_CONTROLBREAK
*&
*&---------------------------------------------------------------------*
*& NEW TO SAP CONTROL BREAK EXAMPLE
*& http://www.newtosap.info
*&
*&---------------------------------------------------------------------*
REPORT zau_controlbreak.
TYPES: BEGIN OF ty_marc,
matnr TYPE marc-matnr,
werks TYPE marc-werks,
END OF ty_marc.
SELECT matnr werks FROM marc INTO TABLE it_marc UP TO 10 ROWS WHERE matnr
ge 40.
SORT it_marc BY matnr.
FIELD-SYMBOLS : <matnr> type matnr.