‎2007 Jun 11 7:13 AM
Hi friends, can any one give me the possible select statement which are used in Report query with some code examples
‎2007 Jun 11 12:05 PM
HI,
a,Open SQL
b,Native SQL
Open SQL , native SQL are the interfaces to create the database applicatons.
Open SQL is consistant across different types of existing Databases.
Native SQL is the database language specific to database.Its API is specific to the databse
we r using most of time open SQL only.
Select single
select ipsto n rows
Select * from itab into table tab1 where (some condition)/
and u can jon the table using inner join and outer joins
Rewards points if helpfull,
Regards
Suresh.D
Message was edited by:
suresh dameruppula
‎2007 Jun 11 12:14 PM
Hi,
SELECT
Syntax
SELECT result
FROM source
INTO|APPENDING target
[[FOR ALL ENTRIES IN itab] WHERE sql_cond]
...
Effect
SELECT is an Open-SQL-statement for reading data from one or several database tables into data objects.
The select statement reads a result set (whose structure is determined in result ) from the database tables specified in source, and assigns the data from the result set to the data objects specified in target. You can restrict the result set using the WHERE addition. The addition GROUP BY compresses several database rows into a single row of the result set. The addition HAVING restricts the compressed rows. The addition ORDER BY sorts the result set.
The data objects specified in target must match the result set result. This means that the result set is either assigned to the data objects in one step, or by row, or by packets of rows. In the second and third case, the SELECT statement opens a loop, which which must be closed using ENDSELECT. For every loop pass, the SELECT-statement assigns a row or a packet of rows to the data objects specified in target. If the last row was assigned or if the result set is empty, then SELECT branches to ENDSELECT . A database cursor is opened implicitly to process a SELECT-loop, and is closed again when the loop is ended. You can end the loop using the statements from section leave loops.
Up to the INTO resp. APPENDING addition, the entries in the SELECTstatement define which data should be read by the database in which form. This requirement is translated in the database interface for the database system´s programming interface and is then passed to the database system. The data are read in packets by the database and are transported to the application server by the database server. On the application server, the data are transferred to the ABAP program´s data objects in accordance with the data specified in the INTO and APPENDING additions.
E.g.
PARAMETERS: p_cityfr TYPE spfli-cityfrom,
p_cityto TYPE spfli-cityto.
DATA: BEGIN OF wa,
fldate TYPE sflight-fldate,
carrname TYPE scarr-carrname,
connid TYPE spfli-connid,
END OF wa.
DATA itab LIKE SORTED TABLE OF wa
WITH UNIQUE KEY fldate carrname connid.
SELECT c~carrname p~connid f~fldate
INTO CORRESPONDING FIELDS OF TABLE itab
FROM ( ( scarr AS c
INNER JOIN spfli AS p ON p~carrid = c~carrid
AND p~cityfrom = p_cityfr
AND p~cityto = p_cityto )
INNER JOIN sflight AS f ON f~carrid = p~carrid
AND f~connid = p~connid ).
LOOP AT itab INTO wa.
WRITE: / wa-fldate, wa-carrname, wa-connid.
ENDLOOP.
Jogdand M B
‎2007 Jun 11 12:25 PM
hi,
<b>follow this link</b>.
http://help.sap.com/saphelp_nw04/helpdata/en/62/10a423384746e8bf5f15ccdd36e8b1/content.htm
<b>link for example progam select statement with innerjoins</b>
http://www.sap-img.com/abap/select-statement-with-inner-join-is-taking-forever.htm
<b>link for select statement with for all entries</b>
http://www.sap-img.com/abap/usage-of-for-all-entries-in-select-statement.htm
<b>follow this link for sample programs using different types of select statement.</b>
http://www.sap-img.com/abap.htm
regards,
Ashokreddy.