At new and onchange statement

Suppose we have a table as
Vbeln   Posnr         Erdat    Matnr    Maktx
10        110508         ---         ---          ---
10        120508         ---         ---          ---
10        130508         ---         ---          ---
20        110508         ---         --           --
20        120508         ---         --           --
20        130508         ---         --           --
30        110508         ---         --           --
30        120508        ---          --           --
30        130508        ---          --           --
The fields Erdat , Maktx and Matnr also have data's. we want to display the output as below:
Order: 10
Posnr        Erdat       Matnr         Maktx
110508       ---           ---                ---
120508       ---           ---                ---
130508       ---           -
Order: 20
Posnr        Erdat       Matnr         Maktx
110508       ---           ---                ---
120508       ---           ---                ---
130508       ---           -
Order: 30
Posnr        Erdat       Matnr         Maktx
110508       ---           ---                ---
120508       ---           ---                ---
130508       ---           -
Which statement will be more suitable to use in this case: At new or On Change?
How will we implement it?

Hi Nitu,
Here is the code.
DATA: t_vbap   TYPE TABLE OF vbap,
      wa_vbap  TYPE vbap,
      e_vbap  TYPE vbap.
SELECT * FROM vbap
  INTO TABLE t_vbap
  UP TO 200 ROWS.
SORT t_vbap BY vbeln.
LOOP AT t_vbap INTO wa_vbap.
  AT NEW vbeln.
    WRITE:/ 'Order No', wa_vbap-vbeln.
  ENDAT.
      WRITE:/ wa_vbap-posnr, wa_vbap-erdat,wa_vbap-matnr.
  AT END OF VBELN.
      uline.
  ENDAT.
ENDLOOP.
Its better to use At New.
Please assign points if helpful.

