0% found this document useful (0 votes)
931 views77 pages

SAP HR Programming Guide

This document provides an overview of SAP HR ABAP programming and infotypes. It covers prerequisites like ABAP, databases, and modules. The training will cover HR modules, infotype structures and creation, enhancement, macros, and examples. Infotypes are used to group related employee data fields and maintain information over time. They have unique numbers and structures. Customers can define their own infotypes between 9000-9999.

Uploaded by

Moisés João
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
931 views77 pages

SAP HR Programming Guide

This document provides an overview of SAP HR ABAP programming and infotypes. It covers prerequisites like ABAP, databases, and modules. The training will cover HR modules, infotype structures and creation, enhancement, macros, and examples. Infotypes are used to group related employee data fields and maintain information over time. They have unique numbers and structures. Customers can define their own infotypes between 9000-9999.

Uploaded by

Moisés João
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd

SAP Programming in HR

HR-ABAP
Septiembre 2014
Prerequisites

Knowledge of

• ABAP Programming
• Logical Database
• Module pool programming
• SAP Scripts

2
Training will cover

• Brief description of modules in SAP-HR


• Concept of Infotypes
• Infotype Structures
• Creation of infotype
• Enhancement of infotype
• HR Macros
• Use of Provide statement
• Cluster reading for Payroll results
• Example of PA letters infotype (Customer defined)

3
Modules in SAP-HR

• Personnel Management (PA)


• Time Management (PT)
• Recruitment (PB)
• Organizational Management (OM)
• Personnel Development (PD)
• Training & Event Management (TM)

4
Infotype

• Definition

• Units of information.

5
Uses of Infotype
 To group related data fields
Name
Personal DOB
Data Nationality
Marital Status
INFOTYPES

Addresses Street
City
Pin code
State

6
Uses of Infotype

 Maintaining Employee Information by Date

7
Infotype Numbers

• Four digit number nnnn


• Unique identification
• 9000 to 9999 reserved for customer infotypes

8
Naming Conventions

 Naming conventions for Infotypes

• 0000 to 0999 – HR Master data / Applicant data


• 1000 to 1999 – Organizational Management
• 2000 to 2999 – Time data
• 4000 to 4999 – Applicant data
• 9000 to 9999 – Customer defined

9
Definition of Infotype within the Data
Dictionary

• Each infotype nnnn requires at least two structures and


one table:
• Structure PSnnnn
• Structure PSnnnn contains all of the infotype data fields.
• Structure Pnnnn
• Structure Pnnnn contains infotype key fields and all of the
data
• fields from structure PSnnnn .
• Transparent table PAnnnn and/or transparent table
PBnnnn

10
Definition of Infotype within the Data
Dictionary

• Transparent table PAnnnn is required if you want to use an


infotype
• within Personnel Administration.
• If you want to use an infotype within Recruitment,
transparent table
• PBnnnn is required.
• In accordance with the distribution of infotype name ranges,
objects
• P9nnn , PS9nnn , PA9nnn and PB9nnn are assigned to
the customer name range.

11
Infotype Module Pool

• A module pool should be used with each infotype. This


module pool is the main program for the maintenance
interface for the infotype.

• The name of the program is MPnnnn00. Where Pstands for


Human Resources (personnel) and nnnn is the four-digit
infotype number.

12
Infotype-specific Includes

• The main program only contains INCLUDE statements. If


you create the main program using transaction PM01
Dialogs in HR, the system also creates the following four
includes:

Name of include The include contains


MPnnnn10 The PROGRAM statement and
the declaration of common data objects
MPnnnn20 PBO modules for the screens
MPnnnn30 PAI modules for the screens
MPnnnn40 Subroutines

13
Infotype-specific Includes

• The system also inserts INCLUDE statements in the main


program for the following includes:
Name of include Use
FP50PPSB Declaration of common data objects
This data area is used as a buffer for imported
infotype records and maintenance information. The
variables specified in this area are used as export or
import parameters when the infotype dialog module
is accessed.
MPPDAT00 Declaration of common data objects
MPPERS00 Standard infotype modules
MPPIRC00 Definition of infotype return codes
MPPREF00 Definition of two data objects that contain the
number of reference personnel numbers in structure
P0031 or P0121 14
Infotype Screens

