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: 

Regarding READ Statement

Former Member
0 Kudos

Hi All,

I have a issue while using READ statement.

Issue IS:

In following Code

<b> SORT i_konv BY knumv.

LOOP AT i_ekbe INTO wa_ekbe.

CLEAR wa_konv.

READ TABLE i_konv WITH KEY knumv = wa_ekbe-knumv

kschl <> space

lifnr <> space

kwert <> space

BINARY SEARCH.

IF sy-subrc EQ 0.

ENDIF.

ENDLOOP.</b>

When i am checking syntax for above code it is giving error as <b>KSCHL <> SPACE LIFNR <> SPACE is not expected</b>.

Can anybody tell me what is the issue over here!

Thanks in advance.

Thanks & Regards,

Prasad.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi prasad,

I dont think you can do <> comparison in READ statment.

Try

READ TABLE i_konv WITH KEY knumv = wa_ekbe-knumv BINARY SEARCH.

use IF after reading, for this comparison.

Regards,

Tanveer.

Mark helpful answers.

8 REPLIES 8

Former Member
0 Kudos

Hi,

Ok i got the issue,

Only <b>=</b> can be used in <b>READ</b>.

Thanks,

Prasad.

0 Kudos

ya u r rite

nishanthbhandar
Contributor
0 Kudos

A negative condition does not work with a read statement.Please try for a better option with the read.

Cheers

Nishanth

0 Kudos

Hi,

I got the solution as:

SORT i_konv BY knumv.

LOOP AT i_ekbe INTO wa_ekbe.

CLEAR wa_konv.

READ TABLE i_konv INTO wa_konv

WITH KEY

knumv = wa_ekbe-knumv

BINARY SEARCH.

IF sy-subrc EQ 0.

IF wa_konv-kschl NE space OR

wa_konv-lifnr NE space OR

wa_konv-kwert NE space.

  • some code

ENDIF.

ENDIF.

ENDLOOP.

Thanks,

Prasad.

Former Member
0 Kudos

Hi prasad,

I dont think you can do <> comparison in READ statment.

Try

READ TABLE i_konv WITH KEY knumv = wa_ekbe-knumv BINARY SEARCH.

use IF after reading, for this comparison.

Regards,

Tanveer.

Mark helpful answers.

Former Member
0 Kudos

I idea is to get only one record using the READ statement.

Regards,

Ravi

NOte : Please mark all the helpful answers

0 Kudos

Hi Prasad,

You can only use = in Read statement while using WITH clause.

Solution to your problem :

Declare three variables of the type that you want to use in the Read Statement.

lv_kschl type kschl.

lv_lifnr type lifnr.

lv_kwert type kwert.

Don't clear the variables and use like this.

READ TABLE i_konv WITH KEY knumv = wa_ekbe-knumv

kschl = lv_kschl

lifnr = lv_lifnr

kwert = lv_kwert

BINARY SEARCH.

Please mark helpful answer and close this thread.

Regards,

Amit Mishra

nishanthbhandar
Contributor
0 Kudos

Prasad,

Please close the thread and award points for helpful answers if your query has been solved.

Cheers

Nishanth