0% found this document useful (0 votes)
80 views

Control Break Statements

Control levels are defined in extract datasets and correspond to the sequence of fields in the HEADER field group. When an extract dataset is sorted, control breaks occur when the value of a field or superior field changes between records. AT statements can be used within a loop to execute blocks of code at control breaks or at the start/end of a field. The order of AT blocks should match the sort sequence.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
80 views

Control Break Statements

Control levels are defined in extract datasets and correspond to the sequence of fields in the HEADER field group. When an extract dataset is sorted, control breaks occur when the value of a field or superior field changes between records. AT statements can be used within a loop to execute blocks of code at control breaks or at the start/end of a field. The order of AT blocks should match the sort sequence.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

Processing Control Levels

When you sort an extract dataset, control levels are defined in it.

For general information about control levels, refer to Processing Internal Tables in Loops.

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 <f> | AT END OF <f>.
...
ENDAT.

A control break occurs when the value of the field <f> 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 <f> 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 <f> 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 <f1>, <f2>, ..., the processing of the control levels should
be written between the other control statements as follows:
LOOP.
AT FIRST.... ENDAT.
AT NEW <f1>....... ENDAT.
AT NEW <f2>....... ENDAT.
...
AT <fgi>..... ENDAT.
<single line processing without control statement>
...
AT END OF <f2>.... ENDAT.
AT END OF <f1>.... 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.

You might also like