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

Select

Former Member
0 Likes
532

Hi all

I have a report as mentioned below.But i want to select only the first 2 record from the table without using control-break statments.Please help.

Vijay

1 ACCEPTED SOLUTION
Read only

rainer_hbenthal
Active Contributor
0 Likes
513

In a relational database no "first" record exists. first second last is only relevant if you do a sorting. Just using package size or up to n rows is not sufficient, you need a sort to tell if you need the two actual values (sorting by date) or whatever. Without having a sort in the select clause you can not assure what values are the first ones.

4 REPLIES 4
Read only

Former Member
0 Likes
513

Hi,

Use PACKAGE SIZE.

SELECT *
        INTO TABLE (internal table)
        FROM (Standard table)
             PACKAGE SIZE 2
       WHERE (Condition).
       ENDSELECT.

Regards

Kannaiah

Read only

Former Member
0 Likes
513

select * from <table> into table itab upto 2 rows ...

Read only

Former Member
0 Likes
513

Hi,

Use like this

select * from mara into it_mara

up to 1 rows

where matnr = '000000000100000174'.

append it_mara.

endselect.

If its useful reward points

Read only

rainer_hbenthal
Active Contributor
0 Likes
514

In a relational database no "first" record exists. first second last is only relevant if you do a sorting. Just using package size or up to n rows is not sufficient, you need a sort to tell if you need the two actual values (sorting by date) or whatever. Without having a sort in the select clause you can not assure what values are the first ones.