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

avoiding endselect

Former Member
0 Likes
903

hi,

i'm doing a select on a table and i want to avoid the endselect . is there anyway to code this in order to avoid the select...endselect.

your help will be appreciated.

Regards,

ravi.

SELECT number date time

INTO (v_number, v_date, v_time)

FROM ztable

UP TO 1 ROWS

WHERE zpro = sy-repid AND

werks IN r_plant

ORDER BY number descending.

ENDSELECT.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
828

Try:


data: begin of itab occurs 0,
        v_number like ztable-number,
        v_date   like ztable-date,
        v_time   like ztable-time,
      end of itab.

SELECT number date time
  INTO table itab
  FROM ztable
  UP TO 1 ROWS
  WHERE zpro = sy-repid AND
        werks IN r_plant
        ORDER BY number descending.

Rob

7 REPLIES 7
Read only

Former Member
0 Likes
828

write as select single...

SELECT single number date time

INTO (v_number, v_date, v_time)

FROM ztable

WHERE zpro = sy-repid AND

werks IN r_plant

ORDER BY number descending.

up to 1 rows also is not a problem (select...endselect) as it will fetch only 1 record and it wont hit the database too much...

Message was edited by:

Ramesh Babu Chirumamilla

Read only

0 Likes
828

Fine ur answer...

But before we going to use Select Single we must be knw the filed/fields wch r in where condition is key field or not...if it is key field it is better suppose it is not key filed "Up to 1 rows" is only better thing...

anyhow for select single no need endselect.

for up to 1 rows alos we can avoid endselect by using TABLE key word..

Read only

alison_lloyd
Active Participant
0 Likes
828

What are the key fields in ZTABLE and why do you want to get rid of endselect?

Read only

Former Member
0 Likes
828

hi,

SELECT single number date time

INTO (v_number, v_date, v_time)

FROM ztable

UP TO 1 ROWS

WHERE zpro = sy-repid AND

werks IN r_plant

ORDER BY number descending.

This should work.

Regards,

Vinod.

Read only

Former Member
0 Likes
829

Try:


data: begin of itab occurs 0,
        v_number like ztable-number,
        v_date   like ztable-date,
        v_time   like ztable-time,
      end of itab.

SELECT number date time
  INTO table itab
  FROM ztable
  UP TO 1 ROWS
  WHERE zpro = sy-repid AND
        werks IN r_plant
        ORDER BY number descending.

Rob

Read only

Former Member
0 Likes
828

Ramesh,

im getting incorrect spelling or comma error. even thing seems to be perfect but i dont understand why?

Regards,

ravi.

Read only

0 Likes
828

That's because of the error in your original statment. If you put the data directly into the table or work area, you will avoid the problem.

rob