Intro to ABAP Chapter 05

background image

BC170_2.05.1

Retrieving Data with SELECT

Statements

background image

BC170_2.05.2

Objectives

The participants will be able to:

Retrieve information from the database
using Open SQL

Create basic Select statements for use in
ABAP Code

Describe the system field SY-SUBRC and
properly use it in an ABAP Program.

background image

BC170_2.05.3

Retrieving Information From the

Database

DB

Data

John

Sm

ith

Ma

ry

Sti

les

background image

BC170_2.05.4

Open SQL

Portable across various databases

A subset of standard SQL

background image

BC170_2.05.5

The Basic SELECT Statement

DB

Mary
Stiles

John Smith

Work Area

SELECT <fields> FROM <table

name> […..]

ENDSELECT.

TABLES: <table name>.

background image

BC170_2.05.6

Example Using the SELECT

Statement

TABLES: KNA1.

SELECT KUNNR

NAME1

INTO (KNA1-KUNNR,
KNA1-NAME1)
FROM KNA1.
WRITE: / KNA1-KUNNR, KNA1-NAME1.
ENDSELECT.

background image

BC170_2.05.7

The SELECT Statement with a

WHERE Clause

TABLES: KNA1.

SELECT KUNNR

NAME1

INTO (KNA1-KUNNR,

KNA1-NAME1)

FROM KNA1
WHERE KTOKD = ‘0001’.
WRITE: / KNA1-KUNNR, KNA1-NAME1.
ENDSELECT.

background image

BC170_2.05.8

SY-SUBRC

TABLES: KNA1.

SELECT KUNNR

NAME1

INTO (KNA1-KUNNR,

KNA1-NAME1)

FROM KNA1
WHERE KTOKD = ‘0001’.
WRITE: / KNA1-KUNNR, KNA1-NAME1.
ENDSELECT.

IF SY-SUBRC <> 0.
WRITE: / ‘No records found.’.
ENDIF.

background image

BC170_2.05.9

INTO CORRESPONDING

FIELDS

TABLES: KNA1.

SELECT KUNNR
NAME1
FROM KNA1
INTO CORRESPONDING FIELDS
OF KNA1.
WRITE : / KNA1-KUNNR, KNA1-NAME1.
ENDSELECT.

IF SY-SUBRC <> 0.
WRITE: / ‘No records found.’.
ENDIF.

background image

BC170_2.05.10

Summary

The participants should be able to:

Retrieve information from the database
using Open SQL

Create basic Select statements for use in
ABAP Code

Describe the system field SY-SUBRC and
properly use it in an ABAP Program


Document Outline


Wyszukiwarka

Podobne podstrony:
Intro to ABAP Chapter 13
Intro to ABAP Chapter 07
Intro to ABAP Chapter 12
Intro to ABAP Chapter 15
Intro to ABAP Chapter 08
Intro to ABAP Chapter 11

więcej podobnych podstron