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

programming

Former Member
0 Likes
540

hi experts,

what is difference bet.. at new and on change of...

i want detailed information abt this.

thanks in advance.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
513

<b>the differences are</b>

<b>1.</b> At New you can use only with in the loop...endloop.

on change u can use inside the loop as well as out side the loop. example.. Select..Endselect.

<b>2.</b> Atnew consider the all the change of left side fields of the purticular field u are reffering

on change consider only the puricular field changes, won't consider left side field changes

4 REPLIES 4
Read only

Former Member
0 Likes
513

at new - > means inside the loop, the new value.

eg :

1

1

2

3

4

5

5

loop at itab

at new matnr

write matnr.

end at.

end loop.

1

2

3

4

5

On change -> chnage of particular value inside the loop.

***********************************************************************************

    • The Major Difference is :

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.

**********************************************************************************

Read only

0 Likes
513

check these threads..

Read only

Former Member
0 Likes
514

<b>the differences are</b>

<b>1.</b> At New you can use only with in the loop...endloop.

on change u can use inside the loop as well as out side the loop. example.. Select..Endselect.

<b>2.</b> Atnew consider the all the change of left side fields of the purticular field u are reffering

on change consider only the puricular field changes, won't consider left side field changes

Read only

Former Member
0 Likes
513

HI Raju,

Beginning of a group of lines with the same contents in the field <f>

<b> AT NEW <f> | AT END OF <f>.

...

ENDAT.</b>

A control break occurs when the value of the field <f> or a superior field in the current record has a different value from the previous record (AT NEW) or the subsequent record (AT END). Field <f> must be part of the HEADER field group.

If the extract dataset is not sorted, the AT... ENDAT block is never executed. Furthermore, all extract records with the value HEX 00 in the field <f> are ignored when the control breaks are determined.

The AT... ENDAT blocks in a loop are processed in the order in which they occur. This sequence should be the same as the sort sequence. This sequence must not necessarily be the sequence of the fields in the HEADER field group, but can also be the one determined in the SORT statement.

If you have sorted an extract dataset by the fields <f1>, <f2>, ..., the processing of the control levels should be written between the other control statements as follows:

am not sure abt ON CHANGE OF,I will surely come back if i able to know regarding this.

regards,

shan