09-22-2008 9:40 AM
Hi experts.
I'm trying to read an internal table to two values but apparently i can't use the keyword OR.
Here is what i tryed. Can anybody tell me what is the correct instruction to use ?
Thanks for your help.
* Test 1
READ TABLE lt_status INTO wa_status
WITH KEY txt04 = ( c_wait_exp OR c_expert ).
*Test 2
READ TABLE lt_status INTO wa_status
WITH KEY txt04 = c_wait_exp.
OR txt04 = c_expert.
Both are incorrects.
09-22-2008 9:42 AM
READ is supposed to return a single entry, so there is a logical problem with using OR conditions. That's why they are not allowed.
See if you can use LOOP AT ... WHERE ... instead.
Thomas
09-22-2008 9:42 AM
READ is supposed to return a single entry, so there is a logical problem with using OR conditions. That's why they are not allowed.
See if you can use LOOP AT ... WHERE ... instead.
Thomas
09-22-2008 9:43 AM
09-22-2008 9:44 AM
You cannot use "AND" or "OR" in READ TABLE.
You have to use "LOOP AT" to use the OR condition.
09-22-2008 9:47 AM
Hi
Use range , Firsttly declare oa variable of type range . Now pass both of your constants in ranhe as
Data ; l type range .
pass both of your constants in range (For help see SAP Help)
now
READ TABLE lt_status INTO wa_status
WITH KEY txt04 in l .
~hitesh
09-22-2008 9:47 AM
Hello,
You have to use READ statement twice.
Like
READ TABLE lt_status INTO wa_status
WITH KEY txt04 = c_wait_exp.
IF sy-subrc NE 0.
READ TABLE lt_status INTO wa_status
WITH KEY txt04 = c_expert.
IF sy-subrc NE 0.
Give u r error message here.
ENDIF.
ENDIF.
IF one of the statement is true , do u r processing after that.
Hope it solves u r problem.
Thanks,
Chandra.
09-22-2008 9:49 AM
Hi Helder,
Both of the syntax are wrong. No OR operator is not supported in READ Statement.
Try using LOOP AT <itab> WHERE <condition> where you can use OR condition.
Regards,
Chandra Sekhar
09-22-2008 9:49 AM
Hi ..
If fields are different don't use opertors...
do like this..,
> read table itab with key field1 = 'gfhg' field2 = 'fhbrsjf'.
But, for the same filed its not possible.!!
Thanks,
Naveen.I
09-22-2008 9:50 AM
Hi,
With READ table you can not use same field more than one time for comparison.
You can get this functionality using LOOP ....Endloop.
Like-
Data:itab like standard table of sflight,
wa like line of itab.
Loop at itab into wa where carrid = 'AA' or carrid = 'AB'.
endloop.
09-22-2008 9:51 AM
Hi Helder,
You can not use expression with logical operators and other relational operators except '=' in READ statement.
So you need to query with the first value then if it fail then query with second value.
READ TABLE lt_status INTO wa_status
WITH KEY txt04 = c_wait_exp.
IF SY-SUBRC EQ 0.
<<Required logic>>
ELSE.
READ TABLE lt_status INTO wa_status
WITH KEY txt04 = c_expert.
IF SY-SUBRC EQ 0.
<<Required logic>>
ENDIF.
ENDIF.
Thanks,
Vinay
09-22-2008 9:56 AM
try this:
data: flag1 type c length 1,
flag2 type c length 1.
READ TABLE lt_status INTO wa_status
WITH KEY txt04 = c_wait_exp .
if sy-subrc = 0.
flag1 = 'X'.
endif.
READ TABLE lt_status INTO wa_status
WITH KEY txt04 = c_expert.
if sy-subrc = 0.
flag2 = 'X'.
endif.
if flag1 = 'X' or flag2 = 'X'.
" Write your code here
endif.