‎2007 Mar 28 4:58 PM
i am using the read statement as follows :
read table tekpo with key werks = '1001'.
it is not reading the corresponding record.
though it reads or not it is returning the sy-subrc value 0.
plz let me know why it is happening as soon as possible.
points will be awarded.
‎2007 Mar 28 5:03 PM
‎2007 Mar 28 5:04 PM
try this..
sort tekpo by werks.
read table tekpo with key werks = '1001'
binary search.
~Suresh
‎2007 Mar 28 5:05 PM
Hi,
The READ statement looks good..
read table tekpo with key werks = '1001'.
The sy-subrc will be 0 only if it finds a corresponding record.
Do you want all the records??what exactly is your requirement..
Thanks,
Naren
‎2007 Mar 28 5:24 PM
Hi Srinivas rao,
You can use this example program and make the changes in your program as well:
DATA: BEGIN OF LINE,
COL1 TYPE I,
COL2 TYPE I,
END OF LINE.
DATA ITAB LIKE SORTED TABLE OF LINE WITH UNIQUE KEY COL1.
FIELD-SYMBOLS <FS> LIKE LINE OF ITAB.
DO 4 TIMES.
LINE-COL1 = SY-INDEX.
LINE-COL2 = SY-INDEX ** 2.
APPEND LINE TO ITAB.
ENDDO.
READ TABLE ITAB WITH TABLE KEY COL1 = 2 ASSIGNING <FS>.
<FS>-COL2 = 100.
READ TABLE ITAB WITH TABLE KEY COL1 = 3 ASSIGNING <FS>.
DELETE ITAB INDEX 3.
IF <FS> IS ASSIGNED.
WRITE '<FS> is assigned!'.
ENDIF.
LOOP AT ITAB ASSIGNING <FS>.
WRITE: / <FS>-COL1, <FS>-COL2.
ENDLOOP.
The output is:
1 1
2 100
4 16
I think you have satisfied.
Thanks and regards
Vipin Das
‎2007 Mar 28 6:02 PM
The information is not sufficient to identify the problem. Please post the data declaration of the internal table and the code around the read statement.
‎2007 Mar 28 6:14 PM
Hi,
Sort your internal table by WERKS before reading it. Also use binary search addition with the read statement.
SORT tekpo BY werks.
READ TABLE tekpo
WITH KEY werks = '1001' BINARY SEARCH.Regards,
RS
‎2007 Mar 28 6:41 PM
hi...,
Your read statement is correct..
If sy-subrc eq 0, then for sure it has got at least one record satisfying the given condition...
first check whether u are checking the Sy-subrc immediately after this read statement or not...
<i>This code onli improves the performance...
sort tekpo by werks.
read table tekpo with key werks eq '1001' binary search.</i>
regards,
sai ramesh.
reward all helpful answers...
‎2007 Mar 28 6:48 PM