Pickup only the newest record in an Internal Table.

Hi all:
I have and internal table that i am accesing in a transformation.
Which is the best approach to read from the internal table only the
record with the newest date. Data look like this:
Date_________MAT___ Qty
12.08.2009___4050___70
10.05.2009___4050___30
18.11.2009___4050___42
20.07.2009___4050___28
In this case, for Material 4050 i need only the third record (18.11.2009),
any code example or guideline..?
Regards,

Hi,
You can sort the internal table by date and material in descending order and then perform read on the internal table with key as material. this would bring the latest date for that material.
Regards,
Rk.

Similar Messages

  • Getting only the newest records in a Grandchild table

    Hi
    I have created a new table in the Siebel schema on an Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bi
    This table is called CX_ASSET_XM and is a Grandchild table of S_ASSET
    CX_ASSET_XM has a parent table S_ASSET_X
    So the structure is like so
    S_ASSET  x 1 record
    S_ASSET_X x 2 child records
    CX_ASSET_XM x 1 grand child records
    Therefore the cardinality is one Grandparent can have 2 Grandchild records
    This CX_ASSET_XM table will hold information about TCP/IP calls of a Grandchild asset. These calls are not synchronized. therefore one Grandchild asset may make a call today but the other one has not made a call since yesterday.
    In my query I find all the grand children records that have been created today (sysdate) and then traverse up the relationship to find the Grandparent, then I traverse back down to find the other twin in the Grandchildren tuple.
    The problem with my query is that it returns every single TCP/IP call a pair has made but I only want the most recent callback of each grandchild to analyse
    SELECT (cb.SSID), cb.created_by, cb.callback_date, cb.callback_num, asset.desc_text, asset.prom_integ_id, asset.integration_id
    --Traversing Up to find the Grandparent record of the
    FROM SIEBEL.CX_ASSET_XM cb
        JOIN SIEBEL.S_ASSET_X assetx
          ON cb.SSID = assetx.attrib_37
        JOIN SIEBEL.S_ASSET asset
          ON assetx.par_row_id = asset.row_id
    WHERE asset.prom_integ_id IN
    --Traversing Down to find the other twin in the pair
    (   SELECT asset.prom_integ_id
        FROM SIEBEL.CX_ASSET_XM cb
        JOIN SIEBEL.S_ASSET_X assetx
          ON cb.ssid = assetx.attrib_37
        JOIN SIEBEL.S_ASSET asset
          ON assetx.par_row_id = asset.row_id
    ORDER BY cb.callback_date DESC;
    e.g. if there are 80 grandchildren which have made two TCP/IP calls that would make a total of 160 records, which is what the query above returns.
    However I want 80 records to be returned
    e
    Grandchildren
    Callback Date
    1111AAAA (Pair 1)
    10-OCT-13
    1111AAAB (Pair 1)
    09-OCT-13
    2222AAAA (Pair 2)
    10-OCT-13
    2222AAAB (Pair 2)
    07-OCT-13
    As you can see from the table, atleast one of the pair will have a Callback_Date = Sysdate (Today) which is how I will need to find them in the table before traversing up.
    How do I achieve these results. I have tried GROUP BY, DISTINCT, ROWNUM = 1

    Hi,
    968432 wrote:
    Sorry for my ignorance but how do I incorporate the ROW_NUM function into my query, or will it be a new query from scratch.
    When you say partition, does that mean the partition would be between my traversal up the tables to the grand parent and then back down again?
    You can use ROW_NUMBER with something very much like your existing query; there's no need to start from scratch; you just won't repeat the joins in the WHERE clause.  You'll just be joining the tables once.  If it really helps you to think of traversing either up or down, then go ahead, but you mind find it simpler just to think of joining.  Every row of the join will include some expression(s) that uniquely identifies the grandparent; that's what you'll PARTITION BY.
    It would be a lot easier to explain and to understand if we had some sample data and desired results.  Either post CREATE TABLE and INSERT statements for a little sample data, or phrase the question in terms of tables that anybody with Oracle probably has, such as those in the hr schema.  (People in hr.employees are related to deparatments in hr_departments, and departments are related to places in hr.locations, so location is the grandparent of employee.  If you knew how to find the most recently hired employee from each location in the hr schema, then you'd know how to solve your problem in your schema.  For example, if you wanted these results:
    CITY                 DEPARTMENT_ID EMPLOYEE_ID LAST_NAME  HIRE_DATE
    London                          40         203 Mavris     07-Jun-2002
    Munich                          70         204 Baer       07-Jun-2002
    Oxford                          80         167 Banda      21-Apr-2008
    Seattle                        100         113 Popp       07-Dec-2007
    South San Francisco             50         128 Markle     08-Mar-2008
    Southlake                       60         104 Ernst      21-May-2007
    Toronto                         20         202 Fay        17-Aug-2005
    you could get them like this:
    WITH  got_r_num  AS
        SELECT  l.city
        ,       d.department_id
        ,       e.employee_id, e.last_name, e.hire_date
        ,       ROW_NUMBER () OVER ( PARTITION BY  l.city
                                     ORDER BY      e.hire_date  DESC
                                   )   AS r_num
        FROM    hr.employees    e
        JOIN    hr.departments  d  ON   d.department_id  = e.department_id
        JOIN    hr.locations    l  ON   l.location_id    = d.location_id
    SELECT  city
    ,       department_id
    ,       employee_id, last_name, hire_date
    FROM    got_r_num
    WHERE   r_num = 1

  • How to delete the matching records from two internal tables

    Hi ,
    I have two internal tables say A and B of the same type. If A has 10 records and B has 4 records , I want to delete the 4 records in B from A .
    loop at B into wa .
    delete A where key = wa - key .
    endloop.
    takes a long time if the table B is huge. how can I improve the performance.
    Thanks.
    Gayathri

    Hi Gayathri,
    You could try field-symbols. It reduces the data transfer from the internal table B to the work area.
    field-symbols <fs_itab_b> like line of B.
    loop at B assigning <fs_itab_b>.
      delete A where key = <fs_itab_b>?-key.
    endloop.
    Regards,
    <a href="https://www.sdn.sap.com:443http://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.sdn.businesscard.sdnbusinesscard?u=zwcc%2fwm4ups%3d">anand Mandalika</a>.

  • Read the last record of an internal table

    Hello All,
    I need to read the last entry of the internal table? Is it possible to achieve this without using loop - endloop?
    In the following example, I need to get the Batch '110776' and store it in a variable.
    ITAB:
    MATNR|CHARG
    010780|110770
    010780|110772
    010780|110773
    010780|110774
    010780|110775
    010780|110776
    Thanks.

    Use DESCRIBE to get the number of entires in variable last_entry
    and then use read table ....index last_entry

  • HI All Capturing the error records in an internal table

    Hi All,
             I am retrieving the data from application server .
            My requirement is to :
         Check if the Measurement Point Id provided in the file is a valid one or not. Query the table EUITRANS by passing the Measurement point Id in the EXT_UI field. If the query is successful, then proceed to next step. If not, log it in the error log with error message DM-001 and proceed with the next Measurement point id.
    so i nee the code for capturing the error log with error message.
    pls provide me ASAP.
    Thanks&Regards,
    Bharat

    Hi,
    if you like do display all messages online have a look at FM:
    'MESSAGES_INITIALIZE'
    'MESSAGE_STORE'
    'MESSAGES_SHOW'
    If you want to write application log look at function group SBAL modules BAL_LOG*. There is also a good documentation in SAPDOCU..
    Kind regards,
    HP

  • How to get the last record of an internall table ....

    Hi All..
    i want to get the last record of an internal table itab, and i want the the value of the last record.

    Hi,
         Use describe statment.
    data: lv_line type i.
        Describe table itab lines lv_line.
        read table itab into wa_itab index lv_line.
    regards,
    Santosh Thorat

  • Count the Records in  an internal table without a loop.

    How do i count the number of records in an internal table without using the loop  statement.
    The Describe statement give the total no. of records in the internal table.But i want the count of the key fields in the internal table
    For eg
    Row Field
    1       A
    2       A
    3       A
    4       B
    5       B
    6       C
    Count of A = 3
    Count of B = 2
    Count of C = 1

    Dilip,
      I think isn't posible. Only 3 ideas:
    1ª, make other table "table2", similar to your actual table.
         table2[] = yourtable[].
         delete table2 where key <> 'A'.
         describe table table2 lines contA.
        But depending the amount of data, you may have problems in performance or memory consumption...
    2ª, make other table, only with the keys fields and a count field,
        data begin table2
           key_field1,
           cont type i.
        end data.
       when you append lines to yourdata, make a collect to this table:
        table2-keys = yourtable-keys.
        table2-cont = 1.
       collect table2.
       But only works if you can modify the program where data is appended, and you may be carefull when data is deleted :-(...
    3ª if your data if filled in a select, you may fill the table2 of point 2ª, making a similar select but:
       select keyfields count( * ) into table table2
      from ...
      where (the same you have to fill your original table...)
       group by keys.
    But you have the same problem is data is deleted later...
    I hope that any of the three is useful for you...
    Edited by: Diego Alvarez on Jan 5, 2010 5:09 PM

  • Displaying only the newest results below. To view all results, narrow your query by adding a filter.

    Hi,
    In one of my list there are 33,000 records.
    It gives message "Displaying only the newest results below. To view all results, narrow your query by adding a filter."
    I don't want to change my threshold limit. Can anybody please tell me steps to resolve this issue?
    Regards,
    Amit Khatri

    I have a list of 11,000 items. Even though I have setup filters on it and it shows all 10 records based on that filter, it still shows that warning on top. For some items, even with those filters, I don't see the list items at all. How do I deal with
    this situation. I don't want to change my threshold limits from CA either. Please help.
    MAK

  • Getting a "Displaying only the newest results below. To view all results, narrow your query by adding a filter" message in error

    I have a list with almost 10000 items. I have a view that should be returning 8 items. For me, the Farm Admin, I see the full set of expected values. The message "Displaying only the newest results below. To view all results, narrow your query by
    adding a filter" shows for other users. This makes no sense -
    there ARE filters on this view. I'd rather not increase the throttle limit.
    Anthony Kelly

    Hi Ajk,
    Check that the list is not scoped by an audience; but, I'm afraid that either way admin, (e.g. non Farm admin or site collection admin)
    I'd recommend exporting to excel, create two new spreadsheets and then import as custom lists.
    Best of luck and cheers,
    Stacy Anothersharepointblog.blogspot.com

  • Spilt the number of records in a internal table

    Hi all,
            I have a requirement where i must spilt the number of records in my internal table itab .Say if i have 2000 records , i must spilt it taking the first 990 records and doing some posting using Bapi and again take the next 990 records and do the posting .Can some one help me out.
    Good answers will be rewarded with points.

    Hi,
    You can use these instructions using two internal tables, but please be aware to not forget any line.
    REFRESH my_table2.
    APPEND LINES OF my_table FROM 1 TO 990 TO my_table2.
    CALL FUNCTION 'BAPI'....
                 (with my_table2)
    REFRESH my_table2.
    APPEND LINES OF my_table FROM 991 TO my_table2.
    CALL FUNCTION 'BAPI'....
                 (with my_table2)
    Regards,
    Mathieu

  • Store the vital info from the absence quota record in an internal table

    Hi experts,
    I want to detrmine if the Absence record’s (PA2001 rec) deduction from date (PA2001-BEGDA) and absence to date (PA2001-ENDDA) are permissible for the validity period of the Absence Quota record (the PA2006 rec).  If the quota’s deduction from date, PA2006-DESTA, is greater than the PA2001-BEGDA, we then need to identify this absence quota record for change and change the deduction from date, PA2006-DESTA, to be the same as PA2001-BEGDA.  Store the vital info from the absence quota record in an internal table and record the new date that the deduction from date that needs to be changed to.  The changes will be made via a BDC session.
    Please help me out...
    Thanks,
    Vicky

    This looks possible if we code it in 'dynamic action' table, but the BDC may not read it during run time.
    Do you still have this issue?
    Thanks
    Narasimha

  • Display only the last record per material in SAP query

    Hi,
    I have created a SAP Query using the quickviewer that is a join between 2 tables (MSEG and MKPF) that consist of material document information and date of posting.
    The results are fine however I would like only the last record per material to be displayed.
    Can anyone tell what do I need to add so for only the last record per material be displayed in the output.
    Thanks,
    Mark

    Hi Mark,
    May be if you use Control Level processing .........I think you will be able to get the result you want. Try displaying as Below,
    LOOP AT XXXXX.
    AT FIRST material.
    ENDAT.
    AT LAST material.
    *...Display what ever you want here. It will display at end of every material.
    ENDAT.
    ENDLOOP.
    Before using sort the table with key material in ascending.
    Hope what I had to say is helpful to you.
    Cheers,
    Raga Suman.

  • How to add the records of 2 internal table records into one file

    hello experts,
    My scenario is...
    I am retrieving the data for the for the credit, debit and trailer records of the customer into 3 different internal tables and finally i have to append all those records into one file first debit records then credit records finally the trailer record.... how to do that can anyone give some idea plzzzzzzzzz..
    Plz its bit urgent..
    Thanks a lot for your anticipation
    SRI

    Hello,
    Do like this.
    " Assume u have three itab.
    "Itab1 - debit
    "Itab2 - credit
    "Itab3 - Credit.
    REPORT ZV_TEST_SERVER .
    *PARAMETERS: P_FILE TYPE STRING."RLGRAP-FILENAME.
    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
    *   BIN_FILESIZE                  =
        FILENAME                      = P_FILE
    *   FILETYPE                      = 'ASC'
       APPEND                        = 'X'  " Check here
    *   WRITE_FIELD_SEPARATOR         = ' '
    *   HEADER                        = '00'
    *   TRUNC_TRAILING_BLANKS         = ' '
    *   WRITE_LF                      = 'X'
    *   COL_SELECT                    = ' '
    *   COL_SELECT_MASK               = ' '
    *   DAT_MODE                      = ' '
    * IMPORTING
    *   FILELENGTH                    =
      TABLES
        DATA_TAB                      = ITAB1
    * EXCEPTIONS
    *   FILE_WRITE_ERROR              = 1
    *   NO_BATCH                      = 2
    *   GUI_REFUSE_FILETRANSFER       = 3
    *   INVALID_TYPE                  = 4
    *   NO_AUTHORITY                  = 5
    *   UNKNOWN_ERROR                 = 6
    *   HEADER_NOT_ALLOWED            = 7
    *   SEPARATOR_NOT_ALLOWED         = 8
    *   FILESIZE_NOT_ALLOWED          = 9
    *   HEADER_TOO_LONG               = 10
    *   DP_ERROR_CREATE               = 11
    *   DP_ERROR_SEND                 = 12
    *   DP_ERROR_WRITE                = 13
    *   UNKNOWN_DP_ERROR              = 14
    *   ACCESS_DENIED                 = 15
    *   DP_OUT_OF_MEMORY              = 16
    *   DISK_FULL                     = 17
    *   DP_TIMEOUT                    = 18
    *   FILE_NOT_FOUND                = 19
    *   DATAPROVIDER_EXCEPTION        = 20
    *   CONTROL_FLUSH_ERROR           = 21
    *   OTHERS                        = 22
    IF SY-SUBRC <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
    *   BIN_FILESIZE                  =
        FILENAME                      = P_FILE
    *   FILETYPE                      = 'ASC'
       APPEND                        = 'X'  " Check here
    *   WRITE_FIELD_SEPARATOR         = ' '
    *   HEADER                        = '00'
    *   TRUNC_TRAILING_BLANKS         = ' '
    *   WRITE_LF                      = 'X'
    *   COL_SELECT                    = ' '
    *   COL_SELECT_MASK               = ' '
    *   DAT_MODE                      = ' '
    * IMPORTING
    *   FILELENGTH                    =
      TABLES
        DATA_TAB                      = ITAB2  " Check here
    * EXCEPTIONS
    *   FILE_WRITE_ERROR              = 1
    *   NO_BATCH                      = 2
    *   GUI_REFUSE_FILETRANSFER       = 3
    *   INVALID_TYPE                  = 4
    *   NO_AUTHORITY                  = 5
    *   UNKNOWN_ERROR                 = 6
    *   HEADER_NOT_ALLOWED            = 7
    *   SEPARATOR_NOT_ALLOWED         = 8
    *   FILESIZE_NOT_ALLOWED          = 9
    *   HEADER_TOO_LONG               = 10
    *   DP_ERROR_CREATE               = 11
    *   DP_ERROR_SEND                 = 12
    *   DP_ERROR_WRITE                = 13
    *   UNKNOWN_DP_ERROR              = 14
    *   ACCESS_DENIED                 = 15
    *   DP_OUT_OF_MEMORY              = 16
    *   DISK_FULL                     = 17
    *   DP_TIMEOUT                    = 18
    *   FILE_NOT_FOUND                = 19
    *   DATAPROVIDER_EXCEPTION        = 20
    *   CONTROL_FLUSH_ERROR           = 21
    *   OTHERS                        = 22
    IF SY-SUBRC <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
    *   BIN_FILESIZE                  =
        FILENAME                      = P_FILE
    *   FILETYPE                      = 'ASC'
       APPEND                        = 'X'  " Check here
    *   WRITE_FIELD_SEPARATOR         = ' '
    *   HEADER                        = '00'
    *   TRUNC_TRAILING_BLANKS         = ' '
    *   WRITE_LF                      = 'X'
    *   COL_SELECT                    = ' '
    *   COL_SELECT_MASK               = ' '
    *   DAT_MODE                      = ' '
    * IMPORTING
    *   FILELENGTH                    =
      TABLES
        DATA_TAB                      = ITAB3 " Check here
    * EXCEPTIONS
    *   FILE_WRITE_ERROR              = 1
    *   NO_BATCH                      = 2
    *   GUI_REFUSE_FILETRANSFER       = 3
    *   INVALID_TYPE                  = 4
    *   NO_AUTHORITY                  = 5
    *   UNKNOWN_ERROR                 = 6
    *   HEADER_NOT_ALLOWED            = 7
    *   SEPARATOR_NOT_ALLOWED         = 8
    *   FILESIZE_NOT_ALLOWED          = 9
    *   HEADER_TOO_LONG               = 10
    *   DP_ERROR_CREATE               = 11
    *   DP_ERROR_SEND                 = 12
    *   DP_ERROR_WRITE                = 13
    *   UNKNOWN_DP_ERROR              = 14
    *   ACCESS_DENIED                 = 15
    *   DP_OUT_OF_MEMORY              = 16
    *   DISK_FULL                     = 17
    *   DP_TIMEOUT                    = 18
    *   FILE_NOT_FOUND                = 19
    *   DATAPROVIDER_EXCEPTION        = 20
    *   CONTROL_FLUSH_ERROR           = 21
    *   OTHERS                        = 22
    IF SY-SUBRC <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    If useful reward.
    Vasanth

  • HT201302 How to import only the newest iPhone photos to iPhoto library/Mac

    I have an iPhone 4s and every time I connect my iPhone to my Mac it downloads all the photos.
    How do I import only the newest photos? To have to check what I already have in albums and select only the latest would be very
    time consuming. There must be an easier way.

    When iPhone is connected and selected in computer iTunes, in Photos tab >
    in Selected albums, Events, and Faces, and automatically include > select "the most recent Event"

  • Maximum record length in internal table?

    Is there a maximum record length in an internal table?  Please note:  My question is NOT related to table space.  I'm referring only to the length of an individual record (A.K.A. row length).
    I am using a work area to insert data into an internal table.  Both the work area and internal table are defined by the same structure.
    The structure has a total length of 672 bytes.  For the sake of this discussion I'll point out that at the end of the structure, bytes 669, 670, 671, and 672 are four separate fields of 1 character each.
    When viewing the work area record in the debugger I'm seeing all the fields and all the values.  When viewing the internal table in the debugger after a record is inserted, the internal table ends with the field defined at Byte 670.  The internal table does not include the two fields defined at Bytes 671 and 672.
    Am I to assume from the above explanation that the length of a record ( A.K.A. row) in an internal table cannot exceed 670 bytes?
    Thank you.

    Manish,
    False alarm!  While, technically, you didn't answer my question, your request for code ended up helping me answer my own question.
    To provide you with some code I wrote a simple test program using the record layout referred to above, with a DO loop to put some records into the internal table, followed by a LOOP AT, with accompanying WRITE statements to display the contents of the internal table and demonstrate that the last two fields weren't being stored.
    However, when I ran the test program, the last two fields were being displayed.
    It was at that point, when stepping through the debugger that I noticed the scroll arrows above the last column of my internal table that allowed me to scroll to the right and see my final two fields.
    Apparently, because of the large number of fields in my internal table I had reached the default display length of the debugger.  While I was obviously aware of the scroll bar found at the bottom of the display, I had never worked with an internal table of that width in the past and hadn't even noticed the scroll arrows above the last column before.
    Thanks for taking the time to respond helping me get to the solution.

Maybe you are looking for

  • How to set a parameter to sysdate() - 1 in the scheduler?

    Hi, I have a report with two parameters. One is the date and in the parameter's definition I have set it to {$SYSDATE()-1$} which works perfectly. However, when I try to schedule the report, it does not accept the default above. How can I schedule a

  • Does anybody use File Syncrhonization from Apple

    I am looking for good file synchronization between my three computers, I am trying something over the web like dropbox, but I am feeling that is too slow and I may live by syncing the computers when I arrive home via Wi-Fi. Thanks

  • Connecting two large FAT32 drives - one doesn't mount

    I have two WD 2TB HDDs formatted as FAT32. One is in a 4-bay external box connected via eSATA, the other in a WD case connected via USB. My computer is a Powermac Dual G5 2.0GHz running 10.4.11 Connecting either box individually leads to no problems,

  • Wants to avoid mapping for an one-to-one scenario..details in the message

    Hello Experts, Need your help on the below problem. We are in Service Pack: 08 Release: NW711_08_REL Scenario : proxy to file(tab separated) mapping: one to one structure: msgname   -recordset (0..n)       -field1 (0..1)       -field2 (0..1)       -f

  • Can I customize the date format?

    When importing camera raw files, I am able to select mmm/dd/yyyy as an option in the photo downloader. Once the files are in Bridge, if I want to batch rename, the date option does not include mmm(the month spelled out instead of numeric). Is there a