‎2007 Mar 01 8:58 AM
Hi,
I want to have a SELECT statement in the FROM clause. I get syntax error when doing this and since I am new to ABAP I need som help.
I want to do the following, (and if anyone has any SELECT statement from their own system which you know there is no syntax error in please post it here so I can analyze the syntax):
*I leave the INTO itab clause out, since I only want to demonstrate the functionality
I am trying to get.
<b>SELECT</b> tableOne~someField
<b>FROM</b> tab <b>AS</b> tableOne (<b>SELECT</b> someField
<b>FROM</b> tab
<b>WHERE</b> someFiled > 1) <b>AS</b> tableTwo
<b>WHERE</b> tableOnesomeField > tableTwosomeField
like I said, the problem is that the select statement in the parenthesis in the from clause seems to be incorrect because I get "wrong expression" when trying to compile. Is this because I cannot have a select statement in the from clause or is it because of a minor syntax error, such as I forgot a dot, or some other sign?
thanks and regards
Baran
‎2007 Mar 01 9:08 AM
Hi
I suppose you want to do a join, don't I?
If it's so:
SELECT tableOnesomeField tableTwosomeField
FROM tab AS tableOne A INNER JOIN tab2 AS tableTwo
on tableOnesomeField > tableTwosomeField
INTO TABLE ITAB.
WHERE tableTwo~someFiled > 1.
Where ITAB is an internal table with fields of TAB and TAB2.
Max
‎2007 Mar 01 9:08 AM
Hi
I suppose you want to do a join, don't I?
If it's so:
SELECT tableOnesomeField tableTwosomeField
FROM tab AS tableOne A INNER JOIN tab2 AS tableTwo
on tableOnesomeField > tableTwosomeField
INTO TABLE ITAB.
WHERE tableTwo~someFiled > 1.
Where ITAB is an internal table with fields of TAB and TAB2.
Max
‎2007 Mar 01 9:09 AM
Baron,
Write the staement like below.
data : begin of itab occurs 0,
some field like tableTwo-somefield,
end of itab.
SELECT someField into table itab
FROM tab
WHERE someFiled > 1.
if not itab[] is initial.
SELECT someField
into table itab2
FROM tableOne
for all entries in itab
WHERE someField > itabsomeField.
endif.
Pls. reward if useful
‎2007 Mar 01 9:11 AM
sorry i am not enough familiar with sub queries but some error i can see which i will state here.
1> you have to use sub queries i.e. select in ( ) after where clause because here you are fulfilling a where clause by another select statement.
like this
SELECT * FROM SFLIGHT
INTO WA
WHERE SEATSOCC = ( SELECT MAX( SEATSOCC ) FROM SFLIGHT ).
2> you cannot specify field name without into clause either you have to use
select * or select f1 into tab-f1 like this...
but if you are using select * without into you have to define
tables : dbtab.
selec * from dbtab. like that.
regards
shiba dutta
‎2007 Mar 01 9:13 AM
hi,
check this
SELECT pcarrid pconnid ffldate bbookid
INTO CORRESPONDING FIELDS OF TABLE itab
FROM ( ( spfli AS p
INNER JOIN sflight AS f ON pcarrid = fcarrid AND
pconnid = fconnid )
INNER JOIN sbook AS b ON bcarrid = fcarrid AND
bconnid = fconnid AND
bfldate = ffldate )
WHERE p~cityfrom = 'FRANKFURT' AND
p~cityto = 'NEW YORK' AND
fseatsmax > fseatsocc.
Regards,
Sruthi
‎2007 Mar 01 9:20 AM
I guess you cannot use subqueries in FROM claus , u can only use in WHERE condition
REPORT ZTEST.
TABLES :MARA , MAKT , DD02L.
DATA : V_MATNR LIKE MARA-MATNR,
V_MAKTX LIKE MAKT-MAKTX.
SELECT SINGLE A~MATNR
B~MAKTX
FROM MARA AS A INNER JOIN
MAKT AS B
ON A~MATNR EQ B~MATNR
INTO (V_MATNR , V_MAKTX)
WHERE A~MATNR EQ ( SELECT MAX( SEATSOCC ) FROM SFLIGHT ).