‎2006 Dec 12 7:42 AM
hi friends,
can i use control break statements on non primary key fields
can u plz give any example if we can use.
regards,
malleswari.
‎2006 Dec 12 7:46 AM
‎2006 Dec 12 7:46 AM
‎2006 Dec 12 7:48 AM
yes we can use control break on any fields
chk this sample program
REPORT YCHATEST LINE-SIZE 350.
TABLES MARA.
DATA : BEGIN OF ITAB OCCURS 0,
MATNR LIKE MARA-MATNR,
AMOUNT TYPE P DECIMALS 2,
END OF ITAB.
ITAB-MATNR = '12345'.
ITAB-AMOUNT = '100.20'.
APPEND ITAB.
CLEAR ITAB.
ITAB-MATNR = '12345'.
ITAB-AMOUNT = '100.20'.
APPEND ITAB.
CLEAR ITAB.
ITAB-MATNR = '3456'.
ITAB-AMOUNT = '100.20'.
APPEND ITAB.
CLEAR ITAB.
sort itab by matnr amount.
LOOP AT ITAB.
AT END OF AMOUNT.
WRITE : / ITAB-MATNR , ITAB-AMOUNT.
ENDAT.
ENDLOOP.
‎2006 Dec 12 7:56 AM
Hi ,
You can use the control breaks on any statement , but only thing is that it will be applicable to all the fields before the field on which you have applied the control break.
As in the above example , if the material of second record is changed from '12345' to '123456' the the output will be
12345 100.20
123456 100.20
3456 100.20.
So for correct application of control breaks all the field before this field must be considered.
Regards
Arun
‎2007 Jun 14 9:37 AM
Hi,
Control break statements are used to stop the control at a particular point.
1. AT NEW f.
2. AT END OF f.
3. AT FIRST.
4. AT LAST.
Effect
In a LOOP which processes a dataset created with EXTRACT , you can use special control structures for control break processing. All these structures begin with AT and end with ENDAT . The sequence of statements which lies between them is then executed if a control break occurs.
You can use these key words for control break processing with extract datasets only if the active LOOP statement is proceesing an extract dataset.
The control level structure with extract datasets is dynamic. It corresponds exactly to the sort key of the extract dataset, i.e. to the order of fields in the field group HEADER by which the extract dataset was sorted .
At the start of a new control level (i.e. immediately after AT ), the following occurs in the output area of the current LOOP statement:
All default key fields (on the right) are filled with "*" after the current control level key.
All other fields (on the right) are set to their initial values after the current control level key.
Between AT and ENDAT , you can use SUM to insert the appropriate control totals in the number fields (see also ABAP/4 number types ) of the LOOP output area (on the right) after the current control level key. Summing is supported both at the beginning of a control level ( AT FIRST , AT NEW f ) and also the end of a control level ( AT END OF f , AT LAST ).
At the end of the control level processing (i.e. after ENDAT ), the old contents of the LOOP output area are restored
use control break on any fields
chk this sample program
REPORT YCHATEST LINE-SIZE 350.
TABLES MARA.
DATA : BEGIN OF ITAB OCCURS 0,
MATNR LIKE MARA-MATNR,
AMOUNT TYPE P DECIMALS 2,
END OF ITAB.
ITAB-MATNR = '12345'.
ITAB-AMOUNT = '100.20'.
APPEND ITAB.
CLEAR ITAB.
ITAB-MATNR = '12345'.
ITAB-AMOUNT = '100.20'.
APPEND ITAB.
CLEAR ITAB.
ITAB-MATNR = '3456'.
ITAB-AMOUNT = '100.20'.
APPEND ITAB.
CLEAR ITAB.
sort itab by matnr amount.
LOOP AT ITAB.
AT END OF AMOUNT.
WRITE : / ITAB-MATNR , ITAB-AMOUNT.
ENDAT.
ENDLOOP.
Regards