Fetch Last Valid Record

I am using PNPCE LDB and I need only PERNR on my selection screen . Hence used ___CE002 report category. Now when I run the report, I get all the records for each pernr from IT0001. But I will need only the last or recent record. How do I control this?
My Declarations:
Nodes
NODES: peras.
Logic:
Get Personnel assignment
GET peras.
Fetch only the Last Record
  rp_provide_from_last p0001 space pn-begda pn-endda.
Thanks,
Kiran

Hi Kiran,
Try this way.
REPORT  ztest_notepad.
NODES peras.
INFOTYPES 0001.
DATA: BEGIN OF it_p0001 OCCURS 0,
        pernr TYPE pa0001-pernr,
        subty TYPE pa0001-subty,
        bukrs TYPE pa0001-bukrs,
        werks TYPE pa0001-werks,
        persg TYPE pa0001-persg,
        persk TYPE pa0001-persk,
      END OF it_p0001.
START-OF-SELECTION.
GET peras.
  rp_provide_from_last p0001 space pn-begda pn-endda.
  IF pnp-sw-found = '1'.
    MOVE-CORRESPONDING p0001 TO it_p0001.
    APPEND it_p0001.
  ELSE.
    REJECT.
  ENDIF.
END-OF-SELECTION.
"Display It_p0001 data once all employess are processed
"between GET PERAS and END-OF-SELECTION.
Thanks
Venkat.O

