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

select query 'for all entries'

Hello Friends,

SELECT emp_id emp_name

INTO corresponding fields of table itab_emp

FROM employee

for all entries in itab_dept

WHERE emp_id = itab_dept_emp_id.

In the above select query we are using 'for all entries' for the internal table itab_dept.What will happen if the join fails?Will we get any data in the output table?

What is the prerequisites for using 'for all entries'.

Please advice me on this.

Regards

Ashish.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Posted on Dec 18, 2007 at 07:13 AM

    Hi,

    Interanl table should not be initial on which ur applying FOR ALL ENTRIES. Check if its not initial before select statement.

    if not itab_dept[] is intital.

    SELECT emp_id emp_name

    INTO corresponding fields of table itab_emp

    FROM employee

    for all entries in itab_dept

    WHERE emp_id = itab_dept_emp_id.

    endif.

    Regards,

    Prashant

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 28, 2008 at 12:26 PM

    Hi

    In this case all the records available in employee table are extracted into internal table itab_emp.

    It is safe to check whether itab_dept is initial or not.

    If it is initial then stop the select query.

    Check the following program u will get an idea.

    Also try this program by removing comment to 'REFRESH IT_LFA1'.

    REPORT ZBM_PG .

    TABLES: LFA1, EKKO.

    DATA:

    • IT_LFA1 TYPE TABLE OF LFA1 WITH NON-UNIQUE DEFAULT KEY INITIAL SIZE 10,

    IT_LFA1 TYPE TABLE OF LFA1 WITH HEADER LINE,

    IT_EKKO TYPE TABLE OF EKKO WITH HEADER LINE.

    • SELECT * FROM LFA1 INTO TABLE IT_LFA1 WHERE LIFNR EQ '0000001000' OR LIFNR EQ '0000001500'.

    SELECT * FROM LFA1 INTO TABLE IT_LFA1 UP TO 1 ROWS.

    • refresh it_lfa1.

    SELECT * FROM EKKO INTO TABLE IT_EKKO FOR ALL ENTRIES IN IT_LFA1 WHERE LIFNR = IT_LFA1-LIFNR.

    LOOP AT IT_EKKO.

    WRITE: / IT_EKKO-LIFNR, IT_EKKO-EBELN.

    ENDLOOP.

    Reward me if it is useful

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 28, 2008 at 12:30 PM

    Hi,

    Do an INITIAL check before you use the internal table through this syntax for a select query. Otherwise all the entries will be fetched which satisfies the criteria in where clause if any.

    Use this

    CHECK NOT I_TAB IS INITIAL.

    <Select with all entries>.

    Regards,

    Mayank.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 28, 2008 at 12:31 PM

    in your code if u will use "for all entries" with out using "not initial" then if join will fail you table will be populated by all the entries that is it will pick up all the records from dbtable which is absolutely wrong.

    reward if useful plz

    keep rockin

    vivek

    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.