2007 Sep 25 6:22 PM
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.
2007 Sep 25 7:50 PM
Yes, you're right, I had it backwards. Those selects should work. You should probably check the data in SE16.
2007 Sep 25 7:07 PM
Check your date logic. The begin date is not going to be <= 12/31/9999
2007 Sep 25 7:34 PM
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?
2007 Sep 25 7:50 PM
Yes, you're right, I had it backwards. Those selects should work. You should probably check the data in SE16.