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

Regarding SELECT statement

Former Member
0 Likes
854

Hi All,

I have a question regarding SELECT statement in ABAP.

Can we restrict number of rows to be fetched from SELECT statement.

Ex: Select * from VBAK INTO I_VBAK.

Suppose i want to restrict above statement to fetch only 50 rows is it possible!

I don't want to fetch all the data and then delete rows more than 50 i want to restrict in Select statement itself.

Thanks in advance.

Thanks.

Deep.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
829

used <b>upto 50 rows..</b>

8 REPLIES 8
Read only

Former Member
0 Likes
830

used <b>upto 50 rows..</b>

Read only

Former Member
0 Likes
829

yes, like

Select * from VBAK INTO I_VBAK. upto rows 50.

More details you can take online help.

Regards

Shashi

Read only

Former Member
0 Likes
829

SELECT *

FROM VBAK

INTO TABLE T_VBAK

<b> UP TO 50 ROWS.</b>

Read only

anversha_s
Active Contributor
0 Likes
829

hi,

chk this.

Report Z_Difference 
Message-id 38 
Line-Size 80 
Line-Count 0 
No Standard Page Heading. 
* 
Start-Of-Selection. 
 
Data: w_Single type Posnr, 
t_Rows type standard table of Posnr 
initial size 0 
with header line. 
* 

Select Posnr 
into table t_Rows 
from zDifference 
up to 50 rows 
order by Posnr descending. 
* 

Write :/ 'Up to 1 rows :'. 

Loop at t_Rows. 
Write t_Rows. 
EndLoop.

rgds

anver

Read only

Former Member
0 Likes
829

Select * from vbak into table i_vbak up to 50 rows.

Read only

Former Member
0 Likes
829

hi,

Please see the following.

report znave_0001.

data: begin of itab occurs 0,

matnr type mara-matnr,

maktx type makt-maktx,

end of itab.

<b>parameters: p_rows type i.</b>

select maramatnr maktmaktx into table itab from mara

inner join makt on maramatnr = maktmatnr <b>up to p_rows rows</b>.

loop at itab.

write:/ itab-matnr, itab-maktx.

endloop.

OR

Select * from VBAK INTO I_VBAK upto 50 rows .

Naveen

Read only

Former Member
0 Likes
829

HI Deep,

U can use the fallowing statement

Select * from VBAK INTO Table I_VBAK up to 50 rows.

Regards,

Kasi. S

Read only

0 Likes
829

Hi Deep,

U cud use 'UP TO 50 ROWS' in ur select query. Check the following code.

DATA: WA_SCUSTOM TYPE SCUSTOM.

SELECT * FROM SCUSTOM INTO WA_SCUSTOM UP TO 50 ROWS

WHERE CUSTTYPE = 'B'

ORDER BY DISCOUNT DESCENDING.

WRITE: / WA_SCUSTOM-ID, WA_SCUSTOM-NAME,

WA_SCUSTOM-DISCOUNT.

ENDSELECT.

Regards,

Johnson