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

select... for all entries in...


Can anybody help me to sort out this issue. This select should work. I m filling an itab with distinct pernr. in temp it should give <b>all the records for which pernr should not be in itab.</b>

report ZTEST4.

data : begin of ITAB occurs 0,

PERNR like PA0001-PERNR,

ename like pa0001-ename,

end of ITAB.

data : temp like itab occurs 0 with header line.

clear : ITAB, TEMP.

refresh : ITAB,TEMP.

select distinct PERNR into table ITAB from PA0001 where PERNR le 10.

select PERNR ENAME into table TEMP from PA0001

for all entries in ITAB where pernr not in itab-pernr.

sort TEMP by PERNR.


Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Posted on Jan 22, 2005 at 07:56 AM

    Sample code from ABAP Key word documentation.

    SELECT * FROM sflight INTO wa_sflight 
        FOR ALL ENTRIES IN ftab 
        WHERE CARRID = ftab-carrid AND 
              CONNID = ftab-connid AND 
              fldate = '20010228'. 
      free = wa_sflight-seatsocc - wa_sflight-seatsmax. 
      WRITE: / wa_sflight-carrid, wa_sflight-connid, free. 



    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 22, 2005 at 10:50 AM


    Please be carefull with "for all entries in"

    Before you execute the select command you should make sure that the table ITAB is not empty.

    If the table is empty this will work as empty select-options - this means you will get all records from PA0001 but you probably want to select no records.

    Best regards

    Thomas Madsen Nielsen

    Add a comment
    10|10000 characters needed characters exceeded

    • Hello,

      One more point has to be kept in mind to get consistant records while using the 'for all enties' is that all the key fields are to be fetched from the table.

      I would prefer to read especially the SAP Online Doc everytime when I use the 'for all entries statement' as this has tricky variants.

      I hope this helps.

      Regards, Murugesh AS

  • author's profile photo Former Member
    Former Member
    Posted on Jan 26, 2005 at 10:46 AM

    Hi Sagar,

    If i understand it well, you exclude all PERNR LE 10.

    But first things first.

    You cannot use the FOR ALL ENTRIES in your case (it doesn't allow the operator "NOT IN").

    Your code should be:

    REPORT ztest4.

    TYPES: BEGIN OF ty_itab,

    pernr TYPE persno,

    ename TYPE emnam,

    END OF ty_itab.

    DATA : itab TYPE ty_itab occurs 0,

    wtab TYPE ty_itab.

    CLEAR: itab,


    SELECT pernr ename

    INTO TABLE itab

    FROM pa0001

    WHERE pernr LE 10

    ORDER BY pernr.

    IF sy-subrc EQ 0.





    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.