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

question about select query.

Former Member
0 Likes
543

Hi,

i want to insert the result of query to a table,

all the fields are corresponding except one field.

is there a way to this or i need to do

insert ( f1 , f2 ....)

----


i did this way

INTO CORRESPONDING FIELDS OF TABLE It_Return_Date

but i have another field which i want to insert to table.

is it possible??

10X

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
508

yo may do that way.

Select f1 ft f3 f4 from TABLE_NAME into table it_table.

Bu order of the fields in your it_table declatation must match order of the fields in select query.

BR< JAcek

6 REPLIES 6
Read only

suresh_datti
Active Contributor
0 Likes
508

if the field names are not the same, you will have to use like you said/ >> i need to do

insert ( f1 , f2 ....)

~Suresh

Read only

Former Member
0 Likes
509

yo may do that way.

Select f1 ft f3 f4 from TABLE_NAME into table it_table.

Bu order of the fields in your it_table declatation must match order of the fields in select query.

BR< JAcek

Read only

0 Likes
508

Hi,

You need to use the SELECT field1 field2...fieldn

INTO inttab

FROM table1.

make sure that the fields in the internal table are in the same order as you have defined in your select query

regards,

sangram

Read only

0 Likes
508

Thank you very much to all about the quick answering.

Read only

Laxmana_Appana_
Active Contributor
0 Likes
508

Hi,

Check this :

select fld1 fld2 fld3 
       from ztable into table i_tab.

suppose your table contains one more field fld4, you want update that field with internal table i_tab,

then do like this :

loop at i_tab.
 i_tab-fld4 = <value>
modify i_tab.
endloop.


insert ztable from table i_tab.

Regards

Appana

Read only

Former Member
0 Likes
508

lets say you are getting values from a table

select & into X_TAB1 from TAB1.

data : x_tab2 type table2.

x_tab2-newfield = 'new value'. "Populate that new field value

move corresponding X_TAB1 TO X_TAB2. "all other will copy here

then use X_TAB2 to insert to your TABLE2.

INSERT TABLE2 FROM X_TAB2.

it would be a good practice to use same structure of the table while you use Insert/modify etc.. commands.

else you can declare TABLES ZTABLE2.

MOVE CORRESPONDING ZTABLE1 TO ZTABLE2.
ZTABLE2-NEW_FIELD = <NEW VALUE>.
then use INSERT.
INSERT ZTABLE2.

Regards

srikanth

Message was edited by: Srikanth Kidambi