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

in select statement

Former Member
0 Likes
1,278

whats the difference between

select * from mara into table it , and select * from mara into corresponding fields of table it.

13 REPLIES 13
Read only

Former Member
0 Likes
1,249

Hi Anjali,

consider the following example

data:

begin of fs_spfli,

carrid type spfli-carrid,

connid type spfli-connid,

cityfrom type spfli-cityfrom,

end of fs_spfli.

data:

t_spfli like standard table of fs_spfli.

select *

from spfli

into table t_spfli.

the above select query goes for a dump as the fields we are retrieving are not in the same order as in spfli.

so in this case we have to use

select *

from spfli

into corresponding fields of table t_spfli.

Read only

Former Member
0 Likes
1,249

Hi,

In select * from mara into table it -> here the structure of table it should be the same like mara.

Select * from mara into corresponding fields of table it -> here structure of it may not be the same...but it will transfer the data for which the fields are same.

Reward with points if satisfied with anser

Regards,

Krishna K.

Read only

Former Member
0 Likes
1,249

Hi Geethat,

For the first will be used only your internal table IT and Mara structure are identital, But other one is if some fields are missing in your Internal table then it will be used.

I hope you understand more clearly.

Warm Regards,

Vijay

Read only

Former Member
0 Likes
1,249

Hi

In the first case Internal tables was declared like

Data:

itab like MARA occurs 0 with header line.

so all data from tables dumped into itab

in the second case

it is declared with some/few fields so only few fields data comes into itab

so it makes the difference

reward points if useful

regards,

Anji

Read only

Former Member
0 Likes
1,249

hi,

for better performance dont use into corresponding field . have your internal table in the same format as you select from the database.

In into corresponding field while storing data the program matches each and every field's datatype before transferring data to internal table. this will hit the performance of the program.

hope it solves your query.

regards,

Navneeth.K

Read only

Former Member
0 Likes
1,249

Hi,

Select * from mara table itab----


><b>when itab has the same structure and same field names of mara</b>

select * from mara into corresponding fields of table itab----


> <b>when itab containes only some fields of mara with the same field names like mara, then based on field names data will be appended</b>.

Regards,

Read only

Former Member
0 Likes
1,249

Hi,

We use INTO CORRESPONDING FIELDS INTO TABLE

to populate the selected data into the fields with similar name that is there in the actual table structure. If the order of the fields in the table structure and the order u r selecting in a select statement is different and if u r not using corresponding fields, uwill get runtime error. If u use INTO CORRESPONDING FIELDS OF TABLE it will not trigger runtime error . it just copies the data into internal table by comparing the names of the fields.

If u u INTO TABLE if there is any mismatch in data types it generates an error.

reward points if helpful.

regards,

kiran kumar k

Read only

Former Member
0 Likes
1,249

Hi,

If you are using Select * from MARA into IT, you internal table structure should be the same as that of table MARA, in the same order.

If you need only certain fields of MARA in your internal table, then use the same field name in your internal table structure, can be of different order, then use Select * from MARA into corresponding fields of table IT.

Regards,

Sharmila

Read only

Former Member
0 Likes
1,249

Hi Geetha,

Into table means that u r taking all the fieldvalues of the DB table into ur internal table in the same order.

Means the order of the fields are same in DB and Internal table.

Whereas <b>into corresponding fields</b> searches for a particular field in the internal table and then fetches the values in the internal table.

Thanks,

Shreya

Read only

Former Member
0 Likes
1,249

Hi Geetha,

If structure of the mara and your internal table are different use CORRESPONDING FIELDS

But it takes huge time for execution.

<b>If it inevitable then only use this option,it takes more time for execution bcz before pushing the record into intenal table it checks field by field.That for every record we have to do this activity.</b>

It is better to use the First query itself........

<b>

Reward all helpful answers</b><b>

Hope your problem is solved</b>

Regards,

V.Raghavender.

Read only

Former Member
0 Likes
1,249

hi,

select * from mara into table it.

means table it has same structure as mara and the all records with all fields from mara is moves to table it.

select * from mara into corresponding fields of table it.

means table it has some structure with some fields of mara and the all records with common fields from mara is moves to table it.

regards,

ananth

Read only

Former Member
0 Likes
1,249

Hi,

"INTO CORRESPONDING FIELDS OF TABLE" is transferring the value from select clause to itab where the field names are same.

suppose you have

data : begin of itab occurs 0,

matnr like mara-matnr,

menge like mseg-menge,

lgort like mard-lgort,

end of itab.

select matnr lgort into table from mard where....

it may give an error because you are not filling menge here or it may fetch the value in matnr and menge field.

but if you use INTO CORRESPONDING FIELDS OF TABLE then it will fetch the data to matnr and lgort field only.

INTO CORRESPONDING FIELDS OF TABLE is only matching by name not by datatype be careful.

Reward points if found helpful.

Regards,

Varun.

Read only

Former Member
0 Likes
1,249

Hello ,

INTO corresponding is not advisable from Performance point of view....

You use this when fields for selection are not in order with the internal table fields...

so system has to match the fields (selected) with the corresponding fields in the table...

If u are having proper order...use into table... this is more suitable...

Praveen .