‎2010 May 10 7:18 AM
I hae written below code in abap hr ,when executed it gives wrong data .
tables : PERNR.
infotypes : 0000,0001,0002.
start-of-selection.
Get PERNR.
PROVIDE * FROM p0000
FROM P0001
FROM P0002
BETWEEN PN-BEGDA AND PN-ENDDA.
.
write : / p0000-begda , p0001-begda, p0002-begda .
endprovide.
Kindly let me know what the issue is .
all the above output dates from write statement are incorrect.
In the selection criteria, i have given only the emloyee number .
Regards,
Rachel
‎2010 May 10 8:03 AM
Rachel,
With provide statement you get a join made on querying tables, which means there are new periods created as a result of all the records from these tables. Please refer the below for example
P0000
'----first_record----'--------second record------------'.
P0001
'--first rec---'------sec.rec.----------'------third rec---'.
Result in provide
'--first-------'--sec-'----third---------'------fourth------'
So in your example you got different results in provide as this is simply a join of all these tables. That's why you see something different from what is in the system (or tables themselves). If you wan to have exact records as they appear in the system use loop instead, but provide gives the opportunity to identify these small chunks of data where records overlaps in time.
Hope this is clear
Marcin
‎2010 May 10 9:12 AM
Rachel,
Post your requirement... if Requirement is there people can guide you better.....
Yes thats not a best practice infact ....Try with 2 inner joins you can understand the diffenrence
Regards
sas
Try by passing PN-BEGDA = PN-ENDDA.
‎2010 May 12 7:44 AM
Hi ,
I am currently giving employee number and dates in PN-BEGDA AND PN-ENDDA.
Even then i am getting wrong output.
I have written write statement , p0001-begda & p0002-begda both displays same date.
TABLES: PERNR.
INFOTYPES: 0001, "Organizational Assignment
0002, "Personal Data
0006. "Addresses
GET PERNR.
PROVIDE * FROM P0001
FROM P0002
BETWEEN PN-BEGDA AND PN-ENDDA.
WRITE: / p0001-begda , p0002-begda.
ENDPROVIDE.
‎2010 May 12 7:57 AM
Rachel,
You will receive that result. Within PROVIDE ... ENDPROVIDE begda and endda of all the table entries will be restrcited to given dates PN-BEGDA and PN-ENDDA .
So if you have period
PN-BEGDA = 01.04.2010
PN-ENDDA = 31.04.2010
and you have entries in tables like
P0001: 06.03.2008 - 31.12.9999
P0002: 07.04.2009 - 06.04.2010, 07.04.2010 - 31.12.9999
the both table begda and eddna will be restrcited to period given in pn-begda and pn-endda like
P0001: 01.04.2010 - 31.04.2010
P0002: 01.04.2010 - 06.04.2010, 07.04.2010 - 31.04.2010
which means that the records in p0001 and p0002 are bound to dates given in between . This is beacause the system assumes you are interested only in that period, so it provides you only the actuall state of employee within that period.
Regards
Marcin
‎2010 May 12 11:12 AM
table: pa0000
ENDDA BEGDA
31.12.2004 15.11.2004
14.11.2005 01.01.2005
27.08.2007 15.11.2005
31.03.2009 28.08.2007
14.09.2009 01.04.2009
31.12.9999 15.09.2009
table : pa0001
31.12.2004 15.11.2004
14.11.2005 01.01.2005
27.08.2007 15.11.2005
31.03.2009 28.08.2007
14.09.2009 01.04.2009
31.12.9999 15.09.2009
table : pa0002
pernr endda begda
00001111 31.12.9999 20.01.1989
SELECT DISTINCT apernr asname aename abegda a~endda
bstat2 bmassn b~massg
cgbdat cbegda
into TABLE itab_emp
FROM ( ( pa0001 AS a
INNER JOIN pa0000 AS b ON apernr = bpernr )
INNER JOIN pa0002 AS c ON apernr = cpernr )
WHERE a~pernr = 1111
AND b~massn <> '03'
AND a~begda <= sy-datum
AND a~endda >= sy-datum
AND b~begda <= sy-datum
AND b~endda >= sy-datum
AND c~endda = '99991231'.
Output :
pernr pa0001-begda pa0001-endda pa0002-begda
00001111 15.09.2009 31.12.9999 20.01.1989
using the above select statement i am getting the proper output .
How can i achieve the same using provide endprovide .
Regards,
Rachel
Edited by: Rachel on May 12, 2010 12:13 PM
‎2010 May 12 11:44 AM
If you want it like that then provide statment does not make sense here. You can simply use loop to achieve that, but with provide you won't get that result. It's for different purpose.
TABLES: pernr.
INFOTYPES: 0001,
0002.
GET pernr.
LOOP AT p0001 WHERE begda <= pn-endda
AND endda >= pn-begda.
LOOP AT p0002 WHERE begda <= p0001-endda
AND endda >= p0001-begda.
WRITE: / p0001-begda , p0001-endda,
/ p0002-begda, p0002-endda.
ENDLOOP.
ENDLOOP.
Regards
Marcin