Fastest way to write out internal table to database table ?

Hi friends,
my question is, what is the fastest way to write about 1,5 mill. of rows from an internal table to a database table ?
points will be awarded immediately,
thanks for your help,
clemens

Hi Clemens,
If you just want to write (INSERT) 1.5 million rows of an internal table into a database table, use:
INSERT <table name> FROM TABLE <itab>.
Transaction Log Size could be a problem, therefore writing in packages could help, but this depends on your row size, your database configuration and on the current changes to your database. May be it runs in one package, if the rows are small (few bytes) then one package will be the fastest but you'll not much faster than with reasonable packages (3-20 MBytes). On Oracle with rollback segments you will probably have no problems at 1.5 million rows.
Best regards
Ralph

Similar Messages

  • Easy way to write out internal table to database table ?

    hi friends,
    i have a special requirement:
    as i do not want to change the profile settings on an r/3 4.6c machine, i want to modify my program so it can handle even large amount of data. the plan is to fill internal table and for say every 100000 rows write those out to a table on database. how could i do this most performant ?
    thanks,
    clemens

    Hi Clemens,
    This solution worked for me, which was suggested by Seshu. May be you can try this,
    Modify ZPPPRICE(your database table name) from table t_final(internal table name).
    In my case I updated Custom table.
    The internal table is of same structure as database table.
    Modify command will insert the record the record if it is new, if the record is existing then it will update the record with the internal table values.
    I got data from Excel file in to my internal table.
    Regards,
    Neelu.

  • Fastest way to write array of million longs to file

    Hi,
    I have an array of 200 million longs. What is the fastest way to write this array to a file, so that I can read it back later. I tried looping, but that is too slow.
    Thanks,
    Taran

    Maxideon wrote:
    Can't he store a portion of those longs into a very large byte array, write the array, and then rinse and repeat? This would increase size of the file writes and should spead up the time...It's still looping. Simply using buffering will decrease the I/O overhead significantly. No need to munge pre-I/O buffering ourselves.

  • Loading internal table to database table

    Hi all,
    I have created a ztable .also i created an internal table with the same structure as ztable.I have some data in internal table.how to load these data from internal table into database table.how thre insert statement will be.

    Hi,
             Check whether entries are there in the internal table. Also check for the structure.
    MODIFY dbtab FROM TABLE itab.
    UPDATE dbtab FROM TABLE itab.
    just read this.
    If you just want to write (INSERT) 1.5 million rows of an internal table into a database table, use:
    INSERT <table name> FROM TABLE <itab>.
    Transaction Log Size could be a problem, therefore writing in packages could help, but this depends on your row size, your database configuration and on the current changes to your database. May be it runs in one package, if the rows are small (few bytes) then one package will be the fastest but you'll not much faster than with reasonable packages (3-20 MBytes). On Oracle with rollback segments you will probably have no problems at 1.5 million rows.
    <b>Rewrad points</b>
    Regards

  • Apply check tables to database tables

    how to apply check tables to database tables???
    plz help

    Hi
    Check Table: means the Table that contains the Primary key in the Foreign key definition.
    It has 2 important uses:
    1. To validate the inputs in the foriegn key field (For Eg: MARC-MATNR) with the values existing in the check table - Primary key field (Eg: MARA-MATNR)
    Here MARA is the Check table for the MARC-MATNR
    2. To provide the input help(F4) for foreign key field
    check table is the field level checking. we can use the Cardinality based on ur requirment.
    see the example.
    if ur using two tables like ekko and ekpo.
    ekko tables having the fields ebeln , bukrs and lifnr.
    here primery key is ebeln.
    ebeln bukrs lifnr
    101 1000 1000
    102 1000 1000
    103 2000 1001(this is entry for ekko).
    we want to insert the entry based on ekko tables.so ekko table is the ckeck table.
    ekpo table is the itam table.
    ekpo tables having the fields ebeln , matnr , menge .
    here forign key is ebeln.
    ebeln matnr menge
    101 m-1 10
    101 m-2 2
    101 m-4 18
    102 m-8 7
    103 m-5 8
    in ekpo table we can't enter other than ekko-ebeln value.
    so we can enter only based on ekko-ebeln table entries.

  • Writing out data from a database table

    Hi guys,
    I am kinda new to ABAP Programming. I need to know how i can write the data stored in my database table which has the following structure:
    data: begin of tablename occurs 100,
    endof tablename.
    I don't know how to loop into it and get the data out from it into a flat file on the application and the presentation server. right now, no data is getting written into the file because I am not looping through the table where the data is is present.
    I need help asap.
    Thanks,
    Minal

    Hi,
    Plz go through this link it will help u a lot
    http://www.sapdevelopment.co.uk/file/file_updown.htm
    also see this link
    http://www.sapdevelopment.co.uk/bdc/bdc_dbupdate.htm
    Thanks & Regards,
    Judith.
    Message was edited by: Judith Jessie Selvi

  • Is it possible to update internal table from database table

    Hello All:
              I know how to update database table from internal table in one shot (batch) but is the reverse possible? Can I update some fields in an internal table from a database table in one shot (without looping) because my internal table is huge? Could you please provide me any ideas how to acheive something like this? Thanks in advance and answers will be rewarded.
    thanks.
    Mithun

    Hello my friend,
    You can do it MAYBE , i think you can reverse the update doing a ROLLBACK, but only after you update....not after the program finishes..
    To update some fields at once use:
    UPDATE DBTABLE FROM TABLE IT_TABLE
    Hope this helps!!
    Gabriel

  • Inserting records from internal table to database table

    Hi all,
    i want to insert records from internal table to zDatabase table, can u plz guide me which statement is better in performance to insert the records.
    1) insert one by one record from internal table
    loop at itab.
    insert ztable from wa.
    endloop.
    2) insert total records at a time
    INSERT <dbtabname> CLIENT SPECIFIED FROM TABLE itab.
    or let me know if any other statement is there with high performance.
    i internal table contains nearly 40000 records.
    thanks.

    Hi,
    Insert the entire table at atime rather than a record so as to increase the performance.
    you can use INSERT <dbtabname> CLIENT SPECIFIED FROM TABLE itab.
    or
    MODIFY ZPRODUCT FROM TABLE GI_AFPO.
    Regards,
    Raj.

  • REG:Internal table and Database table

    Hi Xperts,
    Can you tell me /give me a sample code so as to
    Compare the data present in the database table and internal table.i.e
    Wheher the data in the db table matches with the data in the internal table
    Thanks.

    Hello,  
    First make sure that data is there in the internal table
    TABLES : Declare your table example MARA, VBAK etc
    TYPES: BEGIN OF ITAB1,
    Declare your fields here
    example
    v_mat(10) type c,
    v_code(5) type I,
    END OF ITAB1.
    IF NOT ITAB[] is INITIAL.
    LOOP AT
    END IF.
    To compare the data with DB tables, read the database table and copy into the internal table ITAB2
    Then compare the ITAB and ITAB1
    IF ITAB1[] = ITAB2[]
    END IF
    See these links for [Creating Internal Tables|http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3660358411d1829f0000e829fbfe/content.htm]
    [Comparing Internal Tables|http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3841358411d1829f0000e829fbfe/content.htm]
    See this for more about [Processing Internal Tables|http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb36ae358411d1829f0000e829fbfe/content.htm]
    Declaring the internal table in ABAP objects
    [Thanks|http://chandranonline.blogspot.com/]
    [Chandran|http://chandranonline.blogspot.com/]

  • Write OBIEE report results in database table

    Hi everyone,
    I need to implement a process that executes an OBIEE report and writes the result rows to a database table.
    How can this be done?
    Thanks,
    Alex

    You can do it with delivers/scheduler and a script.
    Delviers give the content to the script and you can do what with it.
    Check this document :
    http://www.oracle.com/technology/products/bi/files/advanced%20delivery%20with%20bi%20publisher%20delivery%20manager%20api.doc

  • Define hashed table using database table

    Hi,
    I have a database table and would want to define a hashed table using this table structure, how would I do that?
    Thanks
    RT

    Hi Rob,
    The syntax is as follows,
    DATA ITAB TYPE HASHED TABLE OF SPFLI
                   WITH UNIQUE KEY CARRID CONNID.
    The table object ITAB has the type hashed table, a line type corresponding to the flat structure SPFLI from the ABAP Dictionary, and a unique key with the key fields CARRID and CONNID. The internal table ITAB can be regarded as an internal template for the database table SPFLI. It is therefore particularly suitable for working with data from this database table as long as you only access it using the key.

  • How to attach a text table to database table

    How to attach a text table to another database table,
    Ex: If we check Mara table and GoTO menu select text table it is displaying MAKT table, how to link that?

    create another table with foriegn key relation with the key field and in the check table give the primary key table and in the text table include sparas field.
    JUAT SAME AS CREATING ANOTHER TABLE WITH FORIEGN KEY RELATION but THE ANOTHER TABLE INCLUDES SPRAS (LANGUAGE KEY)
    A text table is a table that contains spoken-language descriptions of values in a check table. These descriptions are stored in multiple languages. The primary key of the text table is the same as the primary key of the check table, with the addition of a spras (language) column.
    For example, the ztxt005 table has country codes in it. Country names are stored in a separate table named ztxt005t (shown in Figure 4.7) because you actually need many names for one country code. Because it stores language-specific descriptions of a generalized code, ztxt005t is called a text table.
    The primary key of ztxt005t contains the same fields as the primary key of ztxt005, with the addition of a spras (language) column. The spras field contains the language code and enables this table to contain a description for multiple logon languages.
    The primary key of any text table is composed of the fields mandt and spras, followed by the validation field (or fields). One or more description fields follow this primary key.
    A foreign key relationship is defined on ztxt005t-land1 to check table ztxt005. The foreign key field type should be key fields of a text table.

  • Fastest way to write raw data to hard drive (PhysicalDrive) on Windows 7

    My company is developing a "fancy" USB Mass Storage Device running under Windows 7.  The Mass Storage Client Driver that handles the reading and writing to the actual storage media on the client side is being written in C++. 
    The problem we are having is very, very slow write speeds.  About 30 times slower than expected.  We are using calls to WriteFile() to write blocks of data to the storage media (specifically the physical drive 'PhysicalDrive2') as they are received
    from the Host device.  I have read in many other forums that people have experience very slow write speeds using WriteFile() especially on Windows 7.  So I am trying to figure out if I am using the best method and function calls for this particular
    task. 
    Below are some blocks of code.  One for Disk_GetHandle() which gets a handle to the physical drive and is called only once.  One for LockVolume() function that gets called one time by the program during initialization.  The other block of
    code is WriteSector() which is used to write the actual data to the physical drive when its received by the USB Client controller driver.  I am hoping that someone can shed some light on what I might be doing wrong or provided suggestions on a better
    way to implement this.
    UINT WriteSector(HANDLE hWriteDisk, PBYTE Buf, ULONG Lba, ULONG Blocks)
    DWORD bytesWritten;
    LPTSTR errMsg = "";
    //setup overlapped structure to tell WriteFile function where to write the data
    OVERLAPPED osWrite;
    memset(&osWrite, 0, sizeof(osWrite));
    osWrite.Offset = (Lba * SIZE_OF_BLOCK);
    osWrite.hEvent = 0;
    //write the data
    if (!WriteFile(hWriteDisk, Buf, (Blocks * SIZE_OF_BLOCK), &bytesWritten, &osWrite))
    DWORD Errorcode = GetLastError();
    if (Errorcode == ERROR_IO_PENDING)
    WaitForSingleObject(osWrite.hEvent, INFINITE);
    else
    FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(),
    MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), errMsg, 255, NULL);
    printf("WriteSector() - WriteFile failed (%s)\n", errMsg);
    goto exit;
    if (bytesWritten != (Blocks * SIZE_OF_BLOCK))
    printf("WriteSector() - Bytes written did not equal the number of bytes to be written\n");
    return 0;
    else
    return Blocks;
    HANDLE Disk_LockVolume(LPCWSTR _dsk)
    HANDLE hVol;
    LPWSTR errMsg;
    DWORD status;
    bool success = false;
    //now try to get a handle to the specified volume so we can write to it
    hVol = CreateFile(_dsk, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
    //check to see if we were able to obtain a handle to the volume
    if( hVol == INVALID_HANDLE_VALUE )
    FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(),
    MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), errMsg, 255, NULL);
    printf("Disk_LockVolume() - CreateFile failed (%s)\n", errMsg);
    goto exit;
    // now lock volume
    if (!DeviceIoControl(hVol, FSCTL_LOCK_VOLUME, NULL, 0, NULL, 0, &status, NULL))
    FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(),
    MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), errMsg, 255, NULL);
    printf("Disk_LockVolume() - Error attempting to lock device! (%s)\n", errMsg);
    goto exit;
    //dismount the device
    if (!DeviceIoControl(hVol, FSCTL_DISMOUNT_VOLUME, NULL, 0, NULL, 0, &status, NULL))
    FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(),
    MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), errMsg, 255, NULL);
    printf("Disk_LockVolume() - Error attempting to dismount volume. (%s)\n", errMsg);
    goto exit;
    exit:
    return hVol;
    HANDLE Disk_GetHandle(UINT Lun)
    HANDLE hVol;
    LPTSTR errMsg = "";
    DWORD status;
    bool success = false;
    //now try to get a handle to the specified volume so we can write to it
    hVol = CreateFile(MassStorageDisk[Lun].PhysicalDisk, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, 0, OPEN_EXISTING, FILE_FLAG_NO_BUFFERING, 0);
    //check to see if we were able to obtain a handle to the volume
    if( hVol == INVALID_HANDLE_VALUE )
    FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(),
    MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), errMsg, 255, NULL);
    printf("Disk_WriteData() - CreateFile failed (%s)\n", errMsg);
    return hVol;

    Good for you for fixing the bug.  On the second go-round, I noticed another one, though.  You are not setting the hEvent handle on the OVERLAPPED structure.  If you ever do get an ERROR_IO_PENDING, it would probably be bad inside WriteFile,
    but even if that returned, you would get a problem when calling WaitForSingleObject.
    It helps that we know the actual WriteFile call is what is taking the time.  From your description, though, it's not clear what the precise issue is.  You are comparing write speeds of your SSD vs. a regular USB flash drive.  Are you also
    comparing your program to that of another program?  If the comparison is just between SSD and the existing USB drive, why do you not believe you have established that IO on the SSD is slow? Your last sentence is confusing: you first say that the IO on
    the USB drive was as expected and IO on the SSD was slower, then say that a file write unto the USB drive took 2.5 mins and copying it to the SSD took 2.5 seconds.  I assume these times were reversed.
    BTW, personally for that kind of benchmarking, I would prefer non-buffered, synchronous IO myself.
    I would also consider using
    Process Monitor, for more information about what is going on with the low-level IO events.  Ignore the benchmarking numbers when procmon is running, but getting a log from it will give you more visibility into what events are firing and their sequence,
    what flags the IFS is seeing, etc.

  • Insert or Modify statement from internal table to database table

    Hi All,
    I have three tables wakh, wrf and wakp. I have an internal table with 5 columns col1, col2, col3, col4 and col5.
    The value in Col1 is my article no and the articleno. is in the table wakh. The value in col2 is my ccode and it is in the table wrf. The rest three columns col3, col4 and col5 are unit, qty and price and they are in the wakp table. Now when my articleno is equal to ccode I need to update the col3, col4 and col5 values  in the wakp. wakp has around 20 columns.
    Can anyone of you guys please give me the code for this issue. Your help is highly appreciated and thanks for all for your time.
    Cheers,
    Cheng

    Hi Rob,
    let me explain you the whole process what i am trying to do. I have a screen where there are 3 fields. In my first field I have a promoiton no. As soon as the user enters the promotion no. its description will be populated in my second field. If the promotion is not maintained then it will throw an error. In my third field User will upload an excel sheet which has 5 columns articleno, colorcode, salesunit, qty, mdprice. Here articleno is coming from wakh and colorcode is in wrf_charval table and the rest three fields are coming from wakp table. So for the article no. which is in col1. and for its corresponding colorcode which is in col3 i need to update col3, col4, col5 values.
    With my below code I am able to upload the excel into internal table and display it. So instead of displaying I need to update in the database. Can you please let me know how I need to attach the function module within my code and update accordingly.
    REPORT  ZTest.
    tables : wakh, wakt.
    Parameter: PromoID type wakh-aktnr, PromoDec type wakt-aktkt, p_file LIKE rlgrap-filename
                   DEFAULT 'c:\test.xls' OBLIGATORY.   " File Name
    *FileName type string.
    *file_nm type localfile.
    TYPES:   BEGIN OF t_datatab,
             col1(25)  TYPE c,
             col2(30)  TYPE c,
             col3(30)  TYPE c,
             col4(30)  TYPE c,
             col5(30)  TYPE c,
             END OF t_datatab.
    DATA: it_datatab TYPE STANDARD TABLE OF t_datatab INITIAL SIZE 0,
          wa_datatab TYPE t_datatab.
    Data : p_table type t_datatab occurs 0 with header line.
    DATA : gd_scol   TYPE i VALUE '1',
           gd_srow   TYPE i VALUE '2',
           gd_ecol   TYPE i VALUE '5',
           gd_erow   TYPE i VALUE '65536'.
    DATA: it_tab TYPE filetable,
          gd_subrc TYPE i.
    field-symbols : <fs>.
    AT selection-screen on PromoID.
    select single * from wakh where aktnr = PromoID.
      if sy-subrc EQ 0.
    select aktkt from wakt into PromoDec where aktnr eq PromoID.
    endselect.
    else.
    message A000(ZI) with 'Promotion ID is not Maintained.'.
    endif.
    *Title : Excel Uploading
    *Selection screen definition
    *SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
    *PARAMETERS:  p_file LIKE rlgrap-filename
                  DEFAULT 'c:\test.xls' OBLIGATORY.   " File Name
    *SELECTION-SCREEN END OF BLOCK b1.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
      REFRESH: it_tab.
      CALL METHOD cl_gui_frontend_services=>file_open_dialog
        EXPORTING
          window_title     = 'Select File'
          default_filename = '*.xls'
          multiselection   = ' '
        CHANGING
          file_table       = it_tab
          rc               = gd_subrc.
      LOOP AT it_tab INTO p_file.
       so_fpath-sign = 'I'.
       so_fpath-option = 'EQ'.
       append so_fpath.
      ENDLOOP.
    START-OF-SELECTION.
      PERFORM upload_excel_file TABLES   it_datatab
                                 USING   p_file
                                         gd_scol
                                         gd_srow
                                         gd_ecol
                                         gd_erow.
    END-OF-SELECTION.
    END-OF-SELECTION.
      LOOP AT it_datatab INTO wa_datatab.
        WRITE:/ wa_datatab-col1,
                wa_datatab-col2,
                wa_datatab-col3,
                wa_datatab-col4,
                wa_datatab-col5.
      ENDLOOP.
    *&      Form  UPLOAD_EXCEL_FILE
          upload excel spreadsheet into internal table
         -->P_TABLE    Table to return excel data into
         -->P_FILE     file name and path
         -->P_SCOL     start column
         -->P_SROW     start row
         -->P_ECOL     end column
         -->P_EROW     end row
    FORM upload_excel_file TABLES   p_table
                           USING    p_file
                                    p_scol
                                    p_srow
                                    p_ecol
                                    p_erow.
      DATA : lt_intern TYPE  kcde_cells OCCURS 0 WITH HEADER LINE.
    Has the following format:
                Row number   | Colum Number   |   Value
         i.e.     1                 1             Name1
                  2                 1             Joe
      DATA : ld_index TYPE i.
    Note: Alternative function module - 'ALSM_EXCEL_TO_INTERNAL_TABLE'
      CALL FUNCTION 'KCD_EXCEL_OLE_TO_INT_CONVERT'
        EXPORTING
          filename                = p_file
          i_begin_col             = p_scol
          i_begin_row             = p_srow
          i_end_col               = p_ecol
          i_end_row               = p_erow
        TABLES
          intern                  = LT_INTERN
        EXCEPTIONS
          inconsistent_parameters = 1
          upload_ole              = 2
          OTHERS                  = 3.
      IF sy-subrc <> 0.
        FORMAT COLOR COL_BACKGROUND INTENSIFIED.
        WRITE:/ 'Error Uploading file'.
        EXIT.
      ENDIF.
      IF lt_intern[] IS INITIAL.
        FORMAT COLOR COL_BACKGROUND INTENSIFIED.
        WRITE:/ 'No Data Uploaded'.
        EXIT.
      ELSE.
        SORT lt_intern BY row col.
        LOOP AT lt_intern.
         MOVE lt_intern-col TO ld_index.
         assign component ld_index of structure
         p_table to <fs>.
    move : lt_intern-value to <fs>.
        MOVE lt_intern-value TO p_table.
          AT END OF row.
            APPEND p_table.
            CLEAR p_table.
          ENDAT.
        ENDLOOP.
      ENDIF.
      ENDFORM.
    Thanks for your valuable time.
    Cheng

  • Any easy way to generate unique primary key for database table?

    I'm currently playing with the J2EE reference implementation from Sun which comes with the IBM Cloudscape database. This Cloudscape database supports the use of an AutoIncrement field.
    First question: Can I use CMP and assume that the database will generate a proper key for me? Anyone tried it out successfully before?
    Also, based on what I've heard so far, it seems that generating database primary key is not really well-supported by J2EE using CMP in that a lot of J2EE developers have to resort to workarounds like using a session bean, JDBC and (1) some seed numbers for ID implanted in the database itself (as in the J2EE tutorial DukesBankApp example) or (2) using the SQL MAX aggregation command + 1. Usign seed number is contradictory to good database design and using MAX is dangerous for heavy traffic application if 2 beans try to insert themselves into the database at the same time (synchronizarion problem).
    Anyway I find it dumb that we still have to go back to JDBC and SQL which was the reason why the concept Entity Bean was introduced; to make database persistence transparent! Now it seems that J2EE makes it worse and more troublesome than before.
    Second Question: Is there any easy (hopefully transparent/automatic) way of generating primary key ID?

    if you want to rely on your container or database then go hard, will probably be faster.
    to make a cross container/db soln I used a CMP Entity bean called Sequence with one field for uid
    I use one instance and increment the field each time.
    To do the logic, I have a utils class with static method, no need for session bean overhead
    I reckon this approach is OK considering all things

Maybe you are looking for

  • Missing Controls

    I'm using the latest version of iWeb. I dragged an MP3 fro iTunes to my webpage and then added a photo to the object. In iWeb, I get a set of controls that allows me to start/stop the music. However, when I review the page in Safari, after publishing

  • Satellite L650-11F is not suported in service page

    I can't find anything about Satellite L650-11F in service pages. ?f u have any idea please help me. I bought this notebook however I can't find any knowledge abou it in Toshiba web pages.

  • Can I make photo albums to get printed off like on iPhoto on the Mac? I only own an iPad.

    Can I make photo albums to get printed off like on iPhoto on the Mac? I only own an iPad.

  • Ejbc error, no PKWrapper class

    I am getting the following error when tyring to generate the container classes: Exception in thread "main" java.lang.NoClassDefFoundError: weblogic/ejb/internal /PKWrapper I looked in my weblogic install directory, and under c:\weblogic51\classes\web

  • Anyone using reason 4.0 with logic?

    im using reason 4.0 abby road samples and im getting latency when i try to record tracks. i have a 2.0 processor and 2 gigs of ram. any advice?