Difference btwn at new and on change of

Hi all,
can i know the difference between 'at new' and 'on change of'.

Hi,
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 of -> 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.
Regards,
Ferry Lianto

Similar Messages

  • Difference between At-new and on change of

    Hi,
    Can anyone send me the exact difference between At-new and On change of
    Thank You
    Santosh

    Hi anjali,
    I just entered your subject "difference between At-new and on change of" as search terms in the SEARCH FORUM input field.
    Please check the results and come back after.
    Difference between At new and On change of?
    Posted on: 28.09.2006 19:01, by user: subhash soni -- Relevance: 100% -- Show all results within this thread
    Hi What is the difference between At new and On change of? Thank You
    difference between At-new and on change of
    Posted on: 09.03.2007 20:16, by user: anjali nalluri -- Relevance: 89% -- Show all results within this thread
    Hi, Can anyone send me the exact difference between At-new and On change of Thank You Santosh
    Diff between AT new and on change of
    Posted on: 30.11.2006 16:06, by user: Pavan Ravikanti -- Relevance: 53% -- Show all results within this thread
    hi, can any one tell me what is the exact difference between <b>AT new</b> and <b>on change of</b> thanks pavan ...
    Diff. between At New and On Change Of
    Posted on: 05.10.2005 08:58, by user: surya mamtha -- Relevance: 48% -- Show all results within this thread
    Hi, Could anybody exlain the difference between At New event and On Change Of event in detail? And how can we avoid the inner loops ...
    Major Diff. Between On change of and At New
    Posted on: 24.05.2006 12:48, by user: IFF -- Relevance: 46% -- Show all results within this thread
    Hi Experts, Could you please let me know that what is the major difference between the control break statements On change of and At new. Which one is best to used ...
    diff between at new and on change of
    Posted on: 08.03.2007 16:27, by user: saroja ponnam -- Relevance: 44% -- Show all results within this thread
    Hi all, what is the main diff between at new and on change of statements. Regards Saroja.
    Differnce between AT NEW AND ON CHANGE OF
    Posted on: 06.05.2006 10:55, by user: Raja Sekhar T -- Relevance: 44% -- Show all results within this thread
    Hi, Differnce between AT NEW AND ON CHANGE OF Iam waiting foryour reply Thanks & Regards Raja Sekhar.T ...
    Regards,
    Clemens

  • Difference between At new and on change statement?

    What is the difference between at new and on change statement? Please explain with an example.

    hi
    on change of differs from at new in the following respects:
    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.
    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.
    When used within a loop, a change in a field to the left of the control level does not trigger a control break.
    When used within a loop, fields to the right still contain their original values; they are not changed to contain zeros or asterisks.
    You can use else between on change of and endon.
    You can use it with loop at it where . . ..
    You can use sum with on change of. It sums all numeric fields except the one(s) named after of.
    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.
    REGARDS
    PRASANTH

  • Difference  between AT NEW and ON CHANGE

    difference  between AT NEW and ON CHANGE

    HI,
    at new is controlbreak statment and on change of is not and we can use onchange of  out side the loop
    and on at nnwe the left side feild change  the event
    trigers and the values become 0 and *
    -->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
    regards,
    vineela.

  • Which scenerio we use at new and on change....

    i which scenerio we use at new then on change....
    basically what is the difference b/w them...

    Hi,
    if u use 'at-new' statement , basically it dont pick first record of the itab where as 'on chage of' can pick from first record.
    all these control brake statements can work with header line except 'on change of' event.
    At New.
    Effect
    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.
    Example:
    codeLOOP AT itab result ...
    [AT NEW comp1.
    ENDAT.
    endloop.[/code]
    On Change of:
    Effect:
    The statements ON CHANGE OF and ENDON, which are forbidden in classes, define a control structure that can contain a statement block statement_block. After ON CHANGE OF, any number of data objects dobj1, dobj2... of any data type can be added..
    Example:
    In a SELECT loop, a statement block should only be executed if the content of the column CARRID has changed.
    codeDATA spfli_wa TYPE spfli.
    SELECT *
    FROM spfli
    INTO spfli_wa
    ORDER BY carrid.
    ON CHANGE OF spfli_wa-carrid.
    ENDON.
    ENDSELECT.[/code]
    difference btwn at new and on change of

  • In Reports what  is the difference between the AT NEW and ON CHANGE Event

    Hi,
            Could you tell the differences of AT NEW and ON CHANGE events in Repors

    Hi raghava,
    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.
    endloop.

  • At new and on change of

    Hi Friends,
    can any one explain ,
    1) what is main difference between at new and on change of
    control break statements...
    2) in which situation we are supposed use on change of control beark.
    cheers,

    Vijay ,
    Control Break Event AT- NEW :
    Event AT-NEW will be triggered whenever the control level changes or any field prior to the control level changes.
    For Example:
    DATA : BEGIN OF IT_TAB OCCURS 0,
    A(5),
    B(5),
    C(5),
    END OF ITAB.
    Insert some Values to the internal table.
    SORT   IT_TAB.
    LOOP AT   IT_TAB,
    AT NEW A.
    <Only when value of A Changes.>
    ENDAT
    AT NEW B.
    <When Combined vales of A & B Changes i.e either A or B Or both>.
    ENDAT.
    1) Sorting of the INTERNAL TABLE is necessary.
    2) You cannot use multiple fields in AT-NEW statement.
    3) Between AT-NEW and ENDAT the content of work area will not contain any value
    4) If you change the value of a work area within AT-NEW and ENDAT your changes will be lost after the ENDAT statement.
    5) When AT NEW occurs, the alpha-numeric fields have ******* in their value
    6) Can be used in ABAP objects
    ON-CHANGE-OF :
    On Change of will be triggered whenever the control level changes.
    It won't be triggered when the field prior to the control level change.
    For Example:
    DATA : BEGIN OF IT_TAB OCCURS 0,
    A(5),
    B(5),
    C(5),
    END OF ITAB.
    Insert some Values to the Internal table.
    LOOP AT  IT_TAB,
    On CHANGE OF B.
    < Every time a value of B changes >
    ENDON.
    ENDLOOP.
    1)     Sorting of the INTERNAL TABLE is NOT necessary.
    2)     Mutilpe Fields are used in ON-CHANGE-OF
    3)     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.
    4)      In ON CHANGE,the alpha-numeric fields have their corresponding value, of that particular record, where the Event gets fired.
    5)     When used within a loop, a change in a field to the left of the control level does not trigger a control break.
    6)     You can use else between on change of and endon.
    7)     You can use it with loop at it where . . ..
    8)      cannot be used in ABAP objects
    Regards,
    Shiv.G.Sethu

  • What is the perfect defference between AT NEW and ON CHANGE...

    What is the perfect defference between AT NEW and ON CHANGE...?

    hi vijay,
    if u use 'at-new' statement , basically it dont pick first record of the itab where as 'on chage of' can pick from first record.
    all these control brake statements can work with header line except 'on change of' event.
    regards..
    seshu.
    Jogdand M B  
    Hi,
    At New.
    Effect
    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.
    Example:
    LOOP AT itab result ...
        [AT NEW comp1.
         ENDAT.
    endloop.
    On Change of:
    Effect:
    The statements ON CHANGE OF and ENDON, which are forbidden in classes, define a control structure that can contain a statement block statement_block. After ON CHANGE OF, any number of data objects dobj1, dobj2... of any data type can be added..
    Example:
    In a SELECT loop, a statement block should only be executed if the content of the column CARRID has changed.
    DATA spfli_wa TYPE spfli.
    SELECT *
           FROM spfli
           INTO spfli_wa
           ORDER BY carrid.
      ON CHANGE OF spfli_wa-carrid.
      ENDON.
    ENDSELECT.

  • Diff bt  AT NEW  and ON CHANGE OF

    can any one explain me diff bt  AT NEW  and ON CHANGE OF
    Thanks and regards,
    venki..

    Hi
    Both will do the same function
    ON CHANGE OF is not used much now-a-days.
    see the sample for At new
    All this AT NEW, AT FIRST, AT END OF and AT LAST are called control break statements of Internal tables and are used to calculate the TOTALS based on sertain key fields in that internal table
    FIrst to use these statements the ITAB has to be sorted by the key fields on whcih you need the SUM of the fields.
    Some time you will get * when mopving data from this int table to other table using these commands
    so you have to use
    READ TABLE ITAB INDEX SY-TABIX in AT..ENDAT..if you are using other fields between them
    DATA: sflight_tab TYPE SORTED TABLE OF sflight
                      WITH UNIQUE KEY carrid connid fldate,
          sflight_wa  LIKE LINE OF sflight_tab.
    SELECT *
           FROM sflight
           INTO TABLE sflight_tab.
    LOOP AT sflight_tab INTO sflight_wa.
      AT NEW connid.
        WRITE: / sflight_wa-carrid,
                 sflight_wa-connid.
        ULINE.
      ENDAT.
      WRITE: / sflight_wa-fldate,
               sflight_wa-seatsocc.
      AT END OF connid.
        SUM.
        ULINE.
        WRITE: / 'Sum',
                  sflight_wa-seatsocc UNDER sflight_wa-seatsocc.
        SKIP.
      ENDAT.
      AT END OF carrid.
        SUM.
        ULINE.
        WRITE: / 'Carrier Sum',
                  sflight_wa-seatsocc UNDER sflight_wa-seatsocc.
        NEW-PAGE.
      ENDAT.
      AT LAST.
        SUM.
        WRITE: / 'Overall Sum',
                  sflight_wa-seatsocc UNDER sflight_wa-seatsocc.
      ENDAT.
    ENDLOOP.
    <b>Reward points for useful Answers</b>
    Regards
    Anji

  • Differnce between AT NEW AND ON CHANGE OF

    Hi,
    Differnce between AT NEW AND ON CHANGE OF
    Iam waiting foryour reply
    Thanks & Regards
    Raja Sekhar.T

    Hai Raja
    check the following Documents
    1. AT NEW f.
    2. AT END OF f.
    3. AT FIRST.
    4. AT LAST.
    5. AT fg.
    Effect
    In a LOOP which processes a dataset created with EXTRACT , you can use special control structures for control break processing. All these structures begin with AT and end with ENDAT . The sequence of statements which lies between them is then executed if a control break occurs.
    You can use these key words for control break processing with extract datasets only if the active LOOP statement is proceesing an extract dataset.
    The control level structure with extract datasets is dynamic. It corresponds exactly to the sort key of the extract dataset, i.e. to the order of fields in the field group HEADER by which the extract dataset was sorted .
    At the end of a control group ( AT END OF , AT LAST ), there are two types of control level information between AT and ENDAT :
    If the sort key of the extract dataset contains a non-numeric field h (particularly in the field group HEADER ), the field CNT(h) contains the number of control breaks in the (subordinate) control level h .
    For extracted number fields g (see also ABAP/4 number types ), the fields SUM(g) contain the relevant control totals.
    Notes
    The fields CNT(h) and SUM(g) can only be addressed after they have been sorted. Otherwise, a runtime error may occur.
    The fields CNT(h) and SUM(g) are filled with the relevant values for a control level at the end of each control group ( AT END OF , AT LAST ), not at the beginning ( AT FIRST , AT NEW ).
    When calculating totals with SUM(g) , the system automatically chooses the maximum field sizes so that an overflow occurs only if the absolute value area limits are exceeded.
    You can also use special control break control structures with LOOP s on internal tables.
    Variant 1
    AT NEW f.
    Variant 2
    AT END OF f.
    Effect
    f is a field from the field group HEADER . The enclosed sequence of statements is executed if
    the field f occurs in the sort key of the extract dataset (and thus also in the field group HEADER ) and
    the field f or a superior sort criterion has a different value in the current LOOP line than in the prceding ( AT NEW ) or subsequent ( AT END OF ) record of the extract dataset.
    Example
    DATA: NAME(30),
          SALES TYPE I.
    FIELD-GROUPS: HEADER, INFOS.
    INSERT: NAME  INTO HEADER,
            SALES INTO INFOS.
    LOOP.
      AT NEW NAME.
        NEW-PAGE.
      ENDAT.
      AT END OF NAME.
        WRITE: / NAME, SUM(SALES).
      ENDAT.
    ENDLOOP.
    Notes
    If the extract dataset is not sorted before processing with LOOP , no control level structure is defined and the statements following AT NEW or AT END OF are not executed.
    Fields which stand at hex zero are ignored by the control break check with AT NEW or AT END OF . This corresponds to the behavior of the SORT statement, which always places unoccupied fields (i.e. fields which stand at hex zero) before all occupied fields when sorting extract datasets, regardless of whether the sort sequence is in ascending or descending order.
    Variant 3
    AT FIRST.
    Variant 4
    AT LAST.
    Effect
    Executes the relevant series of statements just once - either on the first loop pass (with AT FIRST ) or on the last loop pass (with AT LAST ).
    Variant 5
    AT fg.
    Addition
    ... WITH fg1
    Effect
    This statement makes single record processing dependent on the type of extracted record.
    The sequence of statements following AT fg are executed whenever the current LOOP record is created with EXTRACT fg (in other words: when the current record is a fg record).
    Addition
    ... WITH fg1
    Effect
    Executes the sequence of statements belonging to AT fg WITH fg1 only if the record of the field group fg in the dataset is immediately followed by a record of the field group fg1 .
    Basic form
    ON CHANGE OF f.
    Addition
    ... OR f1
    Effect
    Executes the processing block enclosed by the " ON CHANGE OF f " and " ENDON " statements whenever the contents of the field f change (control break processing).
    Normally, you use the statement to manipulate database fields during GET events or SELECT / ENDSELECT processing.
    Note
    There are special control structures for processing control breaks in LOOP s on internal tables or extract datasets AT ).
    ON CHANGE OF is unsuitable for recognizing control levels in loops of this type because it always creates a global auxiliary field which is used to check for changes. This global auxiliary field can only be changed in the relevant ON CHANGE OF statement. It is not reset when the processing goes into loops or subroutines, so unwanted effects can occur if the loop or subroutine is executed again. Also, since it is set to its initial value when created (like any other field), any ON CHANGE OF processing will be executed after the first test, unless the contents of the field concerned happen to be identical to the initial value.
    Example
    TABLES T100.
    SELECT * FROM T100 WHERE SPRSL = SY-LANGU AND
                             MSGNR < '010'
                       ORDER BY PRIMARY KEY.
      ON CHANGE OF T100-ARBGB.
        ULINE.
        WRITE: / '**', T100-ARBGB, '**'.
      ENDON.
      WRITE: / T100-MSGNR, T100-TEXT.
    ENDSELECT.
    Displays all messages with their numbers in the logon language, provided the number is less than '010'.
    Each time the message class changes, it is output.
    Addition
    ... OR f1
    Effect
    Also executes the code whenever the contents of the field f1 changes.
    You can use this addition several times.
    Example
    Logical database F1S
    TABLES: SPFLI, SFLIGHT, SBOOK.
    GET SBOOK.
      ON CHANGE OF SPFLI-CARRID   OR
                   SPFLI-CONNID   OR
                   SFLIGHT-FLDATE.
        ULINE.
        WRITE: /5 SPFLI-CARRID, SPFLI-CONNID,
                5 SFLIGHT-FLDATE, SPFLI-FLTIME,
                5 SFLIGHT-SEATSMAX, SFLIGHT-SEATSOCC.
      ENDON.
      WRITE: / SBOOK-CUSTOMID.
    The code between ON CHANGE OF and ENDON is executed only if at least one of the fields SPFLI-CARRID , SPFLI-CONNID or SFLIGHT-FLDATE has changed, i.e. there is a different flight connection (which also has bookings).
    Notes
    Thanks & regards
    Sreenivasulu P

  • DIFFERENCE BETWEEN "AT NEW " AND "AT FIRST" , "AT END OF" AND "AT LAST" ?

    WHAT IS THE DIFFERENCE BETWEEN "AT NEW " AND "AT FIRST" , "AT END OF" AND "AT LAST" WITH REFERENCE TO CONTROL BREAK STATEMENTS ? PLEASE EXPLAIN IN DETAIL.
    BEST REGARDS
    RYAN.

    Hi
    i am sending you a simple program in which i had write program on that events
    you can understand very easily
    Using AT FIRST , AT NEW, AT THE END OF , AT LAST.
    DATA: BEGIN OF ITAB OCCURS 0,
          F1 TYPE I,
          F2(6) TYPE C,
          F3(10) TYPE N,
          F4(16) TYPE P DECIMALS  2,
          END OF ITAB.
    DATA: SUB_TOT(10) TYPE P DECIMALS 3.
    **--1
    ITAB-F1 = 1.
    ITAB-F2 = 'ONE'.
    ITAB-F3 = 10.
    ITAB-F4 = '1000.00'.
    APPEND ITAB.
    CLEAR ITAB.
    ITAB-F1 = 1.
    ITAB-F2 = 'ONE'.
    ITAB-F3 = 20.
    ITAB-F4 = '2000.00'.
    APPEND ITAB.
    CLEAR ITAB.
    ITAB-F1 = 1.
    ITAB-F2 = 'ONE'.
    ITAB-F3 = 30.
    ITAB-F4 = '3000.00'.
    APPEND ITAB.
    CLEAR ITAB.
    *--2
    ITAB-F1 = 2.
    ITAB-F2 = 'TWO'.
    ITAB-F3 = 10.
    ITAB-F4 = '1000.00'.
    APPEND ITAB.
    CLEAR ITAB.
    ITAB-F1 = 2.
    ITAB-F2 = 'TWO'.
    ITAB-F3 = 20.
    ITAB-F4 = '2000.00'.
    APPEND ITAB.
    CLEAR ITAB.
    *-- 3
    ITAB-F1 = 3.
    ITAB-F2 = 'THREE'.
    ITAB-F3 = 10.
    ITAB-F4 = '1000.00'.
    APPEND ITAB.
    CLEAR ITAB.
    ITAB-F1 = 3.
    ITAB-F2 = 'THREE'.
    ITAB-F3 = 20.
    ITAB-F4 = '2000.00'.
    APPEND ITAB.
    CLEAR ITAB.
    SORT ITAB BY F1.
    LOOP AT ITAB.
    AT FIRST.
    WRITE: /35 ' MATERIAL DETAILS:'.
    ULINE.
    ENDAT.
    AT NEW F1.
    WRITE: / 'DETAILS OF MATERIAL:' COLOR 7  , ITAB-F1.
    ULINE.
    ENDAT.
    WRITE: / ITAB-F1, ITAB-F2, ITAB-F3, ITAB-F4.
    SUB_TOT = SUB_TOT + ITAB-F4.
    AT END OF F1.
    ULINE.
    WRITE: / 'SUB TOTAL :'  COLOR 3 INVERSE ON, SUB_TOT COLOR 3 INVERSE ON.
    CLEAR SUB_TOT.
    ENDAT.
    AT LAST.
    SUM.
    ULINE.
    WRITE: 'SUM:', ITAB-F4.
    ULINE.
    ENDAT.
    ENDLOOP.
    Using AT FIRST , AT NEW, AT THE END OF , AT LAST.
    DATA: BEGIN OF ITAB OCCURS 0,
          F1 TYPE I,
          F2(6) TYPE C,
          F3(10) TYPE N,
          F4(16) TYPE P DECIMALS  2,
          END OF ITAB.
    DATA: SUB_TOT(10) TYPE P DECIMALS 3.
    **--1
    ITAB-F1 = 1.
    ITAB-F2 = 'ONE'.
    ITAB-F3 = 10.
    ITAB-F4 = '1000.00'.
    APPEND ITAB.
    CLEAR ITAB.
    ITAB-F1 = 1.
    ITAB-F2 = 'ONE'.
    ITAB-F3 = 20.
    ITAB-F4 = '2000.00'.
    APPEND ITAB.
    CLEAR ITAB.
    ITAB-F1 = 1.
    ITAB-F2 = 'ONE'.
    ITAB-F3 = 30.
    ITAB-F4 = '3000.00'.
    APPEND ITAB.
    CLEAR ITAB.
    *--2
    ITAB-F1 = 2.
    ITAB-F2 = 'TWO'.
    ITAB-F3 = 10.
    ITAB-F4 = '1000.00'.
    APPEND ITAB.
    CLEAR ITAB.
    ITAB-F1 = 2.
    ITAB-F2 = 'TWO'.
    ITAB-F3 = 20.
    ITAB-F4 = '2000.00'.
    APPEND ITAB.
    CLEAR ITAB.
    *-- 3
    ITAB-F1 = 3.
    ITAB-F2 = 'THREE'.
    ITAB-F3 = 10.
    ITAB-F4 = '1000.00'.
    APPEND ITAB.
    CLEAR ITAB.
    ITAB-F1 = 3.
    ITAB-F2 = 'THREE'.
    ITAB-F3 = 20.
    ITAB-F4 = '2000.00'.
    APPEND ITAB.
    CLEAR ITAB.
    SORT ITAB BY F1.
    LOOP AT ITAB.
    AT FIRST.
    WRITE: /35 ' MATERIAL DETAILS:'.
    ULINE.
    ENDAT.
    AT NEW F1.
    WRITE: / 'DETAILS OF MATERIAL:' COLOR 7  , ITAB-F1.
    ULINE.
    ENDAT.
    WRITE: / ITAB-F1, ITAB-F2, ITAB-F3, ITAB-F4.
    SUB_TOT = SUB_TOT + ITAB-F4.
    AT END OF F1.
    ULINE.
    WRITE: / 'SUB TOTAL :'  COLOR 3 INVERSE ON, SUB_TOT COLOR 3 INVERSE ON.
    CLEAR SUB_TOT.
    ENDAT.
    AT LAST.
    SUM.
    ULINE.
    WRITE: 'SUM:', ITAB-F4.
    ULINE.
    ENDAT.
    ENDLOOP.
    <b>Reward if usefull</b>

  • AT NEW and AT CHANGE

    Hi,
    what is use of AT NEW and AT CHANGE.
    When we will use it?
    Akash

    Hi Akash,,
    Using the at new and at end of Statements
    Use the at new and at end of statements to detect a change in a column from one loop pass to the next. These statements enable you to execute code at the beginning and end of a group of records.
    sort by c.
    loop at it.
    at new c.
    endat.
    at end of c.
    endat.
    endloop.
    where:
    These statements can only be used within loop at; they cannot be used within select.
    at new does not have to come before at end of. These statements can appear in any order.
    These statements can appear multiple times within the same loop. For example, you could have two at new and three at end of statements within one loop and they can appear in any order.
    These statements should not be nested inside of one another (that is, at end of should not be placed inside of at new / endat).
    There are no additions to these statements.
    Using at new
    Each time the value of c changes, the lines of code between at new and endat are executed. This block is also executed during the first loop pass or if any fields to the left of c change. Between at and endat, the numeric fields to the right of c are set to zero. The non-numeric fields are filled with asterisks (*). If there are multiple occurrences of at new, they are all executed. at end of behaves in a similar fashion.
    A control level is the component named on a control break statement; it regulates the control break. For example, in the following code snippet, f2 is a control level because it appears on the at new statement.
    loop at it.
    at new f2.
    "(some code here)
    endat.
    endloop.
    It is said that a control break is triggered if the control level changes. This means that when the contents of the control level change, the code between the at and endat is executed.
    A control break is also triggered if any of the fields prior to the control level in the structure change. Therefore, you should define the internal table structure to begin with the fields that form your control levels. You must also sort by all fields prior to and including c.
    Between at and endat, numeric fields to the right of the control level will be zero and non-numeric fields will be filled with asterisks.
    The lines of code between at end of and endat are executed:
    If the control level changes.
    If any field prior to the control level changes.
    If this is the last row of the table.
    report Ztemp.
      data: begin of it occurs 4,
                f1,
                f2,
                end of it.
      it = '1A'. append it. "Fill it with data
      it = '3A'. append it.
      it = '1B'. append it.
    it = '2B'. append it.
    sort it by f1.       
    loop at it.
         at new f1.
             write: / it-f1, it-f2.
             endat.
         endloop.
    skip.
    sort it by f2.       
    loop at it.
         at new f2.
             write: / it-f1, it-f2.
             endat.
         endloop.
    skip.
    sort it by f1 f2.    
    loop at it.
         at new f1.
             write: / it-f1.
             endat.
         at new f2.
             write: /4 it-f2.
             endat.
         endloop.
    free it.
    If Found Help Full Do Reward.
    Regards.
    Eshwar.

  • What is use of AT NEW and AT CHANGE

    what is use of AT NEW and AT CHANGE

    Using AT NEW
    Use at new to detect a change in a column from one loop pass to the next. This statements enable you to execute code at the beginning of a group of records.
    Syntax for the at new Statement
    sort by c.
    loop at it.
        at new c.
         endat.
        endloop.
    where:
    it is an internal table.
    c is a component of it.
    The following points apply:
    This statements can only be used within loop at; it cannot be used within select.
    at new does not have to come before at end of. It can appear in any order.
    This statement can appear multiple times within the same loop. For example, you could have two at new and three at end of statements within one loop and they can appear in any order.
    These statements should not be nested inside of one another (that is, at end of should not be placed inside of at new / endat).
    There are no additions to these statements.
    Each time the value of c changes, the lines of code between at new and endat are executed. This block is also executed during the first loop pass or if any fields to the left of c change. Between at and endat, the numeric fields to the right of c are set to zero. The non-numeric fields are filled with asterisks (*). If there are multiple occurrences of at new, they are all executed. at end of behaves in a similar fashion.
    A control level is the component named on a control break statement; it regulates the control break. For example, in the following code snippet, f2 is a control level because it appears on the at new statement.
    loop at it.
        at new f2.
            "(some code here)
            endat.
        endloop.
    It is said that a control break is triggered if the control level changes. This means that when the contents of the control level change, the code between the at and endat is executed.
    A control break is also triggered if any of the fields prior to the control level in the structure change. Therefore, you should define the internal table structure to begin with the fields that form your control levels. You must also sort by all fields prior to and including c.
    Between at and endat, numeric fields to the right of the control level will be zero and non-numeric fields will be filled with asterisks.
    Using ON CHANGE OF
    Another statement you can use to perform control break processing is on change of. It behaves in a manner similar to at new.
    Syntax for the on change of Statement
    The following is the syntax for the on change of statement.
    on change of v1 or v2 .
    else.
    endon.
    where:
    v1 and v2 are variable or field string names.
    any number of or conditions might follow.
    The following points apply:
    If the value of any of the variables (v1, v2, and so on) changes from one test to the next, the statements following on change of are executed.
    If no change is detected and else is specified, the statements following else are executed.
    on change of differs from at new in the following respects:
    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.
    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.
    When used within a loop, a change in a field to the left of the control level does not trigger a control break.
    When used within a loop, fields to the right still contain their original values; they are not changed to contain zeros or asterisks.
    You can use else between on change of and endon.
    You can use it with loop at it where . . ..
    You can use sum with on change of. It sums all numeric fields except the one(s) named after of.
    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.
    When a loop begins execution, the system creates a global auxiliary field for each field named in an on change of statement contained by the loop. On creation, these fields are given default initial values (blanks or zeros). They are freed when the loop ends.
    Each time on change of is executed, the contents of its fields are compared with the contents of the global auxiliary fields. If they are different, the on change of is triggered and the auxiliary fields are updated with the new values. If they are the same, the code within on change of is not executed
    Because global auxiliary fields do not exist outside a loop, you cannot use on change of outside of a loop.
    I hope it helps.
    Best Regards,
    Vibha
    Please mark all the helpful answers

  • Difference between the new and old airport express

    Have an airport express bought in the summer of 2004. It extends my home network and have never had any trouble with it. (Still using system x3.9 ). Everything is stable. Calm. If I were to buy a new airport express today, do I understand right that it would not work with my current system? What's the difference between the newer airport express and the one I have?

    I don't think there's much of a difference between the old Express and the new one. The only difference for sure, will probably be the Airport software, which is at its current version (I forget which). I too, bought my Airport Express when it first came out and I'm running software 6.1.1 on it, I think the newest is at 6.4 now or something like that.
    Only reason why it wouldn't work with your system is most like due to the updated software. The tech specs doesn't really say 10.4 or higher is required, but it looks like it's suggested to use the features such as USB printing, etc. http://www.apple.com/airportexpress/specs.html

  • Diff between AT new and on change of

    hi,
    can any one tell me what is the exact difference between <b>AT new</b> and <b>on change of</b>
    thanks
    pavan

    hi
    good
    In a LOOP which processes a dataset created with EXTRACT, you can use special control structures for control break processing. All these structures begin with AT and end with ENDAT. The sequence of statements which lies between is executed whenever a control break occurs.
    You can use these key words for control break processing with extract datasets only if the active LOOP statement is processing an extract dataset.
    The control level structure with extract datasets is dynamic. It corresponds exactly to the sort key of the extract dataset, i.e. to the order of fields in the field group HEADER by which the extract dataset was sorted.
    At the end of a control group ( AT END OF, AT LAST), there are two types of control level information between AT and ENDAT:
    If the sort key of the extract dataset contains a non-numeric field h (particularly in the field group HEADER), the field CNT(h) contains the number of control breaks in the (subordinate) control level h.
    For extracted number fields g (see also ABAP Number Types), the fields SUM(g) contain the relevant control totals.
    Notes
    The fields CNT(h) and SUM(g) can only be addressed after they have been sorted. Otherwise, a runtime error may occur.
    The fields CNT(h) and SUM(g) are filled with the relevant values for a control level at the end of each control group ( AT END OF, AT LAST), not at the beginning (AT FIRST, AT NEW).
    When calculating totals with SUM(g), the system automatically chooses the maximum field sizes so that an overflow occurs only if the absolute value area limits are exceeded.
    You can also use special control break control structures with LOOPs on internal tables.
    Variant 1
    AT NEW f.
    Variant 2
    AT END OF f.
    Effect
    f is a field from the field group HEADER. The enclosed sequence of statements is executed if
    the field f occurs in the sort key of the extract dataset (and thus also in the field group HEADER) and
    the field f or a superior sort criterion has a different value in the current LOOP line than in the preceding (AT NEW) or subsequent (AT END OF) record of the extract dataset.
    If f is not an assigned field symbol, the control break criterion is ignored, and the subsequent sequence of statements is not executed. If a field symbol is assigned, but does not point to the HEADER field group, the system triggers a runtime error.
    Example
    DATA: NAME(30),
          SALES TYPE I.
    FIELD-GROUPS: HEADER, INFOS.
    INSERT: NAME  INTO HEADER,
            SALES INTO INFOS.
    LOOP.
      AT NEW NAME.
        NEW-PAGE.
      ENDAT.
      AT END OF NAME.
        WRITE: / NAME, SUM(SALES).
      ENDAT.
    ENDLOOP.
    Notes
    If the extract dataset is not sorted before processing with LOOP, no control level structure is defined and the statements following AT NEW or AT END OF are not executed.
    Fields which stand at hex zero are ignored by the control break check with AT NEW or AT END OF. This corresponds to the behavior of the SORT statement, which always places unoccupied fields (i.e. fields which stand at hex zero) before all occupied fields when sorting extract datasets, regardless of whether the sort sequence is in ascending or descending order.
    Variant 3
    AT FIRST.
    Variant 4
    AT LAST.
    Effect
    Executes the relevant series of statements just once - either on the first loop pass (with AT FIRST) or on the last loop pass (with AT LAST).
    Variant 5
    AT fg.
    Addition:
    ... WITH fg1
    Effect
    This statement makes single record processing dependent on the type of extracted record.
    The sequence of statements following AT fg are executed whenever the current LOOP record is created with EXTRACT fg (in other words: when the current record is a fg record).
    Addition
    ... WITH fg1
    Effect
    Executes the sequence of statements belonging to AT fg WITH fg1 only if the record of the field group fg in the dataset is immediately followed by a record of the field group fg1.
    thanks
    mrutyun^

Maybe you are looking for