Reading Database Tables: BCO5647 Applications Programming Techniques (ABAP)
Reading Database Tables: BCO5647 Applications Programming Techniques (ABAP)
Objectives
This lecture will Introduce the ABAP dictionary as part of SAP Introduce ABAP Open SQL Explore reading DB Tables using ABAP SELECT statements Introduce System Variables and examine how they can be incorporated into an ABAP program Examine program documentation options
BCO5647
BCO5647
BCO5647
BCO5647
The INTO clause determines the internal data objects into which the selected data is to be placed.
The WHERE clause defines the conditions that the selection results must fulfil.
BCO5647
BCO5647
BCO5647
BCO5647
The select statement begins a loop. The endselect marks the end of the loop. Code between select and endselect are executed once for each row returned from the database.
BCO5647
10
The where clause allows the program to specify which rows of data are to be returned by the select command.
1. 2. 3. 4. 5. 6. 7. report y234802c. tables sbook. select * from sbook where carrid = LH and connid = 0400. write: / sbook-carrid, sbook-fldate. endselect.
BCO5647
11
1. 2. 3. 4. 5. 6. 7.
report y234802d. tables spfli. select * from spfli order by cityfrom. write: / spfli-carrid, spfli-connid, spfli-cityfrom. endselect.
The order by clause returns the result of a select loop in ascending order by the nominated field.
BCO5647
12
For example:
sy-datum sy-uzeit
Two system variables useful when using the select statement are:
sy-subrc sy-dbcnt
BCO5647
13
9. endif.
BCO5647
14
BCO5647
15
4.
8.
9. endif.
BCO5647
16
BCO5647
17
*----------------------------------------------* * Report Name: y234802h * Author: John Verbatum * Date: February 2007 *----------------------------------------------* * Description: * This program will *----------------------------------------------*
report y234802h.
*----------------------------------------------* * Tables *----------------------------------------------* tables: bsis, kna1, vbrp. Index for G/L Accounts Data in Customer Master Billing: Item Data
*----------------------------------------------* * Variables *----------------------------------------------* data: w_buzei(3) type n, w_monat(2) type n. Line item number Fiscal Period
BCO5647
18