• Each infotype has at least three screens:

• An initial screen
• A single screen
• A list screen

15
Initial Screens

• Initial screen is used as technical interface


• Screen 1000 is used for all infotypes
• Processed in background and not displayed
• Performs general initialization procedures

16
Initial Screens - Preview

17
Single Screens

• Its an interface between the system and the user.


• It enables to create, display or maintain data records.
• Screen 2000 is used for single screen.

18
Single Screen - Preview

19
List Screen

• Unables to list all records in infotye


• Screen 3000 is used for list screen

20
List Screen - Preview

21
Infotype Screen Control

• Through customization some field are made hidden.


• Attributes are specified during runtime.
• The appearance of the screens changes depending on the
function chosen by the user.

22
Infotype Time Constraint

• A time constraint indicates whether more than one infotype


record may be available at one time. The following time
constraint indicators are permissible:

1 No overlapping and no gaps.

2 No overlapping but time gaps are permitted.

3 Overlapping and and time gaps are permitted.

23
Other Possible Time Constraint

A Only one record may exist, valid from 01/01/1800 to


12/31/9999. Splitting and deletion is not permissible.

B Only one record may exist, valid from 01/01/1800 to


12/31/9999. Splitting is not permissible, but may be deleted.

T The time constraint varies depending on the subtype.

Z Refers to time management infotypes.

24
Infotype Characteristics

 The following tables must be maintained for each infotype:

Name of table Task


T582A Basic infotype characteristics (database tables, single
screen, list screen, time constraint, dialog module, and so
on)
T582S Infotype short texts
T777A Technical Characteristics of Infotype (database table,
dialog module, and so on)
T77ID Name of data field structure (PSnnnn)

25
Creating PA infotypes

 Transaction code

 PM01

26
Creating PA infotypes – PM01 SAP

27
Creating PA infotypes –Maintain Structure

28
Creating PA infotypes – Infotype Table

29
Creating PA info types – Infotype table
(Primary Key)

30
Creating PA infotypes – Preview

31
Enhancement of PA Infotype

1. Start the Personnel Administration infotype copier (PM01)

2. Enter the infotype number.

3. Choose Enhance infotype.

32
Enhancing a Single Screen

• Start transaction PM01


• You access the Create Infotype screen:
• Choose Enhance Infotypes.
• In the Infotype no. field, enter the four-digit number of the
infotype you want to create. When you specify the infotype
number, please remember to enter any leading zeros.
• In the Sub-Objects group box, flag CI Include.
• Choose Create. The Dictionary: Initial Screen is displayed.

33
Enhancing a Single Screen

• Create the Cl include.


• Choose Activate.
• Return to the Create Infotype screen.
• Choose Create All.

Result
• You have included additional fields in the standard single
field for an infotype

34
Enhancing a Single Screen – PM01

35
Enhancing a Single Screen – Maintain
Structure

36
Enhancing a Single Screen – Screen
Preview

Enhanced Field

37
Enhancing PA Infotype – CI INCLUDE

 Only those PA Tables can be Enhanced, having structure CI Include

CI_P0000

38
HR Macros

• RP_PROVIDE_FROM_LAST

• RP_PROVIDE_FROM_FIRST

• RP_SET_DATA_INTERVAL

• RP_READ_INFOTYPE

39
Macros Modules

 Macro Modules
TABLES: PERNR.
INFOTYPES:0001, "Organizational Assignment
0002, "Personal Data
0006, "Addresses
....
GET PERNR.
RP_PROVIDE_FROM_LAST P0001 SPACE PN-BEGDA PN-ENDDA.
WRITE...
* * * Include program DBPNPMAC.
DEFINE RP_PROVIDE_FROM_LAST.
PNP-SW-FOUND = '0'.
...
END-OF-DEFINITION.

40
Infotype Record Processing

Processing a Specific Infotype Record

Data selection
January December

Table January December


Pnnnn

GET PERNR.
RP_PROVIDE_FROM_LAST <Pnnnn> SPACE PN-BEGDA PN-ENDDA.
IF PNP-SW-FOUND = 1.
WRITE...
ENDIF.

