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: 

what is the Fuctionality of Select ....End Select

Former Member
0 Kudos

Hi all

Can Anybody tell me the exact functionality of the the <b>Select ..... End Select</b> and the alternative of this statement with some example breifly...

thanks in Advance

1 ACCEPTED SOLUTION

Former Member
0 Kudos

SELECT <f1> <f2>.... INTO CORREPSONDING FIELDS OF itab FROM <TAB>
WHERE <COND>.
"do some data manipulations before loading into itab.
APPEND itab.
ENDSELECT.

"alternative
SELECT <f1> <f2>.... INTO CORREPSONDING FIELDS OF TABLE itab FROM <TAB>
WHERE <COND>.
LOOP AT itab.
"do some data manipulations before loading into itab.
ENDLOOP.

"Second method is good performance wise..

5 REPLIES 5

Former Member
0 Kudos

Hi

IT ACTS LIKE AN LOOP STATMENT IN THE ABAP

1. Avoid nested selects

SELECT * FROM EKKO INTO EKKO_WA.

SELECT * FROM EKAN INTO EKAN_WA

WHERE EBELN = EKKO_WA-EBELN.

ENDSELECT.

ENDSELECT.

The above code can be much more optimized by the code written below.

SELECT PF1 PF2 FF3 FF4 INTO TABLE ITAB

FROM EKKO AS P INNER JOIN EKAN AS F

ON PEBELN = FEBELN.

Note: A simple SELECT loop is a single database access whose result is passed to the ABAP program line by line. Nested SELECT loops mean that the number of accesses in the inner loop is multiplied by the number of accesses in the outer loop. One should therefore use nested SELECT loops only if the selection in the outer loop contains very few lines or the outer loop is a SELECT SINGLE statement.

0 Kudos

Hi Naresh

will this effect the performance of the Program, and is there any alternative for this to fetch the data.

i am very much confused abt why it was used.

LOOP AT t_prd_data INTO wa_prd_data.

SELECT aaplzl bvgw03 bvge03 bbmsch

INTO (wa_plpo-aplzl, wa_plpo-vgw03, wa_plpo-vge03, wa_plpo-bmsch)

FROM afvc AS a INNER JOIN afvv AS b ON baufpl = aaufpl AND

baplzl = aaplzl

WHERE a~aufpl = wa_prd_data-aufpl AND

a~vornr = wa_prd_data-vornr.

IF sy-subrc EQ 0.

wa_plpo-aufnr = wa_prd_data-aufnr.

COLLECT wa_plpo INTO t_plpo.

ENDIF.

ENDSELECT.

ENDLOOP.

Message was edited by:

ABAPER1234

Former Member
0 Kudos

SELECT <f1> <f2>.... INTO CORREPSONDING FIELDS OF itab FROM <TAB>
WHERE <COND>.
"do some data manipulations before loading into itab.
APPEND itab.
ENDSELECT.

"alternative
SELECT <f1> <f2>.... INTO CORREPSONDING FIELDS OF TABLE itab FROM <TAB>
WHERE <COND>.
LOOP AT itab.
"do some data manipulations before loading into itab.
ENDLOOP.

"Second method is good performance wise..

Former Member
0 Kudos

hi,

Select end select has to be used when primary key is not provided in the where condition.

The last record corresponding to the condition given in where clause will be put in the work area.

Eg.

select MATNR form vbap

into lv_matnr

where vbeln = '00000000001'.

endselect.

if there are 2 items for order '00000000001' then 2 records are available for selection, then the second record's matnr will be put in lv_matnr.

This can be overcome in 2 ways.

1.By using the complete primary key

select single MATNR form vbap

into lv_matnr

where vbeln = '00000000001'

and posnr = '00100'.

2. select matnr

from vbap

into lv_matnr

up to 1 rows.

here the first record available will be selected.

Thanks,

Kasiraman R

endselect.

Former Member
0 Kudos

hi,

1)

types: itab1 like standard table of vbak non-....

" table with out header line

data: wa1 like vbak.

" explicit work area

select * from vbak into wa1 where....................

append wa1 to itab1.

endselect.

2)

types: itab1 like standard table of vbak non-....

" table with out header line

data: wa1 like vbak.

" explicit work area

2.a.

select * from vbak into table itab1 where....................

2.b

select single * from vbak into wa1 where...................

In general we avoid select .. endselect to increase performance

select into table is efficient.

regards,

Subbu