Control break processing is used to execute a piece of code whenever a specific condition in the data is detected during the processing of internal table loop.


The following control break statements are available with in LOOP and ENDLOOP.
  • AT FIRST / ENDAT
  • AT LAST /  ENDAT
  • AT NEW / ENDAT
  • AT END OF / ENDAT
  • SUM
  • ON CHANGE OF / ENDON
The code between AT NEW and ENDAT is executed only during the first loop pass. So it is used to write the headers or some other initialization processing.
The code between AT LAST and ENDAT is executed only during the last loop pass. So it is used to write the totals or some report footers.
*————————————————————–* *Data Declaration *————————————————————–*
DATA: gwa_spfli TYPE spfli.
DATA: gt_spfli  TYPE TABLE OF spfli.
*UP TO 5 ROWS addition selects only 5 rows from table SPFLI
SELECT * UP TO 5 ROWS FROM spfli INTO TABLE gt_spfli.

LOOP AT gt_spfli INTO gwa_spfli.
AT FIRST.
    WRITE:/ 'Start of Loop'.
    WRITE:/ 'Flight Details'.
    WRITE:/ 'Airline Code' COLOR 5,14 'Connection No.' COLOR 5,
         29 'Departure City' COLOR 5, 44 'Arival City' COLOR 5.
    ULINE.
ENDAT.
  WRITE:/ gwa_spfli-carrid,14 gwa_spfli-connid,
       29 gwa_spfli-cityfrom,44 gwa_spfli-cityto.
AT LAST.
    ULINE.
    WRITE:/ 'End of Loop'.
ENDAT.
ENDLOOP.
 
 
 
 
Serkan AKKAVAK
Computer Engineer
ABAP Developer & SAP S/4 HANA Logistics Consultant
Contact : serkurumsal@yandex.com