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

here iam using for-all-entries.

Hi...

2....here iam using for-all-entries.

if the internal table is empty.then what will happen for next select statement.

thanks and regards,

k.swaminath

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

10 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Sep 19, 2007 at 07:18 AM

    Hi swaminath

    you won't get any data from select statement.

    Regards

    Wiboon

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 19, 2007 at 07:18 AM

    hi,

    for next select statement it will ignore where condition and take all records from table..

    raj

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 19, 2007 at 07:27 AM

    Hi swaminath,

    It is never advisable to use a select with 'for all entries' direclty after a select

    statement, bcoz it will fetch all the existing values in the database table.

    So to avoid this we chech the sy-subrc first...

    Find the example below explaining the same...

    select * into itab1 from LFA1 where lifnr IN p_lifnr.

    If sy-subrc = 0.

    select * from LFBK into itab2 for all entries in itab1

    where lifnr = itab1-lifnr.

    endselect.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 19, 2007 at 08:11 AM

    You should first check the internal table you were using in the for all entries statement. So if the table has no data the next select statement will not be executed.

    Example:

    Select bukrs

    belnr

    wrbtr

    dmbtr

    from bkpf

    into table i_bkpf

    where bukrs = p_bukrs.

    if i_bkpf[] is not initial.

    Select bukrs

    belnr

    augdt

    from bseg

    into table i_bseg

    for all entries in i_bkpf

    where bukrs = i_bkpf-bukrs

    and belnr = i_bkpf-belnr.

    endif.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 19, 2007 at 08:26 AM

    If <itab> is empty, the addition FOR ALL ENTRIES is disregarded, and all entries are read.

    Please reward is useful...

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 19, 2007 at 08:26 AM

    Hi Swaminath,

    In case of for all entries, If the first internal table is null. then the second internal table will retrieve all the records of the database. But it shouldnÂ’t be happen. Hence if we use for all entries, after writing the first select statement we have to verify whether the first internal table is null or not. If the first internal table is not null then only we have to retrieve records from the database table for the second internal table.

    Hope this will help.

    Regards,

    Thasneem.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 19, 2007 at 08:32 AM

    Hi

    if you write like this

    <b>select data from table into itab where condituioj

    select data from table into itab1 for all entries in itab where condition</b>

    with out checking the weather the above select statement have data or not then it will give all the data which eist in that table

    <b>select data from table into itab where condituioj

    if not itab[] is initial

    select data from table into itab1 for all entries in itab where condition

    endif.</b>

    in this sitvation you don't get any data

    reward if usefull

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Sep 19, 2007 at 08:33 AM

    hi

    in for allentries you have to use

    if itab[] is not initial " statement

    if u have not used above statement if there is no data in first itab

    then where condition for second itab gets failed and select statement fetches

    all data from data base

    it decreases performance of a report

    reward for use ful points

    regards

    Nagesh.Paruchuri

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 19, 2007 at 08:35 AM

    will ignore where condition and take all records.

    always use : if not i_abc[] is initial.

    select..

    for all entries in i_abc

    endif.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 19, 2007 at 08:35 AM

    Hi Swaminath,

    First while using FOR ALL ENTRIES , it is mandatory to check whether the internal table is empty or not. So if the condition fials, it wont go to the subsequent SELECT stmt. at all. It skips the if part and goes to the ELSE part of the IF...ELSE..ENDIF stmt.

    Hope this resolves your query.

    Reward all the helpful answers.

    Regards

    NAGARAJ

    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.