Professional Documents
Culture Documents
Chapter 09 - SELECT Statements
Chapter 09 - SELECT Statements
SELECT Statements
SELECT Statement |
Dec-2008
Objectives
The participants will be able to:
Select data from a database using a restrictive WHERE clause
Describe how the following ABAP commands effect a Select statement:
SELECT SINGLE, LIKE, IN, ORDER BY, BYPASSING BUFFER
Describe when to use a WHERE clause vs. a CHECK statement in an ABAP Program
Describe when to use SELECT <field list> vs. SELECT * in an ABAP Program
Use Aggregate Functions in an ABAP Program
SELECT Statement |
Dec-2008
Database Access I
Physical
Database
Logical
Database
REPORT: ZRACER01.
NODES: LFA1, LFB1,
LFC3.
Authorisation
Checking
GET LFA1.
No
Authorisation
Checking
GET LFB1.
GET LFB3.
ABAP Open SQL
ABAP Native SQL
3
SELECT Statement |
Dec-2008
SQL (SELECT)
ABAP Programs
Database
REPORT: YNEWAPPL.
Data:wa_ytabna type ytabna
SELECT * FROM ytabna into
wa_ytabna
ytabna
LFA1
ENDSELECT.
LFC1
Data
ABAP
Reports
SELECT Statement |
Dec-2008
SELECT Statement |
Dec-2008
ENDSELECT.
EQ
GE
LE
NE
GT
LT
6
SELECT Statement |
=
>=
<=
<>
>
<
=>
=<
><
Dec-2008
Relational
Operators
SELECT Statement |
Dec-2008
SELECT Statement |
Dec-2008
report
YAP00002.
SELECT Statement |
Dec-2008
positional parameter.
report YAP00003.
10
SELECT Statement |
Dec-2008
11
SELECT Statement |
Dec-2008
SELECT Statement |
Dec-2008
*&----------------------------------------------------------------------------------------------- *
*& Report YAP00006
ORDER
* BY <table field 1>
&
*
* <table field 2>
*&----------------------------------------------------------------------------------------------- * <table field 3>
*&
*
:
*&
*
:
*&----------------------------------------------------------------------------------------------- *
<table field n>.
report YAP00006.
PRIMARY KEY.
13
SELECT Statement |
Dec-2008
BYPASSING BUFFER
SELECT * FROM <table>
BYPASSING BUFFER
WHERE <condition>.
:
:
:
ENDSELECT.
14
SELECT Statement |
Dec-2008
Demonstration
Creation a program to retrieve specific records from a SAP standard database
table and displaying those in a report.
15
SELECT Statement |
Dec-2008
Practice
Creation a program to retrieve specific records from a SAP standard database
table and displaying those in a report.
16
SELECT Statement |
Dec-2008
Summary
Accessing the database can be accomplished with two methods GET Event,
SELECT Statement.
The SELECT statement can access data by three methods: Single access with
fully qualified key, Loop processing with restriction, Loop processing without
restriction.
SELECT SINGLE statement allows accessing a single table entry.
The return code (SY-SUBRC) will be set to either of the following values after the
SELECT statement finishes: 0 = Read was successful,4 = Record does not exist.
WHERE clause is to specify selection condition.
Several type of comparisons (BETWEEN, LIKE, IN) can be made in the WHERE
clause to specify ranges, masked literals/templates and field lists.
A masked literal contains the underscore _ for a single character and the
percentage character % for a character string.
17
SELECT Statement |
Dec-2008
Summary (Contd.)
IN operator of the WHERE clause allows to compare a table field with a list of
single values.
RANGES statement creates the identical internal table that is created in the DATA
statement with the columns SIGN, OPTION, LOW, and HIGH.
Additional specification ORDER BY PRIMARY KEY to sort the table entries by the
primary key field(s).
18
SELECT Statement |
Dec-2008
Questions
What are the different types of methods for accessing database records?
How you will understand that a select is successful or not?
What is the significance of SELECT SINGLE statement?
How you can restrict your selection while retrieving records from a database
table?
What is a range table and what are the fields in the range table?
What is the significance of using a range table?.
19
SELECT Statement |
Dec-2008