‎2007 Feb 23 9:04 AM
Hi,
I have a select statement to get the records based on some condition. I got say 1000 records. Now i need this selection for only first 250 records. Can we restict the select statement to get only the first 250 records. If so pls let me know the code how to write the select statement.
Also i don't want the code between select and endselect.
Regards,
Ramesh
‎2007 Feb 23 9:05 AM
‎2007 Feb 23 9:06 AM
Hello,
SELECT * FROM MARA
UP TO 250 rows.
This will select only frist 250 rows.
VAsanth
‎2007 Feb 23 9:14 AM
Hi,
The thing is if i give up to N rows its checking the table for the first 250 records only. But i have my data in around 1000th record in the table. Here its not getting this field for my condition given.
For example if i got some around 1000 records for the select condition, i need only firat 250 records of this.
Regards,
Ramesh
‎2007 Feb 23 9:17 AM
‎2007 Feb 23 9:18 AM
SELECT * FROM MARA
INTO itab
UP TO 250 rows
WHERE xxxxxxxxDATA itab TYPE SCUSTOM.
SELECT * FROM SCUSTOM INTO TABLE itab
UP TO 3 ROWS
WHERE CUSTTYPE = 'B'
ORDER BY DISCOUNT DESCENDING.
WRITE: / WA_SCUSTOM-ID, WA_SCUSTOM-NAME, WA_SCUSTOM-DISCOUNT.
ENDSELECT.
Use <b>order by field</b>, hope this solves.
‎2007 Feb 23 9:07 AM
‎2007 Feb 23 9:08 AM
YOu have to use select * from <table> up to 250 rows into wa where..
endselect.
If you want to restrict the number or records you have to use the endselect.
Other wise, you have to move the data that is selected into another internal table.
loop at itab from 1 to 250.
move-corresponding itab to itab_new.
append itab_new.
endloop.
Regards,
Ravi
‎2007 Feb 23 9:08 AM
hi ramesh,
do this way ..
select * from mara into table it_mara where <conditions>.
if sy-subrc = 0.
loop at it_mara.
lv_tabix = sy-tabix.
if lv_tabix > '250'.
delete it_mara index sy-tabix.
endif.
endloop.
endif.Regards,
santosh
Message was edited by:
Santosh Kumar Patha
‎2007 Feb 23 9:09 AM
‎2007 Feb 23 9:24 AM
Hi,
SELECT * FROM VBAK
INTO IT_TAB
UP TO 250 ROWS.
reward if useful.