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 |
If you are at 3rd list how can you back to 1st list?
What are the different types of the sap abap data dictionary objects?
What is function group?
Which one of the following statements are FALSE about Inactive objects in SAP? a) Development Objects are always saved as inactive versions. b) An inactive version of a Development Object is written to developer’s pc c) In DISPLAY mode, other users can NOT access the code of inactive version of a developer d) Generating a runtime object is same as activating a development object.
What is system-land-scape of your project?
How to maintain subtotals n grand totals in smart forms?
Explain how do you move on to the next screen in interactive reporting?
Why do we use Process On Value Request(POV) event instead of data element,search help in module pool.
What is step-loop? Explain all the steps?
How can I trigger the outbound IDOC?
how many types of interfaces are there in abap ?
1) What is read with binary search? 2) I have initialization write ?a? Top-of-page write ?b? what is the output for this/ 3) If I don?t have start of selection event in report will it execute?it is mandatory or not? 4) What is table maintenance generator? 5) Is it advisable to have secondary index/ 6) How we will imlement BAPI? 7) What is process code in idoc? 8) Where the information msg will display? 9) Where warning msg will display? 10) Where we use watch point?what exactly watch point means? 11) What is a spool? 12) What is program name that contains all print program names and form names other than TNAPR? 13) How we will capture errors in bapi? 14) How to transfer std text from production to quality?