Application Development and Automation 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: 
Read only

on control break statements

Former Member
0 Likes
712

what is difference between AT NEW n ON CHANGE FIELD?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
691

AT NEW and ON CHANGE OF have another critical differance between them other than what are replied so far.

and it is...

in a table's key....while using AT NEW <temp> if any of the field on the left side of temp changes...though temp is the same AT NEW will trigger...

It will make key of feilds starting from leftmost field till the <temp> field and it will mark all the fields on right of <temp> with an asteric (*).

means...say for example these are the records in itab...

Field1 Field2 Field3 Field4

A P X V

A G M N

B G K L

no suppose i use AT NEW Field2.

then on 3rd record also thi will trigegr as the key of all the fields on left of Field2 has changes .

and in case of using ON CHANGE OF Field2 it will just see for the specified filed not other fields on left side of it in key..

Some other info:

Both of them are triggeredwhile the control break level changes, but he functionality changes for both depending on the situation.

1. On change of unlike at new can be used inside any loop construct.

2. Suppose if we trigger the event based on the second field , on change of will not respond to the changes int he first record. It only triggers for changes in the specific field unlike at new which also triggers for every change in the left hand side field of the record also.

3. Also for on change of does not trigger if the first record in the loop is empty unlike at new.

These are the main and useful differences.

what is difference between AT NEW n ON CHANGE FIELD?

4 REPLIES 4
Read only

Former Member
0 Likes
691

At new will work from left column to right column.

On chnage will work from right column to left column.

On chnage you can use anywhere and it is like global.

at new - you can use within loop and endloop only

Read only

Former Member
0 Likes
692

AT NEW and ON CHANGE OF have another critical differance between them other than what are replied so far.

and it is...

in a table's key....while using AT NEW <temp> if any of the field on the left side of temp changes...though temp is the same AT NEW will trigger...

It will make key of feilds starting from leftmost field till the <temp> field and it will mark all the fields on right of <temp> with an asteric (*).

means...say for example these are the records in itab...

Field1 Field2 Field3 Field4

A P X V

A G M N

B G K L

no suppose i use AT NEW Field2.

then on 3rd record also thi will trigegr as the key of all the fields on left of Field2 has changes .

and in case of using ON CHANGE OF Field2 it will just see for the specified filed not other fields on left side of it in key..

Some other info:

Both of them are triggeredwhile the control break level changes, but he functionality changes for both depending on the situation.

1. On change of unlike at new can be used inside any loop construct.

2. Suppose if we trigger the event based on the second field , on change of will not respond to the changes int he first record. It only triggers for changes in the specific field unlike at new which also triggers for every change in the left hand side field of the record also.

3. Also for on change of does not trigger if the first record in the loop is empty unlike at new.

These are the main and useful differences.

Read only

Former Member
0 Likes
691

At new works from left to right.

For ex in your internal table if you 5 fields, the first field takes the control first and then the second and so on.

On change is the other way round..but on change has become obsolute.

Use at new but make sure the field you want to trigger at new should be your first field.

Shreekant

Read only

Former Member
0 Likes
691

Actually ON CHANGE is not supported on OO ABAP....So you better go with AT NEW or some logic...

Something like this....


  LOOP AT T_NPEDI ASSIGNING <NPEDI>.
    IF W_NPEDI NE <NPEDI>-NPEDI.
      W_NPEDI = <NPEDI>-NPEDI.
    ELSE.
      CONTINUE.
    ENDIF.
*DO LOGIC...
ENDLOOP.

Greetings,

Blag.