Technical Document On HR Programming PDF
Technical Document On HR Programming PDF
By Amar Chintam
2
Document by:- Amar Chintam
What is HR ?
The task of Human Resource Management is to produce the organizational hierarchies ,
relationship between employees and to allow storage and administration of employee
data .
Organization :
We can define an organization as an individual enterprise(company or industry) in which
someone is leading it and with some departments like HR, Marketing, Finance, R&D etc.
For any organization employees are the most powerful resource. So to maintain the
employee related data we require one system which ensures accuracy and consistent
within the organization.
Why HR is different from other modules ?
The following concepts are defined in HR which differs this module with other modules
1. Use of Infotypes
2. The use of Logical Database
3. Use of Macros
4. Storage and Access of data
5 Authorization checks
3
Document by:- Amar Chintam
Logical Database:
The use of logical database is very important in HR ABAP Programming. Being an
ABAP programmer you may be knowing about Logical Database (LDB). But I will give
a brief description about the LDB keeping in mind the novice.
Introduction:
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.
A logical database is linked to an ABAP report program as one of the program attributes.
It supplies the report program with a set of hierarchically structured table entries derived
from different database tables. This saves the developer from having to program the data
retrieval. For example The HR PA has the logical database PNP. The program behind this
LDB will be SAPLDBPNP.
HR Logical Databases:
In Human Resources (HR), the following logical databases can be used
1) PNP
2) PAP
3) PCH
Logical Database PNP: Use logical database PNP to report on HR master data. It is
possible to use logical database PCH( this facility can be used only to access this data,
but PNP meets such reporting requirements more quickly because it is best suited to the
task of selecting persons. To use logical database PNP in your program, specify in your
program attributes. Main functions of the logical database PNP
Data Retrieval
Authorization check
4
Document by:- Amar Chintam
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.
5
Document by:- Amar Chintam
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
6
Document by:- Amar Chintam
This is the attributes screen of the program. Look at the field Logical database. You need
to declare your required logical database at this place. I have declared the LDB as PNP.
Logical Database PCH: This logical database generally enables you to report on all HR
infotypes. However, you are advised not to use this logical database unless you want to
report on Personnel Planning data.
Logical Database PAP: Logical database PAP enables you to access data from
Recruitment.
7
Document by:- Amar Chintam
This is the PNP selection screen. You can customize the selection screen with your own
fields by change or create to HR report category.
8
Document by:- Amar Chintam
9
Document by:- Amar Chintam
Employee Subgroups: are further differentiated within the employee group. Eg.
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 eg. you can specify
whether an employee's pay should be determined on hourly or monthly basis.
10
Document by:- Amar Chintam
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.
11
Document by:- Amar Chintam
Infotypes: Infotypes are units of information in the Human Resource System. They are
used to group data fields together that all relate to the same subject matter. Infotypes
structure information, and facilitate data entry and time-dependent data storage. From the
users perspective, infotypes are data entry screens. From the database perspective,
infotypes are a data structure and a set of data records that belong together. The ability to
create histories for infotypes is ensured by time-dependent infotype storage. The system
records a validity period for each infotype record. Each infotype entered for an employee
usually has several data records that are distinguished one from the other by their validity
periods.
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.
12
Document by:- Amar Chintam
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:
13
Document by:- Amar Chintam
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 employees master data and working time data (infotypes).
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 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.
14
Document by:- Amar Chintam
15
Document by:- Amar Chintam
INFOTYPE PROCESSING:
After the Event GET PERNR point, the internal tables of the infotypes contain records
and ready for processing.
*Provide statement
PROVIDE * from pnnnn between PN-BEGDA and PN-ENDDA.
Write: / pnnnn-<field>.
ENDPROVIDE
Pnnnn stands for internal table for infotype nnnn. It is similar to normal
select statement.
16
Document by:- Amar Chintam
Look at the
example below
Personnel number
Name
Language
Date of birth
REPORT zamar.
*-- Declaration
TABLES: pernr.
INFOTYPES: 0002.
"Personal Data
SELECT-OPTIONS: language FOR p0002-sprsl.
*-- Selection screen
INITIALIZATION.
pnptimed = 'D'.
*-- Processing
GET pernr.
PROVIDE * FROM p0002 BETWEEN pn-begda AND pn-endda.
CHECK language.
WRITE: / p0002-pernr,
sy-vline,
pernr-ename,
sy-vline,
p0002-sprsl,
sy-vline,
p0002-gbdat.
ENDPROVIDE.
17
Document by:- Amar Chintam
Suppose you require additional reports that combine data from different infotypes
Then you need to join one or more infotypes.
18
Document by:- Amar Chintam
19
Document by:- Amar Chintam
The * in the PROVIDE statement, which stands for all of the fields in the
infotype, is replaced by the five-digit field name of the infotype included in the
projection.
The * in a simple PROVIDE means that all of the fields in the infotype are
included in the projection.
JOIN and PROJECTION can be combined in a PROVIDE statement.
Infotype records are not allowed to overlap for projection. Data must be unique,
which means that projection is only allowed for time constraints 1 and 2.
The logical validity of the activity period is stored in the infotype's BEGDA and
ENDDA fields.
20
Document by:- Amar Chintam
Look at the
example below
Process the Personal Data infotype (0002) and Addresses infotype (0006) using a
JOIN.
Suppose you want to create a report in which period the employee lived at which address
under which name. The created list should contain the following information:
Start date
End date
Name
Place of residence
Only process the records from Infotype 0006 which have subtype 1.
Only print data for the periods for which address information is available.
Use a variable with the characteristics of field P0001-ENAME, so that the first
and last name are only separated by one space. Use the statement
CONCATENATE.
Enter a width of 100 characters for the list (addition LINE-SIZE for keyword
REPORT).
Restrict the length of the name to 30, and the length of the city to 20
characters.
Separate the resulting field contents in your list by a vertical line (SY-VLINE).
"Personal Data
"Address
*-- Processing
GET pernr.
21
Document by:- Amar Chintam
22
Document by:- Amar Chintam
Look at the
example below
Suppose you want to create a report which documents how an employees job has
developed. The created list should contain the following information:
Name
Date of birth
Start date
End date
Job key
Job title
Only print data for the periods in which organizational assignment information
is available.
Before reading table T513S, check that the table entry to be read for the job
key in question is already in the work area. To do this, use the statement
CHECK.
If the required table entry does not exist, print the personnel number, an error
text, and the job key text.
End further processing with the REJECT statement.
Enter a width of 100 characters for the list (addition LINE-SIZE for keyword
REPORT).
Restrict the length of the name to 20, and the length of the job title to 15
characters.
Separate the resulting field contents in your list by a vertical line (SY-VLINE).
23
Document by:- Amar Chintam
"Job Titles
"Organ. Assignment
"Personal Data
*-- Processing
GET pernr.
PROVIDE stell ename FROM p0001
gbdat
FROM p0002 BETWEEN pn-begda and pnendda.
IF p0001_valid EQ 'X'.
IF p0001-stell NE space.
PERFORM re513s.
WRITE: / pernr-pernr,
sy-vline,
(20) p0001-ename,
sy-vline,
p0002-gbdat,
sy-vline,
p0001-stell,
sy-vline,
(15) t513s-stltx,
sy-vline,
p0001-begda,
sy-vline,
p0001-endda.
ENDIF.
ENDIF.
ENDPROVIDE.
*------------------------------------------------------------*
*
FORM RE513S
*------------------------------------------------------------*
*
Read Job Title
*------------------------------------------------------------*
FORM re513s.
CHECK sy-langu
NE t513s-sprsl OR
p0001-stell NE t513s-stell OR
p0001-begda LT t513s-begda OR
p0001-begda GT t513s-endda.
SELECT * FROM t513s
WHERE sprsl EQ sy-langu
AND
stell EQ p0001-stell
24
Document by:- Amar Chintam
25
Document by:- Amar Chintam
Like subroutines and function modules, macro modules can be used to modularize
programs. Macro modules are frequently used in HR.
These macros are defined in program SAPDBPNP (include DBPNPMAC) with the
keyword DEFINE. They can be used in any program that uses the logical database
PNP.
If you want to use these macros in reports that do not use the logical database PNP,
you must include program DBPNPMAC with the keyword INCLUDE.
You can also define your own macros. In accordance with the naming convention, the
first two letters stand for the application.
Some macros are also stored in the Macros in ABAP Programs table (TRMAC)
26
Document by:- Amar Chintam
The RP_PROVIDE_FROM_LAST macro retrieves the last valid data record in the
data selection period.
The parameters for RP_PROVIDE_FROM_LAST are: infotype, subtype, start date,
and end date. If you do not want to specify a particular subtype, enter SPACE.
You can process not only the last valid data record in the data selection period, but
also the first valid data record using the RP_PROVIDE_FROM_FRST macro.
The macro return code PNP-SW-FOUND has the value 1 if a suitable entry exists in
the infotype table for the specified period. If no entry is found, the value is 0.
27
Document by:- Amar Chintam
28
Document by:- Amar Chintam
It is often necessary to read the groupings stored in the Personnel Area/Subarea table
because they are required as keys for other tables. This must take place individually
for each personnel number to be processed.
Each employee's assignment to a personnel area and subarea is stored in infotype
0001.
The parameters of the macro are:
Personnel areas
Personnel subareas
Reaction, if no entry is found:
X = Termination of report with error message No entry found in table ...
SPACE = SY-SUBRC is set to 4.
Alternatively, if you only want to determine the country indicator, you can use the
function module HR_COUNTRY_GROUPING_GET.
29
Document by:- Amar Chintam
You can also read infotype records for a particular personnel number without using
the logical database.
To do this, use the function module HR_READ_INFOTYPE. However, you must
ensure that the internal table for the required infotype is declared with the INFOTYPE
statement.
30
Document by:- Amar Chintam
The function module reads the HR infotype records for a person (employee or
applicant) in accordance with the specified selection criteria. Values are returned in an
internal table, the structure of which corresponds to the appropriate infotype table. In
the calling program, such tables can be declared with the INFOTYPES statement, for
example. An infotype record is selected if its validity period overlaps with the
specified period.
The function module performs an authorization check.
31
Document by:- Amar Chintam
With this function module, you can determine the initial start date of an employee.
You can take the following infotypes into account when you determine this date:
- P0000 Actions
- P0001 Organizational Assignment
- P0016 Contract Elements
- P0041 Date Specifications
32
Document by:- Amar Chintam
Before you change employee data, you must lock the personnel number. You can do
this with the function module BAPI_EMPLOYEE_ENQUEUE.
Messages are returned in the parameter RETURN. If an error occurs, this structure
contains the following information:- Message type (field TYPE)- Message text (field
MESSAGE).If the step is successful, the structure is blank.
If an employee's data has been locked, only the user who has locked the data can
access the data records linked to the employee. For other users, access is denied. For
this reason, you must remove the lock after the data has been changed. You can do
this with the function module BAPI_EMPLOYEE_DEQUEUE.
33
Document by:- Amar Chintam
With this function module, you can maintain the employee and applicant master data.
You can specify one data record. All validations that would normally take place if the
infotypes were maintained online with the individual maintenance screens are also
carried out here. The module returns the same error messages as in the online
operation. This means the error messages for the individual maintenance screens are
displayed rather than interpreted. The update is carried out by a 'Call dialog' to the
module pool for the infotype. This means that some restrictions apply to the infotypes
processed in that way (see documentation for module).
The following values are amongst those available for the parameter OPERATION:
MOD (change), COPY (copy), DEL (delete), INS (insert), LIS9 (delimit).
With the parameter DIALOG_MODE, you specify whether the action is generally
run in the background or whether it only runs in the background until an error occurs,
or whether the changes are generally carried out in the dialog mode. Possible
values:'0' The changes are generally processed in the background. If an error occurs
(with an E or A message), the complete step is terminated and the module returns the
corresponding error message in the structure 'RETURN'.
'1' The changes are generally processed in the background. If an error occurs, the
system switches to dialog mode so that the user can correct the entries.
'2' The changes are processed in the dialog mode.
34
Document by:- Amar Chintam
If you cannot use the function module HR_INFOTYPE_OPERATION, you can use
the UPDATE statement. Note that the system does not check the correctness of the
new field contents when a direct DB update takes place.
In this example, the field P0002-NATIO (nationality) in DB table PA0002 is updated
directly. The field contents is changed from DE' to D'. The incorrect value 'D' in
field PA0002-NATION then triggers an error message when the infotype record is
changed or copied in dialog mode.
The system field SY-DBCNT contains the number of changed records.
Authorization checks are not supported by the UPDATE statement and should be
carried out on the program level.
Many HR reports use macros. Their program codes are stored in a table or defined
locally using the DEFINE keyword.
The RP_PROVIDE_LAST macro writes the last valid record in the data selection
period to the header line of the internal Infotype table.
You can use the function module HR_READ_INFOTYPE to read the personal data
in reports which do not use an HR logical database.
35
Document by:- Amar Chintam
Look at the
example below
to
read
the
Personnel
Suppose you need to create a report that will generate a list of the recurring payments and
deductions for each employee.
The list should contain the following information for each employee:
Personnel number
Name
Personnel area
Personnel subarea text
36
Document by:- Amar Chintam
To place the last infotype 0001 record valid in the data selection period in
the header of internal table P0001, use the macro
RP_PROVIDE_FROM_LAST.
To read table T001P (Personnel Area/Subarea), use the macro RP-READT001P. The country indicator is assigned to each personnel area/subarea
in the field T001P-MOLGA. The country indicator is part of the key for
table T512T (Wage Type Texts). The personnel area text is taken from
field T001P-BTEXT.
Read the accompanying wage type texts for the wage types for infotype
0014 from table T512T. Before reading table T512T, check that the table
entry to be read is already in the workarea. To do this, use the statement
CHECK.
Restrict the length of the name to 20 characters.
REPORT zpamar2 .
*-- Declaration
TABLES: pernr,
t512t,
t001p.
INFOTYPES: 0001,
0014.
Deduc.
DATA: filled_lines LIKE sy-index.
*-- Processing
GET pernr.
DESCRIBE TABLE p0014 LINES filled_lines.
IF filled_lines GT 0.
rp_provide_from_last p0001 space pn-begda pn-endda.
rp-read-t001p p0001-werks p0001-btrtl space.
SKIP 2.
WRITE: / pernr-pernr,
(20) p0001-ename,
p0001-werks,
t001p-btext.
PROVIDE * FROM p0014 BETWEEN pn-begda AND pn-endda.
CHECK p0014-betrg NE 0.
PERFORM print USING
p0014-lgart
p0014-betrg
p0014-begda
p0014-endda.
ENDPROVIDE.
ENDIF.
37
Document by:- Amar Chintam
38
Document by:- Amar Chintam
39
Document by:- Amar Chintam
When working with infotypes, it is important to comply with the above namespace
conventions.
Other namespace conventions for standard infotypes:
Time Management infotypes are assigned to namespace 2000-2999
Recruitment infotypes are assigned to namespace 4000-4999
40
Document by:- Amar Chintam
41
Document by:- Amar Chintam
Events
Org assignment
Personal info
Payroll data
Work time
Basic pay
Reoccurring pay
1 X pay
Cost Center
Event Dates
Membership dues
Over ride to limits on deductions
Health
Insurance
Savings
Spending
Garnishment reduction
Garnishment order
Residence Tax
Work Tax
Unemployment Tax
Withholding
Garnishment adjustment
Adjustment
Off cycle
OT
Catts direct to cluster
Infotypes 1000 1999 are PD Relationship infotypes
42
Document by:- Amar Chintam
Jobs: A job is the general classification for a set of tasks. Eg. manager, customer
service representative. Each Job identifies a unique classification of activity.
Employees hold positions and not Jobs. Jobs are linked to Positions, which are
held by employees. Equal number of positions should be created for each Job.
Use transaction PP02 to create Org.Units. Object type 'C'. Table HRP1000.
Accounting Manager
43
Document by:- Amar Chintam
In the Dictionary, each HRPnnnn infotype table is defined using the following three include
structures:
HRIKEY: contains the key fields of the infotype table
HRIADMIN: contains administrative information on the infotype record (including the
date on which it was last changed, and the user name of the person who made this last
change)
HRInnnn: contains the infotype-specific fields with the actual infotype data or information
To ensure that transparent table HRPnnnn and logical structure Pnnnn always remain
mutually consistent, structure HRInnnn is also included by structure Pnnnn.
44
Document by:- Amar Chintam
The primary key of transparent table HRPnnnn consists of the following key fields:
MANDT: legally and organizationally independent participants in the system.
PLVAR: a one or two-character alphanumeric plan version key that is used to make a
distinction between different organizational plans.
OTYPE: a one or two-character alphanumeric object key (such as S for position, Q for
qualification, and E for business event).
OBJID: an eight-digit, non-mnemonic key that represents a single object (such as an
organizational unit, qualification, or business event).
SUBTY: subtypes are subdivisions of infotypes. An infotypes subtypes can have
different time constraints and form their own histories.
ISTAT: a one-digit key that stands for a planning status. All objects and their defining
infotypes have a status. This enables you to put objects and infotypes through a planning
cycle.
BEGDA: end date.
ENDDA: start date.
VARYF: variation field of the PLOG file (that contains the target object for relationships).
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). It is assigned by the system automatically.
45
Document by:- Amar Chintam
Report RHMOVE00 transports Planning data records from the R/3 System to a
sequential file.
This sequential dataset can be displayed and edited using report RHMOVE40.
Report RHALTD00 uses a sequential dataset to create a batch input session.
Structure E1Pnnn must be used for records of infotype Pnnnn. This is the IDoc
segment structure of the infotype.
Structure E1Pnnnn is expanded for table infotypes - that is, it contains the primary
record and the table division of the table infotype.
Structure E1PADnn must be used for relationships with additional data of
structure PADnn. For the assignment, see table T77AD.
46
Document by:- Amar Chintam
47
Document by:- Amar Chintam
48
Document by:- Amar Chintam
Positions must be linked to an organizational unit. However, if you want to view the
position hierarchy, you must create a reporting structure by relating positions to each
other.
An organizational unit can incorporate one or more positions. A position belongs to
an organizational unit.
Example:
The organizational unit Personnel incorporates the positions Head of Department
and Secretary.
The position Secretary belongs to the organizational unit Human Resources.
49
Document by:- Amar Chintam
If Organizational Management is integrated with master data, the holder relationship between
position and person is also stored for the person in the Organizational Assignment infotype
(0001), despite the fact that the data is redundant.
50
Document by:- Amar Chintam
The Object infotype performs key functions. It enables you to create new objects, such as
organizational units and jobs, and determines the validity period of other infotypes that
describe the characteristics of existing objects.
Once you have used this infotype to create an object, its characteristics can be described
using other infotypes such as the Relationships Infotype (1001) and the Description Infotype
(1002).
The Object Infotype (1000) defines an object's existence. You can use it to store a short text
and a long text on the object.
An object is uniquely identified by its:
- Plan variant- Object type
- Object identification
Records stored in the Relationships Infotype (1001) serve as a descriptive and functional link
between objects. For example:
A person is the holder of a position
A position belongs to an organizational unit
An organizational unit is assigned to a cost center in CO
51
Document by:- Amar Chintam
The relationships between basic object types are defined in the standard system and should
not be changed.
Each standard relationship has a three-digit code. The customer namespace is from AAA to
ZZZ.
Relationships between objects are reciprocal. If a job describes a position, for example, then
the position is described by the job. When you assign a relationship, the system automatically
creates its inverse relationship. This enables you to carry out reporting from either
perspective.
52
Document by:- Amar Chintam
The Pnnnn structure contains an infotype's key fields and data fields.
The PTnnnn structure contains the table infotype data fields for some infotypes.
The PADnn structure defines additional data for particular relationships.
The transparent HRPnnnn tables contain the infotypes used in Personnel Planning. Table
infotypes are stored in the HRTnnnn tables. Additional data on relationships is stored in the
HRPADnn tables.
Transparent table PLOGI contains an index of all objects on the Personnel Planning database.
They can be displayed and created with report RHPLOGI0. This object directory is the basis
of all evaluations using logical database PCH.
53
Document by:- Amar Chintam
For each selected object, internal table Pnnnn is filled per infotype with all available infotype
records.
The infotypes from Personnel Administration can also be imported.
54
Document by:- Amar Chintam
The only difference between a structural and sequential evaluation is the additional GDSTR
entry in the TABLES statement. This ensures that the structure parameters are shown on the
standard selection screen.
Note:
If you do not specify an evaluation path before starting the program, a sequential evaluation
is performed.
55
Document by:- Amar Chintam
When the INITIALIZATION event occurs, you can set default values for the selection
screen.
The fields for the object ID are defined in include DBPCHSEL. This is an internal table
(PCHOBJID) that must be filled with APPEND.
56
Document by:- Amar Chintam
For each selected object, internal table Pnnnn is filled per infotype with all available infotype
records.
For each selected object, the OBJEC structure contains the most important information from
infotype 1000 (plan version, object type, object ID, short text, and long text).
The GDSTR structure contains information on the current hierarchy, such as the root object
and the number of objects within the hierarchy. The value of the structure does not change
unless the system reaches a new hierarchy root when a structural evaluation is performed for
more than one root object.
For each selected object, the STRUC structure contains internal structure information. In
particular, it includes information on the relationship used by the system to select the current
object along the evaluation path.
57
Document by:- Amar Chintam
RH-GET-TBDAT is a macro for logical database PCH. These macros are defined in include
DBPCHCOM. With this macro, you can import the data for an infotype with a repetitive
structure. See also Table Infotypes.
The parameters for macro RH-GET-TBDAT are:
Parameter 1 : Infotype
Parameter 2 : Reference field
Parameter 3 : Table for structure PTnnnn
Macros for logical database PCH must not be confused with macros for logical database PNP.
Please note that you cannot use macros for logical databases PCH and PNP at the same time.
58
Document by:- Amar Chintam
59
Document by:- Amar Chintam
Look at the
example below
Suppose you require an overview of the staff positions with the name of the employees
holding these positions and their telephone numbers.
Write a report that lists the staff positions in the organization structure along with
the persons assigned to these positions.
Use the evaluation path O-S-P.
For the personal data (first name, last name), use the infotype 0002 records for
the person. For the telephone number, use subtype 1 from infotype 0006.
The staff position information is contained in infotype 1003 for the position. If
the position is flagged as a staff position, the field P1003-STABS has the value
X.
Process the records from infotypes 0006 and 0002 with a join. For these
infotypes, project to the First name, Last name, Telephone number, and Subtype
fields.
For holders of staff positions only, display the object ID, the object identifier,
and the object name. Display this in one line. In the following line, display the
name and the telephone number.
The object type O and the evaluation path should appear in the selection screen
as default values.
REPORT zhsol010.
TABLES: objec, gdstr.
INFOTYPES: 0002, 0006, 1003.
DATA: stabs LIKE p1003-stabs,
name LIKE p0001-ename.
INITIALIZATION.
pchotype = 'O'.
60
Document by:- Amar Chintam
61
Document by:- Amar Chintam
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.
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
62
Document by:- Amar Chintam
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. eg. Punch cards, Manual time sheets that stores hours worked
for each day alongwith any absenses.
All the absence's and attendance in a day are uploaded into SAP and analysed 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.
63
Document by:- Amar Chintam
The employee work schedule is an integral part of R/3 Time Management containing the
planned specifications for employee working time.
An employees 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 days working time including breaks. 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.
64
Document by:- Amar Chintam
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 a personnel
subarea.
Public holidays are taken into account when determining bonuses or calculating
leave, for example.
65
Document by:- Amar Chintam
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 employees 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).
66
Document by:- Amar Chintam
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.
67
Document by:- Amar Chintam
68
Document by:- Amar Chintam
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
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.
69
Document by:- Amar Chintam
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.
70
Document by:- Amar Chintam
71
Document by:- Amar Chintam
Cluster tables combine the data from several tables with identical (or almost identical)
keys into one physical record on the database.
Data is written to a database in compressed form.
Retrieval of data is very fast if the primary key is known.
Cluster tables are defined in the data dictionary as transparent tables.
External programs can NOT interpret the data in a cluster table.
Special language elements EXPORT TO DATABASE, IMPORT TO DATABASE
and DELETE FROM DATABASE are used to process data in the cluster tables.
PCL1 - Database for HR work area;
PCL2 - Accounting Results (time, travel expense and payroll);
PCL3 - Applicant tracking data;
PCL4 - Documents, Payroll year-end Tax data
PCLn database tables are divided into subareas known as data clusters.
Data Clusters are identified by a two-character code. e.g RU for US payroll result,
B2 for time evaluation result...
Each HR subarea has its own cluster.
Each subarea has its own key.
Database Table PCL1
The database table PCL1 contains the following data areas:
B1 time events/PDC
G1 group incentive wages
L1 individual incentive wages
PC personal calendar
TE travel expenses/payroll results
TS travel expenses/master data
TX infotype texts
ZI PDC interface -> cost account
73
Document by:- Amar Chintam
Payroll is used to calculate the remuneration for work done for each employee. SAP
Payroll delivers powerful and efficient gross-to-net, net-to-gross, regular and off-cycle
payroll processing. SAP's complex Payroll process handles everything including
vacation policies, compensation programs, work schedules, Holidays, overtime pay etc.
SAP's ESS (Employee Self Service) function allows employees to view, create and
maintain data anytime, anywhere, via Web-based technology and interactive voice
response functionality. ESS is an effective means for providing real-time access and data
maintenance capabilities to the source or owner of the data. It has the ability to offload
much of the data entry and related customer service activities that may be typically
performed in an organization's human resources, payroll, benefits and purchasing
departments.
Payroll area - groups employees based on the frequency of their paydates. eg. Z1
for salaried staff paid monthly.
Control Record - It determines the current payroll period for a payroll area.
Period Modifier - Period in which payroll accounting is carried out. eg. 10 - for
monthly pay periods.
Date Modifier - Distinguishes periods with same frequency but different date.
Eg. 10 - for monthly pay period but with the pay date being 5th of every month.
Payroll Calendar - Generating calendars for cumulating wage types to get
monthly, quaterly or yearly sum totals.
Payscale type - used for segregation of employees payscales based on the type of
union contracts in a company. Eg. 10 - non union workers 20 - collective
agreement for secretaries contract.
Payscale area - Differentiates payscales based on geographical area. Eg. 10 California.
Payscale group - Differentiates employees payscales based on functionality. Eg.
GR01 - grouping for junior clerks, GR02 - for senior clerks.
Payscale level - Subdivision of employees payscales. Eg. L1 - level 1 clerk, L2 level 2 clerk.
Wage types - The payments and deductions for an employee are coded as wage
types. Eg. A001 - salary payment, B001 - 401K deduction.
74
Document by:- Amar Chintam
Payroll Infotypes: Payroll data is stored in various infotypes, which includes, 0001,
0007, 0008, 0009, 0207, 0208, 0209, 0210, 0234. These infotypes maintain personal
details, payment and deduction info, benefits data, garnishment data, tax data, etc.
Payroll Process involves:
75
Document by:- Amar Chintam
76
Document by:- Amar Chintam
77
Document by:- Amar Chintam
The remuneration elements for an employee are formed from individual wage and
salary types that are used during a payroll period. Payments such as basic pay, various
bonuses and gratuities are included in the remuneration calculation. Deductions can
be made for items such as a company-owned flat, company-sponsored day care or
similar benefits. Different factors determine whether such benefits increase or reduce
the taxable income. This is determined by country-specific regulations and, in some
countries, the philosophy of the company.
An employee's remuneration consists of all wage types calculated for him or her
during a payroll period.
78
Document by:- Amar Chintam
Voluntary and statutory deductions, such as tax and social insurance contributions,
are taken from the gross calculation to determine the payment amount. Different
gross values, for example, total gross amount, and gross tax amount, are used to
calculate the deductions. For this reason, different totals are formed during the payroll
run, and these totals are be used for subsequent processing.
79
Document by:- Amar Chintam
The payroll program is usually run separately for different employee groups. A
typical example is that of salaried employees and hourly employees, for whom
payroll is performed using two different payroll periods. The payroll area determines
when payroll is run.
The payroll area serves two functions, both of which are prerequisites for running the
payroll. The payroll area groups together personnel numbers that must be processed
in the same payroll run
The payroll area determines the payroll period.
Employees for whom payroll is performed at the same time and for the same payroll
period are assigned to the same payroll area. Personnel numbers are assigned to a
payroll area in the Organizational Assignment infotype (0001).
80
Document by:- Amar Chintam
The personnel numbers to be included in the payroll run are selected by specifying a
payroll area in the payroll driver selection screen. The payroll period is transferred
directly from the payroll control record to the payroll program.
In a live run, the payroll period is determined by the system. The last period to be
included in a payroll run is stored in the payroll control record for each payroll area.
The current payroll period is, therefore, the last period to be included in a payroll run,
plus one.
Hint: Payroll driver should be started by Personnel Number or Payroll Area only.
81
Document by:- Amar Chintam
The structure of PCLn database tables provides a basic structure for individual
subareas.
The name of each subarea must include a two-character cluster name or relation ID.
A key structure must also be defined; 40 bytes are available in field SRTFD for this
purpose.
In the international payroll results, for example, the field RELID contains the cluster
name RX and the field SRTFD contains the eight-digit personnel number as well as a
five-digit sequence number for each individual payroll result for a payroll period.
To enable the import of a record from a PCLn database table, the RELID field must
contain the cluster identifier and the SRTFD field must contain the cluster key. The
fields CLIENT and SRTF2 are filled by the system.
82
Document by:- Amar Chintam
If data is imported using macros, the data records are not read directly from table
PCLn. Instead, the buffer directory is checked to determine whether the main memory
already contains a record with the same key. If this is not the case, the record is read
from PCLn to the buffer, and retrieved from the buffer by the report.
If data is read using a buffer, the system checks the cluster authorization. The
standard import programs follow the RPCLSTxy naming convention, where xy =
cluster name.
83
Document by:- Amar Chintam
With this report, you can display the payroll results for any country. The indicator
behind each name shows whether results exist in the selected period.
Green:
Results exist
Red:
No results exist
Gray:
No authorization for displaying personnel numbers
Payroll results are stored as structures and internal tables on the database.
Each payroll result has a status indicator:
A =
Current result
P =
Previous result
O =
All other results
84
Document by:- Amar Chintam
The payroll driver, RPCALCn0, uses HR data (stored in the database tables PAnnnn)
and the last payroll result (stored in the database table PCL2) to run the payroll for the
specified period
The program (payroll driver) imports the processing logic in the form of a schema.
The schema contains functions that call the subroutines contained in the payroll
driver. In many cases, the function is enhanced by rules for specific control of the
subroutines.
The payroll result generated by the payroll driver is stored in cluster xy of the
database table PCL2.
Report H99_DISPLAY_PAYRESULT displays the payroll results for PCL2 and,
from Release 4.6C, replaces reports RPCLSTxy and HxyCLSTR. The report is used
in all country versions and the overview of payroll results is automatically displayed
according to the particular country.
Report RPCEDTn0, for example, lists the formatted result as a payroll form (n = HR
country indicator from table T500L).
85
Document by:- Amar Chintam
Look at the
example below
Suppose you need a report with a list of wage types from the results table for the current
(last) payroll result in a for-period.
Write a report to import the results of international payroll to cluster RX and then display
them. The report should evaluate the last payroll result for the for-period. Test your
program using the personnel number assigned by your trainer.
The created list should contain the following information for each employee:
1st line:
- Personnel number
- Name
- Personnel area
2nd line:
- For-period
- For-payroll area
3rd line:
- In-period
- In-payroll area
4th line:
- Wage type
- Wage type text
- Amount
86
Document by:- Amar Chintam
Then read the payroll result for the sequential number you have determined
using the function module PYXX_READ_PAYROLL_RESULT.
The wage types and amounts are saved in table RT. The text belonging to the
wage types can be found in table T512T. Only display the first 15 characters
of the employee name.
REPORT zpsol080.
TABLES: pernr,
t512t.
"Wage type texts
INFOTYPES: 0001. "Organizational Assignment
*Table data containing directory to PCL2 payroll results
file
DATA: BEGIN OF rgdir OCCURS 100.
INCLUDE STRUCTURE pc261.
DATA: END OF rgdir.
DATA: result TYPE pay99_result.
DATA: rt_header TYPE LINE OF hrpay99_rt.
DATA: country LIKE t001p-molga,
number LIKE pc261-seqnr. "Number of last payroll
result
GET pernr.
rp_provide_from_last p0001 space pn-begda pn-endda.
CALL FUNCTION 'CU_READ_RGDIR'
EXPORTING
persnr
= p0001-pernr
IMPORTING
molga
= country
TABLES
in_rgdir
= rgdir
EXCEPTIONS
no_record_found = 1
OTHERS
= 2.
IF sy-subrc = 1.
WRITE: / 'No records found for '(001), pernr-pernr.
ENDIF.
87
Document by:- Amar Chintam
*
*
*
*
*
*
IF sy-subrc = 1.
WRITE: / 'No payroll result found for'(002), pn-paper.
ELSE.
CALL FUNCTION 'PYXX_READ_PAYROLL_RESULT'
EXPORTING
clusterid
= 'RX'
employeenumber
= p0001-pernr
sequencenumber
= number
READ_ONLY_BUFFER
= ' '
READ_ONLY_INTERNATIONAL
= ' '
CHECK_READ_AUTHORITY
= 'X'
IMPORTING
VERSION_NUMBER_PAYVN
=
VERSION_NUMBER_PCL2
=
CHANGING
payroll_result
= result
EXCEPTIONS
illegal_isocode_or_clusterid = 1
error_generating_import
= 2
import_mismatch_error
= 3
subpool_dir_full
= 4
no_read_authority
= 5
no_record_found = 6
versions_do_not_match
= 7
OTHERS
= 8.
IF sy-subrc = 0.
PERFORM print_rx.
ELSE.
WRITE: / 'Result could not be read (003).
ENDIF.
ENDIF.
*-----------------------------------------------------------*
*
FORM PRINT_RX
*
*-----------------------------------------------------------*
88
Document by:- Amar Chintam
User Exits
Enhancement PBAS0001 has two function exits.
REPORT zuexit_amar_ar .
*(This program when executed will give you all the user
exit *associated
*with the Tcode. Click on the exit you will be taken to
the SMODE.
*Select the components radio button and click on
display.You will be
*taken to the function module exit. Clicking on the
function exit you
*will be taken to the actual function module which has
the include in
*it where you need to put the extra code).
90
Document by:- Amar Chintam
93
Document by:- Amar Chintam
HR Transactions
Master
PA10
PA20
PA30
PA40
PA41
PA42
PRMD
PRMF
PRML
PRMM
PRMO
PRMP
PRMS
PRMT
PSO3
PSO4
Data
Personnel File
Display HR Master Data
Maintain HR Master Data
Personnel Events
Change Hiring Data
Fast Data Entry for Events
Maintain HR Master Data
Travel Expenses: Feature TRVFD
Set Country Grouping via Popup
Personnel Events
Travel Expenses: Feature TRVCO
Travel Expenses: Feature TRVPA
Display HR Master Data
Update Matchcode
Infotype overview
Individual maintenance of infotypes
Time Management
PA51
Display Time Data
PA53
Display Time Data
PA61
Maintain Time Data
PA62
List Entry of Additional Data
PA63
Maintain Time Data
PA64
Calendar Entry
PA70
Fast Data Entry
PA71
Fast Entry of Time Data
PBAB
Maintain vacancy assignments
PT01
Create Work Schedule
PT02
Change Work Schedule
PT03
Display Work Schedules
Payroll
PC00
Run Payroll
PC10
Payroll menu USA
PE00
Starts Transactions PE01,PE02,PE03
PE01
Schemas
PE02
Calculation Rules
PE03
Features
PE04
Create functions and operations
PE51
HR form editor
PRCA
Payroll calendar
PRCT
Current Settings
94
Document by:- Amar Chintam
PRCU
PRD1
SM31
SM12
TSTC
SPR0
SE16
PP03
PP0M
P013
PO03
Benefits
PA85
Benefits - Call RPLBEN11
PA86
Benefits - Call RPLBEN07
PA87
Benefits - Call RPLBEN09
PA89
COBRA Administration
PA90
Benefits Enrollment Individual
PA91
Benefits - Forms
PA92
Benefits Tables - Maintain
PA93
Benefits Tables - Display
PA94
Benefits - Access Reporting Tree
PA95
Benefits IMG - Jump to Views
PA96
Benefits reporting
PA97
Salary Administration - Matrix
PA98
Salary Administration
PA99
Compensation Admin. - rel.changes
PACP
HR-CH: Pension fund, interface
Payroll
PC00
Run Payroll
PC10
Payroll menu USA
PE00
Starts Transactions PE01,PE02,PE03
PE01
Schemas
PE02
Calculation Rules
PE03
Features
PE04
Create functions and operations
PE51
HR form editor
PRCA
Payroll calendar
PRCT
Current Settings
PRCU
Printing Checks USA
PRD1
Create DME
SM31 Maintain Tables
SM12 Locked Secessions
TSTC Table lookup
SPR0 IMG
95
Document by:- Amar Chintam
SE16
PP03
PP0M
P013
PO03
Benefits
PA85
Benefits - Call RPLBEN11
PA86
Benefits - Call RPLBEN07
PA87
Benefits - Call RPLBEN09
PA89
COBRA Administration
PA90
Benefits Enrollment Individual
PA91
Benefits - Forms
PA92
Benefits Tables - Maintain
PA93
Benefits Tables - Display
PA94
Benefits - Access Reporting Tree
PA95
Benefits IMG - Jump to Views
PA96
Benefits reporting
PA97
Salary Administration - Matrix
PA98
Salary Administration
PA99
Compensation Admin. - rel.changes
PACP
HR-CH: Pension fund, interface
General/Reporting
PM00
Menu for HR Reports
PM01
Dialogs in HR - Create custom infotypes
PRF0
Standard Form
PSVT
Dynamic Tools Menu
PAR1
Flexible employee data
PAR2
Employee list
PD - Organizational Management
PP0M Change Org Unit
PO03 Maintain Jobs
PO13
Maintain Position
PO10
Maintain Organizational Unit
PP01
Maintain Plan Data (menu-guided)
PP02
Maintain Plan Data (Open)
PP03
Maintain Plan Data (event-guided)
PP05
Number Ranges
PP06
Number Range Maintenance: HRADATA
PP07
Tasks/Descriptions
PP69
Choose Text for Organizational Unit
PP90
Set Up Organization
PPO1
Change Cost Center Assignment
PPO2
Display Cost Center Assignment
96
Document by:- Amar Chintam
PPO3
PPO4
PPO5
PPO6
PPOA
PPOC
PPOM
PPOS
PQ01
PQ02
PQ03
PQ04
PQ06
PQ07
PQ08
PQ09
PQ10
PQ11
PQ12
PQ13
PQ14
PQ15
PSO5
PSOA
PSOC
PSOG
PSOI
PSOO
PSOS
PSOT
Recruitment
PB10
Init.entry of applicant master data
PB20
Display applicant master data
PB30
Maintain applicant master data
PB40
Applicant events
PB50
Display applicant actions
PB60
Maintain applicant actions
PB80
Evaluate vacancies
PBA0
Evaluate advertisements
PBA1
Applicant index
PBA2
List of applications
PBA3
Applicant vacancy assignment list
PBA4
Receipt of application
97
Document by:- Amar Chintam
RPUCTI00
RPUCTJ00
RPUCCOSE
RPUCTX00
RPUSCD10
RPUCTC00
Time Management
RPTQTA10
RPTQTA00
RPTLEACONV
RPU12W0C
RPU12W0S
RPU99U0V
Displays T599U
RPU5XX0D
RSANAL00
Program analysis
RSABAPIV
RCCLBISC
RPUTRBK0
RPUEUSUP
RPUDEL20
RPDSYS00
RSBDCSUB
RSUSR006
RSPARAM
RPABRIDD
RPUPROTU
RPINCL10
RPCIFU03
RPLTEMV0
99
Document by:- Amar Chintam
References:
The following documents from SAP were referred to do this document:
HR 350
HR 550
HR 050
HR 530
HR 580
The following websites were referred to do this document:
www.planetsap.com
www.atomhr.com
www.sap-img.com
www.abaptools.com
The online help of SAP was also used to do this document.
The following tools were used to do this document:
Snagit
Smart draw
Mspaint
100
Document by:- Amar Chintam