HR Abap PDF

Download as pdf or txt
Download as pdf or txt
You are on page 1of 72

HR ABAP

Table of Content

1 OBJECTIVE .................................................................2
2 HR ABAP PROGRAMMING ............................................2
2.1 Concepts in HR Programming ............................................. 2
2.1.1 Overview & Features in HR Programming ........................................................... 2
2.1.2 Difference from conventional ABAP ....................................................................... 2
2.1.3 Overview of PA/PD/& Integration between PA & PD........................................ 2
2.1.4 Concepts of Infotypes (Structure/Processing etc.) ............................................ 5
2.1.5 Concepts of Clusters (Import/Export etc.), cluster directory ........................ 9
2.1.6 Concepts of Macros (Import/Export etc.) ........................................................... 13
2.1.7 Retrieval of data using LDBs (PNP/PAP/APP/PCH) without LDBs. .......... 19
2.2 Personnel Administration (PA) .......................................... 20
2.2.1 Importance of Dates and periods in payroll ...................................................... 22
2.2.2 Overview of date fields and period-Ex. for period/in-period/ payroll ....... 23
2.2.3 Repetitive Structures processing .......................................................................... 24
2.2.4 Guidelines to retrieve Payroll data (Mainly US/UK/Ireland) ....................... 25
2.2.5 Retroactive accounting/ Retroactive pay calculation ..................................... 33
2.2.6 Time Management...................................................................................................... 34
2.2.7 Guidelines to retrieve Time data ........................................................................... 39
2.2.8 Benefits.......................................................................................................................... 42
2.2.9 Case Studies ................................................................................................................ 49
2.3 Utilities: ........................................................................... 49
2.3.1 List of standard Commands for Macros/ infotyes etc.................................... 49
2.3.2 HR Standard Reporting tools ................................................................................. 50
2.3.3 FAQ, Hints, Tips and tricks in HR, Do & not to do (Warnings)................... 52
2.3.4 List of HR tables & Transactions .......................................................................... 58
2.3.5 List of Standard Reports, Function modules & Utilities available ............. 58
2.3.6 Available Enhancements/User exists.................................................................. 60
2.3.7 Report assignment category/ Customising Report Selection Screens...... 62
2.3.8 Authorization checks ................................................................................................ 65
2.3.9 Views/Join/Projection.............................................................................................. 66
2.3.10 Case Studies ................................................................................................................ 72
HR-ABAP

1 Objective
The Purpose of this document is to:

2 HR ABAP Programming
2.1 Concepts in HR Programming
2.1.1 Overview & Features in HR Programming
The aim in the Human Resources component is to be able to process employee
related data according to business requirements in an effective structure.
The Human Resources module uses a system of data grouped together called
infotypes.
Infotypes mirror a quantity of connected data records; infotypes are identifiable
through a four character numerical string [e.g. infotype Addresses (0006)] and a
complete listing is included.
You can save the infotypes as time-dependent to enable a retroactive evaluation of
Employee data
The infotypes appear as an entry screen for the user, through which you can
maintain infotype records. Infotypes can be processed individually or in fast entry
mode.

2.1.2 Difference from conventional ABAP

Advanced Business Application Programming ABAP is SAP's fourth generation


language. All of R/3's applications and even parts of its basic system are developed
in ABAP. ABAP is used for customization and modification of SAP applications.

In HR ABAP use of select statements significantly less than in other areas of ABAP
development, Logical databases have limited applications in other modules but are
very useful in HR. Also, you really need to understand the infotype time constraint
concept, When you cannot get the information that you need out of the logical DB
look at the function modules starting with HR* and RH*. These function modules will
provide you with multiple ways of accessing data to save time. Worst-case scenario,
use a select statement.

2.1.3 Overview of PA/PD/& Integration between PA & PD

This explains how to use the ABAP programs, which set integration between PA and
PD/OM. They are mainly used after data conversion, bulk updates or to correct
errors caused by other programs.

Page 2 of 72
HR-ABAP
Each program is explained in detail so you can decide which ones you need to run.
To set up/fix full integration between PA and PD, they should be run in this
sequence:

1. RHINTE00 – Transfer PA records into PD positions –batch


2. RHINTE20 – Create OM objects in PA tables – Online
3. RHINTE30 – Bulk update of infotype 0001
4. RHINTECHECK – Program to check PA to PD
5. RHCHECKV - Checks all inverse relationships

Overview

It is important to realize that in PA, there are tables that contain objects from OM,
i.e. for those items displayed on infotype 0001 Organizational Assignment.
Sometimes the tables can get ‘out of step’ with those in PD – table HRP1000.

The tables are:


T513, T513S Object type C (Job)
T528B, T528T Object types S (Position) and A (Work center)
T527X Object type O (Organizational unit)

RHINTE00
This loops through all employees in PA by looking at positions on infotype 0001. It
checks the corresponding person to position relationship exists in PD (A008), if not it
is created.

RHINTE10
Generally, the program RHINTE20 will be used instead of this one. This program
loops through the PD table HRP1000. For each job, position, work centre and
organization unit, corresponding entry is created in the PA tables, which are shown
above. Run this with evaluation path o_s_p, which runs through Org units, jobs and
positions or find a suitable alternative if you wish to update work centers also. The
main difference with this program as opposed to RHINTE20 is that this one has the
option to delete items from the PA tables, which no longer exist in PD.

RHINTE20
This program loops through the PD table HRP1000. For each job, position, work
centre and organization unit, corresponding entry is created in the PA tables, which
are shown above. Run this with evaluation path o_s_p, which runs through Org
units, jobs and positions or find a suitable alternative if you wish to update work
centers also. An example output will show:

Page 3 of 72
HR-ABAP

Expand the tree items to display a list of objects that can be created:

RHINTECHECK
When the above programs have been run, use this check program, which looks
through all employees and reports any inconsistencies found between PA and PD.

Tick each item that you wish to be created, or click on the text

and click ‘select subtree’ to select them all then click to perform

Page 4 of 72
HR-ABAP
multiple updates. This program can prove to be ‘problematic’. If difficulties arise
with it, try using RHINTE10 instead.

RHINTE30
This will create an infotype 0001 record with correct entries for org unit, job,
position and work centre by looking through the organization structure. It creates a
batch job, which must be run via SM35. More details to follow.

RHCHECKV
This will check inverse relationships and create missing ones.

2.1.4 Concepts of Infotypes (Structure/Processing etc.)

Infotypes:

An infotype represents a group of related data fields, provides information


structure, facilitates data entry, and allows time dependent storage.
In other words we can say infotypes are information units used to enter the
time dependent data of the employee.
Master data in HR is stored in infotypes. Each infotype pertains to a specific
type of data.
Each infotype has a database table associated with it.
Time constraints: Enable you to determine how the validity periods of infotype data
records interact

• Time constraint 1: Exactly one valid data record of the infotype in question must
exist for the entire time that the employee belongs to the enterprise.

• Time constraint 2: No more than one valid data record of the infotype in question
can exist at any one time.

• Time constraint 3: Any number of valid data records of the infotype in question can
exist at any one time.

The prerequisites for the existence of a personnel or applicant number are infotypes
0000 Actions, 0001 Organizational Assignment, 0002 Personal Data, and 0003
Payroll Status.

Transparent tables for infotype


Each infotype has a transparent table. Each logical field for an infotype has a
corresponding physical field on the database.
One physical table is stored on the database for each transparent table. The names
of the physical table and logical table definition in the Dictionary are compatible.
The following naming convention applies to infotype tables; nnnn stands for the
infotype number:

Page 5 of 72
HR-ABAP
• PAnnnn for transparent tables in Personnel Administration
• PBnnnn for transparent tables in Recruitment
• HRPnnnn for transparent tables in Personnel Planning
Example: For Infotype 0000, the corresponding database table associated with it is
PA0000

Check and Control Tables for HR Infotypes

T777D

T77ID

T582A T77CD

• Table T777D Infotypes - Dialog/Database Assignment is the central check table


(domain INFOTYP) for all HR infotypes (Administration and planning infotypes). It is
used to store the names of all infotype-dependent repository objects (tables,
structures, programs, and so on).

• Table T77ID Infotypes: Enhancements to T777D is simply an enhancement of table


T777D that exists for reasons of memory space.

• Table T582A Infotypes - Customer-Specific Settings is used for customer settings in


Administration infotypes.

• Table T77CD Infotypes - Customer-Specific Settings is used for customer settings in


planning infotypes.

The primary key of transparent table PAnnnn consists of the following key fields:
• PERNR: the personnel number is the only unique key within a client for identifying
an employee. It is used to access the display and maintenance screens for an
employee’s master data and working time data (infotypes).
• SUBTY: subtypes are subdivisions of infotypes. An infotype’s subtypes can have
different time constraints and form their own histories.
• OBJPS: the object identification is used to make a distinction between records with
the same infotype, subtype, lock indicator, start date, and end date. For example,
the child number in infotype 0021 Family/Related Person.
• SPRPS: the lock indicator for HR master data is used to lock and unlock data
records, which enables the “double verification principle” to be put into practice. In

Page 6 of 72
HR-ABAP
accordance with this principle, at least two users are involved in the process of
writing an active data record to the database. One of the users creates a locked
infotype record, and the other user unlocks - that is, activates - the data record.
• ENDDA: end date.
• BEGDA: start date.
• SEQNR: The Sequential Number is used to make a distinction between infotype
records that have the same key and time constraint '3' (any number of valid infotype
data records at any one time). Unlike the object identification, it is assigned by the
system automatically.

Structure:
The Data Dictionary contains a Pnnnn structure for each infotype nnnn. The
infotype structure Pnnnn corresponds to the table PAnnnn. The Pnnnn structure of
the infotype is used as the field structure for the infotype entry screen (Transaction
code PA30).

Basic form of an infotype:


Infotypes nnnn [name c] [occurs m] [mode n] [valid from comp1 to comp2].
nnnn can be 0000 to 9999.

0000 – 0999 are HR Master Data infotypes.


1000 – 1999 are HR Planning data infotypes.
2000 – 2999 are HR time data infotypes.
3000 – 8999 are not used
9000 – 9999 are used for the custom infotypes

Effect of the above syntax is

It creates an internal table as below...

DATA BEGIN OF c OCCURS m.


INCLUDE STRUCTURE Pnnnn.
DATA END OF c VALID BETWEEN comp1 AND comp2

• If name option is not given in the syntax then the internal table will be created
with the name p<nnnn>
• If occurs clause in not given then the size of an internal table would be 10 * size
of the structure pnnnn. That is in the place of ‘m’ it would be 10.
• If valid clause is not given then the comp1 and comp2 values will be 01/01/1800
and 31/12/9999 respectively.
• Mode n this clause can only be used with the LDB’s PCH and PNP. This addition
stops this infotype being automatically filled at the GET PERNR command.

The infotype records can be processed using the infotype structure when the report
is run.

Processing Infotypes
Processing Single Infotype Record

Page 7 of 72
HR-ABAP
We can process the Single records of an infotype using the following
macros.

1. RP_PROVIDE_FROM_LAST Pnnnn SPACE PN-BEGDA PN-ENDDA.


This macro is used to retrieve the most recent record in the PN-BEGDA and
PN-ENDDA data selection period available in the structure Pnnnn for infotype nnnn
2. RP_PROVIDE_FROM_FIRST Pnnnn SPACE PN-BEGDA PN-ENDDA
This macro retrieves the earliest record for the given selection period.
If the infotype has subtypes, then replace SPACE with the subtype so, the data is
retrieved based on that subtype. If the retrieval is successful then the return code
PNP-SW-FOUND will be ‘1’.
Processing All Infotype Records

Processing of infotype records is time-dependent; by this we mean dependent on the


data selection period entered on the selection screen. The data of several infotypes
can be processed at the same time and made available for a specific partial period

To process all records of internal tables of an infotypes we use the PROVIDE


statement

Syntax:
PROVIDE * FROM Pnnnn BETWEEN PN-BEGDA AND PN-ENDDA.
ENDPROVIDE

nnnn stands for 4-digit infotype number. The relationship between the data and
the selection period is established using the PN-BEGDA and PN- ENDDA variables.

Infotype List

Infotype Infotype Text Description


Number
0000 Actions
0001 Organizational Assignment
0002 Personal Data
0004 Challenge
0006 Addresses
0007 Planned Working Time
0008 Basic Pay
0009 Bank Details
0013 Social Insurance Deductions
0014 Recurring Payments/Deds
0015 Additional Payments
0019 Monitoring of Dates
0021 Family/Related Person
0022 Education
0025 Appraisals
0034 Corporate Function
0035 Company Instructions
0040 Objects on Loan
0041 Date Specifications

Page 8 of 72
HR-ABAP
0048 Residence Status
0077 Additional Personal Data
0094 Residence Status
0105 Communication
0167 Health Plans
0168 Insurance Plans
0169 Savings Plans
0170 Flexible Spending Accounts
0171 General Benefits Information
0172 FSA Claims
0207 Residence Tax Area
0208 Work Tax Area
0209 Unemployment State
0210 Withholding info W4/W5 US
0377 Miscellaneous Plans
0378 Adjustment Reasons
9001 DOD/MWR Specific Data
9002 Payroll Import Data
9003 Retirement Plan Data at Termination
9005 KRONOS Information

