Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

control break statements in ABAP?

Answer Posted / kotireddy5

Control break statements:

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:

AT FIRST : Will trigger at the first run of the loop.

AT LAST: Will trigger at the last run of the loop.

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.

Example Program for Control Break Statements
NOTE: It is important to note that we need a temporary work-area apart from the work-area used in loop for the last 3 control break statements. If we directly use the work-area of the loop, then we will get **** value and not the output we are expecting.
*&---------------------------------------------------------------------*
*& Report ZAU_CONTROLBREAK
*&
*&---------------------------------------------------------------------*
*& NEW TO SAP CONTROL BREAK EXAMPLE
*& http://www.newtosap.info
*&
*&---------------------------------------------------------------------*

REPORTzau_controlbreak.
TYPES: BEGIN OFty_marc,
matnr TYPE marc-matnr,
werks TYPE marc-werks,
END OFty_marc.

DATA: it_marc TYPE STANDARD TABLE OFty_marc,
wa_marc TYPEty_marc,
wa_temp TYPEty_marc.

SELECTmatnrwerks FROM marc INTO TABLEit_marc UP TO 10 ROWS WHEREmatnrge40.
SORTit_marc BY matnr.
FIELD-SYMBOLS :<matnr> typematnr.

WRITE:/'FULL TABLE'.
LOOP ATit_marc INTOwa_marc.
wa_temp = wa_marc.
WRITE: / sy-tabix ,wa_temp-matnr, wa_temp-werks.
ENDLOOP.

WRITE:/'AT FIRST AND LAST'.
LOOP ATit_marc INTOwa_marc.
wa_temp = wa_marc.
AT FIRST.
WRITE:/'First Entry'.
WRITE:/wa_temp-matnr, wa_temp-werks.
ENDAT.
AT LAST.
WRITE:/'Last Entry'.
WRITE:/wa_temp-matnr, wa_temp-werks.
ENDAT.
ENDLOOP.


WRITE:/'AT END OF'.
LOOP ATit_marc INTOwa_marc.
wa_temp = wa_marc.
AT END OFmatnr.
WRITE: / sy-tabix ,wa_temp-matnr, wa_temp-werks.
ENDAT.
ENDLOOP.

WRITE:/'AT NEW'.

LOOP ATit_marc INTOwa_marc.
wa_temp = wa_marc.
AT NEW matnr.
WRITE: / sy-tabix ,wa_temp-matnr, wa_temp-werks.
ENDAT.
ENDLOOP.

WRITE:/'ON CHANGE OF'.
LOOP ATit_marc INTOwa_marc.
wa_temp = wa_marc.
ASSIGNwa_marc-matnr TO<matnr>.
ON CHANGE OFwa_marc-matnr.
WRITE: / sy-tabix ,wa_temp-matnr, wa_temp-werks.
ENDON.
ENDLOOP.

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is ps structure? : abap hr

1321


Explain how to create any functions? How to go about it?

955


Do you know any other patterns if yes.. explain

1239


Structures can contain data only during the runtime of a program (t/f) : abap data dictionary

1247


can anyone please tell me, in orient paper mill project which fields exits for creating report.

1654


How to convert the Unit for 'Distance' (The value from one Unit to another).

1918


What are the two different ways of building a match code object?

984


Explain enhancements

1285


What are the client dependant objects in abap / sap?

1008


Explain what are the various types of selection screen event?

1029


What are the two levels in defining a match code ?

1037


Can we set page headers to details lists?

978


GUYS any one please can u post questions in sap a bap webdynpro questions.. please i need to know some technical questions regarding webdynpro and ADOBE forms ?

1846


What is the bapi?

1087


pls if any one have idea ,reply as soon as possible 1.Allied solution group inc. is a genuine company or not ? 2.what is update module. 3.Transaction: scc3 what it is?

1932