‎2008 Jan 24 11:57 AM
HOW TO WRITE A SINGLE SELECT STATEMENT TO RETRIEVE "PERNR FROM PA0001", "NACHN , VORNA FROM PA0002"?
‎2008 Jan 24 12:04 PM
Hi KRITHIGA APPADURAI,
Do You want to join for these two tables?
Plzz reward if it is useful,
Mahi.
‎2008 Jan 24 12:01 PM
performancewise it is not advisable to use single select for fetching data from these 2 tables...
use 2 selects
select pernr
from pa0001 into table it_0001
where pernr in s_pernr
and begda le s_date-high
and endda ge s_date-low.
if sy-subrc = 0.
sort it_0001 by pernr endda descending.
delete adjacent duplicates from it_0001 comparing pernr.
endif.
if not it_0001[] is initial.
select vorna nachn from pa0002 into table it_0002 for all entries in it_0001 where pernr = it_0001-pernr and endda = '99991231'.
if sy-subrc = 0.
sort it_0002 by pernr.
endif.
endif.
‎2008 Jan 24 12:04 PM
Hi KRITHIGA APPADURAI,
Do You want to join for these two tables?
Plzz reward if it is useful,
Mahi.
‎2008 Jan 24 12:04 PM
Hi Krithiga
I belive if you want to retrieve just NACHN and VORNA, it is already present in PA0001 itself. The ENAME is the concatenation of VORNA, NACHN and TITEL from PA0002, may be you can look at the option of splitting after getting from PA0001.
Regards
Ranganath
PS : Reward points for all useful answers !
‎2008 Jan 24 12:05 PM
Hi krithiga,
use joins as we hav only two tables...
select p1pernr p2nachn p2vorna from pa0001 as p1 join pa0002 as p2 on p1pernr = p2~pernr .
pls reward if helps,
regards.
‎2008 Jan 24 12:20 PM
> select p1pernr p2nachn p2vorna from pa0001 as p1 join pa0002 as p2 on p1pernr =
> p2~pernr .
What sense does this join makes having pernr in pa0002 and selecting nothing else but pernr from pa0001?
‎2008 Jan 24 12:17 PM
Thats not as easy as you might thought. You have to take the date ranges into account, personal subarea may have changed more often then your last name. Thats why the logical database PNP is used very often doing a provide on the records.
if you just need actual lastname and firstname you dont need to read anything from pa0001, you can just do a select on pa0002 using a where clause with pernr and endda = 99991231
Your statement is a little bit unclear, you do not need pa0001 for pernr, its in pa0002 too.