Application Development 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: 

how to select specific number of rows from database table

Former Member
0 Kudos

I want to select particular number of rows , say for example I want to select top 500 rows from table without any conditions or filter...

Is it possible in SAP select query ??

In oracle we have the option of selecting TOP 'n' rows from a database table..

Do we have such option in SAP? can we select certain number of rows alone from a table???

any help wud greatly be appreicated !!!!

5 REPLIES 5

ferry_lianto
Active Contributor
0 Kudos

Hi,

Yes, it is ppossible.

You can use SELECT statement with UP TO 500 ROWS.


SELECT <field> 
INTO TABLE <internal table> 
FROM <table> 
UP TO 500 ROWS. 

Regards,

Ferry Lianto

0 Kudos

Thanks for ur solution !!!!

I have one more query ... if possible kindly give me ur suggestions ...

i have a table with millions of records and each record has to be processed.. but.. Im not supposed to load them into internal table at one shot..

Is it possible to load the table by having a count such that 'n' numbr of rows will be loaded and processed and then we move on to next 'n' number of rows from database table and process them??

Is there any such possibility at all in SELECT query???

0 Kudos

Hi Ramya,

Do in this way

    SELECT matnr FROM marc INTO TABLE xmarc
      PACKAGE SIZE 5000 UP TO p_count ROWS
        WHERE matnr IN s_matnr.
      PERFORM process_package.
    ENDSELECT.

<b>Reward Points for helpful answers</b>

Regards,

Satish

ferry_lianto
Active Contributor
0 Kudos

Hi,

Yes, it is possible.

You can use SELECT statement with PACKAGE SIZE as Satish suggested earlier.

Regards,

Ferry Lianto

0 Kudos

Thanks Ferry and Satish ...

Thanks a lot for ur help !!!