2.1.5 Concepts of Clusters (Import/Export etc.), cluster directory


Definition

Each database object, for example, PCL1 or PCL2, with the type Import/Export file
consists of related areas. These areas are known as clusters, for example. RX, RD.
Cluster objects are dependent on the super ordinate database object.

Cluster objects RX, RD, B2 can be selected for the database PCL2. If the database
object has the type master data then there will be no cluster object.

Import/Export files

They are 4 types of files.


• PCL1: Basis for HR Work area data. Contains information from time data
recording.
• PCL2: Contains derived information like payroll results and generated payroll
schemas.
• PCL3: Contains Applicant Data
• PCL4: Contains change documents for HR master data and recruitment.

Importing and Exporting of data is managed with the commands IMPORT and
EXPORT These commands store objects such as fields, field strings, or internal tables
on the database, or read these from the database. Data is read from and written to
the database using a unique key. RMAC provides two macros for importing and
exporting data RP-IMP-Cn-xx and RP-EXP-Cn-xx; only these macros should be used.

Export Cluster data using standard include.

Page 9 of 72
HR-ABAP
o The EXPORT command causes one or more 'xy' KEY data objects to be written to
cluster xy.
o The cluster definition is integrated with the INCLUDE statement.

REPORT ZHREXPRT.
TABLES: PCLn.
INCLUDE: RPCnxxy0. "Cluster definition
* Fill cluster KEY
xy-key-field = <value>.
* Fill data object
....
* Export record
EXPORT TABLE1 TO DATABASE PCLn (xy) ID xy-KEY.
IF SY-SUBRC EQ 0.
WRITE: / 'Update successful'.
ENDIF.

Export Cluster data using the macro


. Export data using macro RP-EXP-Cn-xy.
· When data records are exported using macro, they are not written to the
database but to a main memory buffer.
· To save data, use the PREPARE_UPDATE routine with the USING parameter 'V'.

REPORT ZHREXPRT.
*Buffer definition
INCLUDE RPPPXD00. INCLUDE RPPPXM00. "Buffer management
DATA: BEGIN OF COMMON PART 'BUFFER'.
INCLUDE RPPPXD10.
DATA: END OF COMMON PART 'BUFFER'.
...
RP-EXP-Cn-xy.
IF SY-SUBRC EQ 0.
PERFORM PREPARE_UPDATE USING ‘V’.
ENDIF.

Importing Cluster Data using standard include

• The IMPORT command causes data objects with the specified key values to be
read from PCLn.
• If the import is successful, SY-SUBRC is 0; if not, it is 4.

REPORT RPIMPORT.
TABLES: PCLn.
INCLUDE RPCnxxy0. "Cluster definition

* Fill cluster Key

* Import record
IMPORT TABLE1 FROM DATABASE PCLn (xy) ID xy-KEY.
IF SY-SUBRC EQ 0.

Page 10 of 72
HR-ABAP
* Display data object
ENDIF.

Importing Cluster data using Macro

• Import data using macro RP-IMP-Cn-xy.


• Check return code SY-SUBRC. If 0, it is successful. If 4, error.
• Need include buffer management routines RPPPXM00

Example

REPORT RPIMPORT.
*Buffer definition
INCLUDE RPPPXD00.
DATA: BEGIN OF COMMON PART 'BUFFER'.
INCLUDE RPPPXD10.
DATA: END OF COMMON PART 'BUFFER'.
*Import data to buffer
RP-IMP-Cn-xy.
....
*Buffer management routines
INCLUDE RPPPXM00.

Cluster Authorization
Simple EXPORT/IMPORT statement does not check for cluster authorization.
Use EXPORT/IMPORT via buffer, the buffer management routines check for cluster
authorization.

How to read the Payroll Results

• Payroll results are stored in cluster Rn of PCL2 as field string and internal
tables.
n - Country identifier.
• Standard reports read the results from cluster Rn. Report RPCLSTRn lists all
payroll results;

• Report RPCEDTn0 lists the results on a payroll form.

• The cluster definition of payroll results is stored in two INLCUDE reports:


include: rpc2rx09. "Definition Cluster Ru (I)
include: rpc2ruu0.”Definition Cluster Ru (II)
o This first INCLUDE defines the country-independent part; the second
INCLUDE defines the country-specific part (US).

o The cluster key is stored in the field string RX-KEY.

• All the field string and internal tables stored in PCL2 are defined in the
ABAP/4 dictionary. This allows you to use the same structures in different
definitions and nonetheless maintain data consistency.

Page 11 of 72
HR-ABAP
• The structures for cluster definition comply with the name convention PCnnn
Unfortunately 'nnn' can be any set of alphanumeric characters.

*Key definition
DATA: BEGIN OF RX-KEY.
INCLUDE STRUCTURE PC200.
DATA: END OF RX-KEY.

*Payroll directory
DATA: BEGIN OF RGDIR OCCURS 100.
INCLUDE STRUCTURE PC261.
DATA: END OF RGDIR.

• How to retrieve Payroll results


o To read payroll results, you need two keys: pernr and seqno
o You can get SEQNO by importing the cluster directory (CD) first.

Example

REPORT ZHRIMPRT.
TABLES: PERNR, PCL1, PCL2.
INLCUDE: rpc2cd09. "Definition cluster CD
PARAMETERS: PERSON LIKE PERNR-PERNR.
...
RP-INIT-BUFFER.
*Import cluster Directory
CD-KEY-PERNR = PERNR-PERNR.
RP-IMP-C2-CU.
CHECK SY-SUBRC = 0.
LOOP AT RGDIR.
RX-KEY-PERNR = PERSON.
UNPACK RGDIR-SEQNR TO RX-KEY-SEQNO.
*Import data from PCL2
RP-IMP-C2-RU.

ENDLOOP.

o Reading records from the Payroll directory


after importing the payroll directory, which record to read is up to the
programmer

o Each payroll result has a status.


'P' - previous result
'A' - current (actual) result
'O' - old result
o Function module CD_EVALUATION_PERIODS will restore the payroll
result status for a period when that payroll is initially run. It also will
select all the relevant periods to be evaluated.

Page 12 of 72
HR-ABAP

Example

Call function 'CD_EVALUATION_PERIODS'


exporting
bonus_date = ref_periods-bondt
inper_modif = pn-permo
inper = ref_periods-inper
pay_type = ref_periods-payty
pay_ident = ref_periods-payid
tables
rgdir = rgdir
evpdir = evp
iabkrs = pnpabkrs
exceptions
no_record_found = 1.

Authorization Check
Authorization for Persons
· In the authorization check for persons, the system determines whether the user
has the authorizations required for the organizational features of the employees
selected with GET PERNR.
· Recruits for which the user has no authorization are skipped and appear in a list at
the end of the report.
· Authorization object: 'HR: Master data'

Authorization for Data


· In the authorization check for data, the system determines whether the user is
authorized to read the infotypes specified in the report.
· If the authorization for a particular infotype is missing, the evaluation is terminated
and an error message is displayed.

Deactivating the Authorization Check


· In certain reports, it may be useful to deactivate the authorization check in order to
improve performance. (E.g. when running payroll)
· You can store this information in the object 'HR: Reporting'.

2.1.6 Concepts of Macros (Import/Export etc.)


Macros:

Introduction
Programs that process the cluster data (for example, RX) do not access the cluster
independently. The data is accessed using a defined interface created with macros.

Macro contains some part of source code, which it will be useful for number of
applications. Macro is module, which is stored

Page 13 of 72
HR-ABAP

Naming Conventions of Macro:


RP-aaa-bb-cc

• aaa is the type of Macro. It takes two values


o IMP Import Macro
o EXP Export Macro

• bb is the Database table where the data is saved:


o C1 Database object PCL1
o C2 Database object PCL2
o C3 Database object PCL3
o C4 Database object PCL4
• Cc is the cluster, it may take
o RX Cluster object RX
o RD Cluster object RD
o B2 Cluster object B2 and so on.

Defining and Calling the Macros

Defining:

There are two options for defining the Macros

• Macros are defined using the ABAP Commands DEFINE…. END-OF-


DEFINITION. A macro can be used within a report or within include. If a
macro is used in a report, and the macro is defined in include with the
DEFINE command, include must be integrated.

• Macros can also be defined as RMAC macros. The source code of these
modules is stored in the function section of the control table TRMAC. The
coding is grouped under a specific name in the table key.
According to conventions, the first two letters of the name must stand for
the application. The rest of the name is freely definable.

Difference between the two methods is:

• If a macro is changed, each report using this macro is automatically


regenerated when it is executed.

• When you change a RMAC macro in the table TRMAC, the reports that use this
macro are not regenerated automatically. You must regenerate them
manually.

Standard HR Macros

o The macro RP-PROVIDE-FROM-FRST retrieves the first (start) data record,


which is valid in the data selection period.

Page 14 of 72
HR-ABAP
o The macro RP-PROVIDE-FROM-LAST retrieves the last (latest) data record,
which is valid in the data selection period.
o The macro RP-READ-INFOTYPE retrieves the data record(s), which is valid
in the data selection period.

How to check whether the macro operation is successful or not

For every macro, whether the operation was successful or not will be checked with
PNP-SW-FOUND.

If PNP-SW-FOUND = 1, then the operation is successful.

Where exactly the Macrocode is stored

The program code pertaining to this macro is stored in the control table RMAC

Guidelines for how and when to use the Standard Macros

o RP_PROVIDE_FROM_FRST

Use macro RP_PROVIDE_FROM_FRST in programs for the logical databases PNP


and PAP where the first data record for a period (can be a subtype) is read from
an infotype table. The infotype table has been filled earlier (for example, with
GET PERNR or RP_READ_INFOTYPE). This macro is only helpful if the infotype has
time constraint 1 or 2.

Prerequisites

• The validity begin date of the time period must be before or the same as the
validity end date.
• Validity start and end dates are correct (preferably of the type DATE).
• The infotype table is sorted in ascending order. Otherwise, you would receive
the first fitting table entry that might not necessarily correspond to the first
time entry.

Features

The first entry for a specified period is placed in the table header entry from an
internal infotype table.

Parameters

RP_PROVIDE_FROM_FRST inftytab subty beg end

IN: 1) Name of the internal table

2) Subtype required or SPACE if no subtype is being specified

3) Validity start date of the time interval

Page 15 of 72
HR-ABAP
4) Validity end date of the time interval

OUT: 1) PNP-SW-FOUND: has the value 0 if there is no matching entry in the


infotype table in the given time period. Otherwise it has the value 1.

2) The matching table header entry if PNP-SW-FOUND = 1 or


the initial table header entry if PNP-SW-FOUND = 0

Example

(RP_PROVIDE_FROM_FRST inftytab subty beg end)


RP_PROVIDE_FROM_FIRST P0021 '1' PN-BEGDA PN-ENDDA.
IF PNP-SW-FOUND EQ '1'.
...

ENDIF.
or
RP_PROVIDE_FROM_FRST P0001 SPACE PN-BEGDA PN-ENDDA.
IF PNP-SW-FOUND EQ '0'.
WRITE: / 'Error: Org. assignment is missing' REJECT.
ENDIF.

o RP_PROVIDE_FROM_LAST

You use macro RP_PROVIDE_FROM_LAST in programs for the logical databases


PNP and PAP where the last data record for a period (can be a subtype) is read
from an infotype table. The infotype table has been filled earlier (for example,
with GET PERNR or RP_READ_INFOTYPE). This macro is only helpful if the
infotype (or subtype) has time constraint 1 or 2.

Prerequisites

• The validity begin date of the time period must be before or the same as
the validity end date.

• Validity start and end dates are correct (preferably of the type DATE).

• The infotype table is sorted in ascending order. Otherwise, you would


receive the last fitting table entry that might not necessarily correspond to
the last time entry.

Features

The macro RP_PROVIDE_FROM_LAST makes sure that the last entry for a
specified period is placed in the table header entry of the report output list.

Page 16 of 72
HR-ABAP
Parameters

RP_PROVIDE_FROM_LAST inftytab subty beg end

IN: 1) Name of the internal table

2) Subtype required or SPACE if no subtype is being specified

3) Validity begin date of the time interval

4) Validity end date of the time interval

OUT: 1) PNP-SW-FOUND: has the value 0 if there is no matching entry in the


infotype table in the given time period. Otherwise it has the value 1.

2) The matching table header entry if PNP-SW-FOUND = 1 or


the cleared table header entry if PNP-SW-FOUND = 0

Example:

RP_PROVIDE_FROM_LAST P0021 '1' PN-BEGDA PN-ENDDA.


IF PNP-SW-FOUND EQ '1'.
...
ENDIF.

OR

RP_PROVIDE_FROM_LAST P0001 SPACE PN-BEGDA PN-ENDDA.

IF PNP-SW-FOUND EQ '0'.
WRITE: / 'Error: Org. assignment is missing'. REJECT.
ENDIF.

• RP_READ_INFOTYPE

You can use the macro in all programs at any point. You can also use it in
function modules. In database PNP, an infotype is usually read with GET PERNR.
Using macro RP_READ_INFOTYPE is an exception.

You can also use the function module HR_READ_INFOTYPE. For information on how
to use the function module, see the documentation on Function Modules.

Prerequisites

• The validity begin date of the time period must be before or the same as the
validity end date.

