11-28-2007 9:50 AM
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
11-28-2007 9:59 AM
If the INTO addition is used in the LOOP statement to assign the content of the current line to a work area wa, its content is changed upon entry into the AT-ENDAT control structure as follows:
The components of the current control key remain unchanged.
All components with a character-type, flat data type to the right of the current control key are set to character "*" in every position.
All the other components to the right of the current control key are set to their initial value.
When the AT-ENDAT control structure is exited, the content of the current table line is assigned to the entire work area wa.
11-28-2007 9:52 AM
to avoid that u need to read table itab index sy-tabix.
after at end of statement
11-28-2007 9:53 AM
AT NEW , AT END work properly only if the field u are refreering s the first field in internal table.. all the numeric field will become 0 and characters * once inside AT new block.
11-28-2007 9:55 AM
Dear Sreejith,
Very true...but i just wanted to know the reason behind it as to why the character fields turn to * and numeric to 0
11-28-2007 9:55 AM
11-28-2007 9:55 AM
Hai,
loop at it_table into wa_table.
AT END OF syntax.
Read table it_table into wa_table with key sy-tabix.
some processing.....
end of wa_table-field.
some code
endat.
now stars wil not com
regards
kish
11-28-2007 9:57 AM
AT END OF & ENDAT has a characteristic where the field which is specified in this statement all the fields to the left of the fields in the table will turn in to its initial value (i.e **** for character fields and '0' for the numeric fields. Right fields will be printed with its value.
Rewards if useful.
11-28-2007 9:59 AM
If the INTO addition is used in the LOOP statement to assign the content of the current line to a work area wa, its content is changed upon entry into the AT-ENDAT control structure as follows:
The components of the current control key remain unchanged.
All components with a character-type, flat data type to the right of the current control key are set to character "*" in every position.
All the other components to the right of the current control key are set to their initial value.
When the AT-ENDAT control structure is exited, the content of the current table line is assigned to the entire work area wa.
11-28-2007 10:00 AM
Dear all,
Why does * and 0 come in the first place??There surely has to be some reason behin it
11-28-2007 10:05 AM
Rahul,
No !dea why SAP has done like this, eevn i have wondered why.. i too watching this thread to know the reason.
11-28-2007 10:17 AM
Just going through i again,i guess it is coz of this:-
Loop at int_table into wa_table.
some processing.
at end of field
endat
endloop
so i guess what must be happening is that when we are looping ,an event is getting triggered .the moment at end of is triggerd ,while looping SAP understands that the previous data has to be processed with before moving on,,so the new data is converted to * .i guess there cant be any other reason....Does ne 1 know
11-28-2007 10:19 AM
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.
11-28-2007 10:23 AM
Just going through i again,i guess it is coz of this:-
Loop at int_table into wa_table.
some processing.
at end of field
endat
endloop
so i guess what must be happening is that when we are looping ,an event is getting triggered .the moment at end of is triggerd ,while looping SAP understands that the previous data has to be processed with before moving on,,so the new data is converted to * .i guess there cant be any other reason...(As xplained by Imtiyaz)
12-05-2007 6:03 AM
If you are working with a work area wa, it does not contain the current line in the AT-ENDATstatement block. All character fields to the right of the current group key are filled with asterisks (*). All other fields to the right of the current group key contain their initial value.
Because in ENDAT you can use only SUM operations of the numeric fields...
So other fields are filled with *.
11-17-2022 3:50 PM
I know this is a very old post but the question appears to be as yet unanswered. So, my best guess is this:
This statement was created before any BW/BI systems existed. As such, aggerate reporting which we now do in BI was done entirely in ERP and required a lot of aggregation reports were created which output sums for many key combinations (aka control levels.)
In ABAP there is a statement COLLECT which provides an easy way to aggregate data. It works by adding all numeric fields together where all of the non-numerics match. Given that AT NEW sets all non-break fields to asterisk, COLLECT could be very easily used with a single internal table as the target causing aggregations to be easily created at multiple control levels in the same target internal table because the asterisks would cause all records at one control level to be summed together.
Summary reports could be easily written out from the target itab.
Just a guess, but it seems plausible.