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

Regarding READ Statement

Former Member
0 Likes
949

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
Read only

Former Member
0 Likes
929

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
Read only

Former Member
0 Likes
929

Hi,

Ok i got the issue,

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

Thanks,

Prasad.

Read only

0 Likes
929

ya u r rite

Read only

nishanthbhandar
Contributor
0 Likes
929

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

Cheers

Nishanth

Read only

0 Likes
929

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.

Read only

Former Member
0 Likes
930

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.

Read only

Former Member
0 Likes
929

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

Regards,

Ravi

NOte : Please mark all the helpful answers

Read only

0 Likes
929

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

Read only

nishanthbhandar
Contributor
0 Likes
929

Prasad,

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

Cheers

Nishanth