Processing Control Levels
When you sort an extract dataset, control levels are defined in it. The control level hierarchy of an extract dataset corresponds to the sequence of the fields in the HEADER field group. After sorting, you can use the AT statement within a loop to program statement blocks that the system processes only at a control break, that is, when the control level changes.
AT NEW | AT END OF .
...
ENDAT.
A control break occurs when the value of the field or a superior field in the current record has a different value from the previous record (AT NEW) or the subsequent record (AT END). Field must be part of the HEADER field group.
If the extract dataset is not sorted, the AT... ENDAT block is never executed. Furthermore, all extract records with the value HEX 00 in the field are ignored when the control breaks are determined.
The AT... ENDAT blocks in a loop are processed in the order in which they occur. This sequence should be the same as the sort sequence. This sequence must not necessarily be the sequence of the fields in the HEADER field group, but can also be the one determined in the SORT statement.
If you have sorted an extract dataset by the fields , , ..., the processing of the control levels should be written between the other control statements as follows:
LOOP.
AT FIRST.... ENDAT.
AT NEW ....... ENDAT.
AT NEW ....... ENDAT.
...
AT ..... ENDAT.
...
AT END OF .... ENDAT.
AT END OF .... ENDAT.
AT LAST..... ENDAT.
ENDLOOP.
You do not have to use all of the statement blocks listed here, but only the ones you require.
REPORT DEMO.
DATA: T1(4), T2 TYPE I.
FIELD-GROUPS: HEADER.
INSERT T2 T1 INTO HEADER.
T1 ='AABB'. T2 = 1. EXTRACT HEADER.
T1 ='BBCC'. T2 = 2. EXTRACT HEADER.
T1 ='AAAA'. T2 = 2. EXTRACT HEADER.
T1 ='AABB'. T2 = 1. EXTRACT HEADER.
T1 ='BBBB'. T2 = 2. EXTRACT HEADER.
T1 ='BBCC'. T2 = 2. EXTRACT HEADER.
T1 ='AAAA'. T2 = 1. EXTRACT HEADER.
T1 ='BBBB'. T2 = 1. EXTRACT HEADER.
T1 ='AAAA'. T2 = 3. EXTRACT HEADER.
T1 ='AABB'. T2 = 1. EXTRACT HEADER.
SORT BY T1 T2.
LOOP.
AT FIRST.
WRITE 'Start of LOOP'.
ULINE.
ENDAT.
AT NEW T1.
WRITE / ' New T1:'.
ENDAT.
AT NEW T2.
WRITE / ' New T2:'.
ENDAT.
WRITE: /14 T1, T2.
AT END OF T2.
WRITE / 'End of T2'.
ENDAT.
AT END OF T1.
WRITE / 'End of T1'.
ENDAT.
AT LAST.
ULINE.
ENDAT.
ENDLOOP.
This program creates a sample extract, containing the fields of the HEADER field group only. After the sorting process, the extract dataset has several control breaks for the control levels T1 and T2, which are indicated in the following figure:
In the loop, the system displays the contents of the dataset and the control breaks it encountered as follows:
For a Excellent Online Resource for SAP EP and SAP Web Dynpro ABAP, Visit Learn SAP Online
SAP EP - Standard Portal Services
Portal Eventing and Navigation
Portal Look and Feel - Branding the Portal
How to Develop Portal Applications
SAP EP-Developing portal content and assigning permissions
SAP EP-Role maintenance
SAP EP-How to make Enterprise Portal highly available
Implement Single Sign On
SAP EP-J2EE architechture
What is SAP Enterprise Portal
And Many More...
Basics of Web Dynpro ABAP
ABAP Data Types and Objects
ABAP Statements
WD4A - Topics to be covered in the upcoming posts
WD4A - Introduction
WDA - SAP Logon Procedures
WD4A-Format the Values appearing on value Axis of Business Graphic
WD4A-Navigate from one view to another and back to previous view
WD4A - How to Calculate next 12 months from current month in web dynpro ABAP
WD4A - Validate Inputs in a web dynpro ABAP Application
And Many More...