SAPHub

Reading Data using Open SQL

SELECT is the open SQL statement to read the data from the database. The general syntax for SELECT statement is as follows.

SELECT      <result>
INTO      <target>
FROM      <source> 
[WHERE    <condition>]

Clause Description
SELECT <result> Specifies which columns you want to read, whether one line or many lines needs to selected, and whether duplicate entries are allowed
INTO <target> Determines the target area into which the selected data is to be placed
FROM <source> Specifies the database table from which the data is to be selected
WHERE <condition> specifies which lines are to be read by specifying conditions for the selection
DATA: gwa_employee TYPE zemployee.

WRITE:/1 'Emp ID' color 5,9 'Name' color 5,17 'Place' color 5,
      27 'Phone' color 5,39 'Dept' color 5.

SELECT * FROM zemployee INTO gwa_employee.
  WRITE:/1 gwa_employee-id,9 gwa_employee-name,
        17 gwa_employee-place,27 gwa_employee-phone,
        39 gwa_employee-dept_id.
ENDSELECT.

In the above code,

Table ZEMPLOYEE Entries

Report Output