2007 Aug 13 3:38 AM
Hi everyone!
The FOR ALL ENTRIES keyword gets the entries in a db table equal to the entries in an internal table right?
What is the inverse of that (meaning excluding the entries in an internal table)?
Thanks!
2007 Aug 13 3:43 AM
When you use FOR ALL ENTRIES there must be atleast one equality in the select statement to that of the FOR ALL ENTRIES internal table field.
This is what i meant -
You can use NE when you are using FOR ALL ENTRIES, but its always good to use +ve checks like = or IN where ever possible than NOT IN and <>.
select <data> from <table>
into table <itab2>
for all entries in <itab1>
where <field> NE itab1-<field>.
Rather you can also use the way below, but is always a performance issue and is not suggested always in cases like large data.
loop at itab.
select <data> from <table> into <itab2> where <field> <b>NE</b> itab-<field>.
clear : itab.
endloop.
Regards
Gopi
2016 Jul 22 7:35 AM
2007 Aug 13 3:44 AM
hi richard,
i guess there is no direct opposite. either u have to use ur own logic or if entries are fewer u can use NOT IN {.....}.
regards,
sap fan
2007 Aug 13 3:57 AM
You can write other way :
Let me say one example :
i want to get material number as well Material description.
Material number at MARA Table,Material description at MAKT Table
you have two options like Join or for all entries.now i am not following join as well for all entries method.
data : begin of i_mara occurs 0,
matnr like mara-matnr,
end of i_mara.
final internal table
data : begin of i_final occurs 0,
matnr like mara-matnr,
maktx like makt-maktx,
end of i_final.
start-of-selection.
select * from mara into table i_mara.
loop at i_mara.
select single maktx from makt into makt-maktx
where matnr = i_mara-matnr
and spras = 'E'.
if sy-subrc eq 0.
i_final-matnr = i_mara-matnr.
i_final-maktx = i_makt-maktx.
append i_final.
endif.
endloop
check the above code ,i simply written select single *
but always use for all entries ,
Thanks
Seshu
2007 Aug 13 4:52 AM
I think the simplest solution is to create a range for the field that you base your exclude on.
For example, say you want to select from MARA, but exclude a few items, which are in local table lt_exclude.
DATA: LT_EXCLUDE TYPE STANDARD TABLE OF MARA,
WA_EXCLUDE TYPE MARA,
LT_MARA TYPE STANDARD TABLE OF MARA..
RANGES LR_MATNR FOR MARA-MATNR.
" BUILDING THE RANGE
LOOP AT LT_EXCLUDE INTO WA_EXCLUDE.
LR_MATNR-SIGN = 'I'.
LR_MATNR-OPTION = 'EQ'.
LR_MATNR-LOW = WA_EXCLUDE-MATNR.
LR_MATNR-HIGH = ' '.
APPEND LR_MATNR.
ENDLOOP.
" THE SELECT QUERY ITSELF
SELECT * FROM MARA INTO LR_MARA
WHERE MATNR NOT IN LR_EXCLUDE.
Hope this helps.
2007 Aug 13 5:03 AM
Hi,
Ranges have limitation of no of records. please check note 635318.
aRs
2007 Aug 13 5:06 AM
Hi,
You can make use of ranges to achieve that as follows.Kindly reward points by clicking the star on the left of reply,if it helps.
tables mara.
select-options s_matnr for mara-matnr.
ranges r_matnr for mara-matnr.
data : itab type standard table of mara,
wa type mara,
itab1 type standard table of makt,
wa1 type makt.
select * from mara into table itab where matnr in s_matnr.
if sy-subrc eq 0.
loop at itab into wa.
r_matnr-low = wa-matnr.
r_matnr-sign = 'I'.
r_matnr-option = 'EQ'.
append r_matnr.
endloop.
endif.
select * from makt into table itab1 where matnr not in r_matnr.
loop at itab1 into wa1.
write : / wa1-matnr.
endloop.
2007 Aug 13 10:56 AM
hi! Ricardo Caliolio
Can use
SELECT <data>FROM <table> INTO TABLE <itab2> FOR ALL ENTRIES IN
<itab1>
WHERE NE <itab1>
but Performance wise its not advisable.
Regards,
Nagulan.