Hi,
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.
break-point.
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. ENDSELECT.
Regards
Raja
Hello
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
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,
wtab.
SELECT pernr ename
INTO TABLE itab
FROM pa0001
WHERE pernr LE 10
ORDER BY pernr.
IF sy-subrc EQ 0.
DELETE ADJACENT DUPLICATES FROM itab COMPARING pernr.
ENDIF.
Regards,
Rob.
Add a comment