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: 

Select amount of Absence leave within a specified time period

abap_user
Explorer
0 Kudos

HI ABAPers,

I am creating a Report which takes in a begda and an endda, one of the methods needs to return the amount of unpaid absence leave taken (PA2001) within the selected time period.

The problem is, if I select for example 01.01.2021-30.11.2021 and there is somebody with an unpaid absence from 01.06.2021 - 31.12.2021, the following SQL Statement will return the amount of absence within the whole time period he is absent, not just for the dates selected:

   SELECT begda, endda, abwtg FROM pa2001 INTO TABLE @DATA(other_unpaid_leave) WHERE pernr = @pernr AND ( ( subty = '0620' ) OR ( subty = '0600' ) OR ( subty = '0601' ) )
AND ( ( begda >= @begda AND endda <= @endda ) " Sickleave between given dates
OR ( begda <= @begda AND endda <= @endda AND begda >= @endda ) " Sickleave starts before given date, ends during given dates
OR ( begda >= @begda AND endda >= @endda AND begda < @endda ) ).

I need to be able to return the amount of "workdays" within the period, without accounting for Bank/National holidays. Does anybody have a suggestion?

1 ACCEPTED SOLUTION

Aditya_SF
Discoverer
0 Kudos

Hi Jonas,

You need to get the data from Time Evaluation Results. Transaction PT66. You can use the function module HR_TIME_RESULTS_IN_INTERVAL. You can get the data directly from PA2001 if date lies within the date range of selection criteria. If any date range of unpaid leave overlaps with the Begda and endda of selection criteia, then get the absence data by using this function module.

Thanks,

Aditya.

2 REPLIES 2

Aditya_SF
Discoverer
0 Kudos

Hi Jonas,

You need to get the data from Time Evaluation Results. Transaction PT66. You can use the function module HR_TIME_RESULTS_IN_INTERVAL. You can get the data directly from PA2001 if date lies within the date range of selection criteria. If any date range of unpaid leave overlaps with the Begda and endda of selection criteia, then get the absence data by using this function module.

Thanks,

Aditya.

Aditya_SF
Discoverer
0 Kudos

Hi Jonas,

You need to get the data from Time Evaluation Results. Transaction PT66. You can use the function module HR_TIME_RESULTS_IN_INTERVAL. You can get the data directly from PA2001 if date lies within the date range of selection criteria. If any date range of unpaid leave overlaps with the Begda and endda of selection criteia, then get the absence data by using this function module.

Thanks,

Aditya.