* IN AT END OF.....ENDAT
Dear all,
Could ne 1 plz tell me why does * come while using AT END OF syntax.
eg loop at it_table into wa_table.
some processing.....
at end of wa_table-field.
some code
endat.
Why does * come into work area? Also all numeric fields turn to 0.
This question is just out of Curiosity
Hi
Using AT FIRST , AT NEW, AT THE END OF , AT LAST.
DATA: BEGIN OF ITAB OCCURS 0,
F1 TYPE I,
F2(6) TYPE C,
F3(10) TYPE N,
F4(16) TYPE P DECIMALS 2,
END OF ITAB.
DATA: SUB_TOT(10) TYPE P DECIMALS 3.
**--1
ITAB-F1 = 1.
ITAB-F2 = 'ONE'.
ITAB-F3 = 10.
ITAB-F4 = '1000.00'.
APPEND ITAB.
CLEAR ITAB.
ITAB-F1 = 1.
ITAB-F2 = 'ONE'.
ITAB-F3 = 20.
ITAB-F4 = '2000.00'.
APPEND ITAB.
CLEAR ITAB.
ITAB-F1 = 1.
ITAB-F2 = 'ONE'.
ITAB-F3 = 30.
ITAB-F4 = '3000.00'.
APPEND ITAB.
CLEAR ITAB.
*--2
ITAB-F1 = 2.
ITAB-F2 = 'TWO'.
ITAB-F3 = 10.
ITAB-F4 = '1000.00'.
APPEND ITAB.
CLEAR ITAB.
ITAB-F1 = 2.
ITAB-F2 = 'TWO'.
ITAB-F3 = 20.
ITAB-F4 = '2000.00'.
APPEND ITAB.
CLEAR ITAB.
*-- 3
ITAB-F1 = 3.
ITAB-F2 = 'THREE'.
ITAB-F3 = 10.
ITAB-F4 = '1000.00'.
APPEND ITAB.
CLEAR ITAB.
ITAB-F1 = 3.
ITAB-F2 = 'THREE'.
ITAB-F3 = 20.
ITAB-F4 = '2000.00'.
APPEND ITAB.
CLEAR ITAB.
SORT ITAB BY F1.
LOOP AT ITAB.
AT FIRST.
WRITE: /35 ' MATERIAL DETAILS:'.
ULINE.
ENDAT.
AT NEW F1.
WRITE: / 'DETAILS OF MATERIAL:' COLOR 7 , ITAB-F1.
ULINE.
ENDAT.
WRITE: / ITAB-F1, ITAB-F2, ITAB-F3, ITAB-F4.
SUB_TOT = SUB_TOT + ITAB-F4.
AT END OF F1.
ULINE.
WRITE: / 'SUB TOTAL :' COLOR 3 INVERSE ON, SUB_TOT COLOR 3 INVERSE ON.
CLEAR SUB_TOT.
ENDAT.
AT LAST.
SUM.
ULINE.
WRITE: 'SUM:', ITAB-F4.
ULINE.
ENDAT.
ENDLOOP.
Similar Messages
-
WHAT IS WRONG
LOOP AT g_tab ASSIGNING <out>.
sum_open = <out>-zsum_open + sum_open.
AT END OF prctr.
ITAB1-PRCTR = <out>-prctr.
itab1-zsum_open = sum_open.
APPEND itab1.
CLEAR sum_open.
ENDAT.
ENDLOOP.
it's work but dont make at end statment
i have 3 kind of prctr
and i need to get 3 lines
i get 100 insteadHi,
what is your purpose?
do you wants to display the SUMS on the basis of Profit centers.
then use this. first Sort by prctr.
then use SUM between AT end..endat.
<b>sort g_tab by prctr.</b>
LOOP AT g_tab ASSIGNING <out>.
sum_open = <out>-zsum_open + sum_open.
AT END OF prctr.
read table g_tab index sy-tabix.
SUM.
ITAB1-PRCTR = <out>-prctr.
itab1-zsum_open = sum_open.
APPEND itab1.
CLEAR sum_open.
ENDAT.
ENDLOOP.
reward if useful
regards,
ANJI -
Doubt in control break statement
Hi All,
Is there any way to trigger control break statements at new & at end of for non primary key fields.
i want to trigger both control break statements for my requirement , not at change of, because i want to trigger at end of also. Please let me know if any possibility. Thanks
regards
vishalhi vishal,
Variants:
1. AT NEW f.
2. AT END OF f.
3. AT FIRST.
4. AT LAST.
Effect
In a LOOP which processes an internal table, 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 internal tables only if a loop is actively processing an internal table and reference is to the innermost currently active loop.
The control level structure with internal tables is static. It corresponds exactly to the sequence of columns in the internal table (from left to right). In this context, the criteria according to which you sort the internal table are unimportant.
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 character type 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 numeric fields (see also ABAP 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.
Notes
When calculating totals, you must ensure that the totals are inserted into the same sub-fields of the LOOP output area as those where the single values otherwise occur. If there is an overflow, processing terminates with a runtime error.
If an internal table is processed only in a restricted form (using the additions FROM, TO and/or WHERE with the LOOP statement), you should not use the control structures for control level processing because the interaction of a restricted LOOP with the AT statement is currenly not properly defined.
With LOOPs on extracts, there are also special control break control structures you can use.
Note
Non-Catchable Exceptions:
SUM_OVERFLOW: Overflow when calculating totals with SUM.
Variant 1
AT NEW f.
Variant 2
AT END OF f.
The syntax check performed in an ABAP Objects context is stricter than in other ABAP areas.See Compatible Work Area with Control Level Processing and Field Symbols Not Allowed as Control Level Criterion.
Effect
f is a sub-field of an internal table processed with LOOP. The sequence of statements which follow it is executed if the sub-field f or a sub-field in the current LOOP line defined (on the left) before fhas a different value than in the preceding (AT NEW) or subsequent (AT END OF) table line.
Example
TYPES: BEGIN OF COMPANIES_TYPE,
NAME(30),
PRODUCT(20),
SALES TYPE I,
END OF COMPANIES_TYPE.
DATA: COMPANIES TYPE STANDARD TABLE OF COMPANIES_TYPE WITH
NON-UNIQUE DEFAULT KEY INITIAL SIZE 20,
WA_COMPANIES TYPE COMPANIES_TYPE.
LOOP AT COMPANIES INTO WA_COMPANIES.
AT NEW NAME.
NEW-PAGE.
WRITE / WA_COMPANIES-NAME.
ENDAT.
WRITE: / WA_COMPANIES-PRODUCT, WA_COMPANIES-SALES.
AT END OF NAME.
SUM.
WRITE: / WA_COMPANIES-NAME, WA_COMPANIES-SALES.
ENDAT.
ENDLOOP.
The AT statements refer to the field COMPANIES-NAME.
Notes
If a control break criterion is not known until runtime, you can use AT NEW (name) or AT END OF (name) to specify it dynamically as the contents of the field name. If name is blank at runtime, the control break criterion is ignored and the sequence of statements is not executed. If name contains an invalid component name, a runtime error occurs.
By defining an offset and/or length, you can further restrict control break criteria - regardless of whether they are specified statically or dynamically.
A field symbol pointing to the LOOP output area can also be used as a dynamic control break criterion. If the field symbol does not point to the LOOP output area, a runtime error occurs.
If you use AT within a LOOP with an explicitly-specified output area, the area must be compatible with the line type of the internal table so that it can be initialized properly (as described above) at the start of a new control level.
You can restrict control break criteria further, regardless of whether they were defined statically or dynamically, by specifying offset and/or length.
Variant 3
AT FIRST.
Variant 4
AT LAST.
Effect
Executes the appropriate sequence of statements once during the first (AT FIRST) or last (AT LAST) loop pass.
Example
TYPES: BEGIN OF COMPANIES_TYPE,
NAME(30),
PRODUCT(20),
SALES TYPE I,
END OF COMPANIES_TYPE.
DATA: COMPANIES TYPE STANDARD TABLE OF COMPANIES_TYPE WITH
NON-UNIQUE DEFAULT KEY INITIAL SIZE 20,
WA_COMPANIES TYPE COMPANIES_TYPE.
LOOP AT COMPANIES INTO WA_COMPANIES.
AT FIRST.
SUM.
WRITE: 'Sum of all SALES:',
55 WA_COMPANIES-SALES.
ENDAT.
WRITE: / WA_COMPANIES-NAME, WA_COMPANIES-PRODUCT,
55 WA_COMPANIES-SALES.
ENDLOOP. -
Field changes on Contract Account change(CAA2).
Hi guys,
I am using BDT to add an checkbox on the Contract Account -> General Data ->
Account management data, and I want to save the change log of this field (checkbox), so after the user changed it, the user can see the change logs by clicking Extras->Field changes on the menu.
Thx in advance, points will be rewarded.
Vincent.you can control break statement is of at new and print that description what ever you want and end with endat.
thanking you -
When using control statements like AT FIRST...ENDAT.AT NEW (field).... ENDAT.
Is it necessary to define the field (thru which we r going to group the records) as a first field in internal table?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 -
Hi friends,
pls explain , what is the use of control break statements( at first, at last, at new, at end of, on change of ) ? and practical difference applying at new and on change.
Pls send me material or links related to control break statements.
Thanks in advance.
SR KHello SR K,
Just go through the following documentation.
AT - Control breaks with extracts
Variants:
1. AT NEW f.
2. AT END OF f.
3. AT FIRST.
4. AT LAST.
5. AT fg.
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 is
executed whenever a control break occurs.
You can use these key words for control break processing with
extract datasets only if the active LOOP statement is
processing 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 end of a control group (AT END OF, AT LAST), there are
two types of control level information between AT and ENDAT:
- If the sort key of the extract dataset contains a
non-numeric field h (particularly in the field group
HEADER), the field CNT(h) contains the number of control
breaks in the (subordinate) control level h.
- For extracted number fields g (see also ABAP Number Types),
the fields SUM(g) contain the relevant control totals.
Notes 1. The fields CNT(h) and SUM(g) can only be addressed after
they have been sorted. Otherwise, a runtime error may
occur.
2. The fields CNT(h) and SUM(g) are filled with the relevant
values for a control level at the end of each control group
(AT END OF, AT LAST), not at the beginning (AT FIRST, AT
NEW).
3. When calculating totals with SUM(g), the system
automatically chooses the maximum field sizes so that an
overflow occurs only if the absolute value area limits are
exceeded.
4. You can also use special control break control structures
with LOOPs on internal tables.
Variant 1 AT NEW f.
Variant 2 AT END OF f.
Effect f is a field from the field group HEADER. The enclosed
sequence of statements is executed if
- the field f occurs in the sort key of the extract dataset
(and thus also in the field group HEADER) and
- the field f or a superior sort criterion has a different
value in the current LOOP line than in the preceding (AT
NEW) or subsequent (AT END OF) record of the extract
dataset.
If f is not an assigned field symbol, the control break
criterion is ignored, and the subsequent sequence of
statements is not executed. If a field symbol is assigned, but
does not point to the HEADER field group, the system triggers
a runtime error.
Example
DATA: NAME(30),
SALES TYPE I.
FIELD-GROUPS: HEADER, INFOS.
INSERT: NAME INTO HEADER,
SALES INTO INFOS.
LOOP.
AT NEW NAME.
NEW-PAGE.
ENDAT.
AT END OF NAME.
WRITE: / NAME, SUM(SALES).
ENDAT.
ENDLOOP.
Notes 1. If the extract dataset is not sorted before processing with
LOOP, no control level structure is defined and the
statements following AT NEW or AT END OF are not executed.
2. Fields which stand at hex zero are ignored by the control
break check with AT NEW or AT END OF. This corresponds to
the behavior of the SORT statement, which always places
unoccupied fields (i.e. fields which stand at hex zero)
before all occupied fields when sorting extract datasets,
regardless of whether the sort sequence is in ascending or
descending order.
Variant 3 AT FIRST.
Variant 4 AT LAST.
Effect Executes the relevant series of statements just once - either
on the first loop pass (with AT FIRST) or on the last loop
pass (with AT LAST).
Variant 5 AT fg.
Addition:
... WITH fg1
Effect This statement makes single record processing dependent on the
type of extracted record.
The sequence of statements following AT fg are executed
whenever the current LOOP record is created with EXTRACT fg
(in other words: when the current record is a fg record).
Addition ... WITH fg1
Effect Executes the sequence of statements belonging to AT fg WITH
fg1 only if the record of the field group fg in the dataset is
immediately followed by a record of the field group fg1.
Reward If Helpful
Regards
Sasidhar Reddy Matli. -
Can anyone explain the concepts of Control break statements
Give me a small simple sample program..Hi ,
Check in 21 days of ABAP book or in abap docu.
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.
Notes
When calculating totals, you must ensure that the totals are inserted into the same sub-fields of the LOOP output area as those where the single values otherwise occur. If there is an overflow, processing terminates with a runtime error.
If an internal table is processed only in a restricted form (using the additions FROM , TO and/or WHERE with the LOOP statement), you should not use the control structures for control level processing because the interaction of a restricted LOOP with the AT statement is currenly not properly defined.
With LOOP s on extracts, there are also special control break control structures you can use.
Note
Runtime errors
SUM_OVERFLOW : Overflow when calculating totals with SUM .
Variant 1
AT NEW f.
Variant 2
AT END OF f.
Effect
f is a sub-field of an internal table processed with LOOP . The sequence of statements which follow it is executed if the sub-field f or a sub-field in the current LOOP line defined (on the left) before f has a differnt value than in the preceding ( AT NEW ) or subsequent ( AT END OF ) table line.
Example
DATA: BEGIN OF COMPANIES OCCURS 20,
NAME(30),
PRODUCT(20),
SALES TYPE I,
END OF COMPANIES.
LOOP AT COMPANIES.
AT NEW NAME.
NEW-PAGE.
WRITE / COMPANIES-NAME.
ENDAT.
WRITE: / COMPANIES-PRODUCT, COMPANIES-SALES.
AT END OF NAME.
SUM.
WRITE: / COMPANIES-NAME, COMPANIES-SALES.
ENDAT.
ENDLOOP.
The AT statements refer to the field COMPANIES-NAME .
Notes
If a control break criterion is not known until runtime, you can use AT NEW (name) or AT END OF (name) to specify it dynamically as the contents of the field name . If name is blank at runtime, the control break criterion is ignored and the sequence of statements is not executed. If name contains an invalid component name, a runtime error occurs.
By defining an offset and/or length, you can further restrict control break criteria - regardless of whether they are specified statically or dynamically.
A field symbol pointing to the LOOP output area can also be used as a dynamic control break criterion. If the field symbol does not point to the LOOP output area, a runtime error occurs.
Note
Runtime errors
AT_BAD_PARTIAL_FIELD_ACCESS : Invalid sub-field access when dynamically specifying the control break criterion.
AT_ITAB_FIELD_INVALID : When dynamically specifying the control break criterion via a field symbol, the field symbol does not point to the LOOP output area.
ITAB_ILLEGAL_COMPONENT : When dynamically specifying the control break criterion via (name) the field name does not contain a valid sub-field name.
Variant 3
AT FIRST.
Variant 4
AT LAST.
Effect
Executes the appropriate sequence of statements once during the first ( AT FIRST ) or last ( AT LAST ) loop pass.
Example
DATA: BEGIN OF COMPANIES OCCURS 20,
NAME(30),
PRODUCT(20),
SALES TYPE I,
END OF COMPANIES.
LOOP AT COMPANIES.
AT FIRST.
SUM.
WRITE: 'Sum of all SALES:',
55 COMPANIES-SALES.
ENDAT.
WRITE: / COMPANIES-NAME, COMPANIES-PRODUCT,
55 COMPANIES-SALES.
ENDLOOP.
ON CHANGE OF and AT NEW are same and we don't use On change of now.
All this AT NEW, AT FIRST, AT END OF and AT LAST are called control break statements of Internal tables and are used to calculate the TOTALS based on sertain key fields in that internal table
FIrst to use these statements the ITAB has to be sorted by the key fields on whcih you need the SUM of the fields.
Some time you will get * when mopving data from this int table to other table using these commands
so you have to use
READ TABLE ITAB INDEX SY-TABIX in AT..ENDAT..if you are using other fields between them
DATA: sflight_tab TYPE SORTED TABLE OF sflight
WITH UNIQUE KEY carrid connid fldate,
sflight_wa LIKE LINE OF sflight_tab.
SELECT *
FROM sflight
INTO TABLE sflight_tab.
LOOP AT sflight_tab INTO sflight_wa.
AT NEW connid.
WRITE: / sflight_wa-carrid,
sflight_wa-connid.
ULINE.
ENDAT.
WRITE: / sflight_wa-fldate,
sflight_wa-seatsocc.
AT END OF connid.
SUM.
ULINE.
WRITE: / 'Sum',
sflight_wa-seatsocc UNDER sflight_wa-seatsocc.
SKIP.
ENDAT.
AT END OF carrid.
SUM.
ULINE.
WRITE: / 'Carrier Sum',
sflight_wa-seatsocc UNDER sflight_wa-seatsocc.
NEW-PAGE.
ENDAT.
AT LAST.
SUM.
WRITE: / 'Overall Sum',
sflight_wa-seatsocc UNDER sflight_wa-seatsocc.
ENDAT.
ENDLOOP.
regards,
Prabhu
Reward if it is helpful -
HI
What happens if I use control break statement in between select & endselect?
ThanksHi,
They are used only with respect to Internal Tables (not between Select...endselect)to calculate Totals for Qty and Amount fields based on certain key fields
see the doc;
AT - Control break with internal tables
Variants
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.
Notes
When calculating totals, you must ensure that the totals are inserted into the same sub-fields of the LOOP output area as those where the single values otherwise occur. If there is an overflow, processing terminates with a runtime error.
If an internal table is processed only in a restricted form (using the additions FROM , TO and/or WHERE with the LOOP statement), you should not use the control structures for control level processing because the interaction of a restricted LOOP with the AT statement is currenly not properly defined.
With LOOP s on extracts, there are also special control break control structures you can use.
DATA: sflight_tab TYPE SORTED TABLE OF sflight
WITH UNIQUE KEY carrid connid fldate,
sflight_wa LIKE LINE OF sflight_tab.
SELECT *
FROM sflight
INTO TABLE sflight_tab.
LOOP AT sflight_tab INTO sflight_wa.
AT NEW connid.
WRITE: / sflight_wa-carrid,
sflight_wa-connid.
ULINE.
ENDAT.
WRITE: / sflight_wa-fldate,
sflight_wa-seatsocc.
AT END OF connid.
SUM.
ULINE.
WRITE: / 'Sum',
sflight_wa-seatsocc UNDER sflight_wa-seatsocc.
SKIP.
ENDAT.
AT END OF carrid.
SUM.
ULINE.
WRITE: / 'Carrier Sum',
sflight_wa-seatsocc UNDER sflight_wa-seatsocc.
NEW-PAGE.
ENDAT.
AT LAST.
SUM.
WRITE: / 'Overall Sum',
sflight_wa-seatsocc UNDER sflight_wa-seatsocc.
ENDAT.
ENDLOOP.
reward if useful
regards,
Anji
Message was edited by:
Anji Reddy Vangala -
Diff between AT new and on change of
hi,
can any one tell me what is the exact difference between <b>AT new</b> and <b>on change of</b>
thanks
pavanhi
good
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 is executed whenever a control break occurs.
You can use these key words for control break processing with extract datasets only if the active LOOP statement is processing 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 end of a control group ( AT END OF, AT LAST), there are two types of control level information between AT and ENDAT:
If the sort key of the extract dataset contains a non-numeric field h (particularly in the field group HEADER), the field CNT(h) contains the number of control breaks in the (subordinate) control level h.
For extracted number fields g (see also ABAP Number Types), the fields SUM(g) contain the relevant control totals.
Notes
The fields CNT(h) and SUM(g) can only be addressed after they have been sorted. Otherwise, a runtime error may occur.
The fields CNT(h) and SUM(g) are filled with the relevant values for a control level at the end of each control group ( AT END OF, AT LAST), not at the beginning (AT FIRST, AT NEW).
When calculating totals with SUM(g), the system automatically chooses the maximum field sizes so that an overflow occurs only if the absolute value area limits are exceeded.
You can also use special control break control structures with LOOPs on internal tables.
Variant 1
AT NEW f.
Variant 2
AT END OF f.
Effect
f is a field from the field group HEADER. The enclosed sequence of statements is executed if
the field f occurs in the sort key of the extract dataset (and thus also in the field group HEADER) and
the field f or a superior sort criterion has a different value in the current LOOP line than in the preceding (AT NEW) or subsequent (AT END OF) record of the extract dataset.
If f is not an assigned field symbol, the control break criterion is ignored, and the subsequent sequence of statements is not executed. If a field symbol is assigned, but does not point to the HEADER field group, the system triggers a runtime error.
Example
DATA: NAME(30),
SALES TYPE I.
FIELD-GROUPS: HEADER, INFOS.
INSERT: NAME INTO HEADER,
SALES INTO INFOS.
LOOP.
AT NEW NAME.
NEW-PAGE.
ENDAT.
AT END OF NAME.
WRITE: / NAME, SUM(SALES).
ENDAT.
ENDLOOP.
Notes
If the extract dataset is not sorted before processing with LOOP, no control level structure is defined and the statements following AT NEW or AT END OF are not executed.
Fields which stand at hex zero are ignored by the control break check with AT NEW or AT END OF. This corresponds to the behavior of the SORT statement, which always places unoccupied fields (i.e. fields which stand at hex zero) before all occupied fields when sorting extract datasets, regardless of whether the sort sequence is in ascending or descending order.
Variant 3
AT FIRST.
Variant 4
AT LAST.
Effect
Executes the relevant series of statements just once - either on the first loop pass (with AT FIRST) or on the last loop pass (with AT LAST).
Variant 5
AT fg.
Addition:
... WITH fg1
Effect
This statement makes single record processing dependent on the type of extracted record.
The sequence of statements following AT fg are executed whenever the current LOOP record is created with EXTRACT fg (in other words: when the current record is a fg record).
Addition
... WITH fg1
Effect
Executes the sequence of statements belonging to AT fg WITH fg1 only if the record of the field group fg in the dataset is immediately followed by a record of the field group fg1.
thanks
mrutyun^ -
Differnce between AT NEW AND ON CHANGE OF
Hi,
Differnce between AT NEW AND ON CHANGE OF
Iam waiting foryour reply
Thanks & Regards
Raja Sekhar.THai Raja
check the following Documents
1. AT NEW f.
2. AT END OF f.
3. AT FIRST.
4. AT LAST.
5. AT fg.
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 end of a control group ( AT END OF , AT LAST ), there are two types of control level information between AT and ENDAT :
If the sort key of the extract dataset contains a non-numeric field h (particularly in the field group HEADER ), the field CNT(h) contains the number of control breaks in the (subordinate) control level h .
For extracted number fields g (see also ABAP/4 number types ), the fields SUM(g) contain the relevant control totals.
Notes
The fields CNT(h) and SUM(g) can only be addressed after they have been sorted. Otherwise, a runtime error may occur.
The fields CNT(h) and SUM(g) are filled with the relevant values for a control level at the end of each control group ( AT END OF , AT LAST ), not at the beginning ( AT FIRST , AT NEW ).
When calculating totals with SUM(g) , the system automatically chooses the maximum field sizes so that an overflow occurs only if the absolute value area limits are exceeded.
You can also use special control break control structures with LOOP s on internal tables.
Variant 1
AT NEW f.
Variant 2
AT END OF f.
Effect
f is a field from the field group HEADER . The enclosed sequence of statements is executed if
the field f occurs in the sort key of the extract dataset (and thus also in the field group HEADER ) and
the field f or a superior sort criterion has a different value in the current LOOP line than in the prceding ( AT NEW ) or subsequent ( AT END OF ) record of the extract dataset.
Example
DATA: NAME(30),
SALES TYPE I.
FIELD-GROUPS: HEADER, INFOS.
INSERT: NAME INTO HEADER,
SALES INTO INFOS.
LOOP.
AT NEW NAME.
NEW-PAGE.
ENDAT.
AT END OF NAME.
WRITE: / NAME, SUM(SALES).
ENDAT.
ENDLOOP.
Notes
If the extract dataset is not sorted before processing with LOOP , no control level structure is defined and the statements following AT NEW or AT END OF are not executed.
Fields which stand at hex zero are ignored by the control break check with AT NEW or AT END OF . This corresponds to the behavior of the SORT statement, which always places unoccupied fields (i.e. fields which stand at hex zero) before all occupied fields when sorting extract datasets, regardless of whether the sort sequence is in ascending or descending order.
Variant 3
AT FIRST.
Variant 4
AT LAST.
Effect
Executes the relevant series of statements just once - either on the first loop pass (with AT FIRST ) or on the last loop pass (with AT LAST ).
Variant 5
AT fg.
Addition
... WITH fg1
Effect
This statement makes single record processing dependent on the type of extracted record.
The sequence of statements following AT fg are executed whenever the current LOOP record is created with EXTRACT fg (in other words: when the current record is a fg record).
Addition
... WITH fg1
Effect
Executes the sequence of statements belonging to AT fg WITH fg1 only if the record of the field group fg in the dataset is immediately followed by a record of the field group fg1 .
Basic form
ON CHANGE OF f.
Addition
... OR f1
Effect
Executes the processing block enclosed by the " ON CHANGE OF f " and " ENDON " statements whenever the contents of the field f change (control break processing).
Normally, you use the statement to manipulate database fields during GET events or SELECT / ENDSELECT processing.
Note
There are special control structures for processing control breaks in LOOP s on internal tables or extract datasets AT ).
ON CHANGE OF is unsuitable for recognizing control levels in loops of this type because it always creates a global auxiliary field which is used to check for changes. This global auxiliary field can only be changed in the relevant ON CHANGE OF statement. It is not reset when the processing goes into loops or subroutines, so unwanted effects can occur if the loop or subroutine is executed again. Also, since it is set to its initial value when created (like any other field), any ON CHANGE OF processing will be executed after the first test, unless the contents of the field concerned happen to be identical to the initial value.
Example
TABLES T100.
SELECT * FROM T100 WHERE SPRSL = SY-LANGU AND
MSGNR < '010'
ORDER BY PRIMARY KEY.
ON CHANGE OF T100-ARBGB.
ULINE.
WRITE: / '**', T100-ARBGB, '**'.
ENDON.
WRITE: / T100-MSGNR, T100-TEXT.
ENDSELECT.
Displays all messages with their numbers in the logon language, provided the number is less than '010'.
Each time the message class changes, it is output.
Addition
... OR f1
Effect
Also executes the code whenever the contents of the field f1 changes.
You can use this addition several times.
Example
Logical database F1S
TABLES: SPFLI, SFLIGHT, SBOOK.
GET SBOOK.
ON CHANGE OF SPFLI-CARRID OR
SPFLI-CONNID OR
SFLIGHT-FLDATE.
ULINE.
WRITE: /5 SPFLI-CARRID, SPFLI-CONNID,
5 SFLIGHT-FLDATE, SPFLI-FLTIME,
5 SFLIGHT-SEATSMAX, SFLIGHT-SEATSOCC.
ENDON.
WRITE: / SBOOK-CUSTOMID.
The code between ON CHANGE OF and ENDON is executed only if at least one of the fields SPFLI-CARRID , SPFLI-CONNID or SFLIGHT-FLDATE has changed, i.e. there is a different flight connection (which also has bookings).
Notes
Thanks & regards
Sreenivasulu P -
what is the AT EVENT in CONTROL BRK EVENTS
Hi,
Check this out -
AT - Control breaks with internal tables
Variants:
AT NEW f.
AT END OF f.
AT FIRST.
AT LAST.
Effect
In a LOOP which processes an internal table, 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 internal tables only if a loop is actively processing an internal table and reference is to the innermost currently active loop.
The control level structure with internal tables is static. It corresponds exactly to the sequence of columns in the internal table (from left to right). In this context, the criteria according to which you sort the internal table are unimportant.
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 character type 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 numeric fields (see also ABAP 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.
Notes
1. When calculating totals, you must ensure that the totals are inserted into the same sub-fields of the LOOP output area as those where the single values otherwise occur. If there is an overflow, processing terminates with a runtime error.
2. If an internal table is processed only in a restricted form (using the additions FROM, TO and/or WHERE with the LOOP statement), you should not use the control structures for control level processing because the interaction of a restricted LOOP with the AT statement is currenly not properly defined.
3. With LOOPs on extracts, there are also special control break control structures you can use.
Note
Non-Catchable Exceptions:
SUM_OVERFLOW: Overflow when calculating totals with SUM.
Variant 1
AT NEW f.
Variant 2
AT END OF f.
Compatible Work Area with Control Level Processing and Field Symbols Not Allowed as Control Level Criterion.
Effect
f is a sub-field of an internal table processed with LOOP. The sequence of statements which follow it is executed if the sub-field f or a sub-field in the current LOOP line defined (on the left) before f has a different value than in the preceding ( AT NEW) or subsequent (AT END OF) table line.
Example
TYPES: BEGIN OF COMPANIES_TYPE,
NAME(30),
PRODUCT(20),
SALES TYPE I,
END OF COMPANIES_TYPE.
DATA: COMPANIES TYPE STANDARD TABLE OF COMPANIES_TYPE WITH
NON-UNIQUE DEFAULT KEY INITIAL SIZE 20,
WA_COMPANIES TYPE COMPANIES_TYPE.
LOOP AT COMPANIES INTO WA_COMPANIES.
AT NEW NAME.
NEW-PAGE.
WRITE / WA_COMPANIES-NAME.
ENDAT.
WRITE: / WA_COMPANIES-PRODUCT, WA_COMPANIES-SALES.
AT END OF NAME.
SUM.
WRITE: / WA_COMPANIES-NAME, WA_COMPANIES-SALES.
ENDAT.
ENDLOOP.
The AT statements refer to the field COMPANIES-NAME.
Notes
1. If a control break criterion is not known until runtime, you can use AT NEW (name) or AT END OF (name) to specify it dynamically as the contents of the field name. If name is blank at runtime, the control break criterion is ignored and the sequence of statements is not executed. If name contains an invalid component name, a runtime error occurs.
2. By defining an offset and/or length, you can further restrict control break criteria - regardless of whether they are specified statically or dynamically.
3. A field symbol pointing to the LOOP output area can also be used as a dynamic control break criterion. If the field symbol does not point to the LOOP output area, a runtime error occurs.
If you use AT within a LOOP with an explicitly-specified output area, the area must be compatible with the line type of the internal table so that it can be initialized properly (as described above) at the start of a new control level.
You can restrict control break criteria further, regardless of whether they were defined statically or dynamically, by specifying offset and/or length.
Note
Non-Catchable Exceptions:
AT_BAD_PARTIAL_FIELD_ACCESS: Invalid sub-field access when dynamically specifying the control break criterion.
AT_ITAB_FIELD_INVALID: When dynamically specifying the control break criterion via a field symbol, the field symbol does not point to the LOOP output area.
ITAB_ILLEGAL_COMPONENT: When dynamically specifying the control break criterion via (name) the field (name) does not contain a valid sub-field name.
Variant 3
AT FIRST.
Variant 4
AT LAST.
Effect
Executes the appropriate sequence of statements once during the first ( AT FIRST) or last (AT LAST) loop pass.
Example
TYPES: BEGIN OF COMPANIES_TYPE,
NAME(30),
PRODUCT(20),
SALES TYPE I,
END OF COMPANIES_TYPE.
DATA: COMPANIES TYPE STANDARD TABLE OF COMPANIES_TYPE WITH
NON-UNIQUE DEFAULT KEY INITIAL SIZE 20,
WA_COMPANIES TYPE COMPANIES_TYPE.
LOOP AT COMPANIES INTO WA_COMPANIES.
AT FIRST.
SUM.
WRITE: 'Sum of all SALES:',
55 WA_COMPANIES-SALES.
ENDAT.
WRITE: / WA_COMPANIES-NAME, WA_COMPANIES-PRODUCT,
55 WA_COMPANIES-SALES.
ENDLOOP.
ashish -
This is a two part exercise...
1. Complete ABAP program zstudent_registration. The program will display the first level list. The list consists of fields:
<i>course_id
course_name
course_type
programme </i>
(The records come from the database table zshafeek_course.)
2. The second level list consists of students registered for a course selected from the first level list. The tables involved is zshafeeek_student_registered.
The fields in the zshafeek_student_registered are:
<i>course_id
student_id
student_name
student_major</i>
The fields that need to be displayed on the list are:
<b> student_id
student_name
student_major</b>
(List the modifications with its ABAP statements required in program zstudent_registraton in order to generate the detail list).
Ive already done it, just need to compare it with someone else's for correctness' purposes...
Any help?I got ur point and everything looks good with respect logic..
Now you want to display header level and item level type list.
Then use Example program,you will get good idea in ALV.
Program : BCALV_TEST_HIERSEQ_LIST
Main FM : REUSE_ALV_HIERSEQ_LIST_DISPLAY
if you want to display in normal way ,then use Internal table events
AT first
endat
at new
enat
at end of
endat.
at last
endat.
Reward Points if it is useful
Thanks
Seshu -
What are the internal table events
hi experts
can u help me for thisHi ramesh,
There are basically internal table events are as below...
at first / endat
at last / endat
at new / endat
at end of / endat
sum
on change of / endon
Use the at first and at last statements to perform processing during the first or last loop pass of an internal table.
Use the at new and at end of statements to detect a change in a column from one loop pass to the next. These statements enable you to execute code at the beginning and end of a group of records.
Use the sum statement to calculate totals for the rows of a control level.
Another statement you can use to perform control break processing is on change of. It behaves in a manner similar to at new.
on change of differs from at new in the following respects:
It can be used in any loop construct, not just loop at. For example, it can be used within select and endselect, do and enddo, or while and endwhile, as well as inside get events.
A single on change of can be triggered by a change within one or more fields named after of and separated by or. These fields can be elementary fields or field strings. If you are within a loop, these fields do not have to belong to the loop.
When used within a loop, a change in a field to the left of the control level does not trigger a control break.
When used within a loop, fields to the right still contain their original values; they are not changed to contain zeros or asterisks.
You can use else between on change of and endon.
You can use it with loop at it where . . ..
You can use sum with on change of. It sums all numeric fields except the one(s) named after of.
Any values changed within on change of remain changed after endon. The contents of the header line are not restored as they are for at and endat.
<b>Reward Points if it useful....</b>
Thanks and Regards
Sreenivasa sharma k. -
hai everyone, plz tell me where should we use the control break statments in the reports i want format of the reports
After you fill an internal table with data, you often need to write the data out. This output will frequently contain summary information (such as totals) at the top or bottom of the report. There might also be interim summaries (such as subtotals) within the body of the report.
For example, suppose you need to write the G/L figures from ztxlfc1 for each vendor, with subtotals by fiscal year and a grand total at the bottom of the report.
To do this, you can read the data into an internal table and then, within loop at, use the following statements:
at first / endat
at last / endat
at new / endat
at end of / endat
sum
on change of / endon
on change of differs from at new in the following respects:
It can be used in any loop construct, not just loop at. For example, it can be used within select and endselect, do and enddo, or while and endwhile, as well as inside get events.
A single on change of can be triggered by a change within one or more fields named after of and separated by or. These fields can be elementary fields or field strings. If you are within a loop, these fields do not have to belong to the loop.
When used within a loop, a change in a field to the left of the control level does not trigger a control break.
When used within a loop, fields to the right still contain their original values; they are not changed to contain zeros or asterisks.
You can use else between on change of and endon.
You can use it with loop at it where . . ..
You can use sum with on change of. It sums all numeric fields except the one(s) named after of.
Any values changed within on change of remain changed after endon. The contents of the header line are not restored as they are for at and endat.
Using on change of in Two Different Ways: Inside of loop at and Inside of select
report ztx1312.
tables ztxlfa1.
data: begin of it occurs 4,
f1 type i,
f2,
f3 type i,
f4,
end of it.
it-f1 = 1. it-f2 = 'A'. it-f3 = 11. it-f4 = 'W'. append it.
it-f1 = 3. it-f2 = 'A'. it-f3 = 22. it-f4 = 'X'. append it.
it-f1 = 1. it-f2 = 'A'. it-f3 = 33. it-f4 = 'Y'. append it.
it-f1 = 2. it-f2 = 'A'. it-f3 = 44. it-f4 = 'Z'. append it.
loop at it.
on change of it-f2.
write: / it-f1, it-f2, it-f3, it-f4.
endon.
endloop.
write: / 'End of loop'.
executing the same code again - the aux field still contains 'A'
loop at it.
at first.
write: / 'Looping without a reset...'.
endat.
on change of it-f2.
write: / it-f1, it-f2, it-f3, it-f4.
else.
write: / 'on change of not triggered for row', sy-tabix.
endon.
endloop.
write: / 'End of loop'.
*reset the aux field to blanks
clear it-f2.
on change of it-f2.
endon.
loop at it.
at first.
write: / 'Looping after reset...'.
endat.
on change of it-f2.
write: / it-f1, it-f2, it-f3, it-f4.
endon.
endloop.
write: / 'End of loop'.
free it.
select * from ztxlfa1 where land1 = 'US'.
on change of ztxlfa1-land1.
write: / 'land1=', ztxlfa1-land1.
endon.
endselect.
write: / 'End of select'.
*executing the same select again without a reset works find
select * from ztxlfa1 where land1 = 'US'.
on change of ztxlfa1-land1.
write: / 'land1=', ztxlfa1-land1.
endon.
endselect.
write: / 'End of select'.
O/p :
1 A 11 W
End of loop
Looping without a reset...
on change of not triggered for row 2
on change of not triggered for row 3
on change of not triggered for row 4
End of loop
Looping after reset...
1 A 11 W
End of loop
land1= US
End of select
land1= US
End of select -
Hi everyone
I need to calculate some totals in an itab and have discivered the SUM statement, which seems a very easy way to achieve this. However, being a cynical chap I was wondering if this carries a large overhead and will be less efficient than just storing a running total in a variable i.e x = x + y.
I anybody able to shed any light...?
Thanks
AndySUM.
Effect
When processing an internal table in a block starting with LOOP and concluded by ENDLOOP , SUM calculates the control totals of all fields of type I , F and P (see also ABAP/4 number types ) and places them in the LOOP output area (header line of the internal table or an explicitly specified work area).
Sum statement in report is basically used in Control Break Processing.
After you fill an internal table with data, you often need to write the data out. This output will frequently contain summary information(uch as totals) at the top or bottom of the report.There might also be interim situations (such as subtotals ) within the body of report.
To do this , you can read the data into an internal table and then, within loop at , use the following statements:
1. at first / endat
2.at last / endat
3.at new / endat
4.at end of / endat
5.sum
6.on change of / endon.
The first statement of each of these pairs - except for Sum - controls when the code lies between them is executed.This type of control is called a control break.Their purpose is to ececute the code between them whenever a specific condition in the data is detected during the processing of the loop.
Using the Sum statement :
syntax :
at first/last/new/end of.
sum
endat.
where :
... represents any number of lines of code.
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 of 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. -
Pse give me the document on control structures
any body have document on control structures pse send me
(at new,at end,on change of,at start ,at last)If it is control break statements.... then here is the types and explanation
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.
Notes
When calculating totals, you must ensure that the totals are inserted into the same sub-fields of the LOOP output area as those where the single values otherwise occur. If there is an overflow, processing terminates with a runtime error.
If an internal table is processed only in a restricted form (using the additions FROM , TO and/or WHERE with the LOOP statement), you should not use the control structures for control level processing because the interaction of a restricted LOOP with the AT statement is currenly not properly defined.
With LOOP s on extracts, there are also special control break control structures you can use.
Note
Runtime errors
SUM_OVERFLOW : Overflow when calculating totals with SUM .
Variant 1
AT NEW f.
Variant 2
AT END OF f.
Effect
f is a sub-field of an internal table processed with LOOP . The sequence of statements which follow it is executed if the sub-field f or a sub-field in the current LOOP line defined (on the left) before f has a differnt value than in the preceding ( AT NEW ) or subsequent ( AT END OF ) table line.
Example
DATA: BEGIN OF COMPANIES OCCURS 20,
NAME(30),
PRODUCT(20),
SALES TYPE I,
END OF COMPANIES.
LOOP AT COMPANIES.
AT NEW NAME.
NEW-PAGE.
WRITE / COMPANIES-NAME.
ENDAT.
WRITE: / COMPANIES-PRODUCT, COMPANIES-SALES.
AT END OF NAME.
SUM.
WRITE: / COMPANIES-NAME, COMPANIES-SALES.
ENDAT.
ENDLOOP.
The AT statements refer to the field COMPANIES-NAME .
Notes
If a control break criterion is not known until runtime, you can use AT NEW (name) or AT END OF (name) to specify it dynamically as the contents of the field name . If name is blank at runtime, the control break criterion is ignored and the sequence of statements is not executed. If name contains an invalid component name, a runtime error occurs.
By defining an offset and/or length, you can further restrict control break criteria - regardless of whether they are specified statically or dynamically.
A field symbol pointing to the LOOP output area can also be used as a dynamic control break criterion. If the field symbol does not point to the LOOP output area, a runtime error occurs.
Note
Runtime errors
AT_BAD_PARTIAL_FIELD_ACCESS : Invalid sub-field access when dynamically specifying the control break criterion.
AT_ITAB_FIELD_INVALID : When dynamically specifying the control break criterion via a field symbol, the field symbol does not point to the LOOP output area.
ITAB_ILLEGAL_COMPONENT : When dynamically specifying the control break criterion via (name) the field name does not contain a valid sub-field name.
Variant 3
AT FIRST.
Variant 4
AT LAST.
Effect
Executes the appropriate sequence of statements once during the first ( AT FIRST ) or last ( AT LAST ) loop pass.
Example
DATA: BEGIN OF COMPANIES OCCURS 20,
NAME(30),
PRODUCT(20),
SALES TYPE I,
END OF COMPANIES.
LOOP AT COMPANIES.
AT FIRST.
SUM.
WRITE: 'Sum of all SALES:',
55 COMPANIES-SALES.
ENDAT.
WRITE: / COMPANIES-NAME, COMPANIES-PRODUCT,
55 COMPANIES-SALES.
ENDLOOP.
ON CHANGE OF f.
Executes the processing block enclosed by the "ON CHANGE OF f" and "ENDON" statements whenever the contents of the field f change (control break processing).
Normally, you use the statement to manipulate database fields during GET events or SELECT/ENDSELECT processing.
ON CHANGE OF is unsuitable for recognizing control levels in loops of this type because it always creates a global auxiliary field which is used to check for changes. This global auxiliary field is only changed in the relevant ON CHANGE OF statement. It is not reset when the processing enters loops or subroutines, so unwanted effects can occur if the loop or subroutine is executed again. Also, since it is set to its initial value when created (like any other field), any ON CHANGE OF processing will be executed after the first test, unless the contents of the field concerned happen to be identical to the initial value.
DATA T100_WA TYPE T100.
SELECT * FROM T100
INTO T100_WA
WHERE SPRSL = SY-LANGU AND
MSGNR < '
ORDER BY PRIMARY KEY.
ON CHANGE OF T100_WA-ARBGB.
ULINE.
WRITE: / '**', T100_WA-ARBGB, '**'.
ENDON.
WRITE: / T100_WA-MSGNR, T100_WA-TEXT.
ENDSELECT.
Displays all messages with their numbers in the logon language, provided the number is less than '010'.
Each time the message class changes, it is output.
AT END OF f.
f is a sub-field of an internal table or extract dataset (EXTRACT) which is being processed with LOOP, i.e. the variants 1 and 2 only make sense within a LOOP.
Both "AT NEW f." and "AT END OF f. " introduce processing blocks which are concluded by " ENDAT.".
These processing blocks are processed whenever the contents of a field f or a sub-field defined before f change as a result of processing with LOOP. "AT NEW f." begins a new group of (table) lines with the same contents as the field f while "AT END OF f." concludes such a group.
Within the AT ... ENDAT processing of internal tables, all argument fields following f are filled with "*".
Examples
1. AT for sub-fields of an internal table
DATA: BEGIN OF COMPANIES OCCURS 20,
NAME(30),
PRODUCT(20),
SALES TYPE I,
END OF COMPANIES.
LOOP AT COMPANIES.
AT NEW NAME.
NEW-PAGE.
WRITE / COMPANIES-NAME.
ENDAT.
WRITE: / COMPANIES-PRODUCT, COMPANIES-SALES.
AT END OF NAME.
SUM.
WRITE: / COMPANIES-NAME, COMPANIES-SALES.
ENDAT.
ENDLOOP.
The AT statements refer to the field COMPANIES-NAME.
Maybe you are looking for
-
* Values for Billing QTY in a Report
Dear SDN, I am getting some values for Billing Qty as star (*)...in a Credit memos Report (SD).. I am using 0SD_C03 InfoCube.. I have checked in the PSA also.. Data is available... Some value should come...but * is coming Help will be greatly appreci
-
in sql we use sysdate in dual to display the system date like wise how to display the system time since i am a beginner i need ur help please.
-
Can I update the number of processes, cache etc per workshift via backend
Hi everyone, after cloning from PROD to a TEST environment, i'd like to be able to reduce the number of concurrent processes and the cache size for the standard manager to a lower number. Most of my post cloning steps are automated through a script,
-
MOVED: I need information about certin mainbord name
This topic has been moved to Off-Topic Technical. https://forum-en.msi.com/index.php?topic=132871.0
-
Hi expert. I have this problem. I have the rol SAP_EMPLOYEE_XX_ESS_WDA_1, in NWBC show the service absence, but I need know which is the service?. which is The web dynpro component or application web dynpro? I need show this service in the portal(ja