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 and On Change of

Former Member

Difference Between At New and On Change of

1 ACCEPTED SOLUTION

Former Member

Hi,

ON CHANGE OF f. is generally used with GET events or SELECT/ENDSELECT .

If we try to use this within LOOP - ENDLOOP, it can give unpredictable results.

AT NEW is used within LOOP - ENDLOOP.

Regards,

Pankaj

7 REPLIES 7

Former Member
0 Kudos

a) When AT NEW occurs,

the alpha-numeric fields have ******* in their value,

b) where as in case of ON CHANGE,

the alpha-numeric fields have their corresponding value,

of that particular record,

where the Event gets fired.*----


Other differences are :

ON CHANGE OF can be used any where in the program..

on change of differs from at new in the following respects:

1.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.

2.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.

3.When used within a loop, a change in a field to the left of the control level does not trigger a control break.

4.When used within a loop, fields to the right still contain their original values; they are not changed to contain zeros or asterisks.

5.You can use else between on change of and endon.

6.You can use it with loop at it where . . ..

7.You can use sum with on change of. It sums all numeric fields except the one(s) named after of.

8.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.

while

AT NEW can be used only within a loop of an INTERNAL TABLE..

*----


5. Sample program to get the taste of it

(just copy paste)

6.

REPORT ABC.

DATA : BEGIN OF ITAB OCCURS 0,

bukrs like t001-bukrs,

f1(10) type c,

end of itab.

itab-bukrs = '1000'.

itab-f1 = '1111111'.

append itab.

itab-bukrs = '1100'.

itab-f1 = '3333333'.

append itab.

itab-bukrs = '1200'.

itab-f1 = '555555'.

append itab.

AT NEW

loop at itab.

at new bukrs.

write 😕 itab-bukrs , itab-f1.

endat.

endloop.

AT ONCHANGE

loop at itab.

ON CHANGE OF ITAB-BUKRS.

write 😕 itab-bukrs , itab-f1.

ENDON.

endloop.

check these threads..

Former Member

Hi,

ON CHANGE OF f. is generally used with GET events or SELECT/ENDSELECT .

If we try to use this within LOOP - ENDLOOP, it can give unpredictable results.

AT NEW is used within LOOP - ENDLOOP.

Regards,

Pankaj

When we use At new for a field, it will trigger whenever there is any change in al lthe fields from the left to that of the particular field. But when we use On change of it triggers only when there is any change in the particular field.

At new can only be used inside loop. On change of can used outside the loop.

No logical Expressions can be added with at new. Logical expressions like AND OR can be used with on change of.

When AT NEW occurs, the alpha-numeric fields have * in their value,where as in case of On Change, the alphanumeric fields have their Corresponding value, of that particular record, where the Event gets fired.

On Change of executes for the first value of field too, this is not the case with At New.

On change of cannot be used in ABAP objects At new can be used in this.

Former Member
0 Kudos

hi,

When we use At new for a field, it will trigger whenever there is any change in al lthe fields from the left to that of the particular field. But when we use On change of it triggers only when there is any change in the particular field.

At new can only be used inside loop. On change of can used outside the loop.

No logical Expressions can be added with at new. Logical expressions like AND OR can be used with on change of.

When AT NEW occurs, the alpha-numeric fields have * in their value,where as in case of On Change, the alphanumeric fields have their Corresponding value, of that particular record, where the Event gets fired.

On Change of executes for the first value of field too, this is not the case with At New.

On change of cannot be used in ABAP objects At new can be used in this.

plz reward points if helpful..

Former Member
0 Kudos

At New

1. When a new record comes at new triggers. Atnew only used inside loop and endloop.

2. At new is controlbreak statment on at new the left side field change, the event

trigers and the values become 0 and *

On Change

1. On change of works same like at-new but the diff is it can be used out side of a loop,like select and endselect,case endcase.

2.. on change of is not a control break statement and we can use onchange of out side the loop

and

The Major difference between the two is that AT NEW can be used ONLY for INTERNAL TABLES, while ON CHANGE OF can be used for any loop processing i.e do..enddo, while..endwhile and loop..endloop also.

rewards if helpful

Former Member
0 Kudos

Hi,

here are the differences...

1 .On change of can use in any LOOP Construct...

For Ex.

Select...Endselect, Do...Enddo, While..Endwhile ,as well

as inside Get Events....

At new can use only with loop...endloop.

2 .When On change of used within loop a change in a field to

the left end of control level does not trigger a control break,

which is opposite to At new.

3. Can use Else in On change of, not in at new.

4. can use where condition with On change of, not in at new

5. can use sum with On change of. It sums all numeric field

expect the one(s) named after of.

reward if usefull....

jordi_escodaruiz
Active Participant
0 Kudos

On Change of is an obsolete construct. Not supported in ABAP Objects context.