2007 Jul 17 7:53 PM
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
2007 Jul 17 7:56 PM
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
2007 Jul 17 7:56 PM
2007 Jul 17 8:00 PM
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
2007 Jul 17 8:01 PM
Hi,
Please try this.
MODIFY <dbtab> FROM TABLE <itab>.
OR
UPDATE <dbtab> FROM TABLE <itab>.
Regards,
Ferry Lianto
2007 Jul 17 8:07 PM
Sorry, if I confused you all with my question, but is it possible to do the reverse like
Update <internaltable> from <dbtable>!!
or even if I can update one internal table from another internal table without looping in one shot, that should be fine too!!
Thanks.
Mithun
2007 Jul 17 8:10 PM
If the two internal tables are of same type then you can just do like this.
itab1[] = itab2[].
Rgds,
Naren
2007 Jul 17 8:13 PM
2007 Jul 17 8:14 PM
Thanks everyone for the replies. I know about itab1[] = itab2[] but I want to update only some fields in itab1 with the values from itab2. WOuld itab1[] = itab2[] work in this case?
Thanks
Mithun
2007 Jul 17 8:16 PM
Hi,
I don't think you can update an internal table from table without using looping/modify and select/read statement.
Regards,
Ferry Lianto
2007 Jul 17 8:18 PM
Mithun,
You cannot achieve that with out looping the internal table. And you can not update an internal table from a database table at one shot. All you have to do is a select * from dbtable into table itab.
Rgds,
Naren
2007 Jul 17 8:19 PM
Thanks Rich. I tried select into statement but it is overriding the values previously present in my internal table. Here is my logic:
For example my internal table has 3 fields f1,f2 and f3.
I first populate my internal table itab1 from some database table db1 and populate my feilds f1 and f2. Now I need to just update feild f3 in my itab from some different database table db2 without loosing the values in f1 and f2. Is this possible?
thanks.
Mithun
2007 Jul 17 8:22 PM
Mithun,
The onl;y solution is read the contents from db2 into itab2.
select * from db2 into itab2.
loop at itab1.
read table itab2 with key field1 = itab1-field1.
move itab2-fld3 to itab1-fld3.
modify itab1.
endloop.
Thanks,
Naren
2009 Feb 03 10:10 AM
Hi Mithun da,
Select * from table dbtab appending table itab.
This code will serve the purpose
2007 Jul 17 9:05 PM
Thanks everyone for the feedback. I rewarded points to everyone.
Mithun.
2009 Feb 03 10:07 AM
Hi Mithun,
I have an exactly same requirement as your. Were you able to find the solution for this?
Regards,
Charu