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

Similar Messages

  • How can i fetch numeriic records from data dictionary table

    hi friends..
    let assume one data dictionary table ztable which contain
    fields like 1. key datatype c length 2
                  2. data datatype c length 10
    which contain data like
    aa      varehouse
    bb      material
    cc      sales
    01      one
    02      two
    03      three
    from these i want to fetch only 01, 02 and 03 records...
    i.e i want all the records that is in numbers only in key field of ztable
    can you guide me how to get tis?

    select * into table itab
    from ztable
    where key eq '01'
    or key eq '02'
    or key eq '03'.
    declare itab of the type same as ur ztable..
    the above select query will giv u required records..
    Edited by: Rudra Prasanna Mohapatra on Jul 14, 2008 11:13 AM

  • Util class to extract Data from Data base Table.

    Is there any Util class to extract all records from Data base table into DAT file.For example(get all amployees from EMPLOYEE table in to employee.DAT )

    What is a DAT file?
    Anyway, this can be achieved using a shot of JDBC [1] and some business logic [2] to populate/group/concat the data together in a DAT format and writing [3] it to that DAT file.
    [1] JDBC tutorial: http://www.google.com/search?q=jdbc+tutorial+site:sun.com
    [2] Use your brains and things you ever learnt in maths and basic Java tutorials/books.
    [3] I/O tutorial: http://www.google.com/search?q=io+tutorial+site:sun.com

  • How to select first several records from a database table by using select?

    Hi,
       I want to select first 100 records from a database table by using select clause. How to write it?
       Thanks a lot!

    hai long!
                 well select statement is used to retrive
    records from the database.
    following is the syntax to be used.
    1) select *  into corresponding fields of itab from basetable where condition.
    endselect.
      ex: select * into corresponding fields of itab from mara
                where matnr >= '1' and  matnr <= '100'.
           append itab.
          endselect.
    select * is a loop statement.it will execute till matnr is less than or equal to 100.
    note: you can also mention the required field names in the select statement otherwise it will select all the field from table mara.
    note: itab means your internal table name.
    hope you got the required thing.if it really solved u r problem then award me the suitable points.<b></b>

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

  • Where can get IDOC Error Message from Data base tables

    Hi ,
    i am automating idoc  checking process,in which i am getting control record from EDIDC tables,now i need to fetch Error message
    using this idoc no.
    How can fetch   error message text ?
    Thanks in advance.
    Regards
    sarath

    Hi its a structure, it doesnt store data.
    Take it from the table specified,
    Pass STAMID,STAMNO,STAPA1,STAPA2,STAPA3,STAPA4 to function module MESSAGE_PREPARE and you will get the message text.
    Also check the function module IDOC_READ_COMPLETELY

  • UNIQUE Problem in pulling DATA from DATA base table to internal table

    Dear Experts,
    I am new to ABAP. I have a very basic question but looks a quite puzzling one to me. Hemnce I am posting it here.
    I am facing an unique problem in pulling data from database table and populating that data into internal table for further use.
    The data in the database table "Zlt_mita" with fields M1 (Employee Name, Type: Char20) and M2 (Employee Code, Type Char7) are:
    Plz refer the screenshot in the attached file:
    My Code:
    1) When I try to pull data from Dbase table by taking M2 as parameter.
         This code is succcessful and I am able to populate data in internal table it_dat.
    TYPES: Begin Of ty_DAT,
                     M1   TYPE  Zlt_mita-M1,
                     M2   TYPE  ZLT_mita-M2,
                 END  OF  ty_DAT.
    DATA: it_dat        TYPE STANDARD TABLE OF ty_dat with header line,
              wa_dat      TYPE   ty_dat.
    PARAMETERS: p_mitar    TYPE  Zlt_Mita-M2.
    SELECT           M1
                           M2
            FROM     ZLt_mita
            INTO       TABLE it_dat
            Where     M2 = p_mitar.
    Loop at it_dat into wa_dat.
       WRITE:/2 wa_dat-M1,
                  10 wa_dat-M2.
    ENDLOOP.
    2) When I try to pull data from Dbase table by taking M1 as parameter.
         This code is NOT succcessful and I am NOT able to populate data in internal table it_dat.
    TYPES: Begin Of ty_DAT,
                     M1   TYPE  Zlt_mita-M1,
                     M2   TYPE  ZLT_mita-M2,
                 END  OF  ty_DAT.
    DATA: it_dat        TYPE STANDARD TABLE OF ty_dat with header line,
               wa_dat      TYPE   ty_dat.
    PARAMETERS:    P_Mita    TYPE   ZLT_Mita-M1.
    SELECT           M1
                           M2
            FROM     ZLt_mita
            INTO       TABLE it_dat
            Where     M1 = P_Mita.
    Loop at it_dat into wa_dat.
       WRITE:/2 wa_dat-M1,
                 10 wa_dat-M2.
    ENDLOOP.
    Why is this happening when both M1 and M2 are Type Character fields.
    Looking forward for your replies.
    Regards
    Chandan Kumar

    Hi Chandan ,
    Database fetch is case sensitive ,So u need to give exact format in where condition.
    Make your parameter and database in same case so that you need not worry about case sensitivity .
    Check the lowecase check box in the domain .
    Then declare your parameter 
    PARAMETERS:
    P_Mita
    TYPE   ZLT_Mita-M1 LOWER CASE . 
    You can do the vice versa also by unchecking lowercase and giving Upper case instead of lower in parameter declartion .
    Regards ,
    Juneed Manha

  • Selecting data from data base tables into itab with multiple select queries

    Hi all,
           i am dealing with a situation where in there is 3 DB tables in all say
              1. ITAB - ZTBL_MAIN.
              2. DB table - ZTBL_SUB1.
              3. DB table - ZTBL_SUB2.
    ZTBL_MAIN contains feilds from both tables 2 and 3 so to choose some records from ZTBL_SUB1 into the ITAB a select query has been written as below.
    SELECT * FROM ZTBL_SUB1 INTO CORRESPONDING FIELDS OF TABLE ZTBL_MAIN
        WHERE <condition>.
    now i also want some feilds in main for each record to be filled from the other DB table for which if i use another select query after the above one in my report prog. say..
    SELECT * FROM ZTBL_SUB2 INTO CORRESPONDING FIELDS OF TABLE ZTBL_MAIN
        WHERE <condition>.
    then all the previous records are going to be erased..Kindly let me know a way in which i can implement the above implementation.
    Thanks&Rgds,
    Naveen M

    hi,
        Ur suggestions solved the syntax error. However my intial problem was not solved i.e., using the statement
    SELECT * FROM ztbl_sub2 APPENDING CORRESPONDING FIELDS OF TABLE ztbl_main FOR ALL ENTRIES IN ztbl_main
         WHERE <field1> =  ztbl_main-<field1>.
    creates or appends some more entries into the itab thats all.. But that is not what i am trying to implement.
    As explained before the first select query would have filled certain fields for all records in ztbl_main from ztbl_sub1.
    Now in the second select query i want to fill other fields of ztbl_main for all the records already fetched using first select query by using my where condition.
    The above select query that was suggested only creates new records in the table ztab_main but does not fill the fields of the records as i expected.
    how do i fullfil my requirment..
    kindly help.
    thnks & Rgds,
    Naveen M

  • How to retrive dynamic directory structure from data base and show it

    i want to display a directory structur on jsp my problem is that i want to read it from a database how i can read
    a tree structure i found a function to read directry structur but if i use this function i am not able to find who the parent is ? this is the function i found cna any one help me ?
    public void iterate(File someDirectory) {
    Vector allFiles = new Vector();
    File[] dirContents = someDirectory.listFiles();
    for (File f : dirContents) {
    allFiles.add(f);
    for (int i = 0; i < allFiles.size(); i++) {
    File file = (File) allFiles.get(i);
    if (file.isDirectory()) {
    dirContents = file.listFiles();
    for (File f : dirContents) {
    allFiles.add(f);
    // Process 'file' or do whatever
    }

    Thanks for reply i am not actualy deling with files i am creating a web application in which i am having organize functionality
    user creat folders and put there document in that like out look user can creat folder inside folder
    i am storing tham in a database table my problem is how to retrive them so i can show them as a tree structur
    i am using this code to show on jsp
    {color:#808000}<table>
    <tr>
    <td >
    <ul class="flipMenu">
    <li><span class="menu">Folder</span>
    <ul>
    <c:forEach var="folderList1" items="${folderList}" >
    {color}
    {color:#808000}<li ><a class="submenu25" id='<c:out value="${folderList1.id}"/>' href="folderAgreement.htm?folderid=<c:out value="${folderList1.id}"/>" onmouseup="a('<c:out value="${folderList1.id}"/>');" ><span ><c:out value="${folderList1.name}" /> T</span></a>
    <ul>
    <li> <a href="# onclick="window.open('createSubFolder.htm?folderid=<c:out value="${folderList1.id"/>&agreetitle=<c:out value="${agreements.title}"/>', 'invite_wnd', 'height=700, width=800, status=no, menubar=no, toolbar=nu, location=400'); return false;">Add Folder
    </li>
    <li> <a href="folderDetail.htm?folderid=<c:out value=${folderList1.id"/>&flag=folder"><span class="submenu2">Detail</span>
    </li>
    <li> <a id="<c:out value="${folderList1.id}"/>" href="folderDelete.htm?folderid=<c:out value="${folderList1.id}"/>&flag=folder" onclick="conformDelete('<c:out value="${folderList1.id}"/>')" ><span class="submenu2">Delete Folder</span></a>
    </li>
    </ul>
    </li>
    </c:forEach>
    {color}
    {color:#808000}</ul>
    </li>
    </ul>
    </td>
    </tr>
    </table>{color}

  • Attach document from Data Base Table Document in email attachment Option

    HI Friends,
    i have create an email option in my application .i have a table CRM_DOC_FILE.this table have collection of all document file.
    i want to send an email with attchment but i want to attch file from my table Named CRM_DOC_FILE ,so i have created an report region with list of all documents .i want jus a button in last column in this report when i click on this button then corresponding document should be attch ,i want to attch more then one document .
    How can i attch a button in last column in report where i would be click on this button to attch documents.
    How can i attch documents click on Attch button.
    how can i do this.
    i have ctreated a Dummy Application
    Workspace: SKILLS IMPROVE
    User: [email protected]
    Password :desomu
    Application: 42370
    page No 4 For Sending email .
    Thanks
    Edited by: 805629 on Nov 28, 2010 11:36 PM

    PLEASE DO NOT POST THE SAME QUESTION MULTIPLE TIMES.... Please see the OTHER version of this question for a possible solution. Please close one of these questions, so others do NOT waste their time answering multiple versions of your questions..
    Thank you,
    Tony Miller
    Webster, TX

  • Get the data from data base tables

    Hi ..
    Iam preparing quotation layout . In that i have to display the address in address window form two tables, means i have to get the address by using two tables like have to select the data from that tables ...
    How can i do that one?
    Can anybody expalin abt that pls...
    Regards,
    pandu.

    Hello,
    If you are looking at fetching the adress details for partner function(Say Ship to, Sold to , payer etc) in the quotation, then you can proceed like this:
    Take the Quotataion number and the item number and the respective partner function say PY for payer etc and then Go to VBPA table and fetch field ADRNR from the table for this partner. With this ADRNR call the FM  ADDR_SELECT_ADRC_SINGLE and as an output of this FM, you will get address details.
    Regards
    <b>Reward points if useful</b>
    Saket Sharma
    Saket Sharma

  • Copy data from data base table

    Hello friends,
    I have some data in a Z-table in QAS. I want to copy all the data from QAS to the table in SDV. Is there way that I can copy without writing a program.
    Thanks in advance,
    Shejal.

    hi,
    use se09-display object list
    insert new line with:
    R3TR TABU "ZTAB01"
    -> insert key:
    Mandt = sy-mandt
    and key  = *
    A.
    Message was edited by:
            Andreas Mann

  • When to refresh Servlet data from Data Base

    Hello all,
    I have a servlet that retrive few hundreds thousands records from data base table.
    The data in data base table being updated once or twice in every week.
    Since same servlet instance serve all users, that access the servlet many times a day.
    I would like to avoid retriving the data from data base on each servlet access.
    and make the users use same data already retrieved and kept in servlet members.
    First, what is the best way to avoid data retrive from data base on each servlet access?
    and how could I have some kind of trigger that will refresh servlet data from data base every few days?
    Thanks in advance for every idea.
    Ami

    Java_A wrote:
    Thanks Saish for your reply.
    I'm not using DAO in my application but retrive the data from BI data base using a web service. response time querying the BI data base is not quick enuogh.
    Since, I wouldn't want to query the BI server on each servlet access.
    Because the data I retrived at the begining using the web service contains all required data for all servlet requests, I thought to store the data (~200K rows) once in the servlet which will be using for all requests.
    Why not store the results locally in your own database after you fetch them?
    This still leave me with the questions: in which event should I query the BI data, and also when or in which event should I update the data again from BI server?
    Query at startup, an user demand, when data becomes stale. It depends on your requirements.
    >
    Thanks
    Ami- Saish

  • How do I skip footer records in Data file through control file of sql*loade

    hi,
    I am using sql*loader to load data from data file and i have written control file for it. How do i skip last '5' records of data file or the footer records to be skiped to read.
    For first '5' records to be skiped we can use "skip" to achieve it but how do i acheive for last '5' records.
    2)
    Can I mention two data files in one control file if so what is the syntax(like we give INFILE Where we mention the path of data file can i mention two data file in same control file)
    3)
    If i have datafile with variable length (ie 1st record with 200 charcter, 2nd with 150 character and 3rd with 180 character) then how do i load data into table, i mean what will be the syntax for it in control file.
    4)if i want to insert sysdate into table through control file how do i do it.
    5) If i have variable length records in data file and i have first name then white space between then and then last name, how do i insert this value which includes first name and last name into single column of the table.( i mean how do you handle the white space in between first name and last name in data file)
    Thanks in advance
    ram

    You should read the documentation about SQL*Loader.

  • Selecting the last record from a database table

    In my ABAP Program, I have to use a select statement to retrieve the last record from the database table with the same key.  In other words, the Program will get more than one hit on the database table for the selected keys and I need to retrieve values from only the last record and not the first.  I know I can use an internal table to sort the records first and then retrieve the right value.   But to make things easier, is there a SELECT statement keyword than I can use to do this in one single step?  Thanks!

    hi,
    tables:mara.
        data: begin of it_mara occurs 0,
                matnr like mara-matnr,
                meins like mara-meins,
                mtart like mara-mtart,
                end of it_mara.
    select-options:s_matnr for mara-matnr.
    select matnr
              meins
              mtart
    from mara
    into table it_mara
    where matnr in s_matnr.
    if not it_mara[] is initial.
    sort it_mara by matnr descending.
    read table it_mara index 1.
    endif.
    then you get the last record of the select statement.
    reward points if useful,
    venkat.

Maybe you are looking for