Page 17 of 72
HR-ABAP
• Validity begin and end are correct date specifications (preferably of the type
DATE).
• The infotype table must match the infotype number.
• The program using the macro must contain the include DBPNPMAC.

Features

The macro RP_READ_INFOTYPE makes sure that all data records for a person for the
specified period are placed in an internal infotype table.

Parameters

RP_READ_INFOTYPE pernr infty inftytab beg end

IN: 1) Personnel number of the person requested

2) Infotype number of the required infotype

3) Name of the internal infotype table

4) Validity start date of the time interval

5) Validity end date of the time interval

OUT: 1) PNP-SW-FOUND = 0, if there is no matching record in the dataset

PNP-SW-FOUND = 1, if there is no matching record in the dataset

2) PNP-SW-AUTH-SKIPPED-RECORD = 0, if the HR authorization check


has not retained any records due to incorrect authorizations.

PNP-SW-AUTH-SKIPPED-RECORD = 1 , if the HR authorization check


has retained at least one record due to lack of authorization

3) Internal infotype table, containing all matching records for which the
user is authorized (this table can also be empty).

Example

(RP_READ_INFOTYPE pernr infty inftytab beg end)

INFOTYPES: 0001.
RP-LOWDATE-HIGHDATE.
DATA: PERNR LIKE P0001-PERNR.
DATA: BEGDA LIKE P0001-BEGDA, ENDDA LIKE P0001-ENDDA.
PERNR = '12345678'.
BEGDA = LOW-DATE + 15
ENDDA = HIGH-DATE - 5.
RP-READ-INFOTYPE PERNR 0001 P0001 BEGDA ENDDA.

Page 18 of 72
HR-ABAP
IF PNP-SW-AUT-SKIPPED-RECORD EQ '1'.
WRITE: / 'Insufficient authorization'. STOP.
ENDIF.

IF PNP-SW-FOUND EQ '0'.
WRITE: / 'Infotype 0001 missing'. STOP.
ENDIF.

2.1.7 Retrieval of data using LDBs (PNP/PAP/APP/PCH) without


LDBs.

Logical database
A logical database is a special ABAP/4 program which combines the contents of
certain database tables. Using logical databases facilitates the process of reading
database tables.

HR Logical Database is PNP

Main Functions of the logical database PNP:

• Standard Selection screen


• Data Retrieval
• Authorization check

To use logical database PNP in your program, specify in your program attributes.

Standard Selection Screen

• Date selection
Date selection delimits the time period for which data is evaluated. GET
PERNR retrieves all records of the relevant infotypes from the database.
When you enter a date selection period, the PROVIDE loop retrieves the
infotype records whose validity period overlaps with at least one day of
this period.
• Person selection
Person selection is the 'true' selection of choosing a group of employees
for whom the report is to run.
• Sorting Data
· The standard sort sequence lists personnel numbers in ascending order.
· SORT function allows you to sort the report data otherwise. All the
sorting fields are from infotype 0001.
• Report Class
· You can suppress input fields, which are not used on the selection screen
by assigning a report class to your program.
· If SAP standard delivered report classes do not satisfy your
requirements, you can create your own report class through the IMG.

Data Retrieval from LDB


1. Create data structures for infotypes.
INFOTYPES: 0001, "ORG ASSIGNMENT

Page 19 of 72
HR-ABAP
0002, "PERSONAL DATA
0008. "BASIC PAY
2. Fill data structures with the infotype records.
Start-of-selection.
GET PERNR.
End-0f-selection.

Read Master Data

• Infotype structures (after GET PERNR) are internal tables loaded with data.
• The infotype records (selected within the period) are processed sequentially
by the PROVIDE - ENDPROVIDE loop.

GET PERNR.
PROVIDE * FROM Pnnnn BETWEEN PN/BEGDA AND PN/ENDDA
If Pnnnn-XXXX = ' '. write:/ Pnnnn-XXXX. Endif.
ENDPROVIDE.

• Period-Related Data
All infotype records are time stamped.

IT0006 (Address infotype)


01/01/1990 12/31/9999 present

Which record to be read depends on the date selection period specified on the
selection screen. PN/BEGDA PN/ENDDA.

• Current Data
IT0006 Address - 01/01/1990 12/31/9999 present

RP-PROVIDE-FROM-LAST retrieves the record, which is valid in the data selection


period.

For example, pn/begda = '19990931' pn/endda = '99991231'


IT0006 subtype 1 is resident address
RP-PROVIDE-FROM-LAST P0006 1 PN/BEGDA PN/ENDDA.

2.2 Personnel Administration (PA)


PA involves administrating employee data, commonly referred to Master Data.
Master Data contains all employee data used in HR processing. Master Data includes
Personal (E.g. address), Organizational (Position description), Benefits (Insurance,
Pension), Time & Payroll.

Master Data is stored in Infotypes. Infotypes are tables (for user Data entry screen)
that contain logically related employee data. Data can be stored for specific periods,
which includes current and historical.

Components of PA:

Page 20 of 72
HR-ABAP
Personnel Area: represents a division of a company code into subunits. It is an
organizational entity representing an area within an organization defined by specific
aspects of personnel administration, time management and payroll. Personnel areas
are subdivided into personnel subareas. Personnel area is specific to HR and is a four
character alphanumeric identification. E.g. Personnel area 100 is for employees in
Karnataka, 200 is for Chennai.

Personnel Subarea: is a further subdivision of Personnel area. It may represent


geographical locations. Functions include:
1. Set groupings for Time Management, so that work schedules, substitution
and absence and leave types can be setup for individual personnel subareas.
2. Generate default pay scale type and area for an employee's basic pay.
3. Define public holiday calendar.

Employee Groups: divides or groups employees into various categories. E.g. Active
employees, Retired employees, Contractors Employee groups are used to generate
default values for payroll accounting area and basic pay.

Employee Subgroups: are further differentiated within the employee group. E.g.
Salaried employees, Hourly employees, unionized employees, Executives The
employee subgroup grouping for the payroll rule allows you to define different payroll
procedures for different employee subgroups. For e.g. you can specify whether an
employee's pay should be determined on hourly or monthly basis. The employee
subgroup grouping for the work schedule defines the validity of work schedule, and
the attendance or absence quota type determines the validity of time quotas.

Here a Data Model

Page 21 of 72
HR-ABAP

2.2.1 Importance of Dates and periods in payroll

Here is a simple ABAP example of reading DATE types stored in infotype 0041.
There can be a maximum of 12 dates stored in this infotype. Here is an example of
an infotype 0041 record:

The date types are stored in PA0041-DAR01, PA0041-DAR02, etc.

In the example above, PA0041-DAR01 is “01”, PA0041-DAR02 is “09”.

The dates themselves are stored in PA0041-DAT01, PA0041-DAT02, etc

Page 22 of 72
HR-ABAP

To read through this in ABAP, the easiest way is to use the DO VARYING statement.
Here is a simple demonstration ABAP:

Note: to print the text of the date type, e.g. “Leave year entry” select from table
T548T.

REPORT ZDATES1.
TABLES: PERNR.

DATA: BEGIN OF MYDATES,


DAR LIKE P0041-DAR01,
DAT LIKE P0041-DAT01,
END OF MYDATES.

INFOTYPES 0041.

GET PERNR.

WRITE: PERNR-PERNR, PERNR-ENAME. "Show employee number and


name

RP-PROVIDE-FROM-LAST P0041 SPACE PN-BEGDA PN-ENDDA.


IF PNP-SW-FOUND = 1.
DO 12 TIMES VARYING MYDATES
FROM P0041-DAR01
NEXT P0041-DAR02.
If mydates-dar ne space.
WRITE: /, MYDATES-DAR, MYDATES-DAT.
Endif.
ENDDO.
ENDIF.

2.2.2 Overview of date fields and period-Ex. for period/in-period/


payroll
FOR-PERIOD: Payroll period (start and end date of a period) for which a payroll
result is created or generated.

IN-PERIOD: The payroll period (start and end date of a period) in which a payroll
result is created or generated.

Example: For every employee payroll should be run, it may be bi-weekly, monthly,
or quarterly. Say it is monthly, then for an employee a payroll should be run for this
month and it is run next month then. For-period start date is 01/9/2003 and end
date is 30 and in-period end date will be the date it is run 15/10/2003.

In-Period View

Page 23 of 72
HR-ABAP
An in-period view is a selection of payroll results from the payroll directory (for
example, RPCLSTRD Payroll Result for Germany,) for a number of in-periods. The
payroll results that were generated for the required number of payroll periods in the
selected period are selected.

Payroll Result

For-Period View

A for-period view is a selection of payroll results from the payroll directory (for
example, RPCLSTRC Payroll Result for Switzerland) for a number of for-periods. The
payroll results that were generated in the required number of payroll periods for the
selected period are selected.

Example: For-Period View / In-Period View

Payroll For-period Start date End date In-period End date


result view for-per. view for-per. view view in-per. view
1 01/1997 01.01.1997. 31.01.1997 02/1997 28.02.1997
2 02/1997 01.02.1997 28.02.1997 02/1997 28.02.1997

Explanation

The payroll result 1 for the payroll period (for-period) 01/1997 has the start date
01.01.1997 and the end date 31.01.1997. This payroll result was generated in the
payroll period (in-period) 02/1997.

2.2.3 Repetitive Structures processing


In many master data infotypes the data is stored in the form of repetitive
structures. For example infotype 0008, the structure wage type line is available for
20 times, that is an employee is eligible for having 20 different wage types based on
his benefits. When evaluating repeat structures, you must ensure that all fields are
entered. In the case of the Basic Pay infotype, 20 * 5 = 100 fields are queried.

To use this method of evaluation, define a field string whose structure


corresponds to the fields in one line of the repetitive structure.

Example for understanding the repetitive Structure

Say, for an employee you want to know that for what all wage types an employee
is eligible for the latest period you mentioned on the selection screen.

Using LDB (PNP)

Program:

Report zhk_repstru.

Page 24 of 72
HR-ABAP

Tables Pernr.

Infotypes 0008.

• You have to declare a structure same as repetitive structure in the


0008 infotype

Data: begin of s_wagetypes,


Wagetype type p0008-lga01,
Amount type p0008-bet01,
Hours type p0008-anz01,
Unit type p0008-ein01,
Ind type p0008-opk01,
End of s_wagetypes,

• Selecting data from the Data base Get pernr

• Getting the latest record based on the selection period.


RP_PROVIDE_FROM_LAST P0008 SPACE PN-BEGDA PN-ENDDA.

• Now knowing for what all wage types the employee is eligible.
Do 20 times varying s_wagetypes from p0008-lga01 next p0008-
lga02. If s_wagetypes-wagetype is initial.

o Here the data is stored sequentially, i.e., if the employee is eligible for 5 wage types
then all the 5 wage types are stored sequentially in lga01 to lga05 respectively. So, if
say the lga05 is initial then it is understood that, employee is eligible for only 4 wage
types and from lga05 to lga20 structures will be empty so, we need not process
further

Exit.
Else.
Write: / s_wagetypes-wagetype,
S_wagetypes-amount.
Endif.
Enddo.

2.2.4 Guidelines to retrieve Payroll data (Mainly US/UK/Ireland)

Before directly going into the Guidelines to retrieve Payroll Data let us look in to the
basic concepts of the Payroll.

Introduction to Payroll
To calculate the remuneration for work done for each employee

Page 25 of 72
HR-ABAP
Payroll does not just involve the calculation of remuneration, but consists of a variety
of processes that are becoming increasingly important due to the employer’s
increased obligation to supply benefits and medical welfare. These benefits are
products of:

• Labor law

• Tax law

• Contribution law

• Benefits law

• Civil law

• Reporting law

• Information law

• Statistics law

Payroll in the SAP System: In the SAP Human Resources Management System, payroll
accounting is executed using the Payroll driver.

Process Flow:

When you access Payroll, the payroll driver calls the accompanying payroll schema, which
consists of a sequence of functions. For each activity, the individual functions import data
from internal tables and payroll relevant files.

Payroll Integration:

Payroll can be integrated in Personnel Administration, Time Management, Incentive Wages


and Accounting:
Standardized data retention enables you to use master data and other payroll relevant data
from Personnel Administration.
Time data, entered via Time Management, is automatically included in the Payroll and is
valuated during the payroll run. Data from the Incentive Wages component is used to
calculate piecework wages and premium wages directly in Payroll.
Information on expenses and payables from Payroll is posted for accounting directly
in Financial Accounting, and you assign the costs to the appropriate cost center.
You can also control the financial system of third-party providers.

Payroll Driver
Payroll driver is a special report for Payroll.
SAP has developed country-specific payroll drivers, which are based on report
RPCALCx0.
The country-specific net calculation of pay must be developed explicitly for every
country.

Page 26 of 72
HR-ABAP

Separate country programs, which meet the tax and insurance requirements of the
respective country, can be created from the basic report RPCALCx0. Since the
payroll driver has a modular structure, you can use the Customizing functions to
quickly modify the payroll procedure to meet the particular requirements of your
enterprise.

Integration
Calculation rules and other reports are stored in an accompanying schema, which
also contains the activities carried out by the payroll driver during payroll. All data is
stored in internal tables and saved in files with a cluster structure.
When you access Payroll, the payroll driver calls the accompanying payroll schema,
which consists of a sequence of functions. For each activity, the individual functions
import data from internal tables and payroll relevant files.

Payroll Schema:
It contains calculation rules to be used by the payroll driver during payroll.
SAP has developed country-specific schemas, which are based on schema X000.
With country-specific reports, the first character in the name refers to the country
indicator.
For example,
D for Germany
F for France
U for USA

Schema Structure A schema consists of the following parts:


1. Initialization
Where system performs the following steps:
Updates the databases
Imports required infotypes
2. Gross calculation of pay
Where system performs the following steps:
Processes basic data and time data
Reads payroll account of the last period accounted
Processes time data and calculate the individual gross values
Performs factoring
3. Net calculation of pay
where system performs the following steps:
Calculates net remuneration
Performs bank transfers

Example:
The classic example is the payroll for salaried employees at the end of the month
in contrast to the wage accounting of hourly workers in the middle of the following
month.

Enter the organizational assignment of employees to a payroll accounting area


(ABKRS) in Infotype 0001. Payroll accounting area also determines the two functions
necessary for payroll accounting:
• The summarization of personnel numbers to be accounted and
• The determination of the exact payroll period.

Page 27 of 72
HR-ABAP

Select Personnel Numbers:


Personnel numbers are selected for payroll accounting by specifying a payroll area
in the payroll driver. Infotype 0001 Organizational Assignment enables you to assign
an employee to the appropriate payroll area.
These Pernrs are locked during Payroll Run.

Determine Payroll Period:

On the Selection screen, you can give Payroll Period Parameter as per the
requirement else you can give Payroll Area, by which system calculates the payroll
period.

Finding Payroll Results for a Specific Query:

Payroll results are stored in cluster Rx of the PCL2. The cluster key is not
mnemonic; it contains only the PERNR (personnel number) and SEQNO (sequential
number) fields.
The internal table RGDIR (PC261 - Cluster Directory for Export and Import of
Payroll Results) contains a directory entry for each payroll result.

This entry is a sequential number (RGDIR-SEQNR), which uniquely identifies


the payroll result.

Payroll results can only be imported if the payroll cluster key (PC200) contains
the personnel number and sequential number.

Function Modules for Selecting Payroll Results


You will probably always have the same queries when importing payroll records.
For example, "Which payroll results (original and retroactively accounted records)
were written for a specific payroll run (defined by IN payroll category, IN payroll
area, IN period)"? To save programmers from having to write their own reports for
this functionality, standard modules are available for the most important queries.
The employee's payroll directory is always transferred to the function modules using
the table RGDIR (PC261). The modules then transfer the payroll records, which
satisfy the specified selection criteria using a table whose type corresponds to that of
the RGDIR (PC261) but which has a different name.

Exporting Pernr – Personal Number

Importing Molga – Country

Tables Rgdir – Payroll Results Directory

This Function Module populates payroll results of all employees with PERNR & SEQNR
as key.
Macro Modules:
We have populated Results Directory & retrieved Sequential Number, we need
to call an import macro module for retrieving the required payroll results. For this we

Page 28 of 72
HR-ABAP
need to pass the unique identification of an Employee payroll Result i.e. rx-key-
pernr = v_pernr.
rx-key-seqno = v_seqnr.
To that import macro.
Calling Import Module: RP-imp-c2-RU.

This Macro populates all the cluster tables required for Payroll, by importing
from PCL2 Cluster Directory. After that we can loop through these cluster tables for
required fields.

Guideline to write a program, which retrieves the data for, specified country

• Use Logical Database As per the Requirement.

• Include Payroll Driver with reference to Country- Specific modules which


inturn includes Country-specific Schemas etc.

• Get the PERNRs for which you want to obtain payroll results.

• Populate Results Directory RGDIR with PERNR & Molga (Country) calling FM
CU_READ_RGDIR.

• Get the Unique Sequential Number with PERNR, From Date & Last Date calling
CD_READ_LAST.

• Pass these KEY Field (PERNR, SEQNR) to IMPORT MACRO


RP-IMP-C2- RU to import all the relevant field entries from PCL2
DIRECTORY to all the cluster tables

• Get the required fields by looping through cluster tables.

Integration
All data is stored in internal tables and saved in files with a cluster structure.

Internal Tables: Internal tables store data during payroll.

The system imports data to these tables and used them to calculate new data. This
data is then also saved in internal tables.

At the start of the payroll run, the system reads the values from the results
tables to the old results table (ORT). Data from the previous period is, therefore,
available in the current payroll period.

The most important internal tables are:


• Input table (IT)
Table IT contains data that can be edited. The table exists only during processing.
•• Output table (OT)
Table OT contains the results of an activity. These results are written to the input
table for further processing. The table exists only during processing.

Page 29 of 72
HR-ABAP
•• Results table (RT)
Table RT contains the results of the period for which payroll has been run. The
system saves this data in the PCL2 file in cluster RX.

Interaction of IT, OT and RT:


The necessary data for the respective processing step is loaded into the input
table and is thus available for various processing procedures. The results of a
processing step are stored either in the output table or the results table. At the end
of a processing step, the data from the OT is loaded back into the IT, where it is
available for further processing steps. The IT and OT are only temporarily filled,
whereas the RT is stored on the database. In one of the first processing steps, the
RT of the last payroll accounting period is imported into the old results table (ORT)
and can consequently be used for further processing.

Payroll Relevant Files:


Payroll files contain data for payroll and payroll results.
Structure
The system requires the following files for payroll:

• Pnnnn (nnnn = number of the infotype)


The Pnnnn files contain data that has been entered in the respective infotypes for an
employee.
Example
P0000 - Actions Infotype
P0008 - Basic Pay Infotype

• PCL1
The PCL1 file contains primary information, in other words, data from the master
data and time recording systems.

• PCL2
The PCL2 file contains secondary information, in other words, derived data and all
generated schemas

Integration

When you start payroll, the system imports the relevant master data from the
Pnnnn files (for example, basic pay and tax class) and imports the time data from
the PCL1 file to the IT table.
The system imports the payroll results from the previous month from table
ORT (for example, to form averages).
The system processes this data and saves the payroll results and generated
schemas in the PCL2 file.

Payroll Control

Use
This function is used to control Payroll.
During Payroll the master data for the personnel numbers to be included in the
payroll run can not be changed for the past or present,

Page 30 of 72
HR-ABAP

Example You should not perform payroll, when master data is being processed for
the personnel numbers for which payroll should be run.

Scope of Function
• Payroll Control Record

• Payroll Status

• Payroll Area

• Payroll Period

Payroll Control Record


Payroll object that is important for the payroll run, and which contains all the
information on a payroll area
Use
The payroll control record has the following functions:
• It locks the personnel numbers, for which payroll should be run, against master data
changes that affect the payroll past or present.
• It locks the payroll for the period during which payroll-relevant changes are made to
the master data for the personnel numbers being processed.

It makes the following information available for the system:


• What is the next payroll period for which regular payroll should be run?
• Up to what date is retroactive accounting carried out?
• What status does the payroll currently have? (For example, Released for Payroll or
Check Payroll Results)?
When you carry out a payroll run, the system automatically changes the
payroll status in the payroll control record. You can also change the status manually
under Payroll ® Tools ® Control Record.

Structure
The control record contains the following information:
• Payroll area
• Payroll status
• Payroll period
• Earliest possible retroactive accounting period
• Last change made to the control record

Payroll Status (Infotype 0003)


Infotype in which data on the Payroll status and Time Management status is stored

For example,
The system stores the date of the last payroll run performed for the employee in the
Payroll Status infotype (0003).
The system can flag an employee that was rejected in the payroll run.
Use
The system automatically creates this infotype when the employee is hired. In
general, the system updates the infotype and writes the changes to the payroll past.

Page 31 of 72
HR-ABAP

Payroll Area
A group of employees for whom payroll should be run together, and at the same
time
Use
You can perform Payroll separately for different employee groups, using different
payroll areas. This is necessary if the payroll period is not the same for all employee
groups.

Examples:
• Industrial worker (monthly, on the 4th day of next month)
• Salaried employee (monthly, on 15th day of the month)
• Company pensioner (monthly, on 20th day of previous month)
• Weekly paid employee (weekly, on Friday)

Every payroll area needs its own payroll control record.

When you run payroll, you must specify the payroll area in the payroll driver
selection screen. The payroll area has the following functions:
In the Payroll Period block it is used to determine the exact payroll period.
In the Selection block it is used to select the personnel numbers that should be
grouped together during the payroll.

Structure
The payroll area contains the following information:
Payroll area text
Eg: Monthly, Weekly, and BI-Weekly
Period parameters
Its two digit numerical parameter
Eg: 01 - Monthly, 02 - BI - Weekly.
• Date Modifiers
Eg: DDMMYYYY, MMDDYYYY etc.

Payroll Period
Exact period in which the regular payroll is carried out
Its (2, 4) digit numerical parameter where first is a unit & second is Year
• A payroll period is usually a month or a week
• A 'special case' (especially in USA)
• A payroll can also be one day

Example
14-day payroll periods have been defined for your enterprise for a particular
year (2003).
The first period begins on 1 January. If you carry out Payroll for payroll period 09,
the payroll period is 01 to 15 May.
01 - 1 Jan to 15 Jan of 2003
02 - 16 Jan to 31 Jan of 2003
03 - 01 Feb to 15 Feb of 2003
09 - 01 May to 15 May of 2003
The method used for defining the payroll period is dependent on whether you are
carrying out a test run or a live payroll run:
• For a test run, you generally enter the specific payroll period.

Page 32 of 72
HR-ABAP
• For a live payroll run, the system uses the value that is in the payroll control record
as the current payroll period.
In the payroll driver selection screen, enter the payroll area for which you want to
run payroll. The system derives the exact start and end date of the payroll for this
payroll area, which are stored in the payroll area or in the payroll control record.

Example
In your enterprise, the first payroll period for 2002 begins on 1 January. It
does not matter which period parameter you use as a basis, for example weekly or
monthly, the payroll period 05 2002 can still have the following meaning:
• Weekly period parameter:
Period 05 2002 = 01-07 February 2002

• Monthly period parameter:


Period 05 2002 = 01-31 May 2002

2.2.5 Retroactive accounting/ Retroactive pay calculation

Retroactive Accounting
If you change the master or time data for an HR master record for a period for which
payroll has already been run, the old payroll results must be checked in the next regular
payroll run, and, if necessary, the payroll run must be repeated.
The system automatically creates a retroactive accounting run in the payroll past
Only changes to master and time data are relevant for retroactive accounting since previous
Payroll results must be corrected.

Example
An employee’s Basic Pay is increased from $3,500 to $3,700 from Sep 1, 2003.
The payroll has already run for this employee for the period up to Oct 30, 2003.
If you change the Basic Pay record, the system performs retroactive accounting when the
next payroll runs for this employee. This ensures that the increase in basic pay, effective as
of Nov 1, 2003, is taken into retroactive consideration.

Earliest Possible Retroactive Accounting Period


The earliest period for retroactive accounting is the payroll period furthest in the
past for which you can run retroactive accounting. This is stored in the payroll control record
for the payroll area.
Use
The company determines this period. You can specify, for example, that retroactive
accounting for the previous year is not possible after a particular date in the current year.

Off-Cycle Activities
Purpose
As an addition to regular payroll, which carries out payroll at fixed regular intervals, this
function enables you to carry out specific off-cycle payroll activities for individual employees
on any day.
The Off-Cycle Workbench is a special user interface in the SAP System for various off-
cycle operations.
Example
• You can pay an employee in advance before he or she takes leave.

Page 33 of 72
HR-ABAP
• You can give a bonus to an employee for special work.
• Off-Cycle Activities are not available in all country versions

2.2.6 Time Management

SAP HR Time Management functionality includes time collection, evaluation of time


and absence data for payroll leave management and reporting. It also automatically
calculates leave accruals, overtime, shift premiums and bonuses.

SAP HR Time Management functionality includes time collection, evaluation of time


and absence data for payroll leave management and reporting. It also automatically
calculates leave accruals, overtime, shift premiums and bonuses.

Time data is used to process Payroll, internal & external reporting Payroll needs time
data to process:

• Hours worked
• Overtime
• Shift times
• Vacation
• Absence to be paid

Time is also used for

Page 34 of 72
HR-ABAP
• Internal reporting - by management to evaluate and project costs.
• External reporting - tracking of time data for Labor Union requirement etc. For
e.g. Labor union requires statistical data concerning the amount of overtime
spent on certain shifts etc.

Time data is stored in various infotypes. This data is evaluated according to various
rules during time evalution and the processed data is transferred to payroll.

Time data is generally collected by a third party recording terminal. Time data is
recorded in various ways. E.g. Punch cards, Manual time sheets that stores hours
worked for each day along with any absences.

All the absence's and attendance in a day are uploaded into SAP and analyzed using
the pre-defined times in the employees Work Schedule rule. After processing the
time events, the system generates wage types and time types based on pre-defined
rules within the time evaluation program. These wage types and time types are then
used for Interfacing to payroll, reporting etc.

• The employee work schedule is an integral part of R/3 Time Management containing
the planned specifications for employee working time.
• An employee’s planned working time is represented in a work schedule. The work
schedule is generated from a period work schedule and a public holiday calendar.
The period work schedule comprises a set sequence of daily work schedules. The
daily work schedule contains information on a day’s working time including breaks.

Page 35 of 72
HR-ABAP
The sequence can reflect regular and variable working times. The period work
schedule is applied to the calendar, taking into account specifications in the public
holiday calendar. The work schedule rule encompasses all the specifications required
to define the work schedule.
The work schedule is used as the basis for time data evaluation.
Examples
The work schedule shows how many hours’ salaried employees must work to be
entitled to their full salary. Depending on the specifications defined for the
individual employee, any additional hours worked are identified as overtime in
R/3 Time Evaluation.
If you only record deviations to the work schedule, planned working time is used
as the basis for time evaluation.
You assign a work schedule to an employee in the Planned Working Time infotype
(0007) using work schedule rules.

• The standard R/3 System already contains public holiday calendars that include
regional public holidays. You can change existing and define new public holidays in
the public holiday list. In addition, you can change existing or define new public
holiday calendars. You assign a public holiday calendar to personnel subarea.
• Public holidays are taken into account when determining bonuses or calculating
leave, for example.

Page 36 of 72
HR-ABAP

In R/3 Time Management, there are certain infotype records that you must create for
every employee. Time management data is stored in the same master data records
used by other HR areas, such as R/3 Payroll Accounting or R/3 Personnel Planning
and Development.
• The following master data infotypes are required for Time Management:
• Organizational Assignment (0001)
• Personal Data (0002)
• Planned Working Time (0007):
You must have entered the appropriate Time Management status, determining
whether the employee‘s time data is processed in R/3 Time Evaluation or in R/3
Payroll Accounting.
• Time Recording Info (0050):
This infotype is used in R/3 Time Evaluation. It can contain interface data on the
subsystem and additional data on the employee that is relevant for time
evaluation. Employees leave entitlement is managed in the Absence Quotas
infotype (2006).

Page 37 of 72
HR-ABAP

• If an employee records his or her actual times at a time recording system, you can
view the recorded time events in the Time Events infotype (2011).
• You can use the Time Events infotype (2011) to enter or correct time events that
were not uploaded or that were incorrectly uploaded to the SAP R/3 System. You can
use list entry to enter several time events for one personnel number at the same
time.
• The infotype contains information on the origin of the record (whether it was
recorded manually or by a subsystem) and on the terminal ID, for instance.
The infotype can also store information on a different payment (premium, different
pay scale group, and so on) or a different cost center. The information can either be
entered manually or by a time recording system.

Page 38 of 72
HR-ABAP

• Time evaluation is performed by the time evaluation driver RPTIME00. It evaluates


employees' time data that has been recorded either at the time recording terminals
or in the time management infotypes.
• Time evaluation generally runs once daily, overnight, and is started using a batch
job. It is normally used for large groups of employees.
You can also run time evaluation for individual employees or groups of employees, or
for particular past evaluation periods. This function is particularly useful for test
purposes, for example.
• The time evaluation report can also be run for future periods. A future evaluation
can be useful in the following situations:
• You want time evaluation to determine an employee’s anticipated absence
entitlements when absence quotas are built up automatically.
• You want to evaluate planned times in shift planning while taking anticipated
overtime income into account, for example

2.2.7 Guidelines to retrieve Time data


Reading Data
Infotypes 2000 to 2999 are time infotypes. The time data in these infotypes stored in
Tables PA2000 to PA2999. Infotypes are declared with the INFOTYPE statement, and
Data is made available for processing in the internal infotype tables (infotype 2011 is
an Exception)

You should not load all time infotype records from the lowest to highest system dates
Into the main memory. This would quickly lead to a memory overload, especially if a

Page 39 of 72
HR-ABAP
Front-end time recording system is connected to your HR system.
This is why time data should be read only for a specific period.
Use the infotype declaration supplement MODE N to define that the internal time
Infotype tables should be declared but not filled at the GET PERNR time point.
Later you can fill these tables using a statement with selection period parameters.
Use the following report to read time data:

REPORT RPABAP05.
TABLES: PERNR.
INFOTYPES: 2001 MODE N.
GET PERNR.
RP-READ-ALL-TIME-ITY PN/BEGDA PN/ENDDA.
LOOP AT P2001.
WRITE: / P2001-ABWTG.
ENDLOOP.

An ABAP/4 macro reads the time data. This macro uses the data selection period
Parameter of the selection screen.

Due to the time constraint of infotypes, several special features must be taken into
account when processing time data. Views of time data are generally not practical.
In time infotypes, data is determined on the basis of the validity period.
When you enter an absence record, the number of days of absence is calculated on
the basis of the absence period.
In a view, new partial periods are created without any changes being made to
infotype data. This would lead to incorrect results in time infotypes, since this data
depends on the validity period.
For example, if, a leave record extends from the middle of January to the middle of
February and 20 days of leave are calculated for this period, then a view for the
month of February would result in a leave record which extends from the beginning
to the middle of February. The number of days of leave would not have changed and
the information would be incorrect.
In master data, the time constraint is a definite feature of the infotype or subtype.
There are no time dependencies between infotypes and subtypes.
Time data is basically different. Let us assume that an employee becomes sick during
vacation. The leave record is then delimited on the first day of the sickness, and the
sickness record follows. Likewise, the system prohibits the entry of a leave record
that coincides with a sickness record. The same also applies to overtime during a
sickness. The time dependency of time infotype records is not limited only to
dependencies between records of one and the same infotype, but covers all infotypes
and subtypes. The time constraint of time infotypes is not an attribute but is defined
by the relationships between infotypes.

Moreover, certain time infotype records have specific clock-in/clock out times.
Several records may therefore exist for one infotype on a particular day. Since views
require explicit data and this prerequisite is not fulfilled by time infotypes, you should
not use joins and projections for time data.

Time infotype tables are processed with the LOOP statement since the PROVIDE
statement limits, and thus changes, the infotype begin and end dates to the data
selection period.

Page 40 of 72
HR-ABAP

Processing 'Time Data'


· Dependence of time data on validity period
· Importing time data
· Processing time data using internal tables

Time Data and Validity Period


· Time data always applies to a specific validity period.
· The validity periods of different types of time data are not always the same as the
date selection period specified in the selection screen.

Date selection period |---------------|


Leave |-------------|

· PROVIDE in this case is therefore not used for time infotypes.

Importing Time Data


· GET PERNR reads all time infotypes from the lowest to highest system data, not
only those within the date selection period.
· To prevent memory overload, add MODE N to the infotype declaration. This
prevents the logical database from importing all data into infotype tables at GET
PERNR.
· Use macro RP-READ-ALL-TIME-ITY to fill infotype table.

INFOTYPES: 2001 MODE N.


GET PERNR.
RP-READ-ALL-TIME-ITY PN/BEGDA PN/ENDDA.
LOOP AT P0021.
If P0021-XYZ = ' '. A=B. Endif.
ENDLOOP.
Processing Time Data
· once data is imported into infotype tables, you can use an internal table to process
the interested data.
DATA: BEGIN OF ITAB OCCURS 0,
BUKRS LIKE P0001-BUKRS, "COMPANY
WERKS LIKE P0001-WERKS, "PERSONNEL AREA
AWART LIKE P2001-AWART, "ABS./ATTEND. TYPE
ASWTG LIKE P2001-ASWTG, "ABS./ATTEND. DAYS
END OF ITAB.
GET PERNR.
RP-PROVIDE-FROM-LAST P0001 SAPCE PN-BEGDA PN-ENDDA.
CLEAR ITAB.
ITAB-BUKRS = P0001-BURKS. ITAB-WERKS = P0001-WERKS.
RP-READ-ALL-TIME-ITY PN/BEGDA PN/ENDDA.
LOOP AT P2001.
ITAB-AWART = P2001-AWART. ITAB-ASWTG = P2001-ASWTG.
COLLECT ITAB. (OR: APPEND ITAB.)
ENDLOOP.

Page 41 of 72
HR-ABAP
2.2.8 Benefits

In a competitive employment market, benefits play a significant role in total compensation


offers designed to attract and keep the best possible employees. The SAP Benefits (PA-BN)
component offers you powerful and comprehensive tools for creating and managing tailor-
made benefits packages for your employees. It allows you to administer an extensive range
of benefit plans, and its sophisticated configuration options can accommodate complex plan
definitions.

The Benefits application component offers comprehensive tools for administering employee
benefits in an organization. It provides all the concepts and functions that are needed to
manage extensive and highly individual benefits packages for the employees of an
organization.

Benefits integrates to SAP's International Payroll, however, it does not integrate to every
SAP Country Payroll version.

If we want to use Benefits for a Country Payroll version that is not integrated, in conjunction
with non-SAP payroll software or an external payroll service, we must provide our own
interface for the transfer of data.

The Benefits Administration component provides the functions needed to handle the
organization's benefits administration processes. It enables us to perform the following key
activities:

• Enroll employees in benefits plans and terminate enrollments


• Monitor eligibility
• View information about current benefit enrollments
• Print enrollment and confirmation forms
• Transfer data electronically to plan providers

ENROLLMENT
This is a process of enrolling employees of an organization for Benefit
Plans depending on their eligibility

The Enrollment function enables us to enroll employees and, where possible, make changes
to employee benefit elections as required for the following tasks:
• Enrollment of employees during an open enrollment period in plans for the coming
Season
• Enrollment of new hires in plans that are automatically offered
• Enrollment of new hires in default plans as an interim measure, until they have made
their benefits choices
• Adjustment of plan enrollments as a result of employee life or job changes

There are four types of Enrollments. They are


1. Open Enrollment Offer
2. Default Enrollment Offer

Page 42 of 72
HR-ABAP
3. Automatic Enrollment Offer and
4. Adjusted Enrollment Offer

These Enrollments are also known as Benefit Offers.

OPEN ENROLLMENT
An open offer is the most unrestricted type of offer. It is generated by the system when you
start enrollment for a date that lies within an open enrollment period. Only those plans are
available in an open offer for which the employee fulfills certain eligibility criteria, as defined
in Customizing.

A period of time during which an organization allows its employees to enroll in new benefits
plans or change existing benefits elections

The benefits offer set up for open enrollment is valid only during the open enrollment
period. Plans available for selection during the open enrollment start on a future date,
typically at the beginning of the coming year

Open enrollment is implemented in the USA and Canada.

Example

A company allows its employees to choose their benefits on an annual basis for the coming
year. The open enrollment period is 1 Oct 1999 to 30 Nov 1999, and any new benefits
elected by employees are valid from 1 Jan 2000 to 31 Dec 2000.

Default

A plan in which employees can be enrolled before they communicate their benefits elections
to the benefits office

Default plans are typically used for giving short-term coverage to new hires and therefore
often allow little flexibility to the employee regarding the plan terms.

Automatic

A plan in which employees are enrolled without the requirement that they consent to the
enrollment or make any elections within the plan An employee is enrolled in all relevant
automatic plans at all times.

Automatic plans are often provided at no extra cost to the employee and often allow little
flexibility to the employee regarding the plan terms.

Adjusted

A personal or organizational change experienced by an employee, as a result of which the


employee is allowed to change his/her current benefit elections.

In the SAP System, the adjustment reason is a user-defined parameter to which certain
adjustment permissions are assigned for different types of benefit plan.

Page 43 of 72
HR-ABAP
The following are examples of adjustment reasons:

• Marriage
• New dependent
• Hiring (initial enrollment)
• Job change

Benefit Area

Benefit areas allow you to have separate administration of different benefit plan pools.
This division is primarily for administrational purposes and would not normally be used
for eligibility.

This is a primary subdivision of plan set up within the benefits component.

Benefit areas are set up and function completely independently of each other.

Typically, employees will be enrolled in a benefit area that groups them according to
common attributes such as country or organizational assignment.

Below mentioned are some of the Benefit Areas:

Benefit Area Name of HR country


01 Germany
02 Switzerland
03 Austria
04 Spain
05 The Netherlands
06 France
07 Canada
08 Great Britain
09 Denmark
10 USA
11 Ireland
12 Belgium
13 Australia
14 Malaysia
15 Italy
16 South Africa
17 Venezuela
18 Czech Republic
19 Portugal
20 Norway
21 Hungary
22 Japan

Page 44 of 72
HR-ABAP

Benefit Category:

Benefit Category is the broadest classification of benefits. Categories are maintained


by SAP.
The following plan categories are provided by SAP:

• Health Plans
• Insurance Plans
• Savings Plans
• Stock Purchase Plans
• Flexible Spending Accounts
• Credit Plans
• Miscellaneous Plans

These categories are predefined because the system handles each differently. In
order to reflect your own requirements regarding the categorization of plans, you
define plan types within these categories.

Benefit Category is the highest level in the Benefit Plan structure. Benefit Categories
are again divided into Plan types. Every Category may consist of one or more Benefit
Plan types.

Benefit Plan Types


Benefit Plan types are the logical grouping of different benefit plans. Each Plan type
is identified by a unique identifier, which is a maximum of four characters.
Ex:
MEDI - Comes under Health Plan Category (MEDI => Medical)
DCAR - Comes under Flexible spending Accts (DCAR => Dependent Care Spending)
LIFE - Comes under Insurance Plans Category (LIFE => Life Insurance)
SAVE - Comes under Savings Plans Category (SAVE => Savings)
STPC - Comes under Stock Option Category (STPC => Stock Purchase)
CAR - Comes under Miscellaneous Plans Category (CAR => Company Car)
CRED - Comes under Credit Plans Category (CRED => Flex Credit)

Plan types are a control mechanism for enrollment, since the system does not allow
an employee to enroll in more than one benefit plan per plan type. This allows you,
for example, to offer a choice of regular health care from different providers under
one plan type, without the risk of accidentally enrolling an employee in more than
one of these benefit plans.

Within each plan category (for example, Insurance Plans) you should define one plan
type for each sort of benefit plan that the employee is likely to elect (for example,

Page 45 of 72
HR-ABAP
Life Insurance, Spousal Life, Supplemental Life). Thus an employee can elect a plan
from the Life Insurance as well as from the Spousal Life plan type.

Example

The following are examples of plan types for each of the plan categories:

Health Plans

• General medical care


• Dental care
• Vision care plan

Insurance Plans

• Basic life insurance


• Dependent life insurance
• Supplemental life insurance

Savings Plans

• Retirement plan
• Savings plan

Stock Purchase Plans

• Own company stock plan

Flexible Spending Accounts

• Health care spending account


• Dependent care spending account

Credit Plans

• Cafeteria plan

Miscellaneous Plans

• Company car

Benefit Plans

Page 46 of 72
HR-ABAP
The Granularity level in the Benefit Plans Structure is identified by Benefit Plans.
Many Benefit plans may be grouped together under a particular plan type. The
benefit Plans are also identified by a unique identifier, which is of a maximum of four
characters.

Ex: MEDI, DENT, VISI for Health Plans Category (MEDI Plan Type)

Benefit plans within the health plan category cover the basic health needs of an
employee. A typical health plan might provide the employee with medical, dental or
vision coverage.

Insurance plans provide monetary amounts of coverage payable to the employee or


designated beneficiaries.

A savings plan allows an employee to accumulate capital within a company


sponsored benefit plan.

A spending account provides an employee with the opportunity to establish account


balances to meet anticipated spending needs during the course of the employee's
benefit plan year. These needs are most often associated with health, dependent
care or legal benefits.

Benefit first program grouping

The first program grouping is a method of grouping employees for purposes of macro
eligibility. The second program grouping is a second, identical method of grouping
employees into other macro eligibility groups.

The cross reference of these two groupings places every employee into a benefit
program.

First program groupings are a means of identifying a group of employees who share
a common set of benefits and eligibility criteria.
Example
An organization offers one set of benefit plans for hourly-paid employees and a
different set for salaried employees. Hourly-paid employees may enroll in medical,
dental and life insurance plans after a four-month waiting period. Salaried employees
may enroll in medical, dental, life and vision plans after a one-month waiting period.

Benefit second program grouping

The second program grouping is a method of grouping employees for purposes of


macro eligibility. The first parameter grouping is a second, identical method of
grouping employees into other macro eligibility groupings.

The cross reference of these two groupings places every employee into a benefit
program.

Page 47 of 72
HR-ABAP

Second program grouping is a means of subdividing your first program groupings


depending upon their employment status.
Example
An organization offers one set of benefit plans for full-time employees and a different
set for part-time employees. Full-time employees may enroll in medical, dental and
life insurance plans after a four-month waiting period. Part-time employees may
enroll in medical, dental, life and vision plans after a one-month waiting period.

Eligibility

The important part in the Benefits is Identifying the all the Eligible Employees for a
given Benefit Plan.
This can be achieved using function module

‘HR_BEN_CHECK_MICRO_ELIGIBILITY’. This function module determines whether a


person is eligible or not.

Similarly to determine the Eligibility date and the Participation date of an employee
for a benefit plan we can use the function module(s)
‘HR_BEN_CALC_ELIGIBILITY_DATE’ for eligibility and
‘HR_BEN_CALC_PARTICIPATION_DATE’ for participation date.

Infotypes used in Benefits

Here below is the most commonly used Infotypes.

Health Plans (Infotype 0167)


Insurance Plans (Infotype 0168)
Savings Plans (Infotype 0169)
Spending Accounts (Infotype 0170)
Credit Plans (Infotype 0236)
Stock Plans (Infotype 0375)
Miscellaneous Plans (Infotype 0377)
General Benefits Data (Infotype 0171)
Family/Related Person (Infotype 0021)
External Organization (Infotype 0219)
Date Specifications (Infotype 0041)
Monitoring of Dates (Infotype 0019)
COBRA Qualified Beneficiary (Infotype 0211)

Control Tables / Catalog Tables


Control tables are master table, here below is some control tables used.

T5UBA --- Benefit Plans

T5UB1 --- Benefit Plan type

T5UBU --- Benefit Program


T5UB3 --- Benefit Area

Page 48 of 72
HR-ABAP

Benefits Specific to USA:

The Benefits, which are specific to USA, are


COBRA plans
Flexible Spending Accounts and
Tax Sheltered Annuity Plans,

The Benefit Plans specific to ASIA are Cloth reimbursements

2.2.9 Case Studies

2.3 Utilities:
2.3.1 List of standard Commands for Macros/ infotyes etc
Some important infotypes (List)

Infotype Description

0000 Actions
0001 Org Assignment
0002 Personal Data
0003 Payroll Status
0006 Address (all types)
0007 Plan Work Time
0008 Basic Pay
0009 Bank Details
0014 Recur Pmts & Deductions
0016 Contract Elements
0015 One Time Pmts
0017 Travel Privileges
0022 Education
0041 Date Specifications
0105 Communications
0167 Health Plans
0168 Insurance Plans
0169 Savings Plans
0170 Flex Spend Account
0171 Gen Benefit Info
0194 Garnishment doc
0195 Garnishment order
0207 Resident Tax Area
0208 Work Tax Area
0209 Unemployment State
0210 W4/W5 Withhold Info
0216 Garnishment adjust
0221 Payroll results adjust
0234
0267 Off Cycle One Time

Page 49 of 72
HR-ABAP
0377 Miscellaneous Plans

Time Management

2001 Absences
2002 Attendances
2005 Overtime
2006 Absence Quota
2007 Attendance Quota
2010 EE Remuneration

2.3.2 HR Standard Reporting tools


To enable you to report on HR data, the R/3 System provides you with numerous
standard reports.

Reporting Tools

• HIS : Reporting tool that gives you easy access to existing reports
• InfoSet Query : Enables to create your own reports, with no programming skills
• SAP Query : Enables to create your own reports, with no programming skills

InfoSet Query:

You can use InfoSet Query to report on data from Human Resources (HR) by
using InfoSets based on HR logical databases (PNP, PCH, PAP).

InfoSet Query is used in HR to create reports to meet requirements that are not
satisfied by standard reports. By selecting selection fields and output fields, you can
access data stored anywhere within the Human Resources System. You do not
require programming skills to create reports using InfoSet Query.

InfoSet Query supports two types of reporting:

• For ad-hoc reporting


• For query development

InfoSet Query has been integrated with HR information systems to enable you to
perform ad-hoc reporting; that is, you can create and save queries in the standard
query area. However, there is no transport link to the Workbench Organizer. In this
context, InfoSet Query is known in HR as Ad Hoc Query.

There are two ways of using InfoSet Query in HR:

• With object selection

Before data is output, a set of objects is selected for which you can output data
as required. You can edit the selected set of objects before output. For example,

Page 50 of 72
HR-ABAP
you can display the list of objects, display details on individual objects, and use
the set of objects as a new reporting set, or relate two sets to each other.

This method of working has the advantage of good system performance


because objects are selected using a selection routine that is particularly
suitable for Human Resources.

• In basic mode (object selection is switched off)

In basic mode, the report’s list of results is output immediately without a hit
list being generated first.

This method of working has the advantage of enabling you to use all InfoSet
fields for selection purposes. Working with object selection restricts these
options.

The following sections describe how to work with object selection. Always use object
selection to create reports for HR. If you require further information on how to work
with InfoSet Query in basic mode

Integration

• You can use InfoSet Query to continue processing and report on sets of
persons selected using Manager’s Desktop or HIS. You can start InfoSet
Query directly from these applications. The selected set of persons is
transferred to InfoSet Query as a reporting set.
• You can branch from InfoSet Query to general reporting. In this case, you
only use the first InfoSet Query level, that is, you select an object set. To
report on this hit list, you use a standard report.
• You can enhance queries created using InfoSet Query by adding features that
are only supported by SAP Query. If you require further information.

Features

If object selection is switched on, working with InfoSet Query consists of two steps:

• In the first step, you select a set of objects (= hit list) in accordance with
selection criteria that you can specify as required. You can then process the
hit list. You can also use InfoSet Query to create two hit lists. You can add
them together, subtract one from the other, or use them to create
intersections.
• In the second step, you output data as required for the objects selected in the
first step. You can display and forward reporting results using the following
options: you can choose a type of output list (basic list, statistics, or ranked
list), and you can determine how data is output to the full screen (for
example, SAP List Viewer, standard list, spreadsheet, word processing). On
the InfoSet Query screen, data is always output to SAP List Viewer.
Furthermore, the preview of output includes formatting options such as
summation and sorting.

Page 51 of 72
HR-ABAP
2.3.3 FAQ, Hints, Tips and tricks in HR, Do & not to do (Warnings)

FAQ:

1. What exactly is an infotype? Why are infotypes only required in HR?


A. An infotype is a collection of logical and/or business-related characteristics of an
object or person. I don't know exactly how to answer the second question but it is
safe to say that items such as materials have similar structures that act like
infotypes. The one outstanding difference that I really see is the concept of time
constraints that infotypes use for interpreting data during a specified period.

2. List the HR Process


A. i) Hiring
ii) Transfer
iii) Promotions
iv) Leaving

3. We use clocking machine for recording employee clock-in/out. All the


data is stored in a 'flat' file, which is supposed to be uploaded into SAP.
When tried to open and read the flat file using OPEN DATASET and READ
DATASET commands, the Sy-subrc value returned is 8 and the error
message 'the specified file not found' is displayed. We checked the path and
the file is in the correct location. What is missing?
A: Check the path once again. Check the upper and lower cases. Define you
parameter file name like filename-file extern. Depending on the place where the flat
file resides, the procedure varies. OPEN DATASET is used for upload of file from the
host system. If your flat (text) file is on the PC, you can use the function
WS_UPLOAD that will upload your text file into an internal table. This internal table
data can be loaded into SAP. The syntax is as follows:

CALL FUNCTION 'WS_UPLOAD'


EXPORTING
FILENAME = pcfile
IMPORTING
FILELENGTH = fileleng
TABLES
DATA_TAB = internal table name
Please note that you have to specify the pcfile of length 128.

4. What are the logical Databases that we use in the HR? And the difference
between them.
A. 1. PCH: Organizational Data
2. PNP: For personnel Data
3. PAP: Application Data

5. We want to make a copy of an organizational structure from one plan


variant to another. This copy should include all assignments like purchasing
groups to organizational units made in PFOM. Can we do this?
A: Make sure that the plan number is established through the IMG. (And that it is
not the active plan.)
Go Human Resources -> Organizational Management Tools -> Plan version -> Copy.

Page 52 of 72
HR-ABAP
It runs RHCOPL00. All or any portion of the plan maybe copied and manipulated and
then copied back in to the active plan.

6. What are the infotypes that you cannot enhance?


A. Infotype 0000 Single Screen, Time management Infotypes

7. We have a requirement to calculate leave entitlement at the anniversary


year not calendar year. The leaves have both paid and unpaid components.
The paid component is based on time worked. The unpaid component is
based on years of service. Leave taken is reduced from both entitlements
depending on employee's request. We are using a Schema based on TM04,
which calls Cycles TS15, TS10. What is the best way to handle this?
A: You can use field 'DAUER' for seniority based vacation entitlement in the VAC01-
>VAC99 features. Time worked is not part of the feature structure (PME03). However
you may create your own source code to make a decision on any field even if it does
not belong to the feature structure. Check feature VAC01.

8. What are the ways to process infotypes?


A. We can read an infotype using macros and provide and end provide commands

9. We have multiple ORGs as we have many subsidiaries of our Parent


company. These subsidiaries are defined as ORG and are assigned an ORG-
ID. Within each ORG, we have Divisions (e.g. Human Resources, Finance,
and Materials etc.) and within each division we have Departments (e.g.
Payroll, Labor Relations, etc.). We plan to use Personnel Development (PD).
What is that we have to consider in this case?
A: You have to consider how the company wants to see its reports while designing
the HR organizational structure in PD. You have addressed the question: for
headcount or regulatory reports to which level does the company need to report, to
the division, department, and group or team level. You have to design the SAP
organizational structure to support the lowest level required. Lower the more levels
of detail, the more maintenance required.

10. When you create an infotype it creates screens, on what basis it creates
the screen elements?
A. On the basis of the PS structure that we create while creating an infotype.

11. How can we configure the options for the Assgn Form. No. field on
Infotype 210. It is the alternate formula to assign tax field and we have
been unable to locate the table in the IMG to edit the options.
A: Options for the BSI Tax Formula cannot be configured.
Possible entries are available in BTXFORM, and they depend on the 'tax authority'
(BTXAUTH) and the 'tax type' (BTXTAXT). Use data dictionary to check existing
entries. This data comes from BSI. Tax calculations are done in the
BSI programs (via RFC from the USTAX function in the payroll schema).

12. How many types of screens are created while you create an infotype
A. 1. Single screen, 2. List Screen

Page 53 of 72
HR-ABAP

13. We are using the US HR/PAYROLL module. We are able to create the
entry to credit the accrued payroll account. But our check writing process
does not produce any accounting entries when we create a paycheck or run
our EFT process (RFFOUS_T). Should RFFOUS_C produce an accounting
entry to debit the payroll payable account and credit the cash account?
A: RFFOCUS_C does not produce any accounting entries. During the FI/CO interface
run, 559 wage types may be posted to your cash account

14. We have approximately 10000 zip codes. We want to relate the


eligibility group to the zip code. We do not want to create 20000 eligibility
groups. Which is the best way to configure basing eligibility for HMO's on
zip codes?
A: Try to group the zip codes by the HMO's they belong to. Then create benefit
groups and programs for the unique combinations. You can create as many benefit
groups as required and use the employee zip code to select the benefit group the
employee is eligible for. You may also look at user exit 2.

15. We are using the PAI user exit in MP000800 screen 2000 to modify the
BET01 field. After modifying the value, the value is not re displayed.
However the updated value is saved on commit. Why the value is not
displayed after modification?
A: Yes. It is true. You may have to apply OSS

16. I have a requirement in which I have to display the free text associated
with an entry in infotype 0028. Until now I've just gone nuts debugging the
code. Can you please let me know how to do it?
A. Can you be more specific here? I have never used 0028 but in investigating a
system with PCC loaded, none of the subtypes have free text associated with them.
Is it possible that you are speaking of something attached via object services? If so I
can give you code that will read those items (hint: look at table SRRELROLES and
SOOD). If it is not that then please tell me which subtype you are looking at and
what screen field the free text is in. I can give you the answer at that point.

17. I have copied report HRBEN0074 and now I want to change the
currently displayed amount coverage from bi-weekly to monthly. How can I
do that?
A. I assume you mean bi-weekly costs since coverage does have a biweekly or
monthly amount. A quick look at the program tells me that you would need to modify
ALV_ITAB around line 260 and change the field you wish to convert into the correct
amount. The field you are looking for is probably either ERCST or ACCST.

18. SAP doesn't allow two actions on the same day. There are occasions
where a person could be ending maternity leave and starting a career break
on the same day. Any suggestions on how to overcome this?
A. SAP cannot store two infotypes of time constraint 1 with the same subtype on the
same day, because the date delimitation is the same. One of the infotypes would be
overwritten. Because there are many occasions when an employee may experience
multiple personnel actions on the same day, SAP created "Additional Actions"
(infotype 0302) to capture these additional actions. This infotype cannot be
maintained directly, but it is located for viewing at the bottom of the Actions infotype

Page 54 of 72
HR-ABAP
(0000). To take advantage of this functionality, you need to set it up using the
following IMG path:
Personnel Management -> Personnel Administration -> Customizing Procedures ->
Actions ->Set up personnel actions
Activations "Additional Actions" should be activated for all personnel number ranges.
This will allow SAP to process multiple actions on the same day.

Tips:

1. EXAMPLE_PNP_GET_PAYROLL (report): Example program to read the payroll data


using the GET PAYROLL.

If you need to do a form to report wages and the data is stored in the PCL4 Cluster.

You can look at this example report or form that retrieves data from this cluster
based on several parameters that are entered when the report is executed online
(like employee number and tax year).

2. A small Program to retrieve the Cumulative data from the cluster

TABLES: PERNR,
PCL2.

*----------------------------------------------------------------------*
* INCLUDE ZHR_PCL2_CU_DATA - Payroll results. *
*----------------------------------------------------------------------*
* Data declarations for the IMPORT of database PCL2 for cluster RU. *
*----------------------------------------------------------------------*

DATA: CD_NEXT_SEQ TYPE I, "Next available seq number


CD_LAST_PAY TYPE D. "Last payroll run date

DATA: BEGIN OF OCD_VERSION.


INCLUDE STRUCTURE PC201. "Technical Version
*DATA: molga LIKE t001p-molga. "Country identifier
DATA: END OF OCD_VERSION.

DATA: BEGIN OF RGDIR OCCURS 100.


INCLUDE STRUCTURE PC261. "(For Export and Import of Payroll Res
DATA: END OF RGDIR.

* Key for database PCL2 cluster RU


DATA BEGIN OF RX_KEY.
INCLUDE STRUCTURE PC200. "Payroll Results Key
DATA: END OF RX_KEY.
* Country dependent
DATA: BEGIN OF RU-VERSION.

Page 55 of 72
HR-ABAP
INCLUDE STRUCTURE PC201. "Technical Version
DATA: END OF RU-VERSION.

DATA: BEGIN OF ORU_VERSION.


INCLUDE STRUCTURE PC201. "Technical Version
DATA: END OF ORU_VERSION.

* Cumulated-result table
DATA: BEGIN OF CRT OCCURS 30.
INCLUDE STRUCTURE PC22Y. "Cumulated result table (USA)
DATA: END OF CRT.

GET PERNR.

IMPORT CD_VERSION TO OCD_VERSION


CD_LAST_PAY
CD_NEXT_SEQ
RGDIR
FROM DATABASE PCL2 (CU) ID PERNR-PERNR.
CHECK SY-SUBRC EQ 0.
* This is where you select the particular period you are searching. The
* selection will change based on what dates you are looking for.
LOOP AT RGDIR WHERE FPPER EQ P_PERIOD
AND INPER EQ P_PERIOD
AND (RUNDT GT Z_RUNDT
OR (RUNDT EQ Z_RUNDT
AND RUNTM GT Z_RUNTI ))
AND SRTZA = 'A'
AND PAYTY = ' '
AND VOID NE 'V'.

CHECK SY-SUBRC = 0.

MOVE PERNR-PERNR TO RX_KEY-PERNR.


MOVE RGDIR-SEQNR TO RX_KEY-SEQNO.

IMPORT RU-VERSION TO ORU-VERSION


CRT
FROM DATABASE PCL2(RU) ID RX_KEY.
CHECK SY_SUBRC = 0.

LOOP AT CRT.
Process crt data.
ENDLOOP.

ENDLOOP.

3. Any changes that are done to infotypes can be known by running the
programming RPUAUD00

Page 56 of 72
HR-ABAP
When you execute this program and specify the employee code and infotype in the
selection screen, it gives us details of when the data was changed, who changed the
data and what data was changed in a particular infotype.

There are few standard infotypes like 0000, 0001, 0002 and few of your own created
infotypes starting with 9 (9XXX) for which you are able to see the log through this
program.

But there are certain other infotypes like 0008, 0581 for which this log is not
coming.

There are some configurations or customizing is to be done so that this log starts
generating for these infotypes and RPUADU00 can read it.

The IMG menu path is:

Personnel Management > Personnel Administration > Tools > Revision >
Set up change document

When you execute this node choose ’HR Documents - infotypes to be logged'

Add entries in this table to audit more infotypes.

Transaction class A is for HR master data, class B is for applicant data.

4. TEM - Deleting Business Events after Historically Recording

Assuming that one of your team users was testing in production After having a
problem with the automated correspondence The user created a business event,
booked people into the event, and then followed up on the event. Unfortunately, the
user also historically recorded the event.

If this happened, you need to delete the event because it will give the people which
the user booked credit for having
attended an invitation only type of leadership seminar.

Using report RHRHDL00 (menu path in 4.6C: Human Resources / Training and
Event Management / Tools / Database / Delete database records), you can
delete data records from the Personnel Planning Database.

Of course, be careful while making the selections for deletion and do a test run
first

5. Change of Employee Position

During the course of a person employment, the employee may changes positions,
cost centers, or is moved to another subsidiary and the organizational assignment
need to be change.

Page 57 of 72
HR-ABAP
Do take note that you cannot change the employee’s payroll area for a period for
which the employee’s payroll has already run. You can only change the payroll area
at the end of the payroll period.

In Personnel Actions, PA40: -

1. Input the Personnel Number


2. Select Organizational reassignment and click the execute button
3. Input the Start date for the reassignment
4. Click the save button and the Position Change screen will appear
5. Save your entries

6. Deleting personnel numbers in SAP HR

If you have some duplicated, personnel numbers on the system and the data is not
complete.

You try to delete these and get the message "record cannot be deleted (time
constraint 1)".

The fastest and simplest way to delete employees is to use program RPUDELPN.

Either that or from PA30, click to Utilities -> Delete Personnel Number.

Certain infotypes have the time constraint set so that you cannot delete them which
is why it is giving you the message.

To avoid problems, use the above methods.

7. Find out the transaction codes used for SAP HR


Execute the program RPDTRA00 to list all HR Transactions

2.3.4 List of HR tables & Transactions


List of HR tables

"List of HR
tables.doc"

2.3.5 List of Standard Reports, Function modules & Utilities


available
Standard Reports in Benefits
Eligible Employees (Report RPLBEN01)
Participation (Report RPLBEN02)
Health Plan Costs (Report RPLBEN03)
Insurance Plan Costs (Report RPLBEN04)
Savings Plan Contributions (Report RPLBEN05)

Page 58 of 72
HR-ABAP
Vesting Percentages (Report RPLBEN06)
Changes in Benefits Elections (Report RPLBEN07)
Flexible Spending Account Contributions (Report RPLBEN08)
Changes in Eligibility (Report RPLBEN09)
Employee Demographics (Report RPLBEN11)
Changes in Default Values for General Benefits Info (Report RPLBEN13)
Costs/Contributions for Miscellaneous Plans (Report RPLBEN15)
Stock Purchase Plan Contributions (Report RPLBEN16)
Benefit Election Analysis (Report RPLBEN17)
Contribution Limit Check (Report RPLBEN18)
Enrollment Statistics (Report RPLBEN19)
Create Payment List Report (RPUBENPAYRQ)
Actual Hours report (RPUBEN47)

Useful programs for Schemas and PCRs


Change Attributes for Schemas and PCRs (change
RPUCTF00
owner)
RPUCTI00 Lists Subschema’s not called up in any other schema
Lists Personnel Calculation Rules which are not called
RPUCTJ00
up
RPUCCOSE Source text search in PC rules
Copy Personnel Calculation Rules from client 000 to
RPUCTX00
other clients
Schema directory – useful after LCP to see changed
RPUSCD10
schemas, also shows who changed it last and when
RPUCTC00 Displays PCRs full source text

Time Management
RPTQTA10 Display Leave Quotas
RPTQTA00 Bulk Leave Quotas Update
Transfer of Remaining Leave from Infotype 0005 to
RPTLEACONV
Infotype 2006

Wage Type Utilities


(HR utility 512W-classes) allows you to reload
backups of specific processing classes, cumulations
RPU12W0C
and evaluation classes created with RPU12W0S in
T512W
Creates a backup of T512W in T599U or reloads
RPU12W0S
the backup into T512W.
RPU99U0V Displays T599U
Generically deletes entries in T599U, T512W or
RPU5XX0D
T512T

Other Useful programs


RSHOWTIM Displays tips and tricks for ABAP Programming
RSANAL00 Program analysis

Page 59 of 72
HR-ABAP
RSABAPIV Lists all ABAP commands
RCCLBISC Display contents of logical filename
RPUTRBK0 Updates infotype 0003 dates after data transfer
RPUEUSUP Activate Additional Actions infotype 0302
RPUDEL20 Deletes payroll results (be careful!)
RPDSYS00 Display System Documentation
RSBDCSUB Release batch-input sessions automatically
RSUSR006 List users last login
RSPARAM Display all instance parameters
RPABRIDD Deletes data in payroll infotypes
RPUPROTU Maintain/delete the log of report starts
RPINCL10 Use RPINCL10 to search through ABAP source code
RPCIFU03 Move TemSe Unix file (e.g. BACS transfer) to PC file
RPLTEMV0 File transfer between TemSe and disc

Function Modules

HR_READ_INFOTYPE
HR_PERSONAL_WORK_SCHEDULE
HR_WORK_SCHEDULE_TIMES
HR_PERSON_INIT_WORK_SCHEDULE
HR_PERSON_READ_WORK_SCHEDULE
CU_READ_RGDIR

2.3.6 Available Enhancements/User exists


Best way to find out the existing available Enhancements is go to SMOD transaction
code press F4 select SAP Applications -> PA / PT / PY
Or you can use this program to get the

REPORT ZENHANCE .

TABLES: tstc, tadir, modsapt, modact, trdir, tfdir, enlfdir, tstct

Page 60 of 72
HR-ABAP

DATA : i_tab LIKE tadir OCCURS 0 WITH HEADER LINE.


DATA : v_field (30).
DATA : v_devclass LIKE tadir-devclass.

SELECTION-SCREEN BEGIN OF BLOCK selection


WITH FRAME TITLE text-z80.

PARAMETERS : p_tcode LIKE tstc-tcode OBLIGATORY.


SELECTION-SCREEN END OF BLOCK selection.

* Checking whether the transaction code is valid or not


