‎2006 Aug 10 7:02 PM
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?
‎2006 Aug 10 7:05 PM
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.
‎2006 Aug 10 7:03 PM
‎2006 Aug 10 7:04 PM
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.
‎2006 Aug 10 7:05 PM
For the other commands you listed, you will have to loop (select ... endselect) and append which is inefficient.
‎2006 Aug 10 7:05 PM
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 !!
‎2006 Aug 10 7:10 PM
> 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.
‎2006 Aug 10 7:13 PM
I agree with Srinivas.. why DBTABs even in case of ITABs I would keep away from MOVE-CORRESPONDING.
~Suresh
‎2006 Aug 10 7:13 PM
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.
‎2006 Aug 10 7:17 PM
Yes that is true, it will reduce the number of lines you may have to type in.
‎2006 Aug 10 7:28 PM
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.
‎2006 Aug 10 7:05 PM
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.