problem in code inspector
Hi,
I have a problem when i have done check with code inspector.
the scenario: i have coded the validation in AT SELECTION-SCREEN for a field HSPART in KNVH table.
when i check the program with code inspector the following message appears:
table KNVH:no first field from table index in WHERE condition.
how can i get rid of this message?
an early response is appreciated.
regards,
CS
Post your actual SELECT statement that does your validation.
my actual select statement is as follows.
AT SELECTION-SCREEN.
SELECT HSPART
FROM KNVH UP TO 1 ROWS
INTO KNVH-HSPART
WHERE HSPART = P_HSPART.
ENDSELECT.
IF SY-SUBRC <> 0.
MESSAGE I000.
ENDIF.
regards,
CS
Try to add to your WHERE clause a value for HITYP, let me know what the results are.
my actual select statement is as follows.
AT SELECTION-SCREEN.
SELECT HSPART
FROM KNVH UP TO 1 ROWS
INTO KNVH-HSPART
WHERE HSPART = P_HSPART.
ENDSELECT.
IF SY-SUBRC <> 0.
MESSAGE I000.
ENDIF.
regards,
CS
AT SELECTION-SCREEN.
SELECT HSPART
FROM KNVH UP TO 1 ROWS
INTO KNVH-HSPART
WHERE HSPART = P_HSPART.
ENDSELECT.
I think the message appears because you don't use a key field in your where clause. However this is not an error, it just means that your select isn't performant.
Also dump the up to 1 rows and use select single instead. It's much faster, since " up to" actually scans the whole table until it retrieves all the valid entries and then returns the first from the resultset .
Select single only selects 1 entry into the resultset and stops searching your table
SELECT SINGLE HSPART INTO KNVH-HSPART
FROM KNVH
WHERE HSPART = P_HSPART.
[quote="stof"]
Also dump the up to 1 rows and use select single instead. It's much faster, since " up to" actually scans the whole table until it retrieves all the valid entries and then returns the first from the resultset .
Select single only selects 1 entry into the resultset and stops searching your table
I checked that in our system a couple of months ago and could not confirm the above mentioned different behaviour.
Unless you do not use any aggregation or order clause in your select, which would make it necessary to retrieve all matching records on database level, you will not sense any significant different between select single or select up to 1 rows.
Christtian.