Control Break Statements in SAP ABAP
By
SAP
-
January 29, 2014
7472
5
Control break events are used to control the sequence data flow inside the loops in ABAP.
1) AT FIRST
2) AT NEW
3) AT END OF
4) AT LAST
5) SUM
6) ON CHANGE OF
Note: AT-FIRST, AT-NEW,AT-END-OF,AT-LAST this events works only in between LOOP——ENDLOOP, We are also calling it as LOOP EVENTS
AT FIRST
It is the loop event, it triggers at first run of the loop.
Using this event we can display the page header.
AT FIRST ——————- END AT.
AT NEW
It is the loop event. Whenever the new field value is occurred then AT NEW event will trigger.
The trigger point will be at the first occurrence of the new value for the field.
SYNTAX
AT NEW ——————— END AT.
AT END OF
It is the loop event. It triggers at end of every field value.
Using this event we can calculate the subtotals.
SYNTAX
AT END OFS ——————— END AT.
AT LAST
It is the loop event. It triggers in the last loop operation
Using this event we can find calculate the grand totals.
SYNTAX
AT LAST ——————— END AT.
SUM
Sum is the keyword to find the totals.
ON CHANG OF
On change of it triggers only when there is any change in the particular field, we can use ON CHANGE OF loop and outside the Loop also.
We can use Logical expressions like AND OR can be used with ON CHANGE OF
SYNTAX
ON CHANGE OF ——————— END OF.
*&———————————————————————*
*& REPORT ZCEVENTS
*&
*&———————————————————————*
*&
*&
*&———————————————————————*
REPORT ZCEVENTS NO STANDARD PAGE HEADING.*// TABLES DECLARATION.
TABLES MARC.
*//TYPES DECLARATION FOR TY_MARC.
TYPES : BEGIN OF TY_MARC,
MATNR TYPE MATNR,
WERKS TYPE WERKS_D,
PSTAT TYPE PSTAT_D,
LVORM TYPE LVOWK,
PLIFZ TYPE PLIFZ,
END OF TY_MARC.*//TYPES DECLARATION FOR TY_MARC1.
TYPES : BEGIN OF TY_MARC1,
WERKS TYPE WERKS_D,
PSTAT TYPE PSTAT_D,
LVORM TYPE LVOWK,
PLIFZ TYPE PLIFZ,
MATNR TYPE MATNR,
END OF TY_MARC1.*//INTERNAL TABLE DECLARATION.
DATA : LT_MARC TYPE TABLE OF TY_MARC,
LT_MARC1 TYPE TABLE OF TY_MARC1.
*//WORKAREA DECLARATION.
DATA : WA_MARC TYPE TY_MARC,
WA_MARC1 TYPE TY_MARC1.
*//SELECTION SCREEN DESIGN.
SELECT-OPTIONS : S_MATNR FOR MARC-MATNR.*//RETRIVE THE DATA FROM MARA.
SELECT MATNR WERKS PSTAT LVORM PLIFZFROM MARC
INTO TABLE LT_MARC
WHERE MATNR IN S_MATNR.
IF SY-SUBRC EQ 0.
*//POPULATING DATA INTO FINAL INTERNAL TABLE.
LOOP AT LT_MARC INTO WA_MARC.***** WA_MARC1-MATNR = WA_MARC-MATNR.
***** WA_MARC1-WERKS = WA_MARC-WERKS.
***** WA_MARC1-PSTAT = WA_MARC-PSTAT.
***** WA_MARC1-LVORM = WA_MARC-LVORM.
***** WA_MARC1-PLIFZ = WA_MARC-PLIFZ.
MOVE-CORRESPONDING WA_MARC TO WA_MARC1.
APPEND WA_MARC1 TO LT_MARC1.CLEAR WA_MARC1.
ENDLOOP.
ENDIF.*// SORT BY SPECIFIC FIELD
SORT LT_MARC1 BY PSTAT.
*******//DISPLAY OUTPUT.
******LOOP AT LT_MARC1 INTO WA_MARC1.
****** WRITE : / WA_MARC1-MATNR,WA_MARC1-WERKS,WA_MARC1-PSTAT,WA_MARC1-LVORM,WA_MARC1-PLIFZ.
******ENDLOOP.
*//APPLY THE CONTROL BREAK EVENTS.
LOOP AT LT_MARC1 INTO WA_MARC1.*//AT FIRST.
AT FIRST.
WRITE : / ‘PLANT DATA’.
ULINE.
SKIP 2.
ENDAT.******//AT NEW.
***** AT NEW PSTAT.
***** WRITE : / ‘MAINTENANCE STATUS: ‘ ,WA_MARC1-PSTAT.
***** ENDAT.
***** WRITE : /,/ WA_MARC1-MATNR,WA_MARC1-WERKS,WA_MARC1-PSTAT,WA_MARC1-LVORM,WA_MARC1-PLIFZ .
*//ON CHANGE OF.
ON CHANGE OF WA_MARC1-PSTAT.
WRITE : /,/ ‘MAINTENANCE STATUS :’,WA_MARC1-PSTAT.
ENDON.WRITE : / WA_MARC1-MATNR,WA_MARC1-WERKS,WA_MARC1-PSTAT,WA_MARC1-LVORM,WA_MARC1-PLIFZ.
*//AT END OF.
AT END OF PSTAT.
SUM .
WRITE : /30 ‘SUBTOTAL’, WA_MARC1-PLIFZ.
ENDAT.*//AT LAST.
AT LAST.
SUM.
WRITE : /30 ‘GRAND TOTAL’,WA_MARC1-PLIFZ.
ENDAT.
ENDLOOP.Click on Execute.
Enjoy
Creating Pushbuttons on Selection Screen.
Display a Column As a Pushbutton in the ALV Report Output.
How to Create Transaction Code for Table Maintenance Generator in SAP.
TAGS
ABAP Tutorials
abap tutorials for beginners
SAP
SAP ABAP
SAP ABAP Tutorials
Previous articleBenefits of BW on HANA
Next articleTable Maintenance without using SE11 and SE30 Transaction Codes
SAP
RELATED ARTICLESMORE FROM AUTHOR
SAP ABAP
SAP ABAP Online Quiz 4
SAP ABAP
Difference Between Main Window and Variable Window in SAP
SAP ABAP
Display PO And Goods Receipt Details Against Purchase Requisition – SAP Reports
SAP ABAP
Business Application Programming Interface Introduction – BAPI
SAP ABAP
Interactive reports in SAP ABAP
SAP ABAP
SAP ABAP report with checkbox to Download selected records at Runtime
5 COMMENTS
Deepthi January 30, 2014 at 12:28 pm
Hi ,i am not finding any post for webdynpro, can you provide it.
Reply
SAP January 30, 2014 at 12:50 pm
Hi deepthi currently i am writing ABAP post, it will take some time to write post on Webdynpro
Reply
garapati surendra February 3, 2014 at 6:37 am
hi can i post some documents on your site and how can i post…
Thank u..
Reply
SAP February 3, 2014 at 6:44 am
Send ur documents editor to editor@sapsimplified.com, i will publish your documents with your name.
Reply
Naveen March 5, 2014 at 11:59 am
. Please Provide Interviews Questions for 2 Years/3 Years Experiences
Reply
Leave a Reply