Problem using AT..NEW statement

I have a internal table with structure
posting_date   amount
20090317       1500000
20090317      -950000
20090317        5000
20090319       8700
20090327       400000
20090327       32000
I am using AT NEW POSTING_DATE  to perform some operation on the amount.
loop at itab.
AT NEW POSTING_DATE
      LOGIC
ENDAT.
endloop.
all the record are working fine for AT NEW except for the last record.( posting date 20090327) It does not enter into AT..ENDAT
and simply goes to the endloop..Probably the reason for this is in AT new the current posting date is compared with the one that is above it...and if they are different AT NEW gets triggered. But in my case both the second last and last posting_date are the same, that's why AT NEW is not getting triggered..Please tell me how to solve this problem, how can I do the processing of last record?
PS this problem does not occur if both second last record and last record are different.
Edited by: priyasingh on Jul 22, 2009 11:01 AM

Hi,
AT NEW gets triggered here (in place where tested value has changed)
20090317       1500000   "<- here
20090317      -950000
20090317        5000
20090319       8700  "<- here
20090327       400000  "<- here
20090327       32000
If you want to get last value, use AT END OF event which get triggered
20090317       1500000  
20090317      -950000 
20090317        5000 "<- here
20090319       8700  "<- here
20090327       400000
20090327       32000 "<-here
And in case you want totally last value, use AT LAST event
20090317       1500000  
20090317      -950000 
20090317        5000
20090319       8700 
20090327       400000
20090327       32000 "<- only here
Regards
Marcin