41
Infotype Record Importing

 Importing Specific Infotype Records

Data selection
May December

PAnnnn

START-OF-SELECTION.
RP_SET_DATA_INTERVAL '<Pnnnn>' PN-BEGDA PN-ENDDA.
GET PERNR.

Table
Pnnnnn

42
Function HR_READ_INFOTYPE

 Reading Infotypes Without Logical DB (1)

PAnnnn INFOTYPES: <nnnn>.



CALL FUNCTION
'HR_READ_INFOTYPE'...

43
Function HR_READ_INFOTYPE

 Reading Infotypes Without Logical DB (2)


INFOTYPES: 0002.
DATA: return LIKE SY-SUBRC.
CALL FUNCTION 'HR_READ_INFOTYPE'
EXPORTING
...
PERNR = <person>
INFTY = '0002'
BEGDA = <begdat>
ENDDA = <enddat>
IMPORTING
SUBRC = return
TABLES
INFTY_TAB = P0002
EXCEPTIONS
INFTY_NOT_FOUND = 1
OTHERS = 2.

44
HR Macro – Summary

• Many HR reports use macros. Their program codes are


stored in a table or defined locally using the DEFINE
keyword.
• The PR_PROVIDE_FROM_LAST macro writes the last valid
record in the data selection period to the header line of the
internal info type table.
• You can use the function module HR_READ_INFOTYPE to
read the personnel data in reports which do not use an HR
logical database

45
Use of PROVIDE Statement

• PROVIDE – ENDPROVIDE is a loop to process Pnnnn


tables, within the validity period.

• Two or more infotypes can be processed in a single


PROVIDE – ENDPROVIDE loop.

• Combines JOIN and PROJECTION.

• Reads time-dependent table entries.

46
Logical database PNP

 Functions of Logical Database PNP

1. Data retrieval
2. Screening

3. Authorization check

47
Logical database PNP - Screening

48
Functions of Logical database PNP

Data Retrieval
1. Create data structures for infotypes

INFOTYPES: 0001,
0002,
0007.
"Organizational Assignment "
"Personal Data"
"Planned Working Time"

2. Fill the data structures with the infotype records

GET PERNR.

49
Processing Master Data using PROVIDE

Processing Master Data


TABLES: PERNR.
INFOTYPES: 0001, “ Actions
0002, “ Personal Data
0006, “ Addresses
....
GET PERNR.
PROVIDE * FROM P0002 BETWEEN PN-BEGDA AND PN-ENDDA.
WRITE...
ENDPROVIDE.

50
Processing Master Data using PROVIDE

Loop Nesting
GET PERNR.
PROVIDE * FROM P0002 BETWEEN PN-BEGDA AND PN-ENDDA. Infotype
WRITE... loop
ENDPROVIDE.
Employee
loop
PROVIDE * FROM P0006 BETWEEN PN-BEGDA AND PN-ENDDA. Infotype
WRITE... loop
ENDPROVIDE.
END-OF-SELECTION.

51
Joins in PROVIDE

Join / Creating Intervals

Personal
Data (0002)

Organizational
Assignment (0001)

Join

52
Joins in PROVIDE

Join / Coding
TABLES: PERNR.
INFOTYPES:0001, "Organizational Assignment
0002, "Personal Data
0006, "Addresses
....
GET PERNR.
PROVIDE * FROM P0001
* FROM P0002
BETWEEN PN-BEGDA AND PN-ENDDA.
WRITE...
ENDPROVIDE.

53
Joins and Projection in PROVIDE

Join and Projection / Coding


TABLES: PERNR.
INFOTYPES: 0001, "Organizational Assignment
0002, "Personal Data
....
GET PERNR.
PROVIDE STELL
ENAME FROM P0001
GBDAT FROM P0002
BETWEEN PN-BEGDA AND PN-ENDDA.
WRITE...
ENDPROVIDE.

54
PA Letters Infotype – Customer Defined

Business Needs:
A letter is to be generated after the following action in the prescribed format:
1. Hiring / Appointment Letter
2. Confirmation Letter
3. Promotion Letter
4. Transfer Letter
5. Relieving Letter on Resignation
6. Retirement Letter

