Skip to Content
author's profile photo Former Member
Former Member

At New and On Change of

Difference Between At New and On Change of

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

6 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jan 17, 2008 at 12:15 PM

    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

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      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.

  • author's profile photo Former Member
    Former Member
    Posted on Jan 17, 2008 at 12:13 PM

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

    differnce-between-at-new-and-on-change-of

    diff-between-at-new-and-on-change-of

    diff-bet-at-new--on-change-of

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 17, 2008 at 12:16 PM

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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 17, 2008 at 12:16 PM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 17, 2008 at 12:17 PM

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

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 17, 2008 at 12:22 PM

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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.