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

Current HR records

Former Member
0 Likes
936

Does anyone see any issues with the following select statements?

I'm trying to retrieve All the current employee records for a specific company code in infotypes: 0000, 0001, 0002, 0006, 0009, 0017, 0105.

With best regards...

p_endda is 12/31/9999

sy-datum is current date

SELECT * FROM pa0001 INTO TABLE gt_0001

WHERE begda <= p_endda

AND endda >= sy-datum

AND bukrs = company_code.

SELECT * FROM pa0000 INTO TABLE gt_0000 FOR ALL ENTRIES IN gt_0001

WHERE pernr = gt_0001-pernr

AND begda <= p_endda

AND endda >= sy-datum.

SELECT * FROM pa0002 INTO TABLE gt_0002 FOR ALL ENTRIES IN gt_0001

WHERE pernr = gt_0001-pernr

AND begda <= p_endda

AND endda >= sy-datum.

SELECT * FROM pa0006 INTO TABLE gt_0006 FOR ALL ENTRIES IN gt_0001

WHERE pernr = gt_0001-pernr

AND begda <= p_endda

AND endda >= sy-datum.

SELECT * FROM pa0009 INTO TABLE gt_0009 FOR ALL ENTRIES IN gt_0001

WHERE pernr = gt_0001-pernr

AND begda <= p_endda

AND endda >= sy-datum.

SELECT * FROM pa0017 INTO TABLE gt_0017 FOR ALL ENTRIES IN gt_0001

WHERE pernr = gt_0001-pernr

AND begda <= p_endda

AND endda >= sy-datum.

SELECT * FROM pa0105 INTO TABLE gt_0105 FOR ALL ENTRIES IN gt_0001

WHERE pernr = gt_0001-pernr

AND begda <= p_endda

AND endda >= sy-datum.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
844

Yes, you're right, I had it backwards. Those selects should work. You should probably check the data in SE16.

3 REPLIES 3
Read only

Former Member
0 Likes
844

Check your date logic. The begin date is not going to be <= 12/31/9999

Read only

0 Likes
844

Shouldn the begda be less than or equal to 12/31/9999

and endda be greater than or equal to the current date?

If employee A has 2 records in pa0001:

1st employee begda 02/01/2007 and endda 05/01/2007

2nd employee begda 05/02/2007 and endda 12/31/9999

Logic for 1 record

begda 02/01/2007 <= 12/31/9999 is true

endda 05/01/2007 >= 09/25/2007 is false so record is not selected

Logic for 2nd record

begda 05/02/2007 <= 12/31/9999 is true

endda 12/31/9999 >= 09/25/2007 is true so record is selected

Does the above seem okay or am I missing something?

Read only

Former Member
0 Likes
845

Yes, you're right, I had it backwards. Those selects should work. You should probably check the data in SE16.