Doubt in updating database table

hi all
i want to modify values ztable from a internal table ....
for eg : the ztable contains matnr and accept_qty
matnr   qty
mat01   
mat02
i need to modify qty of the table .. i am using where condition (ie modify where matnr = ) but where condition is not working for database tables .... how to proceed with this ..
thanks
lokesh

hi,
before that :- modify statemnt will modify a record if there is record having the same key like that of record in work area.
if there is no record in itab with key of work area record, it will insert a new record in itab.
look this sample code.
*modify internal table
loop at itab into wa.
wa-field1 = data1.
wa-field2 = data2.
wa-field 3= data3.
modify itab from wa transporting field1 field2 field3 where key_field = wa-keyfield. "there shuld not be any chang in key field.
endloop.
*now update database table
*work area and data base structure shuld be same type
if itab[] is not initial.
modify ztable from table itab.
endif.
rgds
anver
if hlped pls mark points

Similar Messages

  • Update database table

    I have 1 million records in application server and I want to update database table from that.
    Is UPDATE statement the best technique to do it.
    Just wanted to know if there is any other better tehcniques.
    Also i want to write the errors to job log. How can we do that?
    Regards,
    DNP

    If they are all new records or all changes, it would be best to use INSERT or UPDATE. You will also want to do mass inserts/changes using an internal table. Since you have so many records, you will probably have to do this in chunks in order to avoid dumping on the rollback area.
    Rob

  • How to update database table !!!

    hi all,
    Please advice how to update database table with certain cndition needs to be checked.
    Please consider below scenario.
    have used enqueu and dequeue function to lock entries  and also i have used BAPI so considering that return parameter . i want to update table
    /tdk/st0027.
    1. I want to update database table
    2. there are certain condition needs to be checked like ,
       loop at it_final into wa_final.
    th_return-type = 'S'.
               if th_final-vbeln = /tdk/st0027-vbeln and
                  th_final-posnr = /tdk/st0027-posnr and
                  th_final-etenr = /tdk/st0027-sdslno.
    above condition which i need to check .and need to append below system fields need to be appended in table.
              th_final-prstsind = '20'.
              th_final-chgdate  = g_date.
              th_final-chgtime  = g_uzeit.
              th_final-chgprog  = g_cprog.
              th_final-chguser  = g_uname.
              append th_final to td_final.
              update /tdk/st0027 FROM th_final.
              endif.
    endloop.
    but i am getting error saying that  "The type od database table and work area (TH_FINAL)  are not unicode convertible"?
    I am not able to understandwhat would be the solution for this ?
    Thanks and regards,
    Prasad K. NAralkar

    The error occurs in the UPDATE statement included in the code. In this statement it is seen that there is a mismatch of structure defined for the DDIC table /tdk/st0027 and that of your work area th_final.
    try to create a structure w.r.t the DDIC table.
    Eg: DATA: wa_temp TYPE /tdk/st0027.
    MOVE-CORRESPONDING th_final TO wa_temp.
    Then try to UPDATE using the temporary work area i.e wa_temp which has structure similar to that of the database table.

  • Enqueue and Dequeue before updating Database table

    Hi all,
    We are updating database tables using INSERT, MODIFY and UPDATE statements. Since many people will be running the application at the same time we need to lock the table before updating database table. So we need to use ENQUEUE and DEQUEUE functionality for this purpose.
    Can any plz explain what are the steps we should follow now?
    Thanks in advance.

    Hi,
    Any Database access should carefully handled as multiple applications may be accessing the database at the same time. To read a record from the database you don't need to implement a lock, but to write you need not only locks but also ideally should use the Update Function Modules to comply SAP "All or Nothing" Principle. This will prevent data inconsistency of the database and the data will be proper state. You need to use the COMMIT WORK and ROLLBACK WORK in you code to handle the consistency part of the database.
    The best design approach would be seperate the Database Layer completely from the business layers. This will make your code robust and easy to maintain.
    As, for the Locking Concepts, you will get multiple resources from SDN as how to create Locks and implement the Locking modules in your code. But more than that what matters is why and how to implement the SAP Locking concepts to make your application run better.
    Have a look at the following link
    http://help.sap.com/saphelp_nw70/helpdata/en/cf/21eea5446011d189700000e8322d00/content.htm
    Hope this helps.
    Thanks,
    Samantak.

  • Browse and update database tables

    I'm looking for a tool that will let me connect to an Oracle database, select a table and some fields off the table and build a simple java class to navigate / update the data.
    Essentially, I'm looking for a tool that replicates the way Microsoft Access can build a form for navigation and update of a database table.
    However, I want to use java, not MS Access.
    Any ideas if such a tool is available ?
    Thanks

    http://squirrel-sql.sourceforge.net/

  • How to find out who updated database tables

    Hi
    We are using Oracle Database 10g Release 10.2.0.4.0.
    A user, via pl/sql developer, has been updating data on our database. This resulted in certain reports not balancing. At that time, we did not have database triggers on the tables concerned. We now need to go back at least a month or more to see who had updated these tables. We have a username, is there any script that we can use? How accurate is v$active_session_history? Would it give us all the info we need?

    781424 wrote:
    Hi
    We are using Oracle Database 10g Release 10.2.0.4.0.
    A user, via pl/sql developer, has been updating data on our database. This resulted in certain reports not balancing. At that time, we did not have database triggers on the tables concerned. We now need to go back at least a month or more to see who had updated these tables. We have a username, is there any script that we can use? How accurate is v$active_session_history? Would it give us all the info we need?It is little easy to know with AUDITING, or use Log miner to analyze log files.

  • Updating database table based on BAPI response in case of error

    Dear Experts,
    My scenario includes pulling records from database stagging table, and push one record at a time to BAPI_ALM_NOTIF_CREATE.
    I am using sender JDBC adapter(with select query and update query to mark records as processed).
    My question is : Once XI selects records, immediately status is updated in stagging table for the selected records as processed. what if BAPI could not create document? In this case I need to update status of that record as "Not processed".
    What should I use?
    If BPM, then please tell me the steps.
    Is this possible without BPM?
    What are the chances of failure between XI and BAPI?
    Please provide your inputs.
    Thank you.
    Div

    >
    S.R.Suraj wrote:
    > Hi Divyesh,
    >
    > Your steps are correct..
    >
    > 1. JBDC will read record with code = 0 and make it 1...
    > 2. Once the bapi process is completed all these read records shoudl be made as 2 (if completed successful) else 0 if bapi went into some error.. so that again the jdbc adapter can poll these records and give back to bapi for processing...
    >
    > Now your questions
    > >>So after selection and updation only proxy call will be done right? So for every polling of jdbc adapter ,proxy call will happen?
    > YEs every poll of jdbc will result in a proxy call and every time it will contain next set of records (as the earlier one have already marked as 1)
    >
    > >>How to achieve this?
    > Since this is a synchronous scenario JBDC->XI->Proxy and reverse, I have suggested to use responseonewaybean as a module in sender jdbc adapter (because sender jdbc cannot act synchronously thats why you need to use this module)..
    >
    > >>Do i need to use BPM? please suggest steps.
    > and if this is not working then go for BPM..the steps as i mentioned in my first thread..
    >
    > Regards
    > Suraj
    Hi Suraj,
    Thanks a lot for your support.
    It would be good if you can provide your inputs.
    Stagging table records status:
    Flag = 0 (XI will poll records)
    Flag = 1(XI has polled records and XI will se tthis flag by JDBC adapter)
    Flag =2 (should be done based on response from Proxy Tables parameter) Proxy will set tables parameter which will include info on error message and type.
    (Now based on new requiremets: for error records status should not be reset to 0 so that XI can poll records again, now stagging table should contain error records(for which proxy can not create notification in SAP) with error message and status flag 2)
    Now scenario would be JDBC to Proxy.
    Polling interval for JDBC adapter should be 1 minute.
    So I think status 0 to 1 will be done by XI after immediately selecting records.
    But how about Status 2 that has to be set only for error records only and  with error information.
    I have to update stagging table records with status 2 and error info based on proxy table response. How this can be done?
    This updation will be done in case of error only.
    I was thinking this aproach:
    We can have two interfaces.
    First interface will be jdbc to proxy:
    JDBC adapter select and update records with flag =1 and then send to proxy call and create document in SAP. At SAP side if document can not be created then they will store that error info in some table.
    Second Interfgace:
    Client SAP Proxy will periodically run and send these error records info to XI and XI will update stagging table records accordingly.
    Suraj, What is your sugestion in this solution? Do I need to use Responseonewaybean?
    Thanks Suraj
    Div

  • Not updating database table after editing using theADFapplicationJdev10.1.3

    Hi
    I created the Sample Browse and Edit JSF JSP page oracle ADF application as explained in the cuecards in Jdev10.1.3.
    After editing the department table rows in browser i am checking the database tables for the changes.
    But my table are still with the old data.they are not updating with the values i changed in the browser.
    i followed the steps correctly as explained in cuecards.
    where i am going wrong.
    What i have to do to commit the changes in to database in my ADFApplication.Did i need anything to add my code.

    In Jdev 10.1.3,there is no operations folder directly under the Application data module control.
    there is only constructors,merge entity,persist entity,refresh entity,remove entity and findalldepartments(),findallemployeeas() nodes under the application data module control.
    In findalldepartments,findallemplloyees the operations node is there.under that i don't have the commit .i have only create,execute,first,previous,last,next,delete,removerowwithkey,setcurrentRowWithkey,setcurrentRowWithkeyValue under the operation node.
    so how can i commit the operations in database.
    Please help me.

  • Updating Database table

    Hi,
    My requirement is to update the table EBAN(Purchase Requisition). Let us suppose that there are 3 items in the purchase requisition. If I make any changes to any of the item, the other two items need to be updated with the same changes. I am using a MODIFY....FROM <Internal Table> statement to update the changes in the database,
    Now the problem is if I am making any changes in the 3rd item and press save, the database gets updated for 2nd and 3rd item only but the 1st item is not modified in the database.
    If I make changes to the 1st item, then the modifications are done to 1st, 2nd and 3rd item and is working fine. The problem is when I make changes to 2nd or 3rd item then the 1st item does not get updated. I tried using update statement, locking table EBAN using ENQUEUE_E_TABLE but nothing worked.
    I tried to use MODIFY...FROM <Workarea> inside a loop but it didn't work.
    Kindly suggest.
    Regards,
    Amit Behera

    Hi
    After modifying u append that values work area to internal table.

  • Need help in updating database table from screen fields

    Hi,
    Can anyone tell me how to update the database table with the entries given in the fields of a screen ?...a procedure-wise explanation would be very helpful.
    Thank you.
    Moderator message: sorry, no beginner forums here, please search for available information or attend training.
    locked by: Thomas Zloch on Aug 12, 2010 3:16 PM

    Hi,
    Can anyone tell me how to update the database table with the entries given in the fields of a screen ?...a procedure-wise explanation would be very helpful.
    Thank you.
    Moderator message: sorry, no beginner forums here, please search for available information or attend training.
    locked by: Thomas Zloch on Aug 12, 2010 3:16 PM

  • SQL Mode Command to update database table

    Hi All,
    I have a couple of scenarios which I need help with:
    1)
    - I have a sql query which pulls two columns lets say Equipment and a val1 from a sql database table displayed in a grid.
    - Once the user clicks on a record I have two text boxes which get the value of the selected records on the same page (equipment, val1).
    - I then have an update button, wherein they can change the value of the val1 column.
    I have created a sql query of mode command with an update statement. My question is, how do I execute this update query from the webpage, I know how to assign the parameters so the get passed to the update query I just am not sure how to kick off the update query. Do I have to have it as part of an applet to even refer to it from within my webpage? If so, don't I have to assign an applet a display template? (this command query does not have an output). Please help...
    Thanks,
    Mahwish

    I have done scenario 2, but its not easy.  This is how I did it.
    Instead of using the iGrid applet, I used an XSLT stylesheet to create a "grid" of input boxes in HTML that allow direct editing of the value.  At the end of each row you had an "update" button that passed the value of the updated box, and the corresponding information you need for icommand update.  You can either display the information you need for the update query in the "grid"  or you can use hidden form objects to store the information.   Indexing is pretty easy, you just name the form elements by positions  (eg. frmTxtR1C1)  for example.
    The solution is not for the faint of heart, takes some development time and a fair amount of XSLT knowledge, but if you need this functionality repeatedly in your application, it works great.  It looks really slick too because you can do things like change the color of your form after you have updated it so the user knows there has been a change.    Of course there are always multiple ways to attack a problem I love hearing other suggestions.

  • CRUD using ADF fails to update database table

    Hi All,
    I am very new to ADF and JDev. I am using JDev 11.1.1.2.0 and oracle 10g DB.
    I have created the required
    1. model, view control, Data control files using JDev for a DB table.
    2. .jspx file that has a 'panel accordin' and a 'panel formLayout' layouts to display the required table fields on the page.
    I am using Panel accordin layout to display the data with navigators buttons and works fine.
    In Panel Form layout, after displaying the fields I have added "Submit" button. I have bound this button with "Commit" operation by simple drag and drop.
    PS: I have added the fields by simple drag drop of the data control file mapped to the table in question.
    On running the page I find things work fine till I want to use the submit button. It just updates the UI front but when I verify in my database table I find that it has not been updated.
    I am clueless. Pls guide.
    A site with step - by - step end to end development will be very great.
    Waiting desparately to get this solved.
    Thanks all
    Edited by: user8925296 on Jan 16, 2010 2:13 AM

    You need to be careful. Submit and committing to the database are two different things.
    Submit on a page (and autoSubmit the property) are only posting the changes you typed into the field, back down to the application server. NOTHING is happening with the database at this point. So the applications's internal "cache" of records (using something like ADF BC) is holding the changes but the database doesn't know anything. So if you quit now, no changes will go to the database.
    These changes onlyget submitted down to the app server when you do some sort of action like press a button. Simply navigating fields will be doing nothing back to the app server. If you add autoSubmit then you will automatically submit the changes on that field down to the app server when you leave the field (but again, this is not touching the database)
    You have to explicitly add a COMMIT operation to save those changes to the database.
    Maybe if you try in a simple EMP example and send us your findings we can help direct you further.
    Regards
    Grant

  • Updating Database table across multiple SAP systems

    Dear All,
    I am working on a requirement which is described as follows:
    The requirement is to keep a database table in sync across 10 different SAP clients (for production, test systems etc.). So when the database table is modified in source SAP system, it has to be replicated across all the clients and table of other SAP systems.
    So the queries from my side are:
    1. Whether XI should be used here as a middleware or direct RFC calls can do the updation across the SAP systems?
    2. If XI is to be used what would be the recommended approach (ABAP Proxy to ABAP Proxy communication?)
    Hope you can recommend me the best options to achieve this.
    Thanks & Regards,
    Pratik

    it depends on what tables are involved/ what type of data/what transactions cause the update.
    If you know the table names - then database level replication may be an option u2013 many projects do refresh their QA system with production data for a very real test data. If not, a hard disk level mirroring may have to be considered.
    There are other technologies like change pointers in conjunction with distribution model can also be considered - which could trigger idocs that can be sent to the other systems using ALE layer or ALE *** PI/XI

  • Update database table from a work area

    hi!
    I have a workarea that is like the corresponding database table. There are a lot of fields so I dont want to update each field with an UPDATE but instead I want to do som sort of:
    UPDATE dbase_table
    FROM work_area
    WHERE dbase_table-primary_key = work_area-primary_key
    I could only find a statement called UPDATE dbase_table FROM  work_area but I dont understand how without specifying a WHERE clause it knows which rows to update.
    regards
    Baran

    UPDATE  dbtab      FROM wa. or
    UPDATE (dbtabname) FROM wa.
    Extras:
    1. ... CLIENT SPECIFIED
    2. ... CONNECTION con
    Effect
    Changes one single line in a database table, using a primary key to identify the line and taking the values to be changed from the specified work area, wa. The data is read out of wa from left to right, matching the line structure of the database table dbtab. The structure of wa remains unchanged. This means that wa must be at least as wide (see DATA) as the line structure of dbtab, and have the same alignment. Otherwise, a runtime error occurs.
    If either the database table, dbtab, or the work area, wa, contain Strings, wa must be compatible with the line structure of dbtab.
    Example
    Changing the telephone number of the customer with customer number '12400177' in the current client:
    DATA   wa TYPE scustom.
    SELECT SINGLE * FROM scustom INTO wa
      WHERE id = '12400177'.
    wa-telephone = '06201/44889'.
    UPDATE scustom FROM wa.
    When the command has been executed, the system field SY-DBCNT contains the number of updated lines (0 or 1).
    Examples
    Update discount for the customer with the customer number '00017777' to 3 percent (in the current client):
    DATA: wa TYPE scustom.
    SELECT SINGLE * FROM scustom INTO wa
      WHERE id = '00017777'.
    wa-discount = '003'.
    UPDATE scustom FROM wa.
    The Return Code is set as follows:
    SY-SUBRC = 0:
    The specified line has been updated.
    SY-SUBRC = 4:
    The system could not update any line in the table, since there is no line with the specified primary key.
    BR< JAcek

  • How to update database table from Internal Table

    hi experts,
        Can anyone please assist me in inserting records to a database table from an Internal Table
    whose structures are identical.
    Thanks in Advance,
    Sudhaa............

    Hi Sudha,
    Here are some example of update and insert:
    UPDATE SFLIGHT SET PLANETYPE = 'A310'
    PRICE = PRICE - '100.00'
    WHERE CARRID = 'LH' AND CONNID = '0402'.
    This example overwrites the contents of the PLANETYPE column with A310 and decreases the value of the PRICE column by 100 for each entry in SFLIGHT where CARRID contains u2018LHu2019 and CONNID contains u2018402u2019.
    TABLES SPFLI.
    DATA WA TYPE SPFLI.
    MOVE 'AA' TO WA-CARRID.
    MOVE '0064' TO WA-CONNID.
    MOVE 'WASHINGTON' TO WA-CITYFROM.
    UPDATE SPFLI FROM WA.
    MOVE 'LH' TO SPFLI-CARRID.
    MOVE '0017' TO SPFLI-CONNID.
    MOVE 'BERLIN' TO SPFLI-CITYFROM.
    UPDATE SPFLI.
    CARRID and CONNID are the primary key fields of table SPFLI. All fields of those lines where the primary key fields are "AA" and "0064", or "LH" and "0017", are replaced by the values in the corresponding fields of the work area WA or the table work area SPFLI.
    DATA: ITAB TYPE HASHED TABLE OF SPFLI
    WITH UNIQUE KEY CARRID CONNID,
    WA LIKE LINE OF ITAB.
    WA-CARRID = 'UA'. WA-CONNID = '0011'. WA-CITYFROM = ...
    INSERT WA INTO TABLE ITAB.
    WA-CARRID = 'LH'. WA-CONNID = '1245'. WA-CITYFROM = ...
    INSERT WA INTO TABLE ITAB.
    WA-CARRID = 'AA'. WA-CONNID = '4574'. WA-CITYFROM = ...
    INSERT WA INTO TABLE ITAB.
    UPDATE SPFLI FROM TABLE ITAB.
    This example fills a hashed table ITAB and then overwrites the lines in SPFLI that have the same primary key (CARRID and CONNID) as a line in the internal table.
    Insert statement :
    TABLES SPFLI.
    DATA WA TYPE SPFLI.
    WA-CARRID = 'LH'.
    WA-CITYFROM = 'WASHINGTON'.
    INSERT INTO SPFLI VALUES WA.
    WA-CARRID = 'UA'.
    WA-CITYFROM = 'LONDON'.
    INSERT SPFLI FROM WA.
    SPFLI-CARRID = 'LH'.
    SPFLI-CITYFROM = 'BERLIN'.
    INSERT SPFLI.
    If the database table does not already contain a line with the same primary key as specified in the work area, the operation is completed successfully and SY-SUBRC is set to 0. Otherwise, the line is not inserted, and SY-SUBRC is set to 4.
    Regards,
    Premraj kaushik

Maybe you are looking for