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: 

HR selection upto rows issue....

Former Member
0 Kudos

Hello,

I am using following query to select data from HR infotype tables. Now I want to put a restriction that, select the data below only until maximum number defined.

What I mean to say is if someone enters Last name as 'smith' and I define the maximum number as 5, then only 5 personnel number should be fetched, even if there are 50 personnels with same kind of last name. How can I do this with upto rows ?

SELECT aPERNR bNCHMC b~VNAMC

INTO TABLE itab_data

from PA0001 as a

inner join PA0002 as b

on apernr = bpernr

where a~PERNR in S_PERNR

and a~BUKRS in S_BUKRS

and a~KOSTL in S_KOSTL

and a~PERSG in S_EMPGP

and a~PERSK in S_SUBGP

and b~NCHMC in S_LAST

and b~VNAMC in S_FIRST.

Regards,

Jainam.

Moderator message - Pressing F1 on SELECT should resolve your issue - post locked

Edited by: Rob Burbank on Apr 30, 2009 4:29 PM

1 REPLY 1

Former Member
0 Kudos

Hi,

Try this:


SELECT a~PERNR b~NCHMC b~VNAMC
INTO TABLE itab_data
from PA0001 as a
inner join PA0002 as b
on a~pernr = b~pernr
up to 5 rows
where a~PERNR in S_PERNR
and a~BUKRS in S_BUKRS
and a~KOSTL in S_KOSTL
and a~PERSG in S_EMPGP
and a~PERSK in S_SUBGP
and b~NCHMC in S_LAST
and b~VNAMC in S_FIRST.

Thanks,

SKJ