2016 Jan 05 12:42 PM
Hi,
Getting an error in Code Inspector as : No field of table index in Where
This is my select query
If not s_date is initial.
select date_r
from ztable
into lv_date
up to 1 rows
where date_r in s_date.
endselect.
endif.
if sy-subrc <> 0.
message.
endif.
Kindly help me to overcome this issue.
2016 Jan 05 1:15 PM
Hi,
seems like the field date_r is not part of the table index of ztable.
Try to create an index with that field.
Are you using Code Inspector or ATC?
Thx.
2016 Jan 05 1:23 PM
Hello,
It doesn't look like an error, it's more likely a warning. You don't have a index with date_r in ztable, create the index with this field to correct the problem, also avoid using select ~ endselect, try to use select <fields> into table <internal_table>.
2016 Jan 05 1:28 PM
And more-over why are you using SELECT-ENDSELECT ? This is obsolete. Use Select Single.... Into
(oops - sorry Lucas just repeated what you said)
2016 Jan 05 1:34 PM
As a rule of thumb:
2016 Jan 05 2:37 PM
I think you need to think about just what you are trying to do.
You have a table with multiple rows and has this date column. You also have a SELECT-OPTION that may contain many dates.
You then take a date at random (but within the SELECT-OPTION) from the table.
I don't see any logic here.
Rob
2016 Jan 05 3:03 PM
You could also only execute selection when user actually try to execute the report, and not at each press of Enter key.
AT SELECTION-SCREEN ON s_date.
IF NOT s_date[] IS INITIAL " select-options have header line :-(
AND ( sscrfields-ucomm EQ 'ONLI' OR sscrfields-ucomm EQ 'PRIN' ).
SELECT date_r INTO lv_dummy
FROM ztable UP TO 1 ROWS
WHERE date_r IN s_date.
ENDSELECT.
IF sy-subrc NE 0.
MESSAGE 'Date not found' TYPE 'E'.
ENDIF.
ENDIF.
But if you didn't create any index, better use a single SELECT with every criteria with similar code.
AT SELECTION-SCREEN.
IF sscrfields-ucomm EQ 'ONLI'
OR sscrfields-ucomm EQ 'PRIN'.
SELECT date_r INTO lv_dummy
FROM ztable UP TO 1 ROWS
WHERE date_r IN s_date.
" and other select-options
ENDSELECT.
IF sy-subrc NE 0.
MESSAGE 'No data selected' TYPE 'S' DISPLAY LIKE 'E'.
CLEAR sscrfields-ucomm.
ENDIF.
ENDIF.
(or even already fill the first internal table with the code of START-OF-SELECTION)
Regards,
Raymond