Similar Messages

  • Query takes too much time in fetching last records.

    Hi,
    I am using oracle 8.1 and trying to execute a SQL statement, it takes few minutes and display records.
    When trying to fetch all the records, it is fast up to some level and takes much time to fetch last record.
    Ex: If total records = 16336 , then it fetches records faster up to 16300 and takes app.500 sec to fetch last 36 records.
    Could you kindly let me know the reason.
    I have copied the explain plan below for your reference.Please let me know if anything is required.
    SELECT STATEMENT, GOAL = RULE               4046     8     4048
    NESTED LOOPS OUTER               4046     8     4048
      NESTED LOOPS OUTER               4030     8     2952
       FILTER                         
        NESTED LOOPS OUTER                         
         NESTED LOOPS OUTER               4014     8     1728
          NESTED LOOPS               3998     8     936
           TABLE ACCESS BY INDEX ROWID     IFSAPP     CUSTOMER_ORDER_TAB     3966     8     440
            INDEX RANGE SCAN     IFSAPP     CUSTOMER_ORDER_1_IX     108     8     
           TABLE ACCESS BY INDEX ROWID     IFSAPP     CUSTOMER_ORDER_LINE_TAB     4     30667     1901354
            INDEX RANGE SCAN     IFSAPP     CUSTOMER_ORDER_LINE_PK     3     30667     
          TABLE ACCESS BY INDEX ROWID     IFSAPP     PWR_CONS_PARCEL_CONTENT_TAB     2     2000     198000
           INDEX RANGE SCAN     IFSAPP     PWR_CONS_PARCEL_CONTENT_1_IDX     1     2000     
         TABLE ACCESS BY INDEX ROWID     IFSAPP     PWR_CONS_PARCEL_TAB     1     2000     222000
          INDEX UNIQUE SCAN     IFSAPP     PWR_CONS_PARCEL_PK          2000     
       TABLE ACCESS BY INDEX ROWID     IFSAPP     CONSIGNMENT_PARCEL_TAB     1     2000     84000
        INDEX UNIQUE SCAN     IFSAPP     CONSIGNMENT_PARCEL_PK          2000     
      TABLE ACCESS BY INDEX ROWID     IFSAPP     PWR_OBJECT_CONNECTION_TAB     2     20     2740
       INDEX RANGE SCAN     IFSAPP     PWR_OBJECT_CONNECTION_IX1     1     20     Thanks.

    We are using PL/SQL Developer tool. The time what we have mentioned in the post is approximated time.
    Apologies for not mentioning these details in previous thread.Let it be approximate time but how did you arrive at that time? When a query fetches records how did you derived that one portion is fetched in x and the remaining in y time limit?
    I would suggest this could be some issue with PL/SQL Developer (Never used this tool by myself) But for performance testing i would suggest you to use SQL Plus. Thats the best tool to test performance.

  • Getting Last Payroll Record

    Hi all,
    I need to fetch last payroll record of a pernr,from transaction pc_payresult.
    I am using the LDB PNP.
    After calling GET PERNR, I am using functions CU_READ_RGDIR and then PYXX_READ_PAYROLL_RESULT to fetch the last active payroll record.
    But is there any way to <b>directly</b> fetch the last active payroll record,based on the pernr? Please suggest a way.
    Thanks&Regards
    Ananya

    Hi
    To get the payroll results, you need to read the cluster CU to get RGDIR. For this CU_READ_RGDIR is used and almost all standard programs also use this FM.
    Simple Report using LDBs to get latest payroll result.
    report ythr_read_payroll .
    data: t_rgdir type pc261 occurs 0,
          t_result type payus_result,
          w_bt type line of hrpay99_bt,
          out_seqnr like pc261-seqnr.
    tables: pernr.
    get pernr.
      call function 'CU_READ_RGDIR_NEW'
           exporting
                persnr                = pernr-pernr
           tables
                in_rgdir              = t_rgdir
           exceptions
                no_record_found       = 1
                import_mismatch_error = 2
                no_read_authority     = 3
                others                = 4.
      if sy-subrc <> 0.
        write:/1 'No payroll results for ', pernr-pernr.
      endif.
    call function 'CD_READ_LAST'
           exporting
                begin_date      = pn-begda
                end_date        = pn-endda
           importing
                out_seqnr       = out_seqnr
           tables
                rgdir           = t_rgdir
           exceptions
                no_record_found = 1
                others          = 2.
      if sy-subrc <> 0.
        write:/1 'Error for ', pernr-pernr.
      endif.
      call function 'PYXX_READ_PAYROLL_RESULT'
           exporting
                clusterid                    = 'RU'
                employeenumber               = pernr-pernr
                sequencenumber               = out_seqnr
           changing
                payroll_result               = t_result
    exceptions
                illegal_isocode_or_clusterid = 1
                error_generating_import      = 2
                import_mismatch_error        = 3
                subpool_dir_full             = 4
                no_read_authority            = 5
                no_record_found              = 6
                versions_do_not_match        = 7
                error_reading_archive        = 8
                error_reading_relid          = 9
                others                       = 10.
      if sy-subrc <> 0.
        write:/1 'Error for ', pernr-pernr.
      endif.
      loop at t_result-inter-bt into w_bt.
        write:/1 pernr-pernr, out_seqnr, w_bt-bankl, w_bt-bankn.
      endloop.
    Regards
    Navneet

  • Fetch last record from database table

    hi,
    how to fetch last record from database table.
    plz reply earliest.
    Regards,
    Jyotsna
    Moderator message - Please search before asking - post locked
    Edited by: Rob Burbank on Dec 11, 2009 9:44 AM

    abhi,
    just imagine the table to be BSEG or FAGLFLEXA... then what would be performance of the code ?
    any ways,
    jyotsna, first check if you have a pattern to follow like if the primary key field have a increasing number range or it would be great if you find a date field which stores the inserted date or some thing..
    you can select max or that field or order by descending using select single.
    or get all data.. sort in descending order.(again you need some criteria like date).
    read the first entry. using read itab index 1

  • How to fetch last transactioned values for given period

    Hi,
    I'm working on a report, here I'm fetching data from j_2irg1bal table for some period. it has data to internal table like
    e.g. : given period 01-04.2009 to  30.04.2009
    date        mantr  opening balance closing balance
    04.04.2009  1007     100             130
    08.04.2009  1007     130              80
    here for given date two record are available,
    i need to capture last updated value i.e. for date 08.04.2009.
    Kindly suggest your ideas to move with this

    Hi,
    Assume that your values are in internal table ITAB.  Then,
    Sort ITAB by date DESCENDING.
    Doing so, your records gets sorted in Descending Order with respect to Date. And the Last updated record comes in the first position.
    And now,
    Read table ITAB index 1.
    The above code, fetches the last record into the Work-Area.
    That's it.
    Rgds,
    Ramani N

  • How to populate last 10 records from data base table

    Hi,
    My requirement is to populate last 10 transfer order items confirmed from LTAP. as the table is too large there is no point to fetch all the records and filter them...
    Please let me know better way (in terms of performace) to get last 10 records from LTAP.
    Thanks in advance.
    Nag

    Hi brother,
    the following code is working......(sample code)
    data itmara type mara occurs 0 with header line.
    select matnr from mara into corresponding fields of table itmara up to 20 rows.
    sort itmara descending by matnr.
    loop at itmara .
    write:/ itmara-matnr.
    if sy-tabix = 10.
    exit.
    endif.
    endloop.
    plz reward with maximum points
    Edited by: sreejith gn on May 13, 2008 12:52 PM

  • Form Error 40507: unable to fetch next query record

    Hi there folks,
    I have a Form (10g) where I have a Master Block and a Detail block. However, the other day, there was an Error reported:
    ORACLE error: unable to fetch next query record
    When we do capture Errors, we also capture the Last Query run. From that, it says that the last record that was queried was in the Detail block (Which is multi-record block) in tabular form. I looked at the Error Message but there is not much information on this Error.
    So, it's just a base table block and it has a drop down list which has two values. Any ideas what could have happened?
    Thanks!

    The Block is based on a a table. As a mattr of fact, there are 3 blocks in the form and they are all based on tables. Now, it migth be wrong for me to assume that the detail block in the one that caused the problem just because the Last Query was based on the detail block.
    Block 1 is a single record block -- Master Block
    Block 2 is a tabular block -- Detail Block
    Block 3 is a tabular block -- Detail Block
    There are two relations:
    Block 1 and Block 2
    Block 1 and Block 3

  • How to find last inserted record in the table.

    Version: Oracle 10g
    I have a table called "Manufacture" and 3 columns as mfno,itemname,quantity.
    How to find last inserted record in the table "Manufacture".
    As i come to know that Rowid is not result perfect results. Please provide your inputs.

    user13416294 wrote:
    Version: Oracle 10gThat is not a version. That is a product name. A version is 10.1.0.2 or 10.2.0.4, etc.
    I have a table called "Manufacture" and 3 columns as mfno,itemname,quantity.
    How to find last inserted record in the table "Manufacture".Not possible as your data model does not cater for it. That simple.
    If there is a need to determine some order or associate some time to an entity, then that should be part of the data model - and a relationship, or one or more attributes are needed to represent that information. Thus your data model in this case is unable to meet your requirements.
    If the requirements are valid, fix the data model. In other words - your question has nothing to do with Oracle and nothing to do with rowid, rowscn or other pseudo columns in Oracle. It is a pure data modeling issue. Nothing more.

  • Fetch last match data..

    table
    id carno houseno entrytime                            exit time
    1  11       333        3/4/2014 3:15:18 PM         3/4/2014 3:25:18 PM
    2  11       333        3/4/2014 3:35:18 PM         3/4/2014 3:45:18 PM
    3 11       333        3/4/2014 3:55:18 PM         3/4/2014 4:25:18 PM
    4  14       33        3/4/2014 4:35:18 PM         3/4/2014 5:25:18 PM
    5   15      544      3/4/2014 6:35:18 PM         3/4/2014 7:25:18 PM
    6 11       333        4/4/2014 3:55:18 PM         null
    7 15      544        6/4/2014 3:55:18 PM         6/4/2014 4:25:18 PM
    this is my table structure.............
    so my query is i want to search row which use where clause to match carno and houseno.....in my table so many place carno and houseno are same but only timings are different ..i want to select the last entry which matchs...
    example i give input houseno-333 and carno-11 then i want to serch last entry for this same houseno and carno...that means id-6 will be fetch.......how to achieve this.....i m able to fetch last record with where clause like house no and carno condition.....then
    i want to check is exit time in null in dis row or having some value...
    fynl summary i want to retrive last row based on where clause after retrivinbg i want to check value of exit column....
    is it blank or some value in exit time..

    there are so many issue arise when i test with dummy values..
     some chnges.....
    id carno houseno entrytime                            exit time
    1  11       333        3/4/2014 3:15:18 PM         null
    2  11       333                       null                     3/4/2014 3:45:18 PM
    3 11       333        3/4/2014 3:55:18 PM        null
    4  14       33       null                                     3/4/2014 5:25:18 PM
    5   15      544      3/4/2014 6:35:18 PM         null
    6 11       333        4/4/2014 3:55:18 PM         null
    7 15      544        6/4/2014 3:55:18 PM         null
    now i have to find if there is two  simulatneously entry  happening in a sequence means without exit
     between  two entry of same carno and house no..   thn i need to beep alarm.....if entry tym is store then it should exit first for reenter again....if somehave two duplicate id of card no and house no..then we need to find duplicate of id....this
    is rfid tag which is used for enter in a society,,,,entry gate will open after  identify this tag
    example/////// id-5 carno-15 enter at  3/4/2014 6:35:18 PM  means last entry inserted...after tht no exit
    happen for this carno and houseno.......at 7 id it will try again to enter..but it doesnot have exit so we need to restrict this.......

  • How to fetch last changed date for Header in me22n?

    Hi Experts,
    I need to create a report for PO, where I have created one screen tab in Header level(customer data), therefore I need to fetch last changed date for header , I must mention that I do not want last changed date for item level, only for header last changed date is required.
    Kindly assist me on this.
    Thanx
    Shireen

    Read table CDHDR (object "EINKBELEG") and CDPOS (look for table name EKKO), keep the last CDHDR record with "EKKO" data actually changed.
    Regards,
    Raymond

  • To Fetch current data record

    Hi All,
    I have an Requirement in WebI to fetch the latest updated record for a particular employee.
    In my report I have the columns:
    Employee Emp ID Nationality         Date            Department
    Empx       23156      USA         20-03-2014        ELE
    Empx       23156      USA         26-01-2014        DVX
    Empx       23156      USA         19-12-2013        INV
    Empx       23156      USA         15-11-2013        ME
    Usually an Employee will keeps on changing the department time to time.Upon execution of report, I am getting the above results .
    But the client requirement is to maintain only 1 record for a particular employee and that too latest record.
    Client is nowhere bothered what all departments he has changed before , but he is bothered only the current department which he belongs currently and he wants only that latest record.
    So , if we consider the above mentioned scenerio, the client wants only 1 last updated record for that particular employee in the report i.e
    Employee  Emp ID  Nationality   Date               Department
    Empx        23156      USA         20-03-2014        ELE
    Please be noted that, for the report data is coming from Bex query and I am working on BO 4.1 version.
    Could anyone please let me know what could be done for this requirement?

    Hi Cris,
    Follow Below steps:
    1.     Create one variable as below:
            =[Date] Where( [Date] = Max([Date]) In([Emp ID]))
    2.     Now Select your table. Go to Analysis > Filter. Click on "Add filter", Select the variable created                          above. Now put the filter as "Is not null".
    You will get desired data.
    Regards
    Rakesh

  • Question on SFSF Adapter : Delta sync to fetch only changed records.

    Hi All ,
    As per the SAP Document on SFSF Communication channel, one of the feature supported by SP00 release of the connectivity add-on 1.0 is :-
    1. Delta sync to fetch only changed records
    SFSF Adapter: Delta Sync
    The delta sync features enables you to fetch only the records that were modified after the last successful data fetch from the SuccessFactors system.
    This increases the efficiency of query operation.
    So below are my question accross Successfull run date feature :
    Is it SAP PI Connector internally maintains this last successful run date ?
    what would be Time-Zone of Successful run date : Is it where SF DC is located or where PI Box is Located ?
    what is it mean from successful run date ? - is it process successful run date or is it just communication channel successful run date ?
    For Delta extraction - This Successful Run Date - Is it maintained internally for  Interface wise or Communication Channel wise ?
    eg. If i have 5 Delta Interface - will SAP PI maintain 5 Successfull run dates w.r.t to each connector or w.r.t each Process ?
    for more information please open below URL.
    http://help.sap.com/saphelp_nw-connectivity-addon100/helpdata/en/1e/22aaf0780d4b78b6f889157f6a8035/frameset.htm
    Regards
    Prabhat Sharma

    Hello all,
    I have the same question : in the "official" documentation (SuccessFactors (SFSF) Adapter for SAP NetWeaver Process Integration) is mentioned this :
    Delta Sync - The delta sync features enables you to fetch only the records that were modified after the last successful data fetch from the SuccessFactors system. This increases the efficiency of the query operation.
    Anyway I cant find any specification on how to use this feature. Do you have any suggestion on how to implement it or any reference to an existing documentation?
    Do I need to write you an email to get the info?
    Regards

  • How to fetch all the records

    Hello everybody,
    I am currently working on SQL Developer for the couple of weeks. I have specific need to check, how much time one query take to fetch all the records. Currently it can fetch only 50 records and when scroll then next 50 records and so on.
    Can anybody tell me, how to set this to fetch full records
    Regards,
    Martand M Joshi

    Martand,
    There's no setting to fetch all records. You wouldn't like SQL Developer to fetch for minutes on big tables anyway.
    If, for 1 specific table, you want to fetch all records, you can do Control-End in the results pane to go to the last record. You could time the fetching time yourself, but that will vary on the network speed and congestion, the program (SQL*Plus will be quicker than SQL Dev because it's more simple), etc.
    Now, what I think you really want here, is getting the execution time. If you really want to analyze the query's performance, you'd have to use the explain plan, autotrace and tkprof (see the manual for tuning and performance).
    To make us life easier, the makers of SQL Developer included support of the explain plan, and as of v1.1, autotrace!
    I'm sure you've got enough to work things out from here...
    Regards,
    K.

  • How can I get the last / newest record of a table?

    Hi,
    I am developing an ecard app that has a create greeting page, a preview page with edit and send buttons and an edit page.
    I got he insert working, and on the preview page I created a master record page (displays all records), and delete all unecessary designs. Doing it this way also gives me the 'edit' button, so people are able to edit their page.
    How do I get only the last record displayed though? At the moment it loops through all records and displays them in sets of 10. I found the variable that holds the totla count of records ('$totalRows_rs7417_content1'), but how do I (re-)write the script so it ONLY diplays the last record?
    I need to get the ID of this record as I am writing this into the PARAMs of the object and embed tags of my message .swf (this picks up the ID and based on that sucks the greetings text out of the database via another php script.
    Also, from this page, how can I send an email to the sender (ie creator of the message) as well as the recipient? Both email addresses are in the databse so should be part of the erecord returned.
    Thanks,
    Nik

    -----
    OK, So how do I recreate what I got in a non-ADDT list?
    well, when you´re just about to display one certain record, the term "list" is somewhat inappropriate anyway.
    What you´d simply need to do IMHO, is using DW´s native functions to create the basic "SELECT * FROM table_name ORDEr BY ID DESC" query, add "LIMIT 1" manually, and display the desired "dynamic text" placeholders in 1 table cell -- don´t think there were any need for all the fancy stuff
    (sorting, filtering etc) provided by ADDT´s list, as it´s just 1 record.
    It also occurred to me just now that finding the last record that has been added *may-* notbe enough if the site gets used a lot by our executives (I am thinking of a situation where 2 or three peolpe create greetings at the same time and press submit and then getting each others messges rather than their own).
    in this case you might want to additionally store the respective executive´s "kt_login_id" session variable -- because it´s this unique "identifier" which should be used to show the last inserted record of the person who actually inserted it, means adding a "WHERE submitter_id" equals the session variable kt_login_id - clause to the query.
    When creating a non-ADDT list that´s at some point based on detecting a user session, you´ll BTW need to insert at line 1
    I can't seemt o insert it on the page as it is looking for a insert, update or delete bahaviour on the page which of course I don't have
    please search these forums for several posts I made which explain my "use dummy table" approach that´s made for cases when you actually don´t have anything to insert/update/delete, but need "something" for ADDT´s send email behaviours.
    Cheers,
    Günter Schenk
    Adobe Community Expert, Dreamweaver

  • Simple Query Question - How do I return the Last 3 records of a Table?

    Question.
    For example, I have a table that has 50 records.
    How do I, specify in SQL to only return the last 3 records of the table.
    Select a.* from table a where ????

    I was just trying to show an example to a friend on
    how something like this would work and if it was even possible. But it won't work. Here's a simple example:
    SQL> create table emp
      2  (id)
      3  as
      4  select object_id
      5  from   all_objects
      6  order  by object_id;
    Table created.
    SQL> select *
      2  from  (select rownum rn
      3               ,b.*
      4         from   emp b)
      5  where  rn > ( select (max(rownum) - 3)
      6                from    emp)
      7  ;
            RN         ID
         40830      55891
         40831      55892
         40832      55893So far, so good. These are the "last 3" rows inserted. Now delete a bunch of rows and insert 3 new ones:
    SQL> delete emp where id < 40000;
    33423 rows deleted.
    SQL> commit;
    Commit complete.
    SQL> insert into emp values (60000);
    1 row created.
    SQL> insert into emp values (60001);
    1 row created.
    SQL> insert into emp values (60002);
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> select *
      2  from  (select rownum rn
      3               ,b.*
      4         from   emp b)
      5  where  rn > ( select (max(rownum) - 3)
      6                from    emp)
      7  ;
            RN         ID
          7410      55891
          7411      55892
          7412      55893Here's the problem. Even though the "last 3 rows" are 60000 - 60002, I still get the same ones as the first query.

Maybe you are looking for

  • Acrobat 9 crashes the print spool

    I have isolated the problem but I have no idea how to fix it.  I have windows 7 Home Edition 64  Thanks in advance, Andy

  • Printing markups in "Document" selection

    How can I save a PDF with Markups so that the markups will always print, even when selecting "Document" in the print dialog?

  • Is Lightroom 2.2 color managed? How to soft proof?

    I was just told that LR 2.2 is not color managed and softproofing is not possible... is this true? I also have PS CS4... What is the best way to use LR 2.2 for you image editing in a color managed workflow if you also want to Soft proof before printi

  • Songs not divided by letters?

    i have all my songs in alphabetical order on my iphone but they are all under the 123 bar so i cannot use the letters on the right 2 scroll through songs.. any1 no how 2 fix this?

  • Printing in PM/CS using smartforms (How?)

    Hi, I know that PM/CS uses SAPscript in standard. Now I'd like to switch the printing to Smartforms. The problem is, I have no idea how to manage it or how to confugure the PM/CS printout settings to do so. Any help is highly appreciated! Florian