‎2005 Jun 16 5:15 PM
hi dudes,
I am new to ABAP programming and have a question. I know how to create internal tables and the dB tables.(Also to manipulate data in internal tables) Now i need to know how we can push data which is in the internal table into a dbTable? Can anybody help me out.
thanks,
anand.
‎2005 Jun 16 5:42 PM
It really depends on how the db table is structured and how your internal table is structured. If they are the same, then its this easy.
Data: itab like ztable.
INSERT ztable FROM TABLE itab.Otherwise you will have to do a little more coding.
data: begin of itab occurs 0,
f1 type c,
f2 type c,
f3 type c,
end of itab.
loop at itab.
move-correponding itab to ztable.
insert ztable.
endloop.
Regards,
Rich Heilman
‎2005 Jun 16 5:21 PM
Hi Anand,
Please post this question in the ABAP Programming forum.
Thanks,
Kathy Meyers, SDN
‎2005 Jun 16 5:22 PM
‎2005 Jun 16 5:42 PM
It really depends on how the db table is structured and how your internal table is structured. If they are the same, then its this easy.
Data: itab like ztable.
INSERT ztable FROM TABLE itab.Otherwise you will have to do a little more coding.
data: begin of itab occurs 0,
f1 type c,
f2 type c,
f3 type c,
end of itab.
loop at itab.
move-correponding itab to ztable.
insert ztable.
endloop.
Regards,
Rich Heilman
‎2005 Jun 19 6:35 PM
thanks rich,
the code which you explained solved my issue.
anand.
‎2005 Jun 17 4:48 AM
Hi,
Here I am suggesting one way.In this program,I assumed that zzz_mara is a table which is having some fields of mara table.I am selecting all the records from mara table into an internal table itab and then pushing those data in internal table itab1 and then inserting those records into zzz_mara table.
data : itab type standard table of mara,"internal table
itab1 type standard table of zzz_mara,"internal table for custom table
wa type mara,
wa1 type zzz_mara.
select * from mara into table itab .
loop at itab into wa.
move-corresponding wa to wa1.
append wa1 to itab1.
endloop.
INSERT zzz_mara FROM TABLE itab1.
Hope this helps you.
Regards,
J.Jayanthi
‎2005 Jun 17 7:00 AM
Hi,
To be on the safer side you can use 'Modify' to insert/update entries into ztables from an internal table, if the internal table has some duplicate key fields then the insert gives a short dump, to avoid the dump we use Modify.
Modify acts like an insert & update depends on the scenario, the logic is similar to insert,
Modify dbtab from table itab.
Hope this helps,
Rgds,