Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

AT NEW

Former Member
0 Kudos

Hi All,

"At new" method when it triggers?

Thanks & Regards,

<b>Anil Kumar</b>

5 REPLIES 5

Former Member
0 Kudos

Hi

LOOP AT itab result ...

[AT FIRST.

...

ENDAT.]

[AT NEW comp1.

...

ENDAT.

[AT NEW comp2.

...

ENDAT.

[...]]]

[ ... ]

[[[...]

AT END OF comp2.

...

ENDAT.]

AT END OF comp1.

...

ENDAT.]

[AT LAST.

...

ENDAT.]

ENDLOOP.

. ... |{END OF} comp Effect The statement block of a LOOP loop can contain control structures for control level processing. The respective control statement is AT. The statements AT and ENDAT define statement blocks that are executed at control breaks. Within these statement blocks, the statement SUM can be specified to total numeric components of a group level. In the case of output behavior result, the same applies as for LOOP AT. So that group level processing can be executed correctly, the following rules should be noted: After LOOP there should be no limiting condition cond specified. The internal table must not be modified within the LOOP loop. The work area wa specified in the LOOP statement after the INTO addition must be compatible with the line type of the table. The content of a work area wa specified in the LOOP statement after the INTO addition must not be modified. The prerequisite for control level processing is that the internal table is sorted in exactly the same sequence as the component of its line type - that is, first in accordance with the first component, then in accordance with the second component, and so on. The line structure and the corresponding sorting sequence gives a group structure of the content of the internal table, whose levels can be evaluated using AT statements. The AT-ENDAT control structures must be aligned one after the other, in accordance with the group structure. The statement blocks within the AT-ENDAT control structures are listed if an appropriate control break is made in the current table line. Statements in the LOOP-ENDLOOP control structure that are not executed within an AT-ENDAT control structure are executed each time the loop is run through. 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 group key will remain unchanged. All components with a character-type, flat data type to the right of the current group key are set to character "*" at that position. All the other components to the right of the current group 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. If the INTO addition is used in the LOOP statement, a field symbol can be specified outside of the classes after AT |{END OF}. The appropriate component of the work area wa is assigned to this field symbol.

<b>... |{END OF} comp

Beginning or end of a group of lines with the same content in the component comp1 comp2 ... and in the components to the left of comp1 comp2 .... The components comp1 comp2 ... can be specified, as described in the section Specification of Components, with the limitation that access to object attributes is not possible here.</b>

<b>REWARD IFUSEFULL</b>

Former Member
0 Kudos

Hi Anil ,

The Event AT NEW is trigger when the new records Reached.

Regards.

Nihar swain

Former Member
0 Kudos

at new triggers when the value of record changed as compare to it's previous one .

for example itab .

table :

flight carrier .

A 1

A 1

A 2

B 2

B 1

B 1

if u use at new in loop at itab

at new carrier . will trigger at1,3, 5 and 4,record also as the value of flight field is changed to B from a though value of carrier is same .

at new flight will trigger at 4 th rec not at 5,6 .

1)it is adviced to sort the record for at new .

2) it takes all the field to left of the field .

hope this explains it .. feel free to ask .

and award points if found helpfull .

Former Member
0 Kudos

Hi,

When you say 'AT NEW F1'

For every new occurence of value under field F1 this event would trigger. That is the code in 'AT NEW F1' and 'END AT' will be exicuted.

Regards,

Rama Murthy.P

Former Member
0 Kudos

<a href="http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/at_itab.htm">do refer this link for the explanation!</a>

regards,

srinivas