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: 

Question of a READ TABLE STATEMENT

Former Member
0 Kudos

How can I put in a read table <= or >= like this:

READ TABLE t_pcec1 INTO wa_pcec1 with key checf <=

wa_payr1-chect chect >= wa_payr1-chect.

Thanks!!

9 REPLIES 9

former_member927251
Active Contributor
0 Kudos

Hi,

You can't use logical and aritmetic operators in READ Statement. Instead after reading first time you can use an IF condition to check whatever you want to and then use READ Statement again with different WITH KEY fields.

You can do this multiple times.

<b>But, you can't use operators in READ statement.</b>

<b>Reward points if it helps you.</b>

Message was edited by: Amit Mishra

sridhar_k1
Active Contributor
0 Kudos

I think you cannot use <= and >= in read statement,

use Loop at t_pcec1 where checf le

wa_payr1-chect chect ge wa_payr1-chect ....endloop

and exit after first hit.

Regards

Sridhar

vinod_gunaware2
Active Contributor
0 Kudos

<b>Binary Search in Standard Tables</b>

If you read entries from standard tables using a key other than the default key, you can use a binary search instead of the normal linear search. To do this, include the addition BINARY SEARCH in the corresponding READ statements.

READ TABLE <itab> WITH KEY <k1> = <f1>... <kn> = <fn> <result>

BINARY SEARCH.

OR Use <b>LOOP AT</b>

regards

vinod

former_member188685
Active Contributor
0 Kudos

READ TABLE t_pcec1 INTO wa_pcec1 with key checf <=

wa_payr1-chect chect >= wa_payr1-chect.

it is not possible. but you can try this..


loop at  t_pcec1 INTO wa_pcec1 where checf <= wa_payr1-chect  and chect >= wa_payr1-chect.

"here you get the record,
"after that use exit

endloop.

Regards

vijay

Former Member
0 Kudos

Hi,

READ TABLE can only fetch 1 record at a time. so you say > or < in the WHERE condition of READ TABLE,there is chance that more than 1 record satisfying the criteria,which read table can NOT hold.

so its always have to give '=' in READ TABLE WHERE condition.

if you are looking for more than 1 record processing,

LOOP AT t_pcec1 INTO wa_pcec1

WHERE checf <=

wa_payr1-chect chect >= wa_payr1-chect.

*--Do some processing..

ENDLOOP.

Regards

srikanth

Former Member
0 Kudos

hi carlos,

u cannot use conditional operators in read statement.

so , it is better to loop at the table checking the condition key checf <=

wa_payr1-chect chect >= wa_payr1-chect.

hope this helps,

keerthi.

0 Kudos

Hi,

Hope this will give you some idea since you cannot use operators in a read statement just like what others said.

loop at itab1.

read table itab2 with key f1 = itab1-f1

f2 = itab1-f1.

if sy-subrc = 0.

move itab2-f1 to itab3-f1.

else.

delete itab1.

clear itab1.

continue.

endif.

endloop.

Former Member
0 Kudos

Carlos - I think you question has been pretty well answered. You're getting the same answers over and over. Why not assign some points (not to this) and close it?

Rob

hymavathi_oruganti
Active Contributor
0 Kudos

u cant use conditions other than '='.

to achive ur purpose u can code like below:

loop at t_pcec1 INTO wa_pcec1 where checf <=

wa_payr1-chect and chect >= wa_payr1-chect.

endloop.

u need to ue loop............, no other go.