control break statements in ABAP?
Answers were Sorted based on User's Feedback
Answer / prasad1983
at first ... endat.
at new ... endat.
at end of ... endat.
on change of ... endon.
at last ... andat.
Is This Answer Correct ? | 37 Yes | 4 No |
Answer / prabhakararao
hi all
This is Prabhakararao
Control break statememnts are:
AT FIRST
AT LAST
AT NEW
AT END OF
all the above are used for different purposed
Is This Answer Correct ? | 32 Yes | 5 No |
Answer / niranjan
The Control Break Statements are used to print headings,subheadings,totals and subtotal.
We must use this statements inside the loop.
1.AT FIRST...........ENDAT:It is useful to print headings.
-->it will triggered before starting a first record in a loop.
2.AT LAST............ENDAT:It is useful to print TOTALS.
-->it will triggered after the last record in a loop.
3.AT NEW ON..........ENDAT:It is useful to print subheadings.
-->it will triggered before starting a new value for that particular field.
4.AT END OF..........ENDAT:It is useful to display sub-totals.
-->it will triggered after heading the old value.
5.ON CHANGE OF.......ENDAT:It is same as 'AT FIRST' but the only difference is we can use 'ON CHANGE OF' in any kind of loop statements like loop.....endloop,select.....endselect,do.....enddo,while.....endwhile.
-->it will triggered before starting a new value.
Is This Answer Correct ? | 16 Yes | 1 No |
Answer / g.sivaramakrishnamohan
hi this is
G.sivaramakrishnamohan
Control break statememnts are:
1)At first.....endat
2)At last......endat
3)At new <field name>....endat
4)At end of <field name>........endat
5)change of <field name>........endon
Is This Answer Correct ? | 10 Yes | 4 No |
Answer / deepti pattnaik
at first ... endat.
at new ... endat.
at end of ... endat.
on change of ... endon.
at last ... andat.
Is This Answer Correct ? | 8 Yes | 2 No |
Answer / arasu
Control Break Statement is different from Control statement,
the BREAK, EXIT, CONTINUE are used to break and come out of
the current loop where it occurs, where as AT NEW, AT END,
AT LAST, AT FIRST is used to check for a table field value
(internal table). When u asked for control statements alone,
u need to answer as BREAK, EXIT, CONTINUE, CHECK because it
controls the program flow.
Is This Answer Correct ? | 9 Yes | 5 No |
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 ? | 2 Yes | 0 No |
Answer / rv karthikeyan
Hi this is karthikeyan
control break statement: It is used to control the data flow inside the loop,for example if we need to add some functionality at run time for example subtotal for every new value triggered or sub heading,we use control break statement,now we see the types of control break statement.
at first: when the loop start first this at first will trigger,that when the loop starts the control goes to the at first statement and executed all the function inside it.
at new: when the first occurrence of the new value found this at new will trigger,used for the sub heading or page break purpose.
at end: when the last occurrence of the new value found this at end will trigger,used mainly for sub total purpose.
at last: when the last record in the loop over this at last will trigger used for grand total purpose.
Hope u got idea...
Regards
RV Karthikeyan.
Is This Answer Correct ? | 0 Yes | 1 No |
Answer / lakku sreenivasulu
The Control Break Statements are
AT FIRST
AT LAST
AT NEW
AT END OF
all the above are used for different purposed
Is This Answer Correct ? | 3 Yes | 5 No |
AT NEW, AT FIRST, ... ARE ALL CONTROL LEVEL STATEMENTS.
THE CONTROL BREAK STATEMENTS ARE EXIT, CONTINUE, STOP.
Is This Answer Correct ? | 10 Yes | 21 No |
Is BAdI client Indpendent
How to validate table entries ?
Difference between Call screen, Leave screen and Set screen.
1 Answers Process Weaver, Wipro,
What are field groups?
how to cal driver program in smart forms??
By which function module upload data from application Server to desk top and to code can u explain
How do you read a LOCAL Sequentional file
What are different ABAP editors? What are the differences?
How can we use / display table in a screen?
"What is NAST Table, what it will consists?"
what are the roles and responsibilities of a technical consultant will be assigned in idoc development in real time? in case of a)IDOC EXTENSION b)sending TRANSACTIONAL IDOC c)CHANGE POINTERS
HOW TO TRANSFER MATERIAL MASTER DATA FROM LEGACY SYSTEM (ORACLE) TO SAP USING A FUNCTION MODULE BAPI_MATERIAL_SAVE_DATA. IF ANYBODY KNOW THE ANSWER PLZ MAIL TO MY ID SHAIKZIA@GMAIL.COM