2006 May 03 12:46 AM
Hi
I want to read the data from a itab where a particular field can have one of the three values.
something like this:
Read itab with table key flag = X and ( number = 26 or number = 27 or number = 28. ).
I used select options but it didnt work give me the syntax to so that I can read the table with the above condition
regards,
Ganesh
2006 May 03 1:21 AM
or condition cannot be used with read table. Use loop at with condition.
Hope this helps..
Thanks,
Vamshi Tallada
or condition cannot be used with read table. Use loop at with condition.
Hope this helps..
Thanks,
Vamshi Tallada
2006 May 03 1:21 AM
or condition cannot be used with read table. Use loop at with condition.
Hope this helps..
Thanks,
Vamshi Tallada
2006 May 03 1:23 AM
hi vamshi,
I know that we cant use OR or anyother key words.
i just want to know whether there is a record satisfying the conidition. i am already in a inner loop and if i use another then it may create performance issues. if u have any suggestions let me know.
2006 May 03 1:36 AM
you can use the where clause of the loop and exit after one entry has been found:
loop at tab where matnr = 'a' or mandt = '300'.
exit.
endloop.
if sy-subrc = 0.
*entry found
else.
*entry not found
endif.
For your example:
loop at itab where flag = 'X' and ( number = 26 or number = 27 or number = 28 ).
exit.
endloop.
2006 May 03 2:34 AM
Hi,
I think don't use Loop Where, 'coz it may create performance issues.
You can try use Binary Search, like :
Sort ITAB By FLAG NUMBER.
Read Table Itab Binary Search With Key FLAG = X and NUMBER = 26.
Loop above process for Number = 27 and 28.
Thanks,
2006 May 03 3:46 AM
I would sort the table by flag and number. Then:
read table itab
with key flag = 'X'
binary search.If sy-subrc = 0, check to see if number is 26, 27 or 28.
If it's not, and number is less than 29, do an indexed read:
wk_index = sy-tabix + 1.
read table itab index wk_index.If sy-subrc = 0 check that flag is still X and the number is 26, 27 or 28. Do the above while number is less than 29.
Rob
2006 May 03 7:39 AM
Hi Ganesh,
You cannot depend on flag field to retrive your validated values 26,27,28 , better you can read thrice with binary search for 26,27,28 and check for flag.
You are saying already you have innerloops , please let me know the clear req.
<i>Reward Points If It Helps YOU.</i>
Regards,
Raghav
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |