The Best Run Businesses Run SAP!
SAP has a popular tagline of ‘The best run businesses run SAP’. Indeed, businesses run best with SAP and it is the very reason why SAP is the best ERP in the world. One such area is to monitor attendance of employees. Recording attendance can help us do time evaluation for employees and manage our resources more effectively. We always have emphasis to ensure effective output by our workforce and positive time management is one such way to achieve that. In this blog we will summarize how we can effectively record attendance with seamless integration of SAP to external system’s time machine.
There are multiple ways to integrate time machine with SAP. We can use web services or process integration; however, the most cost effective and simple solution is to use Database connection. Using database connection, we can access employee punch records directly and effectively. We must perform different one-time activities to build up our desired solution.
All time machines have a database at back-end and most popular time machines use MS SQL, however connection with following databases is supported by SAP.
|DB2||DB2 UDB for OS/390|
|DB4||DB2 UDB for AS/400|
|DB6||DB2 UDB for Unix and Windows|
|MSS||Microsoft SQL Server|
|HDB||SAP HANA database|
The setting up of connection is a very powerful tool in standard SAP and it is managed by transaction DBCO. We need to identify the server IP and database name. Along with that we must have a user created in external database with reading authorizations to access records from tables. Once we have all the details available it is just a matter of minutes to create our database connection which is most pivotal part of this integration.
After setting up connection we can test connectivity through program ‘ADBC_TEST_CONNECTION’ in transaction SE38. Once connectivity test is passed, we can proceed with identifying the right tables in external database to write our code.
Accessing attendance records from external database:
We may need assistance from admin of external database to help identifying the right tables containing employee punch information. After identifying the tables we can start building up our program to access records.
Rules to access records from external database are different in comparison to standard ABAP queries. We must follow a specific syntax to establish connection to database and access records and later on closing the connection.
Syntax for opening connection
OPEN dbcur FOR SELECT …
Syntax for accessing records
FETCH NEXT dbcur INTO …
Syntax for closing connection
It is as simple as it can be seen above. The biggest idea is to save the effort and cost that is incurred during using other mediums. The simplicity of this method makes it most attractive and valuable solution. Other ways to do upload this data can be through text files or excel, but that also requires human interaction to do it every time. This way we can schedule a background job and make it an effortless process.
After reading records as per above mentioned way, we can use them in two ways. It all depends on business requirement how we have to use them.
1) Upload in attendance table (Infotype 2011)
2) Upload in timesheet for approval (CAT2 Transaction)
Upload in attendance table (Infotype 2011)
To upload the data in Infotype 2011 for time evaluation, we have to make sure that employees Time recording exists in Infotype 50. If not, we can create and entry in Infotype 50 first. After creating entry in Infotype 50, we have to create attendance entry in Infotype for employee on any specific date. We have two parameters to do that, one is punch-in and the other is punch out. Below are the codes for punch-in and punch-out.
- Punch-in (P10)
- Punch-out (P20)
There are several logics to identify Punch entries if they are more than two, based on business requirements. The most popular way to identify is that first punch is considered as Punch-in and last punch is considered as Punch-out. After identifying the details, we have to use below function module to insert details in Infotype 2011, which will effectively update the TEVEN table. Once the entries are uploaded, they can be seen in HCM through transaction PA20 using Infotype 2011. At the end of the month these entries help HCM Time evaluation.
Function Module: HR_TMW_DB_UPDATE_TEVENT
Upload in time-sheet for approval (CAT2 transaction)
One business requirement is to update timesheet in CAT2 transaction. For updating timesheet, we have to create a Data entry profile first. After creating that we can upload timesheet using below mentioned function modules. The below timesheet entry can be used for approval process. After updating timesheet, we can use the required approval mechanism.
Function Module: BAPI_CATIMESHEETMGR_INSERT
The function module will update the CATSDB table. And further we can use the HCM timesheet functionality as per business requirements.
Using this method for maintenance is very effective and its simplicity is what makes it the best solution for attendance. SAP is all about customer experience and making life of customer easier and at the same time, the quality of solution is always top notch. SAP HCM is a top solution and attendance is core of time management. We can use this convenient way to update attendance by using time machine integration with DB Connection.