Application Development and Automation 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: 
Read only

contd

Former Member
0 Likes
1,302

to copy the contents from the database table to itab of the same structure what commands muct be used?

move?

move corresponding?

into table itab?

append from work area?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,277

hi vamshi,

if ur internal table fields are declared as they r in the table then

u can use <b>into table itab.</b>

if u give names like

material like mara-matnr..

into corresponding fields of table itab.

hope this helps,

do reward if it helps,

priya.

10 REPLIES 10
Read only

suresh_datti
Active Contributor
0 Likes
1,277

SELECT * from <DBTAB> into table ITAB.

~Suesh

Read only

Former Member
0 Likes
1,277

If they(internal table and the database table) have the same structure and you need more than one record then use the INTO TABLE option.

Read only

0 Likes
1,277

For the other commands you listed, you will have to loop (select ... endselect) and append which is inefficient.

Read only

Former Member
0 Likes
1,277

Most efficient (from a coding perspective) are move-corresponding for each row of the DB table into the itab

OR

tables: VBAK.

data: it_VBAK type table of VBAK with header line.

Select * from VBAK into table it_vbak.

The 2nd one is best !!

Read only

0 Likes
1,277

> Most efficient (from a coding perspective) are

> move-corresponding for each row of the DB table into

> the itab

>

> OR

>

> tables: VBAK.

> data: it_VBAK type table of VBAK with header line.

>

> Select * from VBAK into table it_vbak.

>

> The 2nd one is best !!

John, I have to disagree on this one because, move-corresponding adds additional burden on the performance as it has to now parse through the names and match them with that of the table. This adds additional time to the processing. If you know that the structure of the source and the target are the same, a direct move is always efficient. If you know that only some of the field names are common, then move-corresponding can be used. But even there if you do individual assignments, that will be much faster than move-corresponding. So if ITAB has FIELD1, FIELD2, FIELD3 and FIELD2 is common between ITAB and DBTAB, then doing ITAB-FIELD2 = DBTAB-FIELD2 is always efficient than MOVE-CORRESPONDING DBTAB TO ITAB.

Read only

0 Likes
1,277

I agree with Srinivas.. why DBTABs even in case of ITABs I would keep away from MOVE-CORRESPONDING.

~Suresh

Read only

0 Likes
1,277

Srini,

I stated "Most efficient (from a coding perspective)".

It is definitely slower from a PERFORMANCE perspective... but it is faster from a coding perspective b/c you only have to write statement instead of numerous MOVE statements.

Read only

0 Likes
1,277

Yes that is true, it will reduce the number of lines you may have to type in.

Read only

0 Likes
1,277

Srini,

If you are looking for "quick and dirty", it is the way to go. If you are looking the "best" code, it is not.

Read only

Former Member
0 Likes
1,278

hi vamshi,

if ur internal table fields are declared as they r in the table then

u can use <b>into table itab.</b>

if u give names like

material like mara-matnr..

into corresponding fields of table itab.

hope this helps,

do reward if it helps,

priya.