2008 Jan 11 1:51 PM
Hi there -
Does anybody know of a way to do the same thing as 'AT END OF' but will give me access to the field values that I sorted my itab on?
Thanks
Dan
2008 Jan 11 2:00 PM
hi,
not too nice, but works:
LOOP AT itab INTO wa.
wa_temp = wa.
AT END OF ...
Now you have what you need in wa_temp
ENDAT.
ENDLOOP.
hope this helps
ec
hi,
not too nice, but works:
LOOP AT itab INTO wa.
wa_temp = wa.
AT END OF ...
Now you have what you need in wa_temp
ENDAT.
ENDLOOP.
hope this helps
ec
2008 Jan 11 1:59 PM
Hi,
Please go thru the docu below from SAP.
AT END OF f.
Effect
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.
Examples
2. AT for the field of an extract dataset
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 processing you want to perform on an internal table is fairly restricted (i.e. a WHERE addition with the LOOP statement), do not use the AT statements specified in variants 1 to 5, since the interaction of the WHERE addition and the AT statement is currently not defined.
When you use LOOP with an extract dataset, fields on hex zero are ignored during control level checking with AT NEW or AT END OF . This procedure is the same as the SORT statement. When sorting extracted datasets, this statement always sorts blank fields (i.e. fields on hex zero) regardless of the sequence (ascending or descending) before all fields that contain values.
Since fields addressed with AT are not set to an initial value when you enter a LOOP, the first new group of (table) lines in AT NEW f may not be processed, if f happens to be set to this value.
Thanks,
Sriram Ponna.
2008 Jan 11 2:00 PM
hi,
not too nice, but works:
LOOP AT itab INTO wa.
wa_temp = wa.
AT END OF ...
Now you have what you need in wa_temp
ENDAT.
ENDLOOP.
hope this helps
ec
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |