Application Development 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: 

diff b/w select endselect and select into table............

Former Member
0 Kudos

what is the difference b/w

Select

Endselect

and select into table....

Akshitha..

7 REPLIES 7

Former Member
0 Kudos

hi..

<b>Select ..Endselect </b>is used depending upon the requirement.

If u want to check each data in the table . then use it.

generally it is not used. it increases the execution time.

In place of sel endsel populate whole data in to internal table directly. It work as a loop.

SELECT * FROM mara table INTO iab

WHERE matnr in s_matnr.

ENDSELECT.

select into table:

if u waant to place the selected data into a table u can use this statement..

for ex:

select * from mara into table itab where <condition>

Thanks

Ashu

Former Member
0 Kudos

Hi,

Select...Endselect is basically just like a loop in which it goes to the database again and again and each time fetches one record.

Whereas Select into table brings all the data at one shot into the Internal table.

Select...Endselect isgenerally used when we want to place some checks on each record or we wanna do some sort of modifiacations to the data.

Regards,

Himanshu

Former Member
0 Kudos

Hi,

When ever u want to append data into the workarea then use select ... endselect. When u r appending data into the internal table then use select. Also when u use select single then also use only select.

Eg: Using only Select

data : begin of itab occurs 0,

lifnr like lfa1-lifnr,

end of itab.

select single lifnr from lfa1 into itab.

data itab like lfa1 occurs 0 with header line.

select * from lfa1 into table itab.

Eg: Using Select .. endselect.

data : itab like lfa1 occurs 0,

wa like lfa1.

select * from lfa1 into wa.

append wa to itab.

endselect.

Regards

Former Member
0 Kudos

Hi,

SELECT...ENDSELECT acts just like a loop where some fields are selected repeatedly and then passed to an in internal table.The select query is executed everytime as long as there are values satisfying the where condition.

This is not a good practice as is degrades performance by increasing the database fetches.

SELECT <colnames> from KNA1 INTO KNA1_WA.

APPEND KNA1_WA to T_KNA1.

ENDSELECT.

SELECT INTO TABLE is a direct SELECT where all the values are fetched at one time depending on the where condition and put in an internal table.There is no looping in this and so the performance is better.

SELECT <colnames> FROM KNA1 INTO TABLE T_KNA1.

Hope it will be useful.

Thanks,

Sandeep.

Former Member
0 Kudos

HI,

SELECT - END SELECT IS USED TO GET DATA ONE BY ONE FROM DATA BASE TABLE TO WORK AREA

SELECT -INTO TABLE IT WILL RETURN ALL THE DATA FROM DATA BASE TABLE TO SOME INTERNAL TABLE AT A TIME.

THANK YOU

ASHOK KUMAR

Former Member
0 Kudos

Hello Akshitha,

In select endselect the data is selected in such a way that the database will be hit each time for every value which satisfies the condition specified in the select query.

This will increase the process time and incase of huge data sometimes will result in dump. Whereas select into table will select all the data at shot which satisfies the conditions and store in the internal table. Database will be hit only once.

Also note that incase of select endselect if debug by pressing F5 it will result in dump.

Reward if found useful.

Thanks & regards

Prakash Ghantasala

Former Member
0 Kudos

*Select directly into an internal table

SELECT bukrs belnr gjahr buzei mwskz umsks prctr hkont xauto koart
       dmbtr mwart hwbas aufnr projk shkzg kokrs
  FROM bseg
  INTO TABLE it_bseg.

*Select... endselect command

SELECT bukrs belnr gjahr buzei mwskz umsks prctr hkont xauto koart
       dmbtr mwart hwbas aufnr projk shkzg kokrs
  FROM bseg
  INTO wa_bseg.

  APPEND wa_bseg TO it_bseg.
ENDSELECT.

Girish