2007 Jul 20 7:09 AM
2007 Jul 20 7:12 AM
at first is used for control level processing in internal tables whereas start of selection is event used for fetching data from database table.
2007 Jul 20 7:12 AM
at first is used for control level processing in internal tables whereas start of selection is event used for fetching data from database table.
2007 Jul 20 7:14 AM
2007 Jul 20 7:41 AM
Hi Aarif,
1. At first is a condition break statement where as At Selection-screen is a event in which we can write select query.
2. At fist is bascially used inside a loop to trigger the conditons at each new entry.
For eg You have the following data :
Fileds S. No A B
1. 1 2
2. 1 2
3. 2 2
4. 3 4
5. 3 2
Now if you use command AT NEW B , then the system will take S.R No 3rd instead of Serial No 4th because it will take the combination of fields A and B.
where as if the data is like this:
Fileds S. No A B
1. 2 1
2. 2 1
3. 2 2
4. 3 4
5. 3 2
Now if you use AT NEW A the system will take 4th record.
. At new is used inside a Loop whereas AT SELCTION SCREEN is used outside a loop.
I can tell you only these points 😊
Rewards Point if helpful.
Regards
Sourabh Verma
2007 Jul 20 7:20 AM
<b>START-OF-SELECTION</b>
This event occurs after the selection screen has been processed and before data is read using the logical database. You can use it to prepare for reading data and creating the list by, for example, setting values for internal fields and writing introductory notes on the output list.
In an executable program, any non-declarative statements that occur between the REPORT or PROGRAM statement and the first processing block are also processed in the START-OF-SELECTION block
<b>Processing Control Levels</b>
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:
<b>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.
</b>
You do not have to use all of the statement blocks listed here, but only the ones you require.
<b>Example</b>
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.
Regards,
Pavan
2007 Jul 20 7:27 AM
hi Aarif
<b>Start-of-Selection.</b>
Here the program starts selecting values from tables.
<b>at first - endat</b>
Processed at the beginning of the table .
Executes the relevant series of statements just once
example
DATA: BEGIN OF T OCCURS 100,
CODE(4),
SALES TYPE P,
DISCOUNT TYPE P,
END OF T.
LOOP AT T.
AT FIRST.
SUM.
WRITE: /4 'Grand Total:',
20 T-SALES, 40 T-DISCOUNT. ULINE.
SKIP.
ENDAT.
WRITE: / T-CODE,
20 T-SALES, 40 T-DISCOUNT.
AT END OF CODE.
SUM.
WRITE: / T-CODE, 10 'Total:',
20 T-SALES, 40 T-DISCOUNT.
SKIP.
ENDAT.
ENDLOOP.
regards
ravish
<b>
reward if useful</b>
2007 Jul 20 7:30 AM
3 differences can be:
1. At First condition is driven by the data in internal table. At selection screen is condition driven by the User when he enters the data on the selection screen.
2. at first is used for control level processing in internal tables whereas start of selection is event used for fetching data from database table. (as writen by abapuser)
3. At First does not have any addition parameters like at Selection screen where we can use at selection sceen on <field_name>
Award Points if useful.
2007 Jul 20 7:55 AM
hi Aarif
the main difference between Start-of -selection and at first is that...
AT FIRST :
In the group level AT FIRST, the current group key contains no components and all character-type components of the work area wa are filled with "*" and all remaining components are set to their initial value.
START-OF-SELECTION:
if is triggered after the selection screen appears...as soon as this event is triggered the select queries start processing and the output will be executed.
The first program contains an explicit event block START-OF-SELECTION and shows the recommended spelling.
REPORT test_start_of_selection.
DATA text TYPE string.
START-OF-SELECTION.
text = `Hello World!`.
WRITE text.
In the second program, an assignment is inserted before the first processing block, which forms a second implicit event block START-OF-SELECTION before the explicit event block.
REPORT test_start_of_selection.
DATA text TYPE string.
text = `Hello World!`.
START-OF-SELECTION.
WRITE text.
In the third program, there is no explicit processing block. All statements implicitly form the event block START-OF-SELECTION.
REPORT test_start_of_selection.
DATA text TYPE string.
text = `Hello World!`.
WRITE text.
The third program has exactly the same meaning as the first program. The second program, in contrast, would have the following form if expressed explicitly:
REPORT test_start_of_selection.
DATA text TYPE string.
START-OF-SELECTION.
text = `Hello World!`.
START-OF-SELECTION.
WRITE text.
This means that if the second program contained a WRITE statement before the explicit event block, it would behave differently to the first or third programs with the same WRITE statement, as the statement NEW-LINE is executed at the end of the implicit event block.
The first program contains an explicit event block START-OF-SELECTION and shows the recommended spelling.
REPORT test_start_of_selection.
DATA text TYPE string.
START-OF-SELECTION.
text = `Hello World!`.
WRITE text.
In the second program, an assignment is inserted before the first processing block, which forms a second implicit event block START-OF-SELECTION before the explicit event block.
REPORT test_start_of_selection.
DATA text TYPE string.
text = `Hello World!`.
START-OF-SELECTION.
WRITE text.
In the third program, there is no explicit processing block. All statements implicitly form the event block START-OF-SELECTION.
REPORT test_start_of_selection.
DATA text TYPE string.
text = `Hello World!`.
WRITE text.
The third program has exactly the same meaning as the first program. The second program, in contrast, would have the following form if expressed explicitly:
REPORT test_start_of_selection.
DATA text TYPE string.
START-OF-SELECTION.
text = `Hello World!`.
START-OF-SELECTION.
WRITE text.
This means that if the second program contained a WRITE statement before the explicit event block, it would behave differently to the first or third programs with the same WRITE statement, as the statement NEW-LINE is executed at the end of the implicit event block.
The first program contains an explicit event block START-OF-SELECTION and shows the recommended spelling.
REPORT test_start_of_selection.
DATA text TYPE string.
START-OF-SELECTION.
text = `Hello World!`.
WRITE text.
In the second program, an assignment is inserted before the first processing block, which forms a second implicit event block START-OF-SELECTION before the explicit event block.
REPORT test_start_of_selection.
DATA text TYPE string.
text = `Hello World!`.
START-OF-SELECTION.
WRITE text.
In the third program, there is no explicit processing block. All statements implicitly form the event block START-OF-SELECTION.
REPORT test_start_of_selection.
DATA text TYPE string.
text = `Hello World!`.
WRITE text.
The third program has exactly the same meaning as the first program. The second program, in contrast, would have the following form if expressed explicitly:
REPORT test_start_of_selection.
DATA text TYPE string.
START-OF-SELECTION.
text = `Hello World!`.
START-OF-SELECTION.
WRITE text.
This means that if the second program contained a WRITE statement before the explicit event block, it would behave differently to the first or third programs with the same WRITE statement, as the statement NEW-LINE is executed at the end of the implicit event block.
The first program contains an explicit event block START-OF-SELECTION and shows the recommended spelling.
REPORT test_start_of_selection.
DATA text TYPE string.
START-OF-SELECTION.
text = `Hello World!`.
WRITE text.
In the second program, an assignment is inserted before the first processing block, which forms a second implicit event block START-OF-SELECTION before the explicit event block.
REPORT test_start_of_selection.
DATA text TYPE string.
text = `Hello World!`.
START-OF-SELECTION.
WRITE text.
In the third program, there is no explicit processing block. All statements implicitly form the event block START-OF-SELECTION.
REPORT test_start_of_selection.
DATA text TYPE string.
text = `Hello World!`.
WRITE text.
The third program has exactly the same meaning as the first program. The second program, in contrast, would have the following form if expressed explicitly:
REPORT test_start_of_selection.
DATA text TYPE string.
START-OF-SELECTION.
text = `Hello World!`.
START-OF-SELECTION.
WRITE text.
This means that if the second program contained a WRITE statement before the explicit event block, it would behave differently to the first or third programs with the same WRITE statement, as the statement NEW-LINE is executed at the end of the implicit event block.
The first program contains an explicit event block START-OF-SELECTION and shows the recommended spelling.
REPORT test_start_of_selection.
DATA text TYPE string.
START-OF-SELECTION.
text = `Hello World!`.
WRITE text.
In the second program, an assignment is inserted before the first processing block, which forms a second implicit event block START-OF-SELECTION before the explicit event block.
REPORT test_start_of_selection.
DATA text TYPE string.
text = `Hello World!`.
START-OF-SELECTION.
WRITE text.
In the third program, there is no explicit processing block. All statements implicitly form the event block START-OF-SELECTION.
REPORT test_start_of_selection.
DATA text TYPE string.
text = `Hello World!`.
WRITE text.
The third program has exactly the same meaning as the first program. The second program, in contrast, would have the following form if expressed explicitly:
REPORT test_start_of_selection.
DATA text TYPE string.
START-OF-SELECTION.
text = `Hello World!`.
START-OF-SELECTION.
WRITE text.
This means that if the second program contained a WRITE statement before the explicit event block, it would behave differently to the first or third programs with the same WRITE statement, as the statement NEW-LINE is executed at the end of the implicit event block.
The first program contains an explicit event block START-OF-SELECTION and shows the recommended spelling.
REPORT test_start_of_selection.
DATA text TYPE string.
START-OF-SELECTION.
text = `Hello World!`.
WRITE text.
In the second program, an assignment is inserted before the first processing block, which forms a second implicit event block START-OF-SELECTION before the explicit event block.
REPORT test_start_of_selection.
DATA text TYPE string.
text = `Hello World!`.
START-OF-SELECTION.
WRITE text.
In the third program, there is no explicit processing block. All statements implicitly form the event block START-OF-SELECTION.
REPORT test_start_of_selection.
DATA text TYPE string.
text = `Hello World!`.
WRITE text.
The third program has exactly the same meaning as the first program. The second program, in contrast, would have the following form if expressed explicitly:
REPORT test_start_of_selection.
DATA text TYPE string.
START-OF-SELECTION.
text = `Hello World!`.
START-OF-SELECTION.
WRITE text.
This means that if the second program contained a WRITE statement before the explicit event block, it would behave differently to the first or third programs with the same WRITE statement, as the statement NEW-LINE is executed at the end of the implicit event block.
The first program contains an explicit event block START-OF-SELECTION and shows the recommended spelling.
REPORT test_start_of_selection.
DATA text TYPE string.
START-OF-SELECTION.
text = `Hello World!`.
WRITE text.
In the second program, an assignment is inserted before the first processing block, which forms a second implicit event block START-OF-SELECTION before the explicit event block.
REPORT test_start_of_selection.
DATA text TYPE string.
text = `Hello World!`.
START-OF-SELECTION.
WRITE text.
In the third program, there is no explicit processing block. All statements implicitly form the event block START-OF-SELECTION.
REPORT test_start_of_selection.
DATA text TYPE string.
text = `Hello World!`.
WRITE text.
The third program has exactly the same meaning as the first program. The second program, in contrast, would have the following form if expressed explicitly:
REPORT test_start_of_selection.
DATA text TYPE string.
START-OF-SELECTION.
text = `Hello World!`.
START-OF-SELECTION.
WRITE text.
This means that if the second program contained a WRITE statement before the explicit event block, it would behave differently to the first or third programs with the same WRITE statement, as the statement NEW-LINE is executed at the end of the implicit event block.
The first program contains an explicit event block START-OF-SELECTION and shows the recommended spelling.
REPORT test_start_of_selection.
DATA text TYPE string.
START-OF-SELECTION.
text = `Hello World!`.
WRITE text.
In the second program, an assignment is inserted before the first processing block, which forms a second implicit event block START-OF-SELECTION before the explicit event block.
REPORT test_start_of_selection.
DATA text TYPE string.
text = `Hello World!`.
START-OF-SELECTION.
WRITE text.
In the third program, there is no explicit processing block. All statements implicitly form the event block START-OF-SELECTION.
REPORT test_start_of_selection.
DATA text TYPE string.
text = `Hello World!`.
WRITE text.
The third program has exactly the same meaning as the first program. The second program, in contrast, would have the following form if expressed explicitly:
REPORT test_start_of_selection.
DATA text TYPE string.
START-OF-SELECTION.
text = `Hello World!`.
START-OF-SELECTION.
WRITE text.
This means that if the second program contained a WRITE statement before the explicit event block, it would behave differently to the first or third programs with the same WRITE statement, as the statement NEW-LINE is executed at the end of the implicit event block.
The first program contains an explicit event block START-OF-SELECTION and shows the recommended spelling.
REPORT test_start_of_selection.
DATA text TYPE string.
START-OF-SELECTION.
text = `Hello World!`.
WRITE text.
In the second program, an assignment is inserted before the first processing block, which forms a second implicit event block START-OF-SELECTION before the explicit event block.
REPORT test_start_of_selection.
DATA text TYPE string.
text = `Hello World!`.
START-OF-SELECTION.
WRITE text.
In the third program, there is no explicit processing block. All statements implicitly form the event block START-OF-SELECTION.
REPORT test_start_of_selection.
DATA text TYPE string.
text = `Hello World!`.
WRITE text.
The third program has exactly the same meaning as the first program. The second program, in contrast, would have the following form if expressed explicitly:
REPORT test_start_of_selection.
DATA text TYPE string.
START-OF-SELECTION.
text = `Hello World!`.
START-OF-SELECTION.
WRITE text.
This means that if the second program contained a WRITE statement before the explicit event block, it would behave differently to the first or third programs with the same WRITE statement, as the statement NEW-LINE is executed at the end of the implicit event block.
The first program contains an explicit event block START-OF-SELECTION and shows the recommended spelling.
REPORT test_start_of_selection.
DATA text TYPE string.
START-OF-SELECTION.
text = `Hello World!`.
WRITE text.
In the second program, an assignment is inserted before the first processing block, which forms a second implicit event block START-OF-SELECTION before the explicit event block.
REPORT test_start_of_selection.
DATA text TYPE string.
text = `Hello World!`.
START-OF-SELECTION.
WRITE text.
In the third program, there is no explicit processing block. All statements implicitly form the event block START-OF-SELECTION.
REPORT test_start_of_selection.
DATA text TYPE string.
text = `Hello World!`.
WRITE text.
The third program has exactly the same meaning as the first program. The second program, in contrast, would have the following form if expressed explicitly:
REPORT test_start_of_selection.
DATA text TYPE string.
START-OF-SELECTION.
text = `Hello World!`.
START-OF-SELECTION.
WRITE text.
This means that if the second program contained a WRITE statement before the explicit event block, it would behave differently to the first or third programs with the same WRITE statement, as the statement NEW-LINE is executed at the end of the implicit event block.
The first program contains an explicit event block START-OF-SELECTION and shows the recommended spelling.
REPORT test_start_of_selection.
DATA text TYPE string.
START-OF-SELECTION.
text = `Hello World!`.
WRITE text.
In the second program, an assignment is inserted before the first processing block, which forms a second implicit event block START-OF-SELECTION before the explicit event block.
REPORT test_start_of_selection.
DATA text TYPE string.
text = `Hello World!`.
START-OF-SELECTION.
WRITE text.
In the third program, there is no explicit processing block. All statements implicitly form the event block START-OF-SELECTION.
REPORT test_start_of_selection.
DATA text TYPE string.
text = `Hello World!`.
WRITE text.
The third program has exactly the same meaning as the first program. The second program, in contrast, would have the following form if expressed explicitly:
REPORT test_start_of_selection.
DATA text TYPE string.
START-OF-SELECTION.
text = `Hello World!`.
START-OF-SELECTION.
WRITE text.
This means that if the second program contained a WRITE statement before the explicit event block, it would behave differently to the first or third programs with the same WRITE statement, as the statement NEW-LINE is executed at the end of the implicit event block.
REWARD IF USEFUL Aarif......!!!