SELECT SINGLE * FROM tstc WHERE tcode EQ p_tcode.
IF sy-subrc EQ 0.
* Get the Development class of the Object
SELECT SINGLE * FROM tadir WHERE pgmid = 'R3TR'
AND object = 'PROG'
AND obj_name = tstc-pgmna.
MOVE : tadir-devclass TO v_devclass.
* If not found in tadir then get it from trdir
IF sy-subrc NE 0.
SELECT SINGLE * FROM trdir WHERE name = tstc-pgmna.
IF trdir-subc EQ 'F'.
SELECT SINGLE * FROM tfdir WHERE pname = tstc-pgmna.
SELECT SINGLE * FROM enlfdir WHERE funcname =
tfdir-funcname.
SELECT SINGLE * FROM tadir WHERE pgmid = 'R3TR'
AND object = 'FUGR'
AND obj_name EQ enlfdir-area.

MOVE : tadir-devclass TO v_devclass.


ENDIF.
ENDIF.
SELECT * FROM tadir INTO TABLE i_tab
WHERE pgmid = 'R3TR'
AND object = 'SMOD'
AND devclass = v_devclass.
SELECT SINGLE * FROM tstct WHERE sprsl EQ sy-langu AND
tcode EQ p_tcode.
FORMAT COLOR COL_POSITIVE INTENSIFIED OFF.
WRITE:/(19) 'Transaction Code - ',
20(20) p_tcode,
45(50) tstct-ttext.
SKIP.
IF NOT i_tab[] IS INITIAL.
WRITE:/(95) sy-uline.
FORMAT COLOR COL_HEADING INTENSIFIED ON.
WRITE:/1 sy-vline,
2 'Exit Name',
21 sy-vline,
22 'Description',
95 sy-vline.

Page 61 of 72
HR-ABAP
WRITE:/(95) sy-uline.
LOOP AT i_tab.
SELECT SINGLE * FROM modsapt
WHERE sprsl = sy-langu AND
Name = i_tab-obj_name.
FORMAT COLOR COL_NORMAL INTENSIFIED OFF.
WRITE:/1 sy-vline,
2 i_tab-obj_name HOTSPOT ON,
21 sy-vline,
22 modsapt-modtext,
95 sy-vline.
ENDLOOP.
WRITE:/(95) sy-uline.
DESCRIBE TABLE i_tab.
SKIP.
FORMAT COLOR COL_TOTAL INTENSIFIED ON.
WRITE:/ 'No of Exits:’, sy-tfill.
ELSE.
FORMAT COLOR COL_NEGATIVE INTENSIFIED ON.
WRITE:/(95) 'No User Exit exists'.
ENDIF.
ELSE.
FORMAT COLOR COL_NEGATIVE INTENSIFIED ON.
WRITE:/(95) 'Transaction Code Does Not Exist'.
ENDIF.
* Takes you to the SMOD TRANSACTION ON SINGLE CLICK
AT LINE-SELECTION.
Get Cursor field v_field.
CHECK v_field (5) EQ 'I_TAB'.
SET PARAMETER ID 'MON' FIELD sy-lisel+1(10).
CALL TRANSACTION 'SMOD'.

2.3.7 Report assignment category/ Customising Report Selection


Screens

Customizing Report Selection Screens (v4.6)


When programs and reports for Personnel Administration are run, the main selection
screen may appear something like so:

Page 62 of 72
HR-ABAP

This is a sample selection screen from a program/report that runs from Personnel
Administration. Specifically, this means that the program is based on logical
database PNP.

It is possible to amend this basic selection screen to suit your needs, for all programs
that have 'PNP' as the logical database. If you have not worked with logical
databases before and do not understand this part, them it's fairly safe to say that
most PA programs and reports ARE based on PNP. Usually you can see this, as the
selection screen looks very similar to the one above.

Lets look at the example above: perhaps we would like the date selection to be just
for a specific 'key date' and we want to just make the personnel number, personnel
area, subarea and employee group to be selection fields like this:

Page 63 of 72
HR-ABAP

Remember, this can be done for your own programs, and SAP standard ones without
making a 'correction/repair'. It can be useful for amending programs like the payroll
calculation driver, remuneration statements, and many of the PA reports.

First, you have to know the program name. If you do not know it, go to the
selection screen you wish to change, and click to System - Status, and note the
program name shown in the box:

Page 64 of 72
HR-ABAP

We see an example here, which shows the program name, is ZHRDEMO1.

Now for the configuration there are two steps to defining a ‘special’ selection screen
for a program/report:

1. Define a new report category (defining which fields and dates are used)
2. Assign the new category to the ABAP program

There is additional information in attached document about how to define/modify


new report category.

"Defining a new
report category.doc"

2.3.8 Authorization checks

Setting up the organizational key (v4.6)

This example demonstrates how to place the Personnel Area and Cost Centre values
into the Organizational Key field. A full explanation and demonstration of a more
complex scenario is due for publication in the main knowledge library shortly.

Background

The Organizational Key is a 14-character field of infotype 0001. It is used to refine


security/authorizations. It has no fixed contents; you determine the contents
yourself by using configuration settings and by the use of feature VDSK1.

Purpose

The field (P0001-VDSK1) on the Organizational Assignment infotype 0001


is normally used to control security/authorizations. When setting up
authorizations in HR, it is not possible to define profiles, which refer to
the personnel sub-area for example (plus many other fields). However,
one field that is available is the organizational key field from infotype
0001, so the configuration of the field is used to bring in values from
other fields.
Configuring a Simple Example
Please refer attached document.

"Configuration of
authorizations.doc"

Page 65 of 72
HR-ABAP

2.3.9 Views/Join/Projection

Views Introduction

When evaluating data, we distinguish between the logical and the physical view.

The physical view corresponds to the form in which the infotype data is stored in the
HR tables. This data is stored in infotype records with a validity period.

In the logical view, the validity periods of individual fields are determined for several
infotype records. For example, for an evaluation, the time period during which an
employee worked at a particular job may be important, irrespective of whether a
company code, personnel area or cost center change occurred during this time.

Data from several infotypes can also be provided for a specific partial period. When
calculating partial payroll periods, it is especially important that data on basic pay,
work schedule and cost distribution are provided for the relevant partial period.

Join

A join processes records from two or more infotypes. The data from these infotypes
is provided for a specific partial period.

Example We would like to know in which time period an employee worked at which
job and at which address he or she resided during this time.

The following address data is available:

January - June Hamburg

June - December Munich

The following work center data is available:

January - April Programmer

May - December Course instructor

If the address and work center data are provided for specific partial periods, the
following cases result:

Page 66 of 72
HR-ABAP
January - April Hamburg / programmer

May - June Hamburg / course instructor

July - December Munich / Course instructor

The ABAP syntax of this join is as follows:

PROVIDE * FROM Pmmmm


* FROM Pnnnn
BETWEEN PN-BEGDA AND PN-ENDDA.

The partial periods for infotypes Pmmmm and Pnnnn as well as for all other infotypes
of the join are defined in the fields BEGDA and ENDDA.

The data of each infotype in the join must be available during the entire validity
period of the infotype. The time periods of infotype records may not overlap;
therefore, the join may not contain infotypes with time constraint "three".

The time periods of records overlap if an infotype is read without any subtype
restrictions. For example, the Address infotype has the subtypes Permanent
residence, Temporary residence and Home address.

Time periods will ultimately overlap if all addresses are read. Therefore, you must
always select a subtype for a join, and this subtype may not have the time constraint
"three".

The program code for the above join for work center and address data is as follows:

REPORT RPABAP03.
TABLES: PERNR.
INFOTYPES: 0001, 0006.
GET PERNR.
PROVIDE * FROM P0001
* FROM P0006 BETWEEN PN-BEGDA AND PN-ENDDA
WHERE P0006-SUBTY eq '1'.
WRITE: / PERNR-PERNR, P0001-STELL,
P0006-STRAS, P0006-BEGDA, P0006-ENDDA.
ENDPROVIDE.

Sometimes no data is available for a particular infotype in the selected partial period.
Infotype validity periods may not overlap but gaps are permitted.

For example, gaps can occur when personal data is joined with address data:

Personal data

Page 67 of 72
HR-ABAP
January 1960 - May 1998 Miller

May 1998 - December 1998 Smith

Address data:

January 1998 - December 1998 Hamburg

A join for personal and address data is presented as follows:

January 1960 - December 1997 Miller

January 1998 - April 1998 Miller / Hamburg

May 1998 - December 1998 Smith / Hamburg

Only personal data is available in the first partial period. Since the record does not
provide the required information, the join's function of providing data from all
associated infotypes has not been fulfilled.

The variables Pnnnn_VALID recognize that only incomplete data is available for a
particular partial period.

This variable is formed when the report is run for each Pnnnn infotype included in a
join.

If data exists in the partial period for the Pnnnn infotype, the variable Pnnnn_VALID
is filled with X.

These variables are evaluated as follows:

REPORT RPDEMO03.
TABLES: PERNR.
INFOTYPES: 0002,
0006.
GET PERNR.
PROVIDE * FROM P0002
* FROM P0006 BETWEEN PN-BEGDA AND PN-ENDDA
WHERE P0006-SUBTY = '1'.
IF P0006_VALID EQ 'X'.
WRITE: / PERNR-PERNR,
P0002-BEGDA DD/MM/YYYY,
P0002-ENDDA DD/MM/YYYY,

Page 68 of 72
HR-ABAP
P0002-NACHN,
P0006-ORT01.
ENDIF.
ENDPROVIDE.

A list is generated only if address data is available. The first partial period, for which
only personal data is available, is suppressed.

Projection

All data of an infotype is stored on the database with its period of validity.

When you change one or more fields of an infotype record, the system creates a new
record with a new validity period. The date on which you changed the record is the
start date of this new record.

Therefore, the data fields that are not affected by the changes contain the same data
over several infotype records and validity periods.

From a logical perspective, these fields are valid in all infotype records until they are
changed.

When seen from this logical perspective, each field of an infotype has its own validity
period.

This is illustrated in the following case:

An employee has worked as a programmer for three years in three different


personnel areas.

Page 69 of 72
HR-ABAP
The following organizational assignment data is available:

January 1992 - December 1992: Programmer /personnel area 1

January 1993 - December 1993: Programmer /personnel area 2

January 1994 - December 1994: Programmer /personnel area 3

If you only require the time period during which an employee performs a specific job
and not his or her personnel area for an evaluation, the following applies:

January 1996 - December 1998: Programmer

The physical view has three infotype records, the logical view one.

To create meaningful evaluations and avoid redundancies, create logical views for
infotype records.

Select the infotype fields that are important for the evaluation and disregard the
others.

In the above example, the data in the other fields is invalid for the evaluation since it
is unknown which personnel area the employee belonged to from 1996 - 1998.

This view of the validity period of a group of infotype fields is known as projection.

The program code for the projection is:

PROVIDE <Field_1> <Field_2> <Field_n> FROM Pnnnn


BETWEEN PN-BEGDA AND PN-ENDDA .

The infotype data for a projection must be available throughout the entire validity
period. If the time periods of certain infotype records overlap, the data cannot be
clearly assigned to one period.

Therefore, you should not use projections for infotype records with time constraint
‘three’. The report for the above projection is:

REPORT RPABAP04.
TABLES: PERNR.
INFOTYPES: 0001.
GET PERNR.
PROVIDE STELL FROM P0001 BETWEEN PN-BEGDA AND PN-ENDDA.
WRITE: / PERNR-PERNR, P0001-STELL, P0001-BEGDA,
P0001-ENDDA.
ENDPROVIDE .

The logical validity for the activity period is included in the infotype BEGDA and
ENDDA fields.

Page 70 of 72
HR-ABAP

Join and Projection

You can combine the two logical views of infotype data, the join and the projection.

We read the data from several infotypes and create new partial periods. We select
the infotype fields that are important for the evaluation and combine these partial
periods again.

The following example illustrates this.


An employee works as a programmer in the current year and marries in May. Her
name does not change.

Organizational assignment:

January - December Programmer

Personal data:

January - April Donna Debug - single

May - December Donna Debug - married

When the data from both infotypes is read concurrently, the result is:

January - April Donna Debug - single /


programmer

May - December Donna Debug - married /


programmer

Since we can disregard her marital status in the evaluation, we project on her first
and last names:

January - December Donna Debug / programmer

The following report exemplifies the above case:

Page 71 of 72
HR-ABAP
REPORT RPDEMO04.
TABLES: PERNR.
INFOTYPES: 0001,
0002.
GET PERNR.
PROVIDE STELL FROM P0001
NACHN VORNA FROM P0002
BETWEEN PN-BEGDA AND PN-ENDDA
IF P0001_VALID = 'X'.
WRITE: / P0002-NACHN, P0002-VORNA,
P0001-BEGDA DD/MM/YYYY,
P0001-ENDDA DD/MM/YYYY,
P0001-STELL.
ENDIF.
ENDPROVIDE.

This report combines the associated validity periods and provides the data of
relevant infotype fields for a specific period.

Fields, which are not accessed, have their initial value in the projection.

Provision of data for a specific partial period is especially important for partial period
factoring in payroll.

If an employee's basic pay or the cost distribution changes during the payroll period,
you must calculate the salary proportionately for the resulting partial periods.

However, if the payroll administrator of the organizational unit changes, this has no
effect on payroll.

By linking a join and a projection, you can read the master data for a specific partial
period.

2.3.10 Case Studies

Page 72 of 72

You might also like