Enterprise Resource Planning Blogs by Members
Gain new perspectives and knowledge about enterprise resource planning in blog posts from community members. Share your own comments and ERP insights today!
cancel
Showing results for 
Search instead for 
Did you mean: 
parag_parikh
Participant

SAP leave request enables employees and managers to perform all the tasks they need to manage leave requests and other absences. SAP leave request data is stored in different transparent table and not in SAP time infotype tables  ( like PA2001, PA2002, PA2003 ) and CATS database table CATSDB.


In an application landscape where all three applications are running in parallel, this pauses some challenges in synchronizing all three databases. I describe here approach we took in recent implementation. I wish for more inputs on this scenario in form on limitations / advantages of method we adopted which will help community. :smile:


Transfer leave application data to HR time infotype tables.

Use program RPTARQPOST. This program reads leave request data and updates PA2001 accordingly. For example if the employee has approved leave from 1st July 2014 till 5th July 2014, the program will create one entry in PA2001 from 1st July 2014 till 5th July 2014. Scheduling this program on daily or periodic basis is not an ideal solution as in that case HR infotypes will not be updated in real time with leave data but rather will be updated after delays depending on program schedule. We called a SUBMIT statement in the method we used to define final step in leave approval workflow to update database.

*** Call report RPTARQPOST to transfer data to infotype PA2001 if any

  SUBMIT rptarqpost WITH ppernr = ls_leave_data-owner-pernr

                    WITH ign = 'X' AND RETURN.

In the above statement, IGN = 'X' instructs program to send approved leaves only to HR time infotypes.


Transfer leave application data to CATSDB.


Use BAPI_CATIMESHEETMGR_INSERT to update CATSDB. Key points to note here are,


1) Leave request data is not stored in leave tables daywise. Example, for a 5 days leave, there will not be a separate entry in leave tables ( one per day ). Whereas in CATSDB  table, the data is stored per day as it is time sheet data.

2) SAP application automatically corrects incorrect hours for multi-days leave applied. For example, if an employee's work schedule for 8 consecutive days, starting from 1st March 2014 is 6, 12, 12, 10, 10, 10, 10, 10 hours, a leave applied by him/her from 1st March to 8 March will accumulate to a total of 80 hours of leave per work schedule. Leave ours less than or greater than 80 hours will be corrected back to 80 hours by SAP standard application. SAP leave application also takes into account substitutions ( PA2003 ) when performing above checks.

3) For a single day leave, employee can book either half day or full day of absence depending on company policy. However standard application will not stop employee to enter 6 hours of leave for an 8 hour working day.

4) Employee or his supervisor can edit or delete an already approved leave.  This includes scenario where employee may extend his leave, prepone his leave, increase or decrease number of days of leaves.

The logic to update CATSDB and distribute leave hours per day in CATSDB should be developed accordingly. In case of leave deletion scenario, BAPI_CATIMESHEETMGR_DELETE is useful. New entries in CATSDB should be created with status 30 ( Approved ). For any new changes to approved leave, first delete existing records ( no physical deletion but marking status of CATSDB entry to 60 using BAPI ) and then create new entries. When deleting existing entry, read existing entry ( specifically counter ) using BAPI_CATIMESHEETRECORD_GETLIST.

To read employee's work schedule use FM HR_PERSONAL_WORK_SCHEDULE. This FM also takes into account substitutions when returning the work schedule. It is useful in determining how to distribute leave hours per day.

Above BAPIs can be called inside workflow step for data update.

Why not update CATSDB first and then run CAT6 to transfer CATSDB data to HR infotypes?

CAT6 is meant to move timesheet data to HR infotypes and not the leave data. As in the CATSDB table, entries are stored per day, taking this approach will create multiple entries in PA2001 for each day of leave and as a result employee will see multiple rows in leave request ( for example 5 rows for 5 days leave applied ). This is inconvenient and inaccurate as application will show each day as a separate leave.

What if there are some absences which are entered directly from CATS and not from leave application? Will running CAT6 in such scenario effect PA2001 entries?

If some A/A type is entered directly in CATS and subsequently CAT6 is run to update HR data, it will overwrite existing PA2001 entries created by RPTARQPOST. Unfortunately SAP has not provided a selection criteria on CAT6 to allow transfer of selective A/A types.

To avoid CAT6 from picking entries created using BAPI, in workflow method to update CATSDB, we changed status of entries created by BAPI to '1' i.e. transferred. Updating staging table PTEX2000 in this manner ensured that CAT6 does not selects entries updated by BAPI from leave approval workflow.

ptex2000-statu2 = '1'.

ptex2000-statu3 = '1'.

9 Comments
Labels in this area