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

Regarding Insert command

Former Member
0 Likes
835

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.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
816

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

7 REPLIES 7
Read only

Former Member
0 Likes
816

Hello Ambi,

Can you please close you all old threads and reward points accordingly.

regards

....................

Message was edited by: Surpreet Singh Bal

Read only

Former Member
0 Likes
817

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

Read only

Former Member
0 Likes
816

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

Read only

Former Member
0 Likes
816

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

Read only

0 Likes
816

hey guys,

why i could not see points ooption button displaying at left side of post?

looks strange..

is something prob with portal?..

ambichan

Read only

0 Likes
816

yes i am also facing same problem

regards

Read only

Former Member
0 Likes
816

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.