‎2008 Feb 28 3:18 AM
Hi folks!!
I have a few doubts about the select statements, it may be a silly things but its useful for me.
what is difference between below statment.
1)SELECT * FROM TABLE.
2)SELECT SINGLE * FROM TABLE
3)SELECT SINGLE FROM TABLE.
Hope i will get answer,thanks in advance.
Regards
Richie..
‎2008 Feb 28 3:21 AM
Considering there are no syntax errors and to keep it simple:
1)SELECT * FROM TABLE.
"---> Selects all records that meets selection criteria
2)SELECT SINGLE * FROM TABLE
"---> Selects first record that meets the criteria
3)SELECT SINGLE FROM TABLE.
"---> Select value from specified fields from the first record that meets the criteria.
‎2008 Feb 28 3:21 AM
Hi Richie,
1 - You are selecting all the fields, and this is generally used to select the data into internal table
2 - You are selecting all the fields but only one record
3 SELECT SINGLE <field name/s> No of fields based on given parameter.
Regards,
Atish
‎2008 Feb 28 3:25 AM
Hi,
try this and if possible use sap help.i mean place the cursor on select and press F1.
Types of select statements:
1. select * from ztxlfa1 into table it.
This is simple select statement to fetch all the data of db table into internal table it.
2. select * from ztxlfa1 into table it where lifnr between 'V2' and 'V5'.
Thisis using where condition between v2 and v5.
4. select * from ztxlfa1 where land1 = 'DE'. "row goes into default table work Area
5. select lifnr land1 from ztxlfa1
into corresponding fields of it "notice 'table' is omitted
where land1 = 'DE'.
append it.
endselect.
Now data will go into work area. and then u will add it to internal table by
append statement.
6. Table 13.2 contains a list of the various forms of select as it is used with internal tables and their relative efficiency. They are in descending order of most-to-least efficient.
Table 13.2 Various Forms of SELECT when Filling an Internal Table
Statement(s) Writes To
select into table it Body
select into corresponding fields of table it Body
select into it Header line
select into corresponding fields of it Header line
7. SELECT VBRK~VBELN
VBRK~VKORG
VBRK~FKDAT
VBRK~NETWR
VBRK~WAERK
TVKOT~VTEXT
T001~BUKRS
T001~BUTXT
INTO CORRESPONDING FIELDS OF TABLE IT_FINAL
FROM VBRK
INNER JOIN TVKOT ON VBRKVKORG = TVKOTVKORG
INNER JOIN T001 ON VBRKBUKRS = T001BUKRS
WHERE VBELN IN DOCNUM AND VBRK~FKSTO = ''
AND VBRK~FKDAT in date.
Select statement using inner joins for vbrk and t001 and tvkot table for this case based on the conditions
8. SELECT T001W~NAME1 INTO TABLE IT1_T001W
FROM T001W INNER JOIN EKPO ON T001WWERKS = EKPOWERKS
WHERE EKPO~EBELN = PURORD.
here selecting a single field into table it1_t001winner join on ekpo.
9. SELECT BUKRS LIFNR EBELN FROM EKKO INTO CORRESPONDING FIELDS OF IT_EKKO WHERE EBELN IN P_O_NO.
ENDSELECT.
SELECT BUTXT FROM T001 INTO IT_T001 FOR ALL ENTRIES IN IT_EKKO WHERE BUKRS = IT_EKKO-BUKRS.
ENDSELECT.
APPEND IT_T001.
here I am using for all entries statement with select statement. Both joins and for all entries used to fetch the data on condition but for all entries is the best one.
10. SELECT AVBELN BVTEXT AFKDAT CBUTXT ANETWR AWAERK INTO TABLE ITAB
FROM VBRK AS A
INNER JOIN TVKOT AS B ON
AVKORG EQ BVKORG
INNER JOIN T001 AS C ON
ABUKRS EQ CBUKRS
WHERE AVBELN IN BDOCU AND AFKSTO EQ ' ' AND B~SPRAS EQ
SY-LANGU
AND AFKDAT IN BDATE AND AVBELN EQ ANY ( SELECT VBELN FROM
VBRP WHERE VBRP~MATNR EQ ITEMS ).
Here we are using sub query in inner join specified in brackets.
Thanks,
chandu.
‎2008 Feb 28 3:50 AM
hi,
1)SELECT * FROM TABLE
this one selects all records from the table.
2)SELECT SINGLE * FROM TABLE
this one searches all records and selects only single field, but dont use this ststement performance will degarde.
3)SELECT SINGLE FROM TABLE.
this one selects particular field.
4)select * from dbtab into corresponding fields of table itab.
write:/ itab-field1,itab-field2,......
this will selects all the records.
5)select * from dbtb into itab.
write:/ itab-field1,itab-field2,......
endselect.
this one will give all records.
6)select * from dbtb into itab.
endselect.
write:/ itab-field1,itab-field2,......
this one will give only last record.
reward if its useful
Edited by: p541399 on Feb 28, 2008 9:21 AM
‎2008 Feb 28 4:08 AM
Hi,
1. SELECT * FROM TABLE.
This select statement selects all the fields and records from the table.
2)SELECT SINGLE * FROM TABLE
This select statement selects all the fields of the first record according to the where condition.
3)SELECT SINGLE FROM TABLE.
This select statement selects only the field that meets the where condition requirement.
Regards,
kavitha.