SAP WHERE LOGEXP ALL ANY SOME
Get Example source ABAP code based on a different SAP table
ARTICLE
• ALL WHERE - subquery
• ANY WHERE - subquery
• SOME WHERE - subquery
Syntax
Effect
These expressions can be formed with a scalar
Single-Line Result Set
If the result set of the subquery contains only one line, the comparison can be carried out without the specification of
Example
Reading the flight with the most passengers: DATA wa_sflight TYPE sflight.
SELECT *
FROM sflight
INTO wa_sflight
WHERE seatsocc = ( SELECT MAX( seatsocc )
FROM sflight ).
ENDSELECT.
Multiple Line Result Set
If the result set of the subsquery contains more than one line,
Note
The relational operator (
Example
Reading the customer number of the customer or customers who have made the most bookings: DATA: id TYPE sbook-customid,
cnt TYPE i.
SELECT customid COUNT( * )
FROM sbook
INTO (id, cnt)
GROUP BY customid
HAVING COUNT( * ) >= ALL ( SELECT COUNT( * )
FROM sbook
GROUP BY customid ).
ENDSELECT.