How to update Records of SAP table from .CSV file

Hi,
I have written a code which takes a data from (,) delimited CSV file and adds it into the Internal table.
Now I want to update the all fields in SAP table with the Internal table.
I want to use Update statement.
Update <table Name> SET <field needs to update> WHERE connditon.
I don't want to iterate through thousand on record in sap table to check the where condition.
Could you please tell me how to do it.

Hi. I thing you will not workaround the iterating of the internal table.
You can pre-load all the records into another internal table
check lt_csv[] is not initial. " important, otherwise next select would read all records of the table
select .... into lt_dbitab for all entries in lt_csv where key-fieds = lt_csv-key_fields...
check sy-subrc eq 0 and lt_dbitab[] is not initial.
then do in-memory update of the it_dbitab
loop at it_dbitab assign <fs>.
  read table lt_csv assign <fs_csv> with key ... " lt_csv should be sorted table with key, or you should try to use binary search
  if sy-subrc eq 0.
    ...change required lt_dbitab fields: <fs>-comp = <fs_csv>-comp...
  endif.
endloop.
ant then you can do mass-update
update dbtab from table lt_dbitab.
From performance view, this solution should be much faster than iterating lt_csv directly and updating every single database record
Br
Bohuslav

Similar Messages

  • How to update value in internal table from cdpos taking fname n value_new?

    hello everyone,
              i want to insert  value in internal table from cdpos table taking field name  from fname and value from value_new.but the problem is i am not getting how to map the corresponding field of internal table with fname value  which is the field name.
    for example
    i
    fieldname
    value
    name1
    raj
    name2
    sharma
    i want to update field name1. this name1 is there in fname with updated value in value_new  how to make name1 with fname value
    thanks and regards
    laxmikant soni

    Hi Laxmikant,
    If I have understood your requirement correctly, you need to update an internal table with latest 'value_new' from cdpos table where  'fname' = 'fieldname' .
    Hope the below logic will help you:
    FIELD-SYMBOLS: <wa_intab> LIKE LINE OF lt_intab.  "the internal table you want to change
    LOOP AT lt_intab ASSIGNING <wa_intab> .
       READ TABLE lt_cdpos INTO wa_cdpos           "lt_cdpos contains latest data selected from CDPOS
        WITH KEY fname = <wa_intab>-fieldname.
       IF sy-subrc = 0.
         <wa_intab>-value = wa_cdpos-value_new.    
       ELSE.
         "//logic if the name is not there in CDPOS
       ENDIF.
       CLEAR  wa_cdpos.
    ENDLOOP.
    If you wish to improve performance, I suggest using
    1. "transporting value_new" addition in READ TABLE,
    2.  select only the data which you require from CDPOS,
    3.  create the internal tables with only fields which you require,
    4.  when you are using SELECT,LOOP AT statements, limit records by using WHERE condition
    Regards,
    Kavya

  • How to update records in a table based on user selection..

    Hi all,
    This time the above doubt is totally based on the logic of coding which I tried a lot but didn't get any solution. so atlast I come to sdn site.
    please help..
    The requirement is like that I have a table with 6 fields (1 primary key and other are nonkeys). If the user inputs some values in the fields on the screen, then a row will be added in the table. Upto this i have done well. but when the user want to change some value  in the existing row of the table my program unable to do so. Because I couldn't get any logic to do that as there are 5 nonkey fields, so if any one field is modified then the respective row should be selected first based on the user selection and then it should be updated.
    At this point I could not get any idea as it may take a lots of if conditions (I guess) to reach to that particular row.
    Please help..
    thanks ,
    sekhar

    Hi Sekhar,
    I am afraid, the whole design of your program is wrong, let me explain
    Let us say you have two rows(5 non key fields) that the user wants to update and the data in these five non key fields are identical and in your program you are getting a number(which is the key) using a number range object. So you will have two entries in the table for the same data.
    And on the update page when the user enters the non key fields, how will the program know(or for that matter any one of us) which record to pick, if you have two identical books and if asked for a book wouldn't you ask which one among these two do you want?
    Possible Solution: Identify a possible key maintaining the integrity of the data, that is a combination of the non key fields which will help you identify a unique row and make these fields as key fields in the table.
    A more costly solution(if you do not want to change the non key field keys to key fields) would be to, adding a check(using select statement) to see if the non key fields combination already exists in the Z table before inserting a record into the table.
    If yes, throw a message to the user and just update the values in the table, else insert the record.
    Another solution would be to, use the non key fields to generate a key(using some logic) and using this instead of the number range object.
    regards,
    Chen

  • Loading 361000 records at a time from csv file

    Hi,
    One of my collegue loaded 361000 records from one file file , how is this possible as excel accepts 65536 records in one file
    and even in the infopackage the following are selected what does this mean
    Data Separator   ;
    Escape Sign      "
    Separator for Thousands   .
    Character Used for Decimal Point   ,
    Pls let me know

    hi Maya,
    it just possible, other than ms-excel, we have editor like Textpad that support more 65k rows (and windows Notepad), the file may be generated by program or edited outside in excel, or newer version of excel is used, ms-excel 2007 support more 1 million rows.
    e.g we have csv file
    customer;product;quantity;revenue
    a;x;"1.250,25";200
    b;y;"5.5";300
    data separator ;
    - char/delimeter used to separate field, e.g
    escape sign, e.g
    - "1.250,25";200 then quantity = 1.250,25
    separator for thousands = .
    - 1.250,25 means one thousand two hundred ...
    char used for decimal point
    - - 1.250<b>,</b>25
    check
    http://help.sap.com/saphelp_nw70/helpdata/en/80/1a6581e07211d2acb80000e829fbfe/frameset.htm
    http://help.sap.com/saphelp_nw70/helpdata/en/c2/678e3bee3c9979e10000000a11402f/frameset.htm
    hope this helps.

  • Bulk Insert into a Table from CSV file

    I have a CSV file with 1000 records and i have to insert those records into a table.
    I tried for Bulk Insert command and Load data infile command but it throws error.
    Am using Oracle 10g Express Edition.
    I want to achieve it thru query command and not by plsql procedures
    Please send me query syntax for this problem. . . .
    Thanks in Advance,
    Hariharan ST.

    Hi
    If you create an external table that points to your csv file you will then be able populate your table from a query.
    See: http://www.astral-consultancy.co.uk/cgi-bin/hunbug/doco.cgi?11210
    Hope this helps

  • First Row Record is not inserted from CSV file while bulk insert in sql server

    Hi Everyone,
    I have a csv file that needs to be inserted in sql server. The csv file will be format will be like below.
    1,Mr,"x,y",4
    2,Mr,"a,b",5
    3,Ms,"v,b",6
    While Bulk insert it coniders the 2nd column as two values (comma separte) and makes two entries .So i used filelterminator.xml.  
    Now, the fields are entered into the column correctly. But now the problem is, the first row of the csv file is not reading in sql server. when i removed the  terminator,  i can get the all records. But i must use the above code terminator. If
    am using means, am not getting the first row record.
    Please suggests me some solution.
    Thanks,
    Selvam

    Hi,
    I have a csv file (comma(,) delimited) like this which is to be insert to sql server. The format of the file when open in notepad like below:
    Id,FirstName,LastName,FullName,Gender
    1,xx,yy,"xx,yy",M
    2,zz,cc,"zz,cc",F
    3,aa,vv,"aa,vv",F
    The below is the bulk insert query which is used for insert above records,
    EXEC(BULK INSERT EmployeeData FROM '''+@FilePath+'''WITH
    (formatfile=''d:\FieldTerminator.xml'',
    ROWTERMINATOR=''\n'',
    FIRSTROW=2)'
    Here, I have used format file for the "Fullname" which has comma(,) within the field. The format file is:
    The problem is , it skip the first record (1,xx,yy,"xx,yy",M) when i use the format file. When i remove the format file from the query, it takes all the records but the "fullName" field makes the problem because of comma(,) within the
    field. So i must use the format file to handle this. So please suggest me , why the first record skipped always when i use the above format file.
    If i give the "FirstRow=1" in bulk insert, it shows the "String or binary data would be truncated.
    The statement has been terminated." error. I have checked the datatype length.
    Please update me the solution.
    Regards,
    Selvam. M

  • How to delete duplicate data that generated from csv file??

    The thing i have done is that i red all the data in the csv file without removing the duplicate data and display it.. For where i should have a known number of index (about 13), my main file should have 13 records no duplicate values. and how can my Java program update the corresponding record in the main file each time an index is updated??
    Hope somebody can assist me on this..it would be really helpful for me...
    Thank you.
    -Rao-
    Edited by: reemarao on Apr 1, 2010 3:58 AM

    Hi Sudhir,
    In case you have edit access in your system carry out the following procedure:
    1. Create an export datasource on your cube.
    2. Now create the update rules to your cube using the datamart Infosource.
    3. In the update rules multiply all the key figures by
    -1.
    4. Now create an infopackage and give the request id of the duplicate request as selection.
    5. Load the datamart request and do the data validation.
    If you do not ahve edit access there is no other alternative you would have to delete all the data and reconstruct the requests that you need.
    Bye
    Dinesh

  • Error while creating table from csv file

    I am getting an error while creating a table using 'Import Data' button for a csv file containing 22 columns and 8 rows. For primary key, I am using an existing column 'Line' and 'Not generated' options.
    ORA-20001: Excel load run ddl error: drop table "RESTORE" ORA-00942: table or view does not exist ORA-20001: Excel load run ddl error: create table "RESTORE" ( "LINE" NUMBER, "PHASE" VARCHAR2(30), "RDC_MEDIA_ID" VARCHAR2(30), "CLIENT_MEDIA_LABEL" VARCHAR2(30), "MEDIA_TYPE" VARCHAR2(30), "SIZE_GB" NUMBER, "RDC_IMG_HD_A" NUMBER, "START_TECH" VARCHAR2(30), "CREATE_DATE" VARCHAR2(30), "RDC_MEDIA_DEST" VARCHAR2(30), "POD" NUMBER, "TAPE" NUMBER, "ERRORS_YN" VA
    Any idea?

    I am getting an error while creating a table using 'Import Data' button for a csv file containing 22 columns and 8 rows. For primary key, I am using an existing column 'Line' and 'Not generated' options.
    ORA-20001: Excel load run ddl error: drop table "RESTORE" ORA-00942: table or view does not exist ORA-20001: Excel load run ddl error: create table "RESTORE" ( "LINE" NUMBER, "PHASE" VARCHAR2(30), "RDC_MEDIA_ID" VARCHAR2(30), "CLIENT_MEDIA_LABEL" VARCHAR2(30), "MEDIA_TYPE" VARCHAR2(30), "SIZE_GB" NUMBER, "RDC_IMG_HD_A" NUMBER, "START_TECH" VARCHAR2(30), "CREATE_DATE" VARCHAR2(30), "RDC_MEDIA_DEST" VARCHAR2(30), "POD" NUMBER, "TAPE" NUMBER, "ERRORS_YN" VA
    Any idea?

  • How to update date in a table from another database

    Hello,
    I am trying to code a way to Update my Testing database from another database. In the coding below the database that has the updated data ends in Restore.
    Use ClientDB_MASTER_Restore
    Truncate Table ClientDB_MASTER_Testing.dbo.Activity_Tracking_AZ
    GO
    SELECT * INTO ClientDB_Master_Testing.dbo.Activity_Tracking_AZ
    FROM Activity_Tracking_AZ
    Go
    I know with this Technique the table must be truncated if not deleted first.  There is probably a better way to do this which I'm very open to.  I'm also looking for coding that will roll back any changes made should an error occur.
      As always, any help is greatly appreciated.
    David92595

    USE ClientDB_MASTER_Testing
    go
    SET XACT_ABORT ON
    BEGIN TRANSACTION
    Truncate Table dbo.Activity_Tracking_AZ
    -- SET IDENTITY_INSERT dbo.Activity_Tracking_AZ ON
    INSERT dbo.Activity_Tracking_AZ (col1, col2, ...)
    SELECT col1, col2,
    FROM ClientDB_MASTER_Restore.dbo.Activity_Tracking_AZ
    -- SET IDENTITY_INSERT dbo.Activity_Tracking_AZ OFF
    COMMIT TRANSACTION
    If you find it boring to type the column lists, just find the table in Object Explorer, and drag the columns node to where you want the column list.
    You need the SET IDENTITY_INSERT command if the table has an IDENTITY column.
    By wrapping the code in a transaction, you are not left with an empty table if the INSERT fails. The command SET XACT_ABORT ON makes sure that the batch is aborted and rolled back in case of an error.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Insert data into oracle table from XML file

    I need to insert data into oracle table from XML file
    If anybody handled this type of scenario, Please let me know how to insert data into oracle table from XML file
    Thanks in advance

    The XML DB forum provides the best support for XML topics related to Oracle.
    Here's the FAQ on that forum:
    XML DB FAQ
    where there are plenty of examples of shredding XML into Oracle tables and such like. ;)

  • How to update Records from Internal table to u2018Zu2019 table?

    Hi Friends,
    How to update Records from Internal table to u2018Zu2019 table.
    I have records in Internal table , that records want to update on u2018Zmarau2019 Table.
    ( my internal table & u2018 Zu2019 table structures are same.)
    Thanking you.
    Regards,
    Subash

    Hi,
    loop at internal table.
    modify <Z- table > from values < internal table Workarea>.
    if sy-subrc = 0.
      COMMIT work.
    else.
      ROLLBACK waork.
    endif.
    endloop.
    or
    UPDATE <Z- table > from table < internal table Workarea>.
    if sy-subrc = 0.
      COMMIT work.
    else.
      ROLLBACK waork.
    endif.
    Prabhudas

  • Loading records from .csv file to SAP table via SAP Program

    Hi,
    I have a .csv file with 132,869 records and I am trying to load it to an SAP table with a customized SAP program.
    After executing the program, only 99,999 records are being loaded into the table.
    Is there some setting to define how many records can be loaded into a table? Or what else could be the problem?
    Pls advice.
    Thanks!!!

    hi Arun ,
    A datasource need a extract structure to fetch data .It is nothing but a temp table to hold data.
    First you need to create atable in SE11 with fields coming from CSV file.
    Then you need to write a report program to read you CSV file and populate your table in BW .
    Then you can create a datasource on top of this table .
    After that replicate and load data at PSA and use to upper flow.
    Regards,
    Jaya Tiwari

  • How to insert new record into oracle table from GridView in VS2005.

    I need to insert records into Oracle10g table from VS2005 GridView using the Insert Method in Business Logic Class. The Update and Delete Methods are working fine. What's the best way out?

    How is it "not possible"?
    Either modify the Class for the new fields, or give the new fields default values (if applicable). If the type of an existing column has changed, then only the first option is available.
    Where's the problem?

  • How to change records in standard tables ?

    how to change records in standard tables ?

    HI,
    If you are asking from program..Then you can use BDC or BAPI to update the records in teh standard tables..
    OR
    use the corresponding tcode to update the record
    Thanks
    Naren

  • How to update my mac book pro from 10.5.8 to the leatest version

    how to update my mac book pro from 10.5.8 to the leatest version

    Upgrading to Snow Leopard, Lion, or Mountain Lion
    Upgrading to Snow Leopard
    You can purchase Snow Leopard by contacting Customer Service: Contacting Apple for support and service - this includes international calling numbers. The price is $19.99 plus tax. You will receive physical media - DVD - by mail.
    Third-party sources for Snow Leopard are:
    Snow Leopard from Amazon.com
    Snow Leopard from eBay
    After you install Snow Leopard you will have to download and install the Mac OS X 10.6.8 Update Combo v1.1 to update Snow Leopard to 10.6.8 and give you access to the App Store.
    Before upgrading check that you computer meets the minimum requirements:
    Snow Leopard General requirements
      1. Mac computer with an Intel processor
      2. 1GB of memory
      3. 5GB of available disk space
      4. DVD drive for installation
      5. Some features require a compatible Internet service provider; fees may
          apply.
      6. Some features require Apple’s MobileMe service; fees and terms apply.
    Upgrading to Lion
    First, you need to upgrade to Snow Leopard 10.6.8 as stated above.
    You can purchase Lion by contacting Customer Service: Contacting Apple for support and service - this includes international calling numbers. The cost is $19.99 (as it was before) plus tax.  It's a download. You will get an email containing a redemption code that you then use at the Mac App Store to download Lion. Save a copy of that installer to your Downloads folder because the installer deletes itself at the end of the installation.
    Before upgrading check that you computer meets the minimum requirements:
    Lion System Requirements
      1. Mac computer with an Intel Core 2 Duo, Core i3, Core i5, Core i7, or
          Xeon processor
      2. 2GB of memory
      3. OS X v10.6.6 or later (v10.6.8 recommended)
      4. 7GB of available space
      5. Some features require an Apple ID; terms apply.
    Upgrading to Mountain Lion
    Be sure your computer meets the minimum requirements:
    Apple - OS X Mountain Lion - Read the technical specifications.
    Macs that can be upgraded to OS X Mountain Lion
      1. iMac (Mid 2007 or newer)
      2. MacBook (Late 2008 Aluminum, or Early 2009 or newer)
      3. MacBook Pro (Mid/Late 2007 or newer)
      4. MacBook Air (Late 2008 or newer)
      5. Mac mini (Early 2009 or newer)
      6. Mac Pro (Early 2008 or newer)
      7. Xserve (Early 2009)
    Are my applications compatible?
    See App Compatibility Table - RoaringApps - App compatibility and feature support for OS X & iOS.
    Am I eligible for the free upgrade?
    See Apple - Free OS X Mountain Lion upgrade Program.
    For a complete How-To introduction from Apple see Apple - Upgrade your Mac to OS X Mountain Lion.

Maybe you are looking for

  • Powerbook g4 charger not working, changed fuse and still no luck

    I've got a powerbook g4 laptop. A few nights ago the charger just stopped working. The wire is totally intact and we have tried changing the fuse within the plug but it keeps fusing out and still not working. I really don't want to buy a new charger

  • Creating  a Method

    OK, now I need to create a method: public boolean isLeapYear(int year) This is the script public class MyDate{      //...code that defines sate and behaviour of all date objects public static void main(String[] args) { System.out.println("My Date!");

  • Updated to 10.9.5 and trouble loading saved game FM2014

    Hi, playing Football Manager 2014 was never a problem on my Macbook Air.  Yesterday I updated the system to 10.9.5.  Today I wanted to play the game again and there seems to be a problem with the free memory. Any idea how to solve this problem? I'm a

  • Test Result set procedure with cursor

    i am really new for oracle and i don't know how to test my result set procedure in oracle. i am now working on Oracle 10g Express Edition. my procedure is below. create or replace procedure "GETORDERSBYCATALOGUECODE" (p_cataloguecode IN VARCHAR2, p_c

  • Item Approval Looping over approver level 2

    Hi Have an issue with item based cart approval (using BADI) looping around the same approver and not getting to the next/final approver. Working on simple 3 level approval model. Item received ok to level 1, once approved, ok to level 2 (approval ind