‎2006 Aug 15 5:55 AM
‎2006 Aug 15 6:00 AM
‎2006 Aug 15 6:07 AM
select single as the name implies gets a single record based on some condition while select up to 1 rows is the same except that for example, you can get the latest value by adding the statement ORDER BY in you select statement. Here is an example:
***SELECT SINGLE
SELECT single bukrs anln1 gjahr
afabe knafa kansw
answl kaafa nafal
aafav aafag nafap
aafap nafav nafag
FROM anlc INTO (it_anlc-bukrs, it_anlc-anln1, it_anlc-gjahr,
it_anlc-afabe, it_anlc-knafa, it_anlc-kansw,
it_anlc-answl, it_anlc-kaafa, it_anlc-nafal,
it_anlc-aafav, it_anlc-aafag, it_anlc-nafap,
it_anlc-aafap, it_anlc-nafav, it_anlc-nafag)
WHERE anln1 EQ it_anla-anln1
AND anln2 EQ it_anla-anln2
AND bukrs IN r_iwerk
AND afabe EQ '01'.
***SELECT UP TO 1 ROWS
SELECT bukrs anln1 gjahr
afabe knafa kansw
answl kaafa nafal
aafav aafag nafap
aafap nafav nafag
FROM anlc UP TO 1 ROWS
INTO (it_anlc-bukrs, it_anlc-anln1, it_anlc-gjahr,
it_anlc-afabe, it_anlc-knafa, it_anlc-kansw,
it_anlc-answl, it_anlc-kaafa, it_anlc-nafal,
it_anlc-aafav, it_anlc-aafag, it_anlc-nafap,
it_anlc-aafap, it_anlc-nafav, it_anlc-nafag)
WHERE anln1 EQ it_anla-anln1
AND anln2 EQ it_anla-anln2
AND bukrs IN r_iwerk
AND afabe EQ '01'
ORDER BY gjahr DESCENDING.
ENDSELECT.
In the example, select single will get the record that matches your condition unlike in select up to 1 rows it will get the latest record since I am ordering it by GJAHR(Fiscal year) in descending order.
Hope this helps...
P.S. Please award points for useful answers.
‎2006 Aug 15 6:10 AM
Select Single -> You need to specify all the key fields
Select upto 1 rows - > Keys fields are not required.
Select Single is not a loop.
Select Upto 1 rows is a Loop. So you have to specify SELECT & ENDSELECT.
Cheers
VJ
‎2006 Aug 15 6:13 AM
have a look at the below link..
Cheers,
Abdul Hakim
Mark all useful answers...