Similar Messages

  • What is exact differernce of at new and at onchange events?

    hello,
    what is exact differernce of at new and at onchange events?
    paramesh.kalluri

    Hi,
    Usually beofoer processing any internal table,
    we use the conrtrol events (AT NEW, AT FIRST, ON CHANGE OF etc) for better formatting options.
    When ever we go for these events, its better to sort the table by key fields .
    AT NEW-
    1) Only opne field can be given.
    2) It is a event that is used only with in a internal tabel (LOOP and ENDLOOP) processing.
    for ex:
    Assume internal table has these fields-
    spfli- carrid, connid, fldate.
    loop ..
    at new connid.
    endat.
    endloop.
    case 1.
    at new connid.
    On every new value, ie the comobination of both carrid,connid is checked here. For every new combination of both, the control jumps to next statement.
    case 2.
    at new carrid.
    here for every new carrid the event is triggered.
    AT NEW <field>- here the position of this field is important in table. based on this postiion it will check the proir feilds aslo
    into consideration for trigeerring the event.
    ON CHANGE OF <field1> field2>...
    1) here we can give any number if fields.
    2) the position of the field1 is not considered in the internal table.
    3) Its usually used in support projects.
    4) If we use this, then its a performance issue because,
    internally the field1 is stored in the other filed and this is used to compare for change in value. This rechacking is done internally. Hence it is not used mostly except in support projects.
    For ex: on change of connid.
    here only for every change in only connid is considered not the prior field ie carrid included. here the position of connid in internal table is not considered.
    On change of connid fldate.
    here exclusively both are cheked the combination is not considered. separately connid and fldate are cheked. for every new value the evvent is trigggered.
    Reward if useful.
    Chandralekha

  • I keep getting an error message when downloading a new app which states " Zinio and 5 other apps cannot be purchased at this time" and then it let's me purchase the app that I was looking at? Can anyone explain that?

    I keep getting an error message when downloading a new app which states " Zinio and 5 other apps cannot be purchased at this time" and then it let's me purchase the app that I was looking at? Can anyone explain that?

    apple_master New Delhi, India
    This solved my questionRe: Unable to Purchase 
    Apr 16, 2012 10:22 PM (in response to eight4seven)
    This worked for someone
    I had this problem for about six weeks. I was following this forum but was too unsure of what might happen to try the fixes that were suggested.
    About two weeks ago I decided to delete the downloads.28.sqlitedb file (usingDiskAid(a free program), on a PC running Windows 7). The original downloads.28.sqlitedb was 936 KB. The new one that the system created is 80 Kb., and has stayed at about that size. After about four days I also deleted all the other contents of the Download folder. Ten days later and still no more problems. Downloads are much quicker, nothing greys-out (as was happening frequently before).
    Everything has worked well since with no more error messages.
    I am using an iPod 4G, iOS 5.1 (originally iOS 5.0). I do not have a manifest file, and as far as I know, have not had one. DiskAid can search the whole "hard drive" on the iPod.
    Deleting downloads.28.sqlitedb and the contents of Downloads worked for me.

  • I put a Tesco sim (02 carrier) in 2 unlocked phones, Both phones are now locked to 02, 02 blame apple, I connect the iphone to itunes and it states that the new carrier (orange) is not supported

    I put a Tesco sim (02 carrier) in 2 unlocked phones, Both phones are now locked to 02, 02 blame apple, I connect the iphone to itunes and it states that the new carrier (orange) is not supported, Isk this of both 02 and apple, who's phone is this and what right do you have to lock a previously unlocked phone?  very angry

    Where did you get these phones?
    These and other forums are full of people with iPhone unlocking problems - the net result is that, as others have said, is:
    If you bought them from Apple they will be (and stay) unlocked.
    If you bought them PAYG from CPW then they will lock to the first SIM activated.
    Any other contract or PAYG phone iPhone bought from the networks WILL be locked by them too.
    However, all is not lost. The original purchaser can request for the phones to be unlocked by Apple, via the carrier. The carriers usually charge around £20 to do this, or gratis if you're out of contract.
    You are the original purchaser, right? If not, you need to get in touch with that person and pray they'll help you out.

  • TS1368 click on itunes and it states new itunes library error

    I was downloading music 2 days ago and went to log on today and it states New itunes Library. 
    Did I lose all my information/account

    So I just downloaded the new itunes, and immediately after it started acting up.  I would click on it, it would start loading for about 3 seconds, and then it would completely die.
    Are you getting any sort of error message, Al? if so, what does it say? (Precise text, please.)

  • I am buying a new macbook pro but i want to fit my own ram memory and solid state hard drive , will apple permit this without voiding the waranty.

    i am buying a new macbook pro but i want to fit my own ram memory and solid state hard drive , will apple permit this without voiding the waranty.

    yes you can do it and not void the warranty.  Those are the only hardware changes that Apple permits.  Instructions on how to upgrade the ram and remove and replace the hard drive are even included in the owners manuals for MacBook Pros.

  • At new and at end of statement

    how to use AT NEW and AT END OF
    efficiently,kindly give some solid examples.
    thanks!!

    Now say, u have internal table with mateirals....there are 100 records with 10 mterials...
    loop at it_matnr.
      at new matnr.
        <b>write code</b>
      endat.
      <b>write code.</b>
      at end of matnr.
         <b>write code</b>
      endat.
    endloop.
    Check this which is explained...
    Control Level Processing
    When you perform a sort using the SORTstatement, control levels are defined in the extract dataset. For general information about control levels, refer to Processing Internal Tables in Loops The control level hierarchy of an extract dataset corresponds to the sequence of the fields in the header field group. After sorting, you can use the ATstatement within a LOOP loop to program statement blocks that the system processes only when the control level changes.
    AT NEW f | AT END OF f.
    ENDAT.
    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 null 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 in the LOOP loop as follows:
    LOOP.
      AT FIRST.... ENDAT.
        AT NEW f1....... ENDAT.
          AT NEW f2....... ENDAT.
              AT fgi..... ENDAT.
              Single record processing without control statement
          AT END OF f2.... ENDAT.
        AT END OF f1.... ENDAT.
      AT LAST..... ENDAT.
    ENDLOOP.
    You do not have to use all of the statement blocks listed here, but only the ones you require.
    REPORT demo_extract_at_new.
    DATA: t1(4) TYPE c, t2 TYPE i.
    FIELD-GROUPS: header.
    INSERT t2 t1 INTO header.
    t1 ='AABB'. t2 = 1. EXTRACT header.
    t1 ='BBCC'. t2 = 2. EXTRACT header.
    t1 ='AAAA'. t2 = 2. EXTRACT header.
    t1 ='AABB'. t2 = 1. EXTRACT header.
    t1 ='BBBB'. t2 = 2. EXTRACT header.
    t1 ='BBCC'. t2 = 2. EXTRACT header.
    t1 ='AAAA'. t2 = 1. EXTRACT header.
    t1 ='BBBB'. t2 = 1. EXTRACT header.
    t1 ='AAAA'. t2 = 3. EXTRACT header.
    t1 ='AABB'. t2 = 1. EXTRACT header.
    SORT BY t1 t2.
    LOOP.
      AT FIRST.
        WRITE 'Start of LOOP'.
        ULINE.
      ENDAT.
      AT NEW t1.
        WRITE / '   New T1:'.
      ENDAT.
      AT NEW t2.
        WRITE / '   New T2:'.
      ENDAT.
      WRITE: /14 t1, t2.
      AT END OF t2.
        WRITE / 'End of T2'.
      ENDAT.
      AT END OF t1.
        WRITE / 'End of T1'.
      ENDAT.
      AT LAST.
        ULINE.
      ENDAT.
    ENDLOOP.
    This program creates a sample extract, containing the fields of the header field group only. After the sorting process, the extract dataset has several control breaks for the control levels T1 and T2, which are indicated in the following figure:
    In the LOOP loop, the system displays the contents of the dataset and the control breaks it recognized as follows:
    http://help.sap.com/saphelp_erp2005vp/helpdata/en/9f/db9f1f35c111d1829f0000e829fbfe/frameset.htm

  • 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

  • My Mac Book Pro has just had a new memory and solid state drive installed. After the installation, the Lightroom tools all became grey. There is no longer any color on the screen other than my picture. Even the color sliders are grey.  Can you please help

    My MacBook Pro just had a new memory and solid state drive installed. Since the installation, the Lightroom tools are now all grey. Even the color sliders are grey. Please help!

    My guess is that your operating system got updated to Mavericks and that you are running an old version of Lightroom:
    Sliders are white, look different | Mac OS X 10.9 Mavericks
    Be aware of a Lightroom bug with color management in mavericks that makes shadows too deep in the Develop module: Jao's photo blog: Serious color management bug in Mac OS 10.9 "Mavericks" and Jao's photo blog: Further quantification of the Mavericks color management problem.

  • New ARB Issue:  Button navigation and Declarative States

    <[email protected]il.forums.adobe.com>
    Message-ID: <C6277898.7F37%[email protected]>
    Thread-Topic: New ARB Issue:  Button navigation and Declarative States
    Thread-Index: AcnOqlv/oTWkTNjMukqDP18VFO76uA==
    Mime-version: 1.0
    Content-type: multipart/alternative;
         boundary="B_3324475544_8859892"
    This message is in MIME format. Since your mail reader does not understand
    this format, some or all of this message may not be legible.
    --B_3324475544_8859892
    Content-type: text/plain;
         charset="US-ASCII"
    Content-transfer-encoding: 7bit
    A new ARB issue has been posted to the flex open source site:
    http://opensource.adobe.com/wiki/display/flexsdk/buttonnavigationand+decla
    rative+states
    This issue concerns the new state syntax and what it means to leave a value
    of a property implicit in one or more states.
    Comments, suggestions, and feedback are welcome.
    --B_3324475544_8859892
    Content-type: text/html;
         charset="US-ASCII"
    Content-transfer-encoding: quoted-printable
    <HTML>
    <HEAD>
    <TITLE>New ARB Issue:  Button navigation and Declarative States</TITLE=
    >
    </HEAD>
    <BODY>
    <FONT FACE=3D"Calibri, Verdana, Helvetica, Arial"><SPAN STYLE=3D'font-size:11pt=
    '><BR>
    <BR>
    <BR>
    A new ARB issue has been posted to the flex open source site:<BR>
    <BR>
    <a href=3D"http://opensource.adobe.com/wiki/display/flexsdk/button+navigation=
    anddeclarative+states">http://opensource.adobe.com/wiki/display/flexsdk/bu=
    ttonnavigationanddeclarativestates
    This issue concerns the new state syntax and what it means to leave a value= of a property implicit in one or more states.
    Comments, suggestions, and feedback are welcome.
    B_3324475544_8859892

    Ned Murphy wrote:
    Select the textfield that is inside the movieclip and in the properties panel you should see a dropdown for selecting the type of textfield.  If you select Dynamic and then assign an instance name to the textfield you can use that instance name in your code to assign the text when the file runs.  If you were to name the textfield "tField", then the code you would use inside an instance of your movieclip named "mClip1" would be...
    mClip1.tField.text = "your text";
    So, if I have multiple buttons, using your example, would the code read
    mClip1.tField.text = "your text";
    mClip1.tField2.text = "your text2";
    mClip1.tField3.text = "your text3";
    mClip1.tField4.text = "your text4";
    And my buttons are built inside movieclips, ie
    Main Timeline > aboutButton_mc > aboutText_mc > "about"
                        > contactsButton_mc > contactsText_mc > "contacts"
    can the code be put at any level, or does it need to reside on the Main Timeline to access all the movie clips' text fields?
    Just in case this may be too complex to get into via this forum, if you know of any good tutorials, that would be awesome too!
    I tried doing a search, but it's so hard to tell if they might be in AS2, or AS3, and if they would apply to newer versions of Adobe Flash (I have CS5)

  • So I updated the itunes and now it won't open it, it states a message "the itunes library.itl" cannot be open because it was created by a newer version of itunes, I have unistalled and re-installed newer and older version and still i get this message.

    I updated and now i can't use the itunes. I have unistalled several times, installing newer and older versions but still i get this message. Is there anything i can do to fix this problem??

    Try the following user tip with that one:
    Empty/corrupt iTunes library after upgrade/crash

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

  • New MacAir error states "your Mac OSX startup disk has no more space available for application memory"  All I have added is MS Office

    My new Mac Air states that my " Mac OSX startup disk has no more space available for application memory" and wants to force quit Safari.  I have only added MS Office to the computer and Carbonite.  Any suggestions?

    Select the icon of your startup volume ("Macintosh HD," unless you renamed it) in the Finder and open the Info window. What value is shown for Available (space)?

  • Mutating table and row state - this was unexpected

    So, I learned in a class about 3 years ago to expect the following
    SQL> create table p (pk number primary key);
    Table created.
    SQL> create table c (fk number references p(pk));
    Table created.
    SQL> create or replace trigger t_insrt
      2  before insert on p
      3  for each row
      4  begin
      5   insert into c values (:new.pk);
      6  end;
      7  /
    Trigger created.
    SQL> insert into p values (1);
    insert into p values (1)
    ERROR at line 1:
    ORA-02291: integrity constraint (FORBESC.SYS_C00169150) violated - parent key
    not found
    ORA-06512: at "FORBESC.T_INSRT", line 2
    ORA-04088: error during execution of trigger 'FORBESC.T_INSRT'and so it led me to think that replicating ON MODIFY PARENT - MODIFY CHILD functionality wouldn't work in a BEFORE ROW trigger, but it does
    SQL> drop trigger t_insrt;
    Trigger dropped.
    SQL> create or replace trigger p_updt
      2  before update on p
      3  for each row
      4  begin
      5   update c
      6   set fk = :new.pk
      7   where fk = :old.pk;
      8  end;
      9  /
    Trigger created.
    SQL> insert into p values (1);
    1 row created.
    SQL> insert into c values (1);
    1 row created.
    SQL> select * from c;
            FK
             1
    SQL> update p
      2  set pk = 2
      3  where pk = 1;
    1 row updated.
    SQL> select * from c;
            FK
             2Why would the first scenario fail while the second succeeds? The update seems prone to a parent record also not existing, at least not by the BEFORE ROW trigger.
    ---=Chuck

    < mutating table and row state >
    BTW, you don't seem to have run into the mutating table error though 2 other threads today are also about it. You have a constraint violation, a different thing entirely.
    I believe the second scenario works because you're neatly avoiding the error of the first. The error "ORA-02291: integrity constraint (FORBESC.SYS_C00169150) violated" means that on insert Oracle is looking up the value you're trying to insert, not finding it, and raising an error. With the before trigger you are taking the assigned value from the insert, updating the parent to it, so that on actual insert when the check happens the value is there due to the update.
    I'm not convinced this is a good idea because any on-the-fly approach to data entry needs to be examined carefully.

  • Dynamic build of a table trigger - Issue building :new and :old vars

    (which leads me to my next issue - this one might be a deal killer for me; see "Are Optional Parameters possible in Procedural Units?"
    I'm using a Select statement to dynamically create a table trigger which looks like the following:
    create or replace trigger tr_audit#reporter
    after update on reporter
    for each row
    begin
    ttms_audit_pkg.insert_audit_info( 'reporter', 'ZIP', :new.ZIP, :old.ZIP, 'REPORTER.REPORTER,REPORTER.PROJECT_CD', 'EXFC', :new.reporter, :new.project_cd);
    end;
    The :new. and :old. variables are generated based on which table_name is passed to the script creating this trigger. My problem is that I need all the :new. and :old. parameters to be passed in as Char. regardless of whether they are Number or Date variables.
    So in the example above...if :new.reporter is a number on the table then I need to to_char is like this:
    create or replace trigger tr_audit#reporter
    after update on reporter
    for each row
    begin
    ttms_audit_pkg.insert_audit_info( 'reporter', 'ZIP', :new.ZIP, :old.ZIP,
    'REPORTER.REPORTER,REPORTER.PROJECT_CD', 'EXFC', to_char(:new.reporter), :new.project_cd);
    end;
    However, since this trigger is created dynamically I will not know in advance which :new. and :old. parameters will need to be converted to character. So if to_char(:new.reporter) is used and :new.reporter is already a character on the table then I will get an error.
    So my question then is this. Is there a way to write this dynamic sql in a way to accomidate this problem? I'm thinking something that would act a bit like a decode does with values...pehaps something like this:
    decode(:new.reporter, NUMBER, to_char(:new.reporter), DATE, to_char(:new.reporter,'DD-MON-YYYY HH12:MIPM'), :new.reporter)
    ...if :new.reporter is a number then to_char it; if :new.reporter is a date then to_char it; otherwise let it be.
    By any chance does anyone know if this is possible? I would greatly appreciate any insights.

    Sure, you can selectively version-enable tables using Workspace Manager (you call DBMS_WM.EnableVersioning on each table you want Workspace Manager to track history for).
    What do you mean by "programmatically rollback changes"? Workspace Manager has the ability to call GotoTime and queries against a version-enabled table will return results as if you were querying it at that specific point in time (unless you've purged history of course). You can also use it to create what are essentially long-running transactions where you can work on multiple sets of proposed data changes simultaneously for days or months before finally deciding to commit a one particular set. It's incredibly powerful.
    Justin

Maybe you are looking for