Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

read

Former Member
0 Likes
641

can we use an read statement on a database table

if yes then wat should be the syntax.

6 REPLIES 6
Read only

Former Member
0 Likes
609

Hi,

No we cannot use Read Statement for Database table.

Read only

prasanth_kasturi
Active Contributor
0 Likes
609

hi

its present but obselete use it only with internal tables

READ TABLE dbtab [WITH KEY key]

[SEARCH {FKEQ|FKGE|GKEQ|GKGE}]

[VERSION vers].

This variant of the statement READ (not allowed in classes) reads a row from the database table dbtab and assigns the content to the respective table work area. For dbtab, you must specify the name of a database table that begins with "T" and is not longer than five characters. The table work area must have been declared with statement TABLES for database table dbtab. If a database table is specified that does not begin with "T", then the first letter is implicitly replaced by "T".

Without the addition WITH KEY, the row to be read is determined by the content of the components of the table work area that correspond to the primary key fields of database table dbtab.

Addition 1

... WITH KEY key

Effect

With the addition WITH KEY, the key is determined through the content of data object key for which a flat character-type data type is expected.

The content of the table work area resp. of the data object key is taken from the database table as search key (left-aligned with the length of the key components); then a matching entry is searched in the database.

Addition 2

... SEARCH {FKEQ|FKGE|GKEQ|GKGE}

Effect

The addition SEARCH determines how the row is searched:

Without the addition SEARCH and with SEARCH FKEQ, the first row in the database table is searched that matches the withdrawn search key.

With SEARCH GKEQ, you search generically for the first row of the database table that matches the withdrawn search key. The search key treats blanks as if they match all values.

With SEARCH FKGE, the first row of the database table is searched that is larger or equal to the withdrawn search key.

With SEARCH GKGE, you search generically for the first row of the database table that is larger or equal to the withdrawn search key. The search key treats blanks as if they match all values.

Addition 3

... VERSION vers

Effect

If the addition VERSION is specified, then not the database table dbtab is read, but the table whose name is composed of "T" and the content of vers. For vers, you have to specify a data object of the type c with a maximum length of four characters. If the database table is not available, sy-subrc is set to 12.

The content of the rows is still assigned to table work area dbtab, on whose type it is also cast onto. If table work area is too short, then sy-subrc is set to 8.

The statement is not executed if the database table does not exist or does not comply with the naming conventions stated above.

Example

Reading of a row from the database table T100 or another database table that starts with "T".

TABLES t100.

PARAMETERS p TYPE c LENGTH 4 DEFAULT '100T'.

t100-sprsl = 'E'.

t100-arbgb = 'BC'.

t100-msgnr = '010'.

READ TABLE t100 SEARCH FKEQ VERSION p.

IF sy-subrc = 0.

...

ENDIF.

The Open-SQL-syntax to be used instead reads:

PARAMETERS p TYPE c LENGTH 5 DEFAULT 'T100T'.

DATA dref TYPE REF TO data.

FIELD-SYMBOLS <fs> TYPE ANY.

CREATE DATA dref TYPE (p).

ASSIGN dref->* TO <fs>.

SELECT SINGLE *

FROM (p)

INTO <fs>

WHERE sprsl = 'E' AND

arbgb = 'BC' AND

msgnr = '010'.

IF sy-subrc = 0.

...

ENDIF.

regards

prasanth

Read only

Former Member
0 Likes
609

hi,

No you cannot use read statement for reading the database table as it is obsolete . It is used only to read internal tables.. Use select statement to fetch the data from database tables...


select single * from mara where matnr = p_matnr.

Read only

Former Member
0 Likes
609

Hi,

Use

read table dbtab.

If it is helpfull pls reward me.

Regards

Srimanta

Read only

Former Member
0 Likes
609

No

Read Table is used for reading internal tables record line by line

Read only

abdul_hakim
Active Contributor
0 Likes
609

Hi,

No you cannot use READ Statement to read from DB Table.You can use SELECT Statement to read.

Regards,

Hakim