This action might not be possible to undo. Are you sure you want to continue?
Programming in HR
This course will prepare you to: Program your own HR reports using logical databases and HR-specific statements
SAP AG 1999
At the conclusion of this course, you will be able to: Use the logical databases in HR and also Join and Projection views Use HR-specific statements Evaluate time data and repetitive structures Import and process payroll results
SAP AG 1999
Functional Areas in SAP HR • • • • • • • • Personnel Management (PA) Recruitment (PA-RC) Personnel Administration (PA-PA) Personnel Development Organizational Management Benefits (PA-BN) Compensation Management (PA-CM) Travel Management (FI-TV) .
Functional Areas in SAP HR 2 • • • • Personnel Time Management (PT) Work Schedule (PT-WS) Shift Planning (PT-SP) Time Data Recording and Administration • Time Evaluation Incentive Wages .
Functional Areas in SAP HR 3 • • • • • • • • • Payroll (PY) Payroll Other Countries (PY-XX) Payroll Basics (PY-XX-BS) The Payroll Process Payroll in a Background Operation Off-Cycle Activities (PY-XX-OC) Gross Part of Payroll Net Part of Payroll Deductions Subsequent Activities .
Functional Areas in SAP HR 4 • • • • • • • • • • Training and Event Management (PE) HR Tools (PY-XX-TL) Schemas Rules Functions and Operations Features Editor Developing an Infotype HR Form Editor PT Form Editor Documentation Maintenance .
. 5) Specific Commands. 3) Logical Database PNP.Content 1) Overview of HR 2) ABAP Programming v/s HR Programming. 6) Authorization Check. 4) Views – Join and PROJECTION.
7) Repetitive Structure and List Display.Content 6) Time Data. 11)Logical Database PAP. . 9) HR ABAP Features. 8) Exporting/Importing DB Tables in HR. 10)Logical Database PCH.
Overview Of HR • • • • • • • What is HR Why HR is different from other modules? Data handling in HR (Using of Infotypes) What is Infotype? Why Infotype What is logical database? How are logical database used .
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. .
So to maintain the employee related data we require one system.• 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. and R&D etc. Marketing. . • For any organization employees are the most Powerful resource. Finance. which ensures accuracy and consistent within the organization.
The use of Logical Database • 3. Storage and Access of data • 5. Authorization checks . which differs this module with other modules • 1. Use of Infotypes • 2. Use of Macros • 4.Why HR is different from other modules? • The following concepts are defined in HR.
. the corresponding Database table associated with it is PA0000. • Each infotype pertains to a specific type of data.Data handling in HR (Using of Infotypes): • Master data in HR is stored in infotypes. • Each infotype has a database table associated with it. • Example: For Infotype 0000.
IT0006.(address) . • E. • The infotypes are used to group related data fields together.g..What is Infotype? • The information units used to enter the data of an employee are called infotypes.
.Why Infotype • As HR is related to time. The data we enter into the infotypes are automatically checked for accuracy and against the table entries. we require old data as well as new data. • In simple. HR data is huge and to access data easily we require infotype.
The sequence in which the data is supplied to the program is determined by a tree structure.What is logical database? • The LDB is special type of ABAP program that combines the contents of certain related database tables and retrieves some related data and make it available to application programs. . • • In other words. a LDB is a method by which ABAP programs read and process the data.
The LDB usually consists of the following components. . • A logical database can contain a maximum of 300 tables SAPDBPNP is the name of the database program for the logical database PNP. • Structure • Selections Database programs Logical databases have a tree structure.
How are logical database used • 1 Logical databases when generating an ABAP program • The selection screen generated contains the selections (SELECT-OPTIONS AND PARAMETERS) of both the logical database and the program. • The only database-specific selections displayed on the selection screen are those needed by the program for data retrieval purposes .
etc. calculating default values such as key date.) are performed for the selection screen by the logical database and the program. o The selection screen is displayed and the user enters data in the input fields .g. certain initializations (e. the system processes the events in the program and in the logical database in the following order: Before displaying the selection screen. Logical databases at run-time of an ABAP program At run-time.• 2.
o In the event END-OF-SELECTION. the ABAP program performs any concluding operations (for example. exporting files). importing files).The logical database and the program check that the input is correct and complete . so that the user can make the necessary correction(s). o In the event START-OF-SELECTION. calculating totals. some fields are made ready for input again. but also that the user has the appropriate authorizations. the ABAP program performs any preliminary work (for ex. If an error occurs. o The logical database reads the selected data and the program processes it within the GET events according to the sequence specified by the structure. .
The flow logic for such screens is also generated automatically and therefore cannot be modified. Any program-specific selections appear after the database selections. • You can define your own selection screens for any logical database. Designing the selection screens • o The standard selection screen of a logical database has a standard layout where SELECT-OPTIONS and PARAMETERS appear in the sequence they are declared. The system automatically generates such a screen for each program that does not have its own selection screen entered in the attributes. the system uses this screen as a model when generating. each on a new line. If the attributes of a program include the number of its own selection screen. You cannot delete database selections .• 3 .
E....Person selection and data selection period.Hourly wage earners in a particular personnel sub area.g. . There are two types of screening. • Screening: Employees can be selected according to the organizational criteria entered on the selection screen.Functions of LDB: • Data retrieval: The personnel data of each employee is loaded into the main memory where it can be accessed for processing.
• E...Employees who assigned to certain cost center.Features of org. • E.Employee status.Active or inactive.g.. .Monthly wage earners in a specific personnel sub-area..Assignment.Functions of LDB:2 • Person selection :defines those employees for whom a report is to be run..g. • E..g.Personnel number range • E..g.
When you enter the data selection period. • Authorization check : This ensures that the person starting the evaluation Is authorized to access the report data. .the provide loop retrieves the infotype records whose validity period overlaps with at least one day of this period.Functions of LDB:3 • The data selection : period delimits the time period for which data is evaluated.
.REPORT CLASS WITH LDB : • You can change the layout of the selection screen by assigning classes to reports of the logical database PNP. • All reports without a report class are assigned the customer default report class '00000000'.This allows you to suppress the input fields which are not used. Otherwise the sap default report class ' ' is assigned.
through RP-READ-INFOTYPE. • All reports that use the logical database PNP automatically contains DBPNPCOM module.either the customer default class(t599c) or the SAP default class(t599f) is used.REPORT CLASS WITH LDB : • Report class assignments are stored in table t599b or t599w. • Table t599b contains customer report classes and t599w the sap report classes. • You can also read the records of an infotype for a particular personnel number without using the logical database. • If a report has no report class. .
Have you included PNP for the logical database screen field in the program attributes. • Whenever GET PERNR statement is included in your program check the following two . . • 2. • Data selection does not delimit the records that retrieved from the database. • 1.Have you included PERNR structure in the tables declaration.GET PERNR : • This event fills the data structures of declared infotypes with all records that exists for a personnel number.
• Macros : Macro contains some part of source code which it will be useful for number of applications • The macro RP-PROVIDE-FROM-LAST retrieves the last(latest) data record which is valid in the data selection period.secondary residence and home address. .Each subtype representing an infotype category with its own time character. • Infotype 0006 is for addresses. • Subtypes : The sub-division of infotype records are subtypes.This addresses are sub-divided in the IT0006 as permanent residence. TRMAC Table has Macros.
• Elementary fields . . PCL2. will come under data objects. • You can store data clusters in ABAP/4 memory for short time and in database for longer time. • e. field strings and internal tables etc.• Cluster : set of data objects. cluster database tables PCL1.g. PCL3 and PCL4.
1) ABAP Programming v/s HR Programming .
Use of Authorization Checks. .ABAP Programming v/s HR Programming Storage and accessing of data. Use of Info types to enter and store data. Use of Macros. Use of the logical Database extensively.
HR Data is huge and to enable easy data entry the concept of an Info type took birth. .The INFOTYPE An Info type is just another way to handle/store data.
HR Time Record: Infotype 2010. Infotype 0003 (Payroll Status).).The INFOTYPE The existence of an Infotype implies that an internal table (system defined) and a database table of same structure exist!. Infotype 0001 (Org. Infotype 0002 (Personal Data). Assignment). . (Employee Remuneration Info.
2) Logical Database PNP .
Database Tables PAnnnn : Data Records PA.Logical Structure and DB Tables in PA Logical Structures Pnnnn: Key fields and Data fields. Payroll. . Travel Management. Time Management. Psnnnn. Qnnnn : Special Screen fields. PCLn: Data Clusters E. PBnnnn: Data Records PB.g.
Additional field Q0002-ANREX is provided to store the displayed and entered fields not its numeric key.Structure for screen fields Fields for every Infotype (Header lines) are stored in RP50M. . An employees form of Address is stored in P0002-ANRED with a numeric key. Additional Screen fields are stored in Qnnnn structure.
Data Retrieval When you run your report. . The entire history of each info type is loaded into the main memory. the logical database loads the personnel data for each employee into the main memory and makes it available for processing. that is all info type records from the lowest to highest system date.
The data of the previous personnel number is deleted when you select another personnel number.Data Retrieval Structure PERNR contains standard selections for HR Master data reporting. .
. It checks whether the master record of the user who starts the report contains the authorizations for the data that is to be read in the report. A distinction is made between a personnel and a data authorization.Authorization Checks The logical database executes an authorization check for personnel data.
Employees for which the user has no authorization are not evaluated. The system then checks whether the user is authorized to process the info types of the specified report. .Authorization Checks The system first checks whether the user has an authorization for the employee in accordance with the criteria of organizational assignment. A list would be meaningless if the data were not evaluated completely.
.Screening Criteria Two types: Person Selection. Data Selection.
. Selected by Personnel Number Range. Selected Employees are processed in ascending order according to personnel number. Org Assignment. Status. etc.Screening Criteria Person Selection: Specifies those employees for whom the report is to be run.
. you can define the period for which info type data is to be evaluated. the system processes only those info type records which either partly or completely are within the data selection period.Screening Criteria In the data selection field. Although the entire info type history is loaded into the main memory during data retrieval.
You can do this by assigning the report to a report class.Report Class Since the required selection criteria depend on the report. . you must define the scope of the selection screen.
Report Class Assigning a report class can help in changing the LDB selection screen. In Program Attributes Screen we use „EDIT-HR Report Class‟ while using the PNP database. .
Report Class Report Class assignments are stored in tables T500B (Customer Class) and T599W(SAP Classes). default report classes are used from T599C(Customer) and T599F(SAP Default Class). . If no report Class is assigned to a report.
The personnel number and Matchcode function key are the only permissible selection criteria in this report class.g.The time evaluation report RPTIME00 is assigned the report class __0001.Report Class E. .
personnel number and payroll area.x is the country grouping) is assigned the report class X_M00002. The active selection criteria of this report are period defined/payroll area.Report Class The report RPDEDTx0 (editing of payroll results. .
.The GET PERNR Event This event fills the data structures of declared infotypes with all the records that exist for a particular personnel number . The “check select-options” command.
.Processing the Infotype structures Infotype structures are internal tables that are processed using a PROVIDEENDPROVIDE loop.
Opt 2: Array fetch Active. . Opt 3: A combination of opt1 and opt2. Opt 1: Selection fields of LDB forwarded directly to the database.Flow control for LDB IMG enables you to determine the type of data selection for your own reports. Options available for online and Batch Processing.
Flow control for LDB .
P0001-BEGDA.Example of an HR report REPORT ZTEST_HR1. P0001-ENAME. P0001-ENDDA. PROVIDE * FROM P0001 BETWEEN PNPBEGDA AND WRITE: / P0001-PERNR. PNPENDDA. ENDPROVIDE. INFOTYPES: 0001. GET PERNR. TABLES: PERNR. .
3) Views – Join and PROJECTION .
JOIN Personal Data: JAN 1960 – MAY 1993 MAY 1993 – DEC 1993 Address Data JAN 1993 – DEC 1993 Result of Join JAN 1960 – DEC 1992 JAN 1993 – APR 1993 MAY 1993 – DEC 1993 ABCD EFGH BOMBAY ABCD ABCD/Bomb EFGH/Bomb .
Join and Time Constraint
Time Constraint of an Infotype have an effect on JOIN. SE38: Utilities Help On. Table T591A.
JOINS are only possible for info types with time constraint 1 or 2.
PROVIDE * FROM P0002 FROM P0006 FROM PNNNN BETWEEN PN/BEGDA & PN/ENDDA. ------------------------ENDPROVIDE.
Each Infotype can be processed individually or several infotypes can be processed simultaneously. Join takes into account the validity period of the data.
JOIN Personnel data is valid only for a particular time period. JOIN represents one or more validity periods during which that data of both the infotypes is valid. .
.e. Data to be JOINED must be UNIQUE for the validity period i. the time periods of the Infotype records should not overlap.JOIN Any number of infotypes can be combined in a JOIN. To further obviate this problem the Infotype must be read using a sub-type.
GET PERNR.JOIN REPORT ZTEST_HR2. PROVIDE * FROM P0001 * FROM P0006 BETWEEN PN/BEGDA AND PN/ENDDA WHERE P0006-SUBTY eq ‟1‟. TABLES: PERNR. INFOTYPES: 0001. . 0006.
WRITE: / PERNR-PERNR, P0001-STELL, P0006-STRAS, P0006-BE GDA,P0006ENDDA. ENDPROVIDE.
Sometimes no data is available for a particular Info type 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:
REPORT ZTEST_HR3. TABLES: PERNR. INFOTYPES: 0002,0006 GET PERNR. PROVIDE * FROM P0002 * FROM P0006 BETWEEN PN/BEGDA AND PN/ENDDA WHERE P0006-SUBTY = ‟1‟.
P0002-BEGDA DD/MM/YYYY. P0002-NACHN. ENDIF.Variable Pnnnn_Valid IF P0006_VALID EQ ‟X‟. . P0006-ORT01. P0002-ENDDA DD/MM/YYYY. ENDPROVIDE. WRITE: / PERNR-PERNR.
PROJECTION Selecting one or more infotype fields for processing is called Projection. Projection is only allowed for time constraints 1 and 2. . The process of combining data records during projection is called contraction.
PROVIDE STELL FROM P0001 BETWEEN PNPBEGDA AND PNPENDDA. TABLES: PERNR. 0006. GET PERNR. ENDPROVIDE. . INFOTYPES: 0001.PROJECTION REPORT ZTEST_HR.
4) SPECIFIC COMMANDS .
RMAC . They are in TRMAC Table.MACROS Like Subroutines and Function modules Macros can be used to modularize codes. . The first two letters are the application and the rest are freely assigned.
RP-PROVIDE-FROM-FIRST PNNN SPACE BEGDA ENDDA. . Parameters: Info type. Sub type.Processing A Specific Infotype Record To access only the first or last records. Begin date and End date. RP-PROVIDE-FROM-LAST PNNN SPACE BEGDA ENDDA.
.Processing A Specific Infotype Record Macros are defined in program SAPDBPNP ( Include DBPNPMAC() using the DEFINE Keyword. They are only available for programs that use LDB PNP.
. SPACE = SY-SUBRC is set to 4.Reading the Personnel Area/Subarea Table It is often necessary to read the groupings stored in Personnel Area/ Subarea because they are required as keys for other tables. RP-READ-T001P P0001 P0001-WERKS P0001BTRTL SPACE.
. RP-UPDATE OLD NEW. This macro calls the update routine of HR file.Changing Infotypes RP-UPDATE macro update the database. Parameters: Old Internal Table. New Internal Table.
.Changing Infotypes You can‟t make key changes. In customer specific info types it may be useful to create utilities to change HR data directly in Database tables. To ensure the consistency of the table entries database changes should always made with batch reports which automatically execute online data checks. which means you can‟t create or delete data.
Select the Info type to be changed. Make the required changes and store the records in an alternative table.Changing Infotypes Three steps involved in changing Info types. .
…………………… NEW = OLD.Changing Infotypes REPORT ZTEST_HR. INFOTYPES: nnnn NAME OLD nnnn NAME NEW. . GET PERNR.. TABLES: PERNR. PROVIDE * FROM OLD…….
RP-UPDATE OLD NEW. ENDPROVIDE. .Changing Infotypes APPEND NEW.
Reading IT without LDB The Function Module HR_READ_INFOTYPE records for a person. 4. 8. 12. Function Module performs an authorization check. The Return codes have the following values: 0. Values are returned in an internal table. .
CALL FUNCTION „HR_READ_INFOTYPE EXPORTING PERNR = INFTY = BEGDA= ENDDA= . INFOTYPES: 0002.Reading IT without LDB REPORT ZTEST_HR6.
Reading IT without LDB IMPORTING SUBRC = <RETURN> TABLES INFTY_TAB = P0002 EXCEPTIONS INFTY_NOT_FOUND = 1 OTHERS = 2. .
5) Authorization Checks .
HR makes a distinction between two types of authorization . one for person and another for data. . LDB does this check automatically.Authorization Checks Checks if a person starting the report has the required authorizations.
Authorization for Persons Checks if a person starting the report has the required authorizations. Employees for whom the user has no authorization are skipped and then listed at the end of evaluation. .
the evaluation is canceled and an error message displayed. . If the user has no authorization for a particular Info type.Authorization for DATA Checks if a person have all the authorizations required for all of the info types used in the evaluation.
Deactivating the Authorization Check In certain programs it may be useful to deactivate the authorization check in order to improve performance. If the appropriate authorization are available . . a simplified and therefore faster checks take place. For this reason HR Master data object is supplemented by the HR: Reporting authorization object.
6) Time Data .
Time data IT 2001 is determined on the basis of the validity period. .Time Data A characteristic of the PROVIDE is that the Validity period of IT records is restricted to the data selection period on the selection screen. The number of Absence days is calculated on the basis of absence period.
Time Data Since the data depends on the validity period . . PROVIDE statement is not used for time infotypes ( 2000. time infotypes leads to incorrect data.2099).
Time Data A principle of the LDB is that all of the IT records between the lowest to highest system dates are read when GET PERNR event occurs. . Bad performance issues because of memory problem while reading large time data.
RP_READ_ALL_TIME_ITY.Time Data To control this MODE N is assigned while declaring the time Infotypes. .
RP-READ-ALL-TIME-ITY PN/BEGDA PN/ENDDA. Endif. GET PERNR. ENDLOOP. A=B. If P0021-XYZ = ' '. . LOOP AT P0021.Program 1 INFOTYPES: 2001 MODE N.
COLLECT ITAB. ITAB-BUKRS = P0001-BURKS. ITAB-AWART = P2001-AWART. "ABS. DAYS END OF ITAB. GET PERNR. "PERSONNEL AREA AWART LIKE P2001-AWART. BUKRS LIKE P0001-BUKRS. ITAB-WERKS = P0001-WERKS. LOOP AT P2001. TYPE ASWTG LIKE P2001-ASWTG. "ABS. (OR: APPEND ITAB.) ENDLOOP. RP-PROVIDE-FROM-LAST P0001 SAPCE PN/BEGDA PN/ENDDA. ITAB-ASWTG = P2001-ASWTG./ATTEND.Program 2 DATA: BEGIN OF ITAB OCCURS 0. RP-READ-ALL-TIME-ITY PN/BEGDA PN/ENDDA. CLEAR ITAB. . "COMPANY WERKS LIKE P0001-WERKS./ATTEND.
7) Repetitive Structure and List Display .
All of the fields in this table structure are named and defined in the Infotype structure on which they are based.Repetitive Structure On some infotype entry screens like leave data is entered in Tables. Table datas are stored in a linear structure. .
. where it continues to be processed. Loop Processing within DO/ENDDO or WHILE/ENDWHILE can be used to transport such data block by block to work area.Repetitive Structure In some Infotypes data entered in screen tables is stored as repeat fields groups on the database.
P0005-UARnn P0005-UANnn P0005-UBEnn P0005-UENnn P0005-UABnn .0005 0008 0041 In the infotype structure. fields are grouped by the same name followed by sequence number.
"Leave type UAN LIKE P0005-UAN01. DO 6 TIMES VARYING VACATION FROM P0005-UAR01 "Starting point NEXT P0005-UAR02. "Leave entitlement UBE LIKE P0005-UBE01. "Start date UEN LIKE P0005-UEN01. endif. ENDDO. UAR LIKE P0005-UAR01. RP-PROVIDE-FROM-LAST P0005 SPACE PN/BEGDA PN/ENDDA. "End date UAB LIKE P0005-UAB01. "Increment If p0005-xyz then . "Leave accounted END OF VACATION. GET PERNR. ...Repetitive Structure DATA: BEGIN OF VACATION.
Used to display single-level lists.List Display Function Module HR_DISPLAY_BASIC_LIST. Maximum no. of column is 20. .
8) Export/Import DB Tables in HR .
Accounting Results (time. Payroll year-end Tax data Export/Import Tables in HR .Database for HR work area PCL2 .Database Tables in HR. travel expense and payroll) PCL3 . Tracking Record) PCL4(Documents). PCL1(HR Work Areas). PCL2(Acctg Results & Payroll). Pannnn (personnel data).Applicant tracking data PCL4 .Documents. PCL3(Applicant. PCL1 .
.Data Clusters Data Clusters have a two character code. Each HR subarea has its own cluster and its own key.
PC(Personal Calendar). TX(Infotype Texts). G1(Group Incentive Wages). .Database Table PCL1 B1(Time Events).
CD(Cluster Directory). RX(Payroll Accounting Results/International). Rn(Country Specific Payroll Accounting. .Database Table PCL2 B2(Time accounting results).
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 .
Database Table PCL2 · The database table PCL2 contains the following data areas: B2 time accounting results CD cluster directory of the CD manager PS generated schemas PT texts for generated schemas RX payroll accounting results/international Rn payroll accounting results/country-specific ( n = HR country indicator ) ZL personal work schedule Database Table PCL3 · The database table PCL3 contains the following data areas: AP action log / time schedule TY texts for applicant data infotypes .
e the cluster („RX‟ for payroll accounting. . The field PCLn-RELID stores the basic relation type i.Table Management EXPORT IMPORT Commands are used A Unique KEY ID is required to read or write from/to table. „TE‟ for Travel Expenses etc).
The first component of this field string is PERNR. Naming convention for these programs is RPCnxxy0 ( n = 1 or 2.Cluster Definition Data definitions of a work area are stored in separate programs. y = 0 for international). The key structure is stored in xx-KEY field string. . xx = Cluster Name.
And Rp-IMP-Cn-xy. These are the macros which are used for Exporting/Importing results from the PCLn tables.Import/Export with Macros Rp-EXP-Cn-xy. .
IF SY-SUBRC EQ 0.REPORT ZHREXPRT. INCLUDE RPPPXM00. . PERFORM PREPARE_UPDATE USING 'V'. "Buffer management DATA: BEGIN OF COMMON PART 'BUFFER'. DATA: END OF COMMON PART 'BUFFER'. RP-EXP-Cn-xy.. *Buffer definition INCLUDE RPPPXD00.. .. ENDIF. INCLUDE RPPPXD10.
DATA: BEGIN OF COMMON PART 'BUFFER'. *Buffer definition INCLUDE RPPPXD00. . *import data to buffer RP-IMP-Cn-xy.REPORT RPIMPORT. DATA: END OF COMMON PART 'BUFFER'. INCLUDE RPPPXD10.
9) HR ABAP Features .
HR ABAP Features Accessing Reports using Dynamic Action. Selection reports for fast entry. . Reports that are used for fast entry are contained in table T588R. Table T588Z is a control table that triggers steps taken when an IT record is maintained.
HR ABAP Features Accessing subroutines for specific periods. . Table T596F enables you to access various subroutines for specific periods in order to solve a task defined by a symbolic name.
. Eg: RPCPBSRC. Par1 – Feature name. Par2 – Error handling type. PERFORM RE549D USING par1 par2 par3 par4. Par3 – Return value.HR ABAP Features Accessing Feature from Reports. Par4 – The type of error.
THANK YOU .