SAP DATA DICTIONARY
 
 
 
 
 
 
 
 
 
 

  SAP REPORTS
 
 
 
 
 
 
SAP ABAP Control Break Statements

Control break processing in a internal table loop is used to execute statements written within the block AT and END AT, when the control structure changes. The AT statements (Begining of the blocks) determine the control break at which the statements written within the blocks are executed. Within these statement blocks, the SUM statement can be use to total the numeric components of a control level.

The prerequisite for using control break statements is that the internal table must be sorted in the exact order of the components of its row type according to the processing sequence in which the LOOP loop reads the rows of the internal table.

The control break "ON CHANGE OF - ENDON", can be used in any loop, not just LOOP... ENDLOOP. It can also be used in WHILE ... ENDWHILE.

   There are Five control break statements -
      1. At First / End At
      2. At Last / end At
      3. At New / End At
      4. At End Of / End At
      5. On Change Of / EndOn


Q. What is the difference between 'At New / End At' and 'On Change Of / EndOn'?
1. 'On Change Of' can be used in any loop construct, not just 'Loop At'.
2. A Single 'On Change Of' can be triggered by a change within one or more fields named after of and separated by OR.
3. When used within a loop, a change in a field to the left of the control level does not trigger a control break.
4. When used within a loop, fields to the right still contain their original values; they are not changed to contain zero or asterisks.
5. You can use 'else' statement between 'On Change OF' and 'End On'. You can also use ELSEIF statements in conjunction with special implementation of ON, but should always try to avoid this because they may not be supported in future.
6. You can use it with 'Loop At' IT WHERE clause……
7. You can use 'SUM' with 'On Change Of'. It sums all numeric fields except the one(s) named after Of.
8. Another difference is while using 'at new' in case if you code any write statements between 'at new' and 'end at' the value for the numeric fields will be returned as 0 and that of no numeric fields will be returned as *(asterisk). But in on change of the original values will be returned.

NOTE: Use the 'At First' and 'At Last' statement to perform during the first or last pass of internal table. These statements can only be used within 'LOOP AT'; they cannot be used within select.

What is the difference between collect and sum?
Following are the differences -


- COLLECT statement is used to sum the value on a default key fields in the work area. The default key is composed of the values from all fields of type c, n, d, t, and x. Where the SUM statement is used to sum the value to the right of control level. The key is formed with the control level defined on the control break processing statement.

- SUM statement is used with the control break AT...ENDAT processing statement though COLLECT statement do not so.

- In the COLLECT statement, the system searches the body of the internal table for a row that has the same key as the key in the work area. If it doesn't find one, the row is appended to the end of the table. If it does find one, the numeric fields (types I, p, and f) in the work area are added to the corresponding fields in the found row.

While SUM, calculates a total for the current value of the control level that contains it. It finds all rows that have the same values within the control level field and all fields to the left of it. It sums each numeric column to the right of the control level. It places the totals in the corresponding fields of the work area.

 
 

  

  

  

  

  

  



                                                      Copyright © 2011 SAPApplication.com. All rights reserved.