10-31-2007 12:45 PM
Hi all,
I use the following statement to select all records from table equi that also exist in itab lt_temp:
SELECT mandt equnr
FROM equi
INTO CORRESPONDING FIELDS OF TABLE lt_equi_temp
FOR ALL ENTRIES IN lt_temp
WHERE equnr EQ lt_temp-equnr
AND equnr LIKE 'C%'.
Problem is I want the records in equi that do not exist in itab lt_temp. I tried changing the 'EQ' to 'NE' in the where clause but that query never comes back.
thanks in advance,
10-31-2007 12:50 PM
try this....
SELECT mandt equnr
FROM equi
INTO CORRESPONDING FIELDS OF TABLE lt_equi_temp
where equnr LIKE 'C%'.
if sy-subrc = 0.
loop at lt_equi_temp.
read table lt_temp with key equnr = lt_equi_temp-equnr.
if sy-subrc = 0.
delete lt_equi_temp index sy-tabix.
endif.
endloop.
endif.
Regards
vasu
10-31-2007 12:54 PM
HI MAthew,
SELECT mandt equnr
FROM equi
INTO CORRESPONDING FIELDS OF TABLE lt_equi_temp
where equnr LIKE 'C%'.
if sy-subrc = 0.
loop at lt_temp.
read table lt_equi_temp with key equnr = lt_temp-equnr.
if sy-subrc = 0.
delete lt_equi_temp index sy-tabix.
endif.
endloop.
endif.
never loop at an internal table and perform a delete operation on the same internal table.
It may lead to severe problems.
10-31-2007 12:56 PM
hi Mathew,
move the entries from lt_temp to a range the following way:
sign = I
option = NE
low = ...
and now select :
SELECT mandt equnr
FROM equi
INTO CORRESPONDING FIELDS OF TABLE lt_equi_temp
WHERE equnr IN lt_temp-equnr
for the range you can do as well:
sign = E
option = EQ
hope this helps
ec
10-31-2007 1:06 PM
Hi,
Do as below :
ranges : gr_equnr for equi-equnr.
loop at lt_temp.
gr_equnr-sign = 'I'.
gr_equnr-option = 'EQ'.
gr_equnr-low = lt_temp-equnr.
gr_equnr-high = lt_temp-equnr.
append gr_equnr.
endloop.
SELECT mandt equnr
FROM equi
INTO CORRESPONDING FIELDS OF TABLE lt_equi_temp
WHERE equnr not in gr_equnr
or equnr LIKE 'C%'.
Thanks,
Sriram Ponna.