‎2008 Jun 21 12:34 PM
Hi Abapers ,
I have an internal table it_bsak .I have to read the internal table with the condition xragl field in it_bsak table should not be equal to 'X'.
READ TABLE it_bsak1 WITH KEY
lifnr = it_disb_output-fi_lifnr
xragl NE 'X'
BINARY SEARCH.
This statement is not working .
What is the correct statement to read from it_bsak table condition as xragl field not equal to 'X'.
Please help .
Jaga
‎2008 Jun 21 12:35 PM
Hi
READ accepts only equality condition.
so use loop condition.
Loop at it_bsak where lifnr = it_disb_output-fi_lifnr
and xragl NE 'X'
endloop.regards,
madhu
‎2008 Jun 21 12:39 PM
use the following
loop at it_bsak1 where lifnr = it_disb_output-fi_lifnr
and xragl NE 'X' .
:
:
:
endloop.
inside the loop u can make use of it_bsak1 for ur requirement...
‎2008 Jun 21 12:42 PM
hi check this....
before loop use the sort table by the field used in the read statement ...and check
‎2008 Jun 21 1:39 PM
Hi,
It appears you want to "code" this READ because you are already within a LOOP on table it_disb_output, hence trying to avoid loop within loop.
For this purpose, create another internal table of identical structure as it_bsak1 say it_bsak1_tmp.
Then before loop at it_disb_output do the following:
REFRESH it_bsak1_tmp.
APPEND LINES OF it_bsak1 TO it_bsak1_tmp.
DELETE it_bsak1_tmp WHERE xragl EQ 'X'.
SORT it_bsak1_tmp BY LIFNR.
Now within your loop, you can
READ TABLE it_bsak1_tmp WITH KEY lifnr = it_disb_output-fi_lifnr . because, the new table it_bsak1_tmp does not have any entries with xragl as 'X'.
Cheers,
Aditya
‎2008 Jun 22 12:47 PM
Hi,
Which ever statement you use( Read or Loop ) depends on the records you have in the internal table. Moreover when you are using binary search to the read statement always " SORT the internal table with the fields given in the where condition ", otherwise the binary search will work in a wrong way.
ex:
sort it_tab by field1 field2.
read table it_tab into is_tab with key field1 = 'value'
field2 = 'value'
binary search.
‎2008 Jun 22 5:09 PM
Hi Jagdish,
"NE" Not Equal Operator doesn't work in Read Statement.
Instead of doing this type use the Loop statement Logic.
Loop at it_bsak1 where lifnr = it_disb_output-fi_lifnr
xragl NE 'X' .
<Play with your data>
EndLoop.
&*******************Reward Point if helpful******************&
‎2008 Jun 23 4:41 AM
Try This
Sort it_bsak1 by lifnr ascending.
loop at it_disb_output.
READ TABLE it_bsak1 WITH KEY
lifnr = it_disb_output-fi_lifnr BINARY SEARCH.
if sy-subrc = 0.
if it_bsak1-xragl NE 'X'.
____________
endif.
endif.
‎2008 Jun 23 4:47 AM
Hi,
First you should not use EQ, NE etc in read statement.
Sort it_bsak1 by lifnr ascending.
READ TABLE it_bsak1 WITH KEY lifnr = it_disb_output-fi_lifnr
*NOT xragl = 'X' *
BINARY SEARCH.
OR
Sort it_bsak1 by lifnr ascending.
READ TABLE it_bsak1 WITH KEY lifnr = it_disb_output-fi_lifnr
xragl <> 'X' *
BINARY SEARCH.