‎2005 Aug 31 5:17 AM
Dear guys,
I have internaltable with 10 fields with different data types. and i have addontable with 8 fields(with differnt data type)
Now i want to insert records from internal table to addontable.which will be the best way.
I have done as below..pls confirm this is best way or not.
<b>Created internal table xtab same as addontable 8 fields.</b>
loop at mytab into ltab.
move-corresponding ltab into xtab.
append xtab.
endloop.
<b>now insert internal table valus to addontable.</b>
loop at xtab into ytab.
insert table zlottab values ytab.
endloop.
and
Commit work.
is there any alternative way or any wrong in my code..
ambichan.
‎2005 Aug 31 5:21 AM
loop at mytab into ltab.
move-corresponding ltab into xtab.
*check the data are transferring correctly..else move field by field..
append xtab.
endloop.
insert table zlottab from table xtab.
commit work.
regds
gv
Message was edited by: Venkat
‎2005 Aug 31 5:20 AM
Hello Ambi,
Can you please close you all old threads and reward points accordingly.
regards
....................
Message was edited by: Surpreet Singh Bal
‎2005 Aug 31 5:21 AM
loop at mytab into ltab.
move-corresponding ltab into xtab.
*check the data are transferring correctly..else move field by field..
append xtab.
endloop.
insert table zlottab from table xtab.
commit work.
regds
gv
Message was edited by: Venkat
‎2005 Aug 31 5:27 AM
one thing you can take care while inserting is that whether data already exist and still you want to overwrite it then use update. else insert it.
for this you can use 'popup_to_confirm' FM.
regards
‎2005 Aug 31 5:29 AM
yeah, I agree with venkat
'INSERT dbtab FROM TABLE itab'
this is better in performance, as its select statements runned by DB is less than insert every entry one by one.
Thanks
‎2005 Aug 31 5:33 AM
hey guys,
why i could not see points ooption button displaying at left side of post?
looks strange..
is something prob with portal?..
ambichan
‎2005 Aug 31 5:35 AM
‎2005 Aug 31 5:32 AM
Instead of this loop at, if the table mytab and xtab are of the same structrue,
loop at mytab into ltab.
move-corresponding ltab into xtab.
append xtab.
endloop.
Can do as below mytab[] = xtab[].
INSERT zlottab FROM TABLE xtab.
This two line code is enough if all r of teh same structure.
Or
mytab[] = xtab[].
LOOP AT xtab into ytab.
INSERT INTO zlottab VALUES ytab.
CLEAR ytab.
ENDLOOP.Hope this helps.
Kindly reward points and close the thread.