Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to Move data into user-defined dbTable

Former Member
0 Kudos

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.

1 ACCEPTED SOLUTION

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

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

6 REPLIES 6

Former Member
0 Kudos

Hi Anand,

Please post this question in the ABAP Programming forum.

Thanks,

Kathy Meyers, SDN

Former Member
0 Kudos

here's the link:

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

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

0 Kudos

thanks rich,

the code which you explained solved my issue.

anand.

jayanthi_jayaraman
Active Contributor
0 Kudos

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

Former Member
0 Kudos

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,