Skip to Content
author's profile photo Former Member
Former Member

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

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Dec 04, 2007 at 12:42 PM
    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..
    
    
    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 04, 2007 at 12:38 PM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      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

  • author's profile photo Former Member
    Former Member
    Posted on Dec 04, 2007 at 12:44 PM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 04, 2007 at 12:44 PM

    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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.