‎2006 Nov 23 6:33 AM
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.
‎2006 Nov 23 6:34 AM
‎2006 Nov 23 6:34 AM
‎2006 Nov 23 6:35 AM
yes, like
Select * from VBAK INTO I_VBAK. upto rows 50.
More details you can take online help.
Regards
Shashi
‎2006 Nov 23 6:35 AM
‎2006 Nov 23 6:35 AM
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
‎2006 Nov 23 6:36 AM
‎2006 Nov 23 6:37 AM
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
‎2006 Nov 23 6:37 AM
HI Deep,
U can use the fallowing statement
Select * from VBAK INTO Table I_VBAK up to 50 rows.
Regards,
Kasi. S
‎2006 Nov 23 6:37 AM
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