The generated letter should be modifiable and same is to be stored along


with each employee and action.

55
Sample format of Appointment Letter
LETTER NO. REC.01 APPOINTMENT LETTER
Mr./Miss [Full name of Employee]
[Position] [Grade]
[Location]

The management is pleased to appoint you as the [POSITION] in [GRADE] with effect from [DATE]. You will
report to [POSITION].

Your salary & other benefits are stated in the attached compensation package sheet.
You will be on probation for a period of six months. On satisfactory completion of probation you will be
confirmed in service.
You shall be governed by the Services rules of the Company, a copy of which is enclosed. A summary of
Benefits & Leave Rules as applicable to you is also enclosed.
Please confirm your acceptance by signing the duplicate copy of this letter & intimate the date of joining.
This offer is valid for two months from the date of receipt of this letter.
Faithfully

[Signatory] / SECRETARY
[Designation]
56
Structure for PA letter Infotype
Structure: PS9011
Component Component Type Data Type Len Dec Short Text

LDATE ZLDATE DATS 8 0 Letter Date

LTYPE ZLTYPE1 CHAR 50 0 Letter Type

SIGN1 ZSIGN1 CHAR 40 0 Signatory

DESGN ZDESGN CHAR 40 0 Designation

MASSN ZMASSN CHAR 2 0 Action Type

EFFDT BEGDA DATS 8 0 Start Date

SUPER ZSUPER CHAR 40 0 SBU / Functional Head

SBUNM ZSBUNM CHAR 40 0 SBU / Name

APDAT ZAPDAT DATS 8 0 Appointment Date

RLDAT ZRLDAT DATS 8 0 Relieving Date

LETTERID TDOBNAME CHAR 70 0 Name


57
ZHR_LTYPE

Table ZHR_LTYPE created for help drop down of field LTYPE of structure
PS9011.

Table: ZHR_LTYPE

Fields Field Type Data Len Dec Short Text


Type
INFTY INFTY CHAR 4 0 Infotype

SUBTY SUBTY_591A CHAR 4 0 Subtype

LTYPE ZLTYPE1 CHAR 50 0 Letter type

ACTION MASSN CHAR 2 0 Action type

FRMNM ZFRMNM CHAR 30 0 Form name

58
Screen Layout for PA Letters Infotype

59
STD Text for Appointmnet Letter – SO10
• *
• * Ref No. &itab-ref_no&
• *
• * &cldate&
• *
• * &itab-ename&
• * &itab-zdesgn&
• * &itab-orgtx&
• * &itab-name1&
• *
• * &itab-first_line&
• *
• B The Management is pleased to appoint you as the &itab-zdesgn& in grade
&itab-pktxt& with effect from &itab-effdt&. You will report to .....
• *
• B Your salary & other benefits are stated in the attached compensation
package sheet.
• *

60
STD Text for Appointmnet Letter – SO10
• B You will be on probation for a period of six months. On satisfactory
• completion of probation you will be confirmed in service.
• *
• B You shall be governed by the Services rules of the Company, a copy of which is enclosed. A summary of Benefits &
Leave Rules as applicable to you is also enclosed.

• B Please confirm your acceptance by signing the duplicate copy of this letter & initimate the date of joining.
• *
• B This offer is valid for two months from the date of receipt of this letter.
• *
• * Faithfully
• *
• * &pp9011-sign1&
• *
• P2 CC:,,Chief Personnel Officer
• P2 ,,Chief Manager, Management Systems and Information
• P2 ,,

61
Clusters

• 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.

62
Display of Cluster data – Payroll Result

63
Display of Cluster data – Payroll Result

64
Display of Cluster data – Payroll Result

65
Display of Cluster data – Payroll Result

66
Display of Cluster data – Payroll Result

67
Display of Cluster data – Payroll Result

68
Reading Cluster Directory

Reading the Cluster Directory