Similar Messages

  • Problem Using Multiple With Statements

    I'm having a problem using multiple WITH statements. Oracle seems to be expecting a SELECT statement after the first one. I need two in order to reference stuff from the second one in another query.
    Here's my code:
    <code>
    WITH calculate_terms AS (SELECT robinst_current_term_code,
    CASE
    WHEN robinst_current_term_code LIKE '%60' THEN robinst_current_term_code - '40'
    WHEN robinst_current_term_code LIKE '%20' THEN robinst_current_term_code - '100'
    END first_term,
    CASE
    WHEN robinst_current_term_code LIKE '%60' THEN robinst_current_term_code - '100'
    WHEN robinst_current_term_code LIKE '%20' THEN robinst_current_term_code - '160'
    END second_term
    FROM robinst
    WHERE robinst_aidy_code = :aidy)
    /*Use terms from calculate_terms to generate attendance periods*/
    WITH gen_attn_terms AS
    SELECT
    CASE
    WHEN first_term LIKE '%60' THEN 'Fall '||substr(first_term,0,4)
    WHEN first_term LIKE '%20' THEN 'Spring '||substr(first_term,0,4)
    END first_attn_period,
    CASE
    WHEN second_term LIKE '%60' THEN 'Fall '||substr(second_term,0,4)
    WHEN second_term LIKE '%20' THEN 'Spring '||substr(second_term,0,4)
    END second_attn_period
    FROM calculate_terms
    SELECT *
    FROM gen_attn_terms
    <code>
    I get ORA-00928: missing SELECT keyword error. What could be the problem?

    You can just separate them with a comma:
    WITH calculate_terms AS (SELECT robinst_current_term_code,
    CASE
    WHEN robinst_current_term_code LIKE '%60' THEN robinst_current_term_code - '40'
    WHEN robinst_current_term_code LIKE '%20' THEN robinst_current_term_code - '100'
    END first_term,
    CASE
    WHEN robinst_current_term_code LIKE '%60' THEN robinst_current_term_code - '100'
    WHEN robinst_current_term_code LIKE '%20' THEN robinst_current_term_code - '160'
    END second_term
    FROM robinst
    WHERE robinst_aidy_code = :aidy),
    /*Use terms from calculate_terms to generate attendance periods*/
    gen_attn_terms AS
    SELECT
    CASE
    WHEN first_term LIKE '%60' THEN 'Fall '||substr(first_term,0,4)
    WHEN first_term LIKE '%20' THEN 'Spring '||substr(first_term,0,4)
    END first_attn_period,
    CASE
    WHEN second_term LIKE '%60' THEN 'Fall '||substr(second_term,0,4)
    WHEN second_term LIKE '%20' THEN 'Spring '||substr(second_term,0,4)
    END second_attn_period
    FROM calculate_terms
    )Not tested because there are no scripts.

  • Problem using the new Lightening Plug in my car's USB port?

    I have an 2011 Lexus RX 350 and just got a new IPAD mini.  I tried using the Mini on a recent trip by plugging it into my car's USB port and got a message on the car's entertainment display that it could not recognize the USB device.  Anyone else having this problem?

    Karlfromny wrote:
    I realize that. The plug in question has a USB connector on one side and the new Lightening interface on the other.  The USB side is plugged into the car and the otherside of the cable into the Mini.
    If this is a connector supplied by the electronics manufacturer for use with that radio and iOS devices then something is wrong.  If it supplied by a 3rd party then I wouldn't expect it to work at this stage of the game.  I also suspect that in a few months most manufacturers will have a new system that will work fine with the Lightning connector.
    I have an audio system based upon the Pioneer Z140BH head unit and it worked very well with the iPhone 4S.  It works fine for audio from my iPhone 5 with the 30-pin to Lightning connector but doesn't work at all with the video functions.  Pioneer has announced an adapter that will allow it to work with the iPhone 5 but it won't be available for a few weeks.
    As another said, if this is just a USB connection and not a 30-pin Apple style connection then its not likely to work at all without an update.

  • Problems using my new iPod classic, says it requires iTunes version 10.7!

    I've just bought an iPod classic to store my music collection, but it says it can't be used because it requires iTunes version 10.7 or later. (I'm currently running iTunes version 10.6.3) I can't download iTunes version 10.7 because my iMac is running on OS X version 10.5.8. I hadn't anticpated this problem as the iPod classic is a relatively old model, not updated since 2009. I didn't really want to buy new operating software for my Mac as well. Any ideas what to do please?

    Whatever you do, DO NOT update to iTune 11.  It won't work with iPod Classic.

  • Having extreme problems using the new iMac, adobe CS5 (in particular InDesign) and OSX 10.8.2 (and now also 10.8.3) Mountain Lion

    Is anyone else experiencing the same thing? My computer is 2 months old and has hardly any files stored on it. Also, my
    Graphics  NVIDIA GeForce GT 650M 512 MB and my memory is 16 GB 1600 MHz DDR3.
    I am only running one thing on the computer as we speak - making a small pattern in InDesign - yet is has been frozen for over 20 mins, and that's not the first time this has happened.
    I updated to the latest Mountain lion this morning (10.8.3) and its exactly the same.
    I dont understand why this is happening, but on the older iMac i could run several windows of the entire creative suite without a problem - i was also using Snow Leopard.
    please help!

    noellia wrote:
    Is anyone else experiencing the same thing? My computer is 2 months old and has hardly any files stored on it. Also, my
    Graphics  NVIDIA GeForce GT 650M 512 MB and my memory is 16 GB 1600 MHz DDR3.
    I am only running one thing on the computer as we speak - making a small pattern in InDesign - yet is has been frozen for over 20 mins, and that's not the first time this has happened.
    I updated to the latest Mountain lion this morning (10.8.3) and its exactly the same.
    I dont understand why this is happening, but on the older iMac i could run several windows of the entire creative suite without a problem - i was also using Snow Leopard.
    please help!
    Do you have any Security/Anti-Virus software installed? Mackeeper? Any Third Party programs you have installed recently?
    Pete

  • Is anybody else having big problems using the new pages?

    Everything has moved and even the help section isn't that helpful. I have been sitting in class for over an hour trying to make a portfolio, but can't because everything is so different. I have no idea how any of the changes are supposed to make it simpler. You can't even save as a word document! Instead there's all this export rubbish. I'm going to fail this class because of the new pages update. I have been putting off this update for weeks but since the newest OS update, everything is automatically updating so I had no choice. Actually make it easier, or make it possible to undo the update.

    It's been 7 months since it came out. Didn't you read the reviews in the App Store? Plus all the forum posts here?
    http://www.freeforum101.com/iworktipsntrick/viewforum.php?f=22&mforum=iworktipsn trick
    Use Pages '08/'09 it should still be in your Applications/iWork folder.
    Peter

  • Problem using a new sim card!

    Hi!
    Hope someone can help me with this! I have curve 9360, bought it in England and have used it there on an english simcard. But I'm home in Norway for Christmas and can't get it to work with my norwegian simcard.. When I put the norwegian one in the phone and it asks me to log in with my blackberry id, it doesn't work.. Says: username and password provided do not correspond to a valid BlackBerry ID. 
    But I'm able to log in with that bb id on my computer, so it obviously works. If I try the "forgotten your password" and says: your request cannot be completed. Please ensure that your BlackBerry ID has been activated and that you have typed the correct email address.
    Does anyone know what might be happening?
    Really appreciate all the help I can get!

    Hello ashharuddin,
    Thank you for using Apple Support Communities.
    For more information, take a look at:
    iPhone: Troubleshooting No SIM
    http://support.apple.com/kb/ts4148
    Toggle Airplane mode On and Off.
    Try turning iPhone off and then on again.
    Check for a carrier settings update. Tap Settings > General > About. If an update is available, a prompt will appear.
    Remove the SIM Card and verify that it is a valid, carrier-manufactured SIM. Also verify that it is not damaged, worn, or modified. Then reinsert it.
    Restore the iPhone.
    Have a nice day,
    Mario

  • Workarea field is changing to ********* when i use at new command

    Hi All,
    I have a workarea. In that work area i have a field (zsample -zbill_zrass). I am using  at new statement.
    My problem is when i debug the code, am able to see that when the control goes inside at new statement, my field (zsample -zbill_zrass). which is holding a number is changing into ***********.  I have attached the code below for your reference.
    Please help me to solve this issue.
    loop at lt_zsample[] into wa_ zsample.
          clear wa_usr_addr.
          read table it_usr_addr into wa_usr_addr
                            with key accnt = zsample -zbill_zrass.
          if sy-subrc = 0.
            CONCATENATE lv_string zsample -zbill_zreff into wa_temp-zbill_zreff
                           SEPARATED BY space.
            wa_temp-zbill_zrass   = zsample -zbill_zrass.
            wa_temp-accnt        = wa_usr_addr-accnt.
            wa_temp-smtp_addr    = wa_usr_addr-smtp_addr.
            lv_temp = lv_string.
            lv_string = wa_temp-zbill_zreff.
            at new zbill_zrass.   -
    >  when control goes inside this (at new ) my problem occurs
              clear lv_string.
              if lt_temp is not initial.
                describe table lt_temp lines lv_line.
                read table lt_temp into wa_temp index lv_line .
                if sy-subrc is initial.
                  wa_temp-zbill_zreff = lv_temp.
                  modify lt_temp index lv_line from wa_temp TRANSPORTING zbill_zreff.
                endif.
                clear wa_temp.
              endif.
              wa_temp-zbill_zreff  = wa_ zsample -zbill_zreff.
              wa_temp-zbill_zrass   = wa_zsample -zbill_zrass.
              wa_temp-accnt        = wa_usr_addr-accnt.
              wa_temp-smtp_addr    = wa_usr_addr-smtp_addr.
              lv_string = wa_temp-zbill_zreff.
              append wa_temp to lt_temp.
              clear wa_temp.
            endat.
          endif.
    clear wa_sample.
    endloop.

    Hi, Mohamed Aslam 
    Suppose you have the following Internal Table.
    Field1 Field2 Field3
    When ever you will use AT NEW, AT END or AT LAST mean any of Control Break Statement one the Field1 you will find all the Fields on the right hand side of that field as *** Stars in it, Suppose if you will use these all on Field2 than Field1 OK Field2 will also be OK but Field3 will again have Stars to over come this you can define a new work are and just before going into these Statement's Blocks assigns the current work area to that one just like the following.
    wa_all_ok = wa_stars.
    than do your processing on that wa_all_ok instead of wa_stars
    Please Reply if any Confusion,
    Best Regards,
    Faisal

  • 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

  • Using a newer db version than what a COTS application supports

    This is more of a general question ...
    My manager today asked me what I thought about moving an application's back-end from SQL Server into Oracle. He was concerned because in SQL Server, they were repeatedly constrained in upgrading the database to newer versions, because the vendor was slow in approving newer versions of SQL Server. He didn't want to impact our plans to upgrade Oracle (95% of our data) because one application (5% of our data) was in conflict.
    So it got me to thinking, has anyone ever had a problem using a newer version of the database, than what a vendor claims to support? I guess I'm thinking that as long as the software has a compatible client, then a newer database should be a safe gamble? Am I being naive? It just seems like with Oracle, newer versions bring in newer features, but rarely remove anything.
    --=Chuck

    I wouldn't run a version of Oracle that the vendor didn't support. While it's true that Oracle isn't likely to remove a particular feature, adding a new feature can cause just as many problems-- you may find that query plans change, for example, or you may find bugs where the COTS vendor assumes that SQL behaves one way because it happens to do that in one version of Oracle but the behavior changes in a future version. Plenty of COTS software assumed that GROUP BY did an implicit ORDER BY because Oracle happened to implement GROUP BY by doing a sort. Until 10g, I believe, when hash group by's were introduced, and suddenly things that were supposed to be sorted weren't sorted anymore.
    Normally, each COTS application would have its own separate database. That allows you to upgrade and patch other Oracle instances without worrying about whether the COTS vendor supports it. When the COTS vendor validates their application against the new version of the database, you then upgrade the COTS Oracle instance. So it normally doesn't affect your upgrade schedules for everything else in the world if one application wants to use an older version of Oracle.
    Justin

  • At New statement problem

    Hello experts,
    I am currently having a problem with my At New statement. It is treating every field of the itab as a new record even though it is the same.
    For example,
          on the first loop the field matnr has a value of mat-A then the at new will trigger.
         then on the second loop matnr has a value of mat-B then again, At New will trigger.that is correct.
        But on the third loop, the field matnr will have a value again of mat-B or Mat-A- the same as that of the second or first loop. So it must not trigger the At New statement but it does.
               Any solutions?
       MY CODING.....
    SORT IT_FINAL BY MATNR.
    LOOP AT IT_FINAL.
    wa_final = it_final.
       at new matnr.
             it_final1-matnr = wa_final-matnr.
              it_final1-maktx = wa_final-maktx.
              it_final1-bdmng = VAL1.
              APPEND it_final1.
              clear : it_final, it_final1, wa_final.
              endat.
    ENDLOOP.
                                          Thanks!
    REGARDS,
    NAVANEETH.

    Hi navaneethan,
    it is important to understand SAP's concept of Control Level Processing using statements AT NEW f and AT END OF f.
    Originally this was defined for the obsolete technique of extracts and that is where the documentation can be found.
    [<a href="http://help.sap.com/saphelp_erp2005vp/helpdata/en/9f/db9f1f35c111d1829f0000e829fbfe/content.htm">Control Level Processing</a>]
    The documentation for extract datasets applies exactly to internal tables:
    The table mus be sorted to get control levels defined. 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 internal table is not sorted, the AT - ENDAT block is never executed.
    Please have a look at the graphical demonstration of Control level processing in this document: <a href="http://help.sap.com/saphelp_erp2005vp/helpdata/en/fc/eb381a358411d1829f0000e829fbfe/content.htm">Processing Table Entries in Loops</a>
    Regards,
    Clemens
    BTW: Too bad we have anonymous MOD

  • Problem with AT NEW and AT END Statements

    Hi all,
    I am facing a problem in a report with i have to change ,
    currently report is for single plant input but now multiple option is to be given , so now the material quantity and value should come along with material and plant.
    But in report lot's of AT NEW matnr and AT END of matnr has been use but now i have to add plant in it , but these statements take only one parameter.
    I tried using ON CHANGE Statement but in that SUM Can't be use.
    So please help me in sorting out this problem.
    Thanks and Regards,
    Vivek

    Hi,
      Already you are using material in AT NEW statements and you want to include Plant. by changing the structure you can continue with the same statement i.e., AT NEW matnr.
    Structure:
    Data: begin of itab  occurs 0,
               werks  type werks,
               matnr   type  matnr,
               qyt     type  matqty,
             end of itab.
    SORT itab BY  werks, matnr.
    If you use AT NEW matnr. this will be triggered  when plant value changes and also when matnr changes.
    Hope it is clear.

  • Sharpener Pro 3 has problems in Aperture as the Pre sharpener continually asks one to buy or activate and the Output Sharpener causes Aperture to hang. Have removed all duplicate fonts and tried using a new user account. Any ideas?

    I am experiencing problems with Sharpener Pro 3 as an Aperture 3 plug-in. These are:  the Pre sharpener continually asks one to buy or activate and the Output Sharpener causes Aperture to hang. Following discussions with Nik Software I have removed all duplicate fonts and tried using a new user account. Neither of the courses of action worked. Have other users experienced these difficulties? Can you suggest an alternative remedy?

    I am experiencing problems with Sharpener Pro 3 as an Aperture 3 plug-in. These are:  the Pre sharpener continually asks one to buy or activate and the Output Sharpener causes Aperture to hang. Following discussions with Nik Software I have removed all duplicate fonts and tried using a new user account. Neither of the courses of action worked. Have other users experienced these difficulties? Can you suggest an alternative remedy?

  • I refurbished my macbook air 7 months ago because there was a problem with the steady state drive. Now my battery seems to be dead again. How long does the warranty last? Do I need to pay for a new battery?

    I refurbished my macbook air 7 months ago because there was a problem with the steady state drive. Now my battery seems to be dead again. How long does the warranty last? Do I need to pay for a new battery?

    As I wrote Apple will diagnose an Apple product even if it is out of warranty for free. That should be your first step to find out if the problem is the battery or something else.
    Once you have Apple telling you a 7 month old battery is defective (if that turns out to be the case)  then it becomes a game of horse trading. You'll need to speak to the tech and when he tells you there is nothing he can do you will need to speak to the tech manager and when she says most likely there is nothing they can do you go to the store manager, etc.  It is unlikely (though possible) that they will give in easily you need to be firm, polite and let on that you're willing to accept a partial reimbursement.
    So again the first step is to find out what is wrong.
    good luck

  • OS is Mountain Lion, upgraded no problems, used an external Hard drive for my time machine, now my iPhoto will not show any of my photo's or ay new ones I import! Help please!!

    OS is Mountain Lion, upgraded no problems, used an external Hard drive for my time machine, now my iPhoto will not show any of my photo's or ay new ones I import! Help please!!

    Do you get this window when you hold down the Command+Option keys and launch iPhoto?
    If not then you're not holding down both keys long enough.
    OT

Maybe you are looking for

  • Download Oracle Forms 4.5 documentation

    hi, I want to download Oracle forms 4.5 complete documents. Can any one help me where i can look for that. Thanks. Alka

  • BUG: RTSP cannot play live streams

    Sun's RTSP implementation does not handle live streams. Live streams have a range with a starting time but no ending time. Looking at the source code of com.sun.media.content.rtsp.RtspUtil.setDuration(), there's no check for the possibility that the

  • Haw to get movie's on my IPad??

    I have a movie with a digital copy with it and it says it works with iTunes bot wen I put it in my windows computer iTunes doesn't do any thing so what do I do???

  • Desktop Icon does not launch program on Mac after download

    Purchased from Adobe via internet.  Akamai interface downloaded and then Photoshop Elements 11.  Both icons on Mac desktop.  Double clicking on PE 11 does not launch program.  Is it fully downloaded?  I get Read Me file in four languages as well as a

  • Inserting Flash Video Error

    I am using CS3 and trying to insert a .flv file that is on a remote server and I keep getting this error: /Scripts/ - error occurred - Unable to create remote folder /Scripts/. Access denied. The file may not exist, or there could be a permission pro