2012 Feb 23 5:24 AM
I have a program where in i want to update mutiple records into database table from an internal table using update statement. i want to update only 1 field into that DB table.
I want to set a field xyz = 'X' where xyz = ' '.
Does anybody have solution for that?
2012 Feb 23 5:32 AM
Hi,
This is very simple. No matter how many fields you want to update if you put all your data into internal table with updated values and use update statement againest this internal table automatically only those fields you modified will change in the database.
UPDATE DBtable FROM TABLE Internal table.
Hope this helps.
Aswath.
2012 Feb 23 6:02 AM
I want to update a single field xyz passing an internal table along with condition in the same update statement.Is it possible ?
2012 Feb 23 6:12 AM
Hi Navya,
You can do like this.
Loop at Itab into wa.
if condition on workarea whatever condition you have.
update dbtable from workarea.
endloop.
If this is not your requirment please provide what condition you have and how you want to update.
Thanks.
Aswath.
2012 Feb 23 6:24 AM
If i use update within the loop , it would hit the database many times leads to performance issue. So is there any other solution to update from internal table with certain condition other than using loop or update <database tab> from <internal tab> ?
2012 Feb 23 6:26 AM
HI,
you can use ,
UPDATE DBtable From Internaltable where xyz = 'some'.
Thanks.
Aswath.
2012 Feb 23 6:38 AM
Hi,
Then u can use
update <database tab> from <internal tab>
By having the records in the internal table where xyz = ' ' & internal table having all the key fields of DB
Regards,
Madhukar Shetty
2024 Jan 30 9:43 PM
2024 Feb 05 1:40 PM
Hello,
While we're happy that you've come to SAP Community to get an answer to your question, you posted your question as an answer in an old thread.
Posting in older threads is not the best way to get guidance.
If you're looking for help, you should start a new discussion: https://community.sap.com/t5/application-development-discussions/bd-p/application-developmentforum-b...
Best regards,
Anne
2012 Feb 23 6:16 AM
Hi
Update Table name
set xyz = 'X'
where xyz = ''.
Regards,
Gopi
2012 Feb 23 6:23 AM
Hi,
Can u tell what data are u having in the internal table ?
Does the internal table have all the key field of the DB table which u want to update ?
If u have the all key field then u can use below logic
LOOP at it where xyz = ' '.
UPDATE ztable
SET xyz = 'X'
WHERE id = it-id "Here u have to add all table key fields
and xyz = ' '.
ENDLOOP.
Thanks,
Madhukar Shetty
2012 Feb 23 6:34 AM
Hi Navya,
You can use 'MODIFY' command to update in internal table level ,it wont update in database level.
But if you use 'UPDATE' command it will update the data in database level.So try to use modify command .
Thanks and regards,
Dhaya.G
Edited by: Dhayalinie Ganesh on Feb 23, 2012 7:36 AM
2012 Feb 23 6:44 AM
Hi Navya,
1) Declare a work area type database table OR containing primary key combination.
2) Use the work area to update your database table
Please remember:
1) MODIFY statement - if record is available in DB table, it will modify it. If record is not available, it will create a new entry.
2) UPDATE statment - only to update an existing entry
Regards,
Ajoy
2012 Feb 23 6:45 AM
Hi Navya,
You can refer this ,
Loop at ITAB1 into WA1.
read table ITAB2 into WA2 with key XYZ = WA1-XYZ .
if sy-subrc = 0.
move WA2-field to WA1-field.
modify ITAB1 index sy-tabix from WA1 transporting field.
endif.
endloop.
Thanks and Regards,
Dhaya.G