*Table containing directory of payroll results
DATA: BEGIN OF RGDIR OCCURS 100.
INCLUDE STRUCTURE PC261.
DATA: END OF RGDIR.
DATA: COUNTRY LIKE T001P-MOLGA.
...
CALL FUNCTION 'CU_READ_RGDIR‘
EXPORTING
PERSNR = PERNR-PERNR
IMPORTING
MOLGA = country
TABLES
IN_RGDIR = RGDIR
EXCEPTIONS
NO_RECORD_FOUND = 1
OTHERS = 2.

69
Determining Last Payroll Result

Determining Current Payroll Result (1)


DATA: number LIKE PC261-SEQNR.
...
GET PERNR.
...
CALL FUNCTION 'CU_READ_RGDIR'
...
CALL FUNCTION 'CD_READ_LAST'
EXPORTING
BEGIN_DATE = PN-BEGDA
END_DATE = PN-ENDDA
IMPORTING
OUT_SEQNR = number
TABLES
RGDIR = RGDIR
EXCEPTIONS
NO_RECORD_FOUND = 1
OTHERS = 2.

70
Determining Last Payroll Result

Determining Current Payroll Result (2)


DATA: result TYPE PAY99_RESULT.
DATA: rt_header TYPE LINE OF HRPAY99_RT.
...
CALL FUNCTION 'PYXX_READ_PAYROLL_RESULT'
EXPORTING
CLUSTERID = 'RX'
EMPLOYEENUMBER = p0001-pernr
SEQUENCENUMBER = number
* READ_ONLY_BUFFER =''
* READ_ONLY_INTERNATIONAL =''
* CHECK_READ_AUTHORITY = 'X'
...
CHANGING
PAYROLL_RESULT = result
EXCEPTIONS . .
LOOP AT result-INTER-RT INTO rt_header.
WRITE: / rt_header-LGART, ...
ENDLOOP.

71
Structure for Payroll Result

Structure for Payroll Results


Structure: PAY99_RESULT

EVP INTERStructure PAY99_INTERNATIONAL NAT


Structure PC261 Dummy
for national
VERSC RT CRT BT part
Type PC202 Type HRPAY99_RT Type HRPAY99_CRT

DATA: result TYPE PAY99_RESULT.


DATA: rt_header TYPE LINE OF HRPAY99_RT.
...
* Access to payroll result data
WRITE: result-INTER-VERSC-FPPER,
...
LOOP AT result-INTER-RT INTO rt_header.
WRITE: / rt_header-LGART, . . .
ENDLOOP.

72
EXERCISE (1)
• 1. Whenever an employee is hired, it is mandatory to provide certain documents,
which will form a checklist on joining the organization.

• The joining checklist are as follows:


• a. Relieving letter from last employer
• b. Salary Slip of last employer
• c. Graduation certificate
• d. Copy of latest qualification certificate, specify
• e. Income Tax certificate of last employer
• f. Others specify – (3 lines)

• Create a customer defined infotype where above details are maintained.

73
EXERCISE (2)

• 2. Eligibility for LTA allowance is one basic for a financial year. If last
year it is not claimed, it can be claimed in the current year.

• LTA is one time payment and maintained in IT 0015, i.e. Additional


payments & deductions.

• Provide and additional field to maintain year for LTA claim. (Infotype
Enhancement to IT 0015)

• If LTA claim is not of current year, then LTA reduces to 80% of the
current basic. Built a validation for the same.

74
EXERCISE (3)

• 3. Generate a report to list employee with the latest action in the given
date range.

• Display following fields:


• a. Employee Number
• b. Employee Name
• c. Action Type
• d. Action Text
• e. Action Start Date

• Tips: Make use of HR macros

75
EXERCISE (4)

• 4. Generate a report to list an employment history in a given date range.

• Display following fields:


• a. Employee Number
• b. Employee Name
• c. Action Start Date
• d. Action Type
• e. Action Text

• Tips: Make use of provide – endprovide loop

76
EXERCISE (5)

• 5. Generate a Salary register which will list following fields in matrix


format.

• Emp.No. Basic HRA Conv Spl.Pay


• 00001
• 00002
• 00100

• Read data from Payroll Cluster and display it in the above format.

• Tips: Refer to SAP standard programs in T.Code PC00_M99_CLGA09


and PC_M99_CLGV09

77

You might also like