Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Performance issue in selection screen validation

Former Member
0 Likes
920

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.

6 REPLIES 6
Read only

bauert
Explorer
0 Likes
843

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.

Read only

Former Member
0 Likes
843

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>.

Read only

Former Member
0 Likes
843

And more-over why are you using SELECT-ENDSELECT ?  This is obsolete.  Use Select Single.... Into

(oops - sorry Lucas just repeated what you said)

Read only

retired_member
Product and Topic Expert
Product and Topic Expert
0 Likes
843

As a rule of thumb:

  • If you need tbe contents of the selected row(s)
    • You use SINGLE when selecting a fully specified row into a structure
    • You use UP TO n ROWS (together with ORDER BY) when selecting a restricted number of partly specified rows into a table or structure
  • If you merely want to check the existence of a row (not interested in contents) you can use both


See

Read only

Former Member
0 Likes
843

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

Read only

RaymondGiuseppi
Active Contributor
0 Likes
843

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