Application Development 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: 

Synatx error with READ statement

Former Member
0 Kudos

Hi

Is the below syntax correct

Read table itab1 with key a = it_tab2-a and b = it_tab2-b and c = it_tab2-c.

The above syntax is showing some error

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Don't use AND in read statement. Try it

Read table itab1 with key a = it_tab2-a

b = it_tab2-b

c = it_tab2-c

L.Velu

7 REPLIES 7

Former Member
0 Kudos

remove all 'and'

Read table itab1 with key a = it_tab2-a

b = it_tab2-b

c = it_tab2-c.

Peter_Lintner
Participant
0 Kudos

Hi!

The correct syntax is:

Read table itab1 with key a = it_tab2-a

b = it_tab2-b

c = it_tab2-c.

Kind regards,

Peter

Former Member
0 Kudos

Hi

Hope it will help you.

reward if help.

Read table doesn't allow ne operator.

It reads only one record...Either by index or key.

READ TABLE MY_TAB INDEX 1.

READ TABLE MY_TAB WITH KEY CODE = 'ATG'.

these are the results for SY-SUBRC checks after read table

SY-SUBRC = 0:

An entry was read.

SY-TABIX is set to the index of the entry.

SY-SUBRC = 2:

An entry was read.

SY-TABIX is set to the index of the entry. This return code can only occur when you use the COMPARING addition. For further detauls, refer to the COMPARING section of the additions

SY-SUBRC = 4:

No entry was read.

The value of SY-TABIX depends on the table type and whether the BINARY SEARCH addition was specified.

If the table is a SORTED TABLE or a table sorted in ascending order of the type STANDARD TABLE with the BINARY SEARCH addition, SY-TABIX refers to the next-highest index.

Otherwise, SY-TABIX is undefined.

SY-SUBRC = 8:

No entry was read.

This return code only occurs with a SORTED TABLE or a STANDARD TABLE with the BINARY SEARCH addition. SY-TABIX is set to the number of all entries plus 1.

Reading records with keys

http://help.sap.com/saphelp_47x200/helpdata/en/fc/eb35f8358411d1829f0000e829fbfe/content.htm

Reading lines with Index

http://help.sap.com/saphelp_47x200/helpdata/en/fc/eb3730358411d1829f0000e829fbfe/content.htm

Former Member
0 Kudos

Hi,

Write as below

Data: wa1 like line of itab1.

Read table itab1 into wa1 with key a = it_tab2-a b = it_tab2-b c = it_tab2-c.

Regards,

Satish

Former Member
0 Kudos

Hi,

The correct syntax is

READ TABLE itab1 WITH KEY a = itab2-field1

b = itab2-field2.

If itab1 and itab2 are defined with header line.

If they do not have a header line then declare work areas for them and read as follows :

READ TABLE itab1 INTO wa1 WITH KEY a = wa2-field1

b = wa2-field2.

Former Member
0 Kudos

Hi,

Don't use AND in read statement. Try it

Read table itab1 with key a = it_tab2-a

b = it_tab2-b

c = it_tab2-c

L.Velu

Former Member
0 Kudos

Hi ajay, ur iab1 should contains a, b, c fileds, and it_tab2 also should contain a, b, c fields.

then remove and in ur syntax.

loop at it_tab2.

read table itab1 with key a = it_tab2-a

b = it_tab2-b

c = it_tab2-c.

process code......

endloop.