Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Programming in HR
Course Goals
This course will prepare you to: Program your own HR reports using logical databases and HR-specific statements
SAP AG 1999
Course Objectives
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
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
Content
1) Overview of HR 2) ABAP Programming v/s HR Programming. 3) Logical Database PNP. 4) Views Join and PROJECTION. 5) Specific Commands. 6) Authorization Check.
Content
6) Time Data. 7) Repetitive Structure and List Display. 8) Exporting/Importing DB Tables in HR. 9) HR ABAP Features. 10)Logical Database PCH. 11)Logical Database PAP.
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.
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, and 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.
What is Infotype?
The information units used to enter the data of an employee are called infotypes. The infotypes are used to group related data fields together. E.g.. IT0006.(address)
Why Infotype
As HR is related to time, we require old data as well as new data. The data we enter into the infotypes are automatically checked for accuracy and against the table entries. In simple, HR data is huge and to access data easily we require infotype.
2. Logical databases at run-time of an ABAP program At run-time, the system processes the events in the program and in the logical database in the following order: Before displaying the selection screen, certain initializations (e.g. calculating default values such as key date, etc.) 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
The logical database and the program check that the input is correct and complete , but also that the user has the appropriate authorizations. If an error occurs, some fields are made ready for input again, so that the user can make the necessary correction(s). o In the event START-OF-SELECTION, the ABAP program performs any preliminary work (for ex, importing files). 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. o In the event END-OF-SELECTION, the ABAP program performs any concluding operations (for example, calculating totals, exporting files).
3 . 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, each on a new line. The system automatically generates such a screen for each program that does not have its own selection screen entered in the attributes. You can define your own selection screens for any logical database. If the attributes of a program include the number of its own selection screen, the system uses this screen as a model when generating. Any program-specific selections appear after the database selections. The flow logic for such screens is also generated automatically and therefore cannot be modified. You cannot delete database selections
Functions of LDB:
Data retrieval: The personnel data of each employee is loaded into the main memory where it can be accessed for processing. Screening: Employees can be selected according to the organizational criteria entered on the selection screen. E.g...Hourly wage earners in a particular personnel sub area. There are two types of screening..Person selection and data selection period.
Functions of LDB:2
Person selection :defines those employees for whom a report is to be run. E.g..Monthly wage earners in a specific personnel sub-area. E.g..Personnel number range E.g..Features of org.Assignment...Employees who assigned to certain cost center. E.g..Employee status..Active or inactive.
Functions of LDB:3
The data selection : period delimits the time period for which data is evaluated. When you enter the data selection period,the provide loop retrieves the infotype records whose validity period overlaps with at least one day of this period. Authorization check : This ensures that the person starting the evaluation Is authorized to access the report data.
GET PERNR :
This event fills the data structures of declared infotypes with all records that exists for a personnel number. Data selection does not delimit the records that retrieved from the database. Whenever GET PERNR statement is included in your program check the following two . 1.Have you included PNP for the logical database screen field in the program attributes. 2.Have you included PERNR structure in the tables declaration.
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. TRMAC Table has Macros. Subtypes : The sub-division of infotype records are subtypes.Each subtype representing an infotype category with its own time character. Infotype 0006 is for addresses.This addresses are sub-divided in the IT0006 as permanent residence,secondary residence and home address.
Cluster : set of data objects. Elementary fields , field strings and internal tables etc. will come under data objects. You can store data clusters in ABAP/4 memory for short time and in database for longer time. e.g. cluster database tables PCL1, PCL2, PCL3 and PCL4.
1)
The INFOTYPE
An Info type is just another way to handle/store data. HR Data is huge and to enable easy data entry the concept of an Info type took birth.
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. Assignment). Infotype 0002 (Personal Data). Infotype 0003 (Payroll Status). HR Time Record: Infotype 2010. (Employee Remuneration Info.).
Data Retrieval
When you run your report, the logical database loads the personnel data for each employee into the main memory and makes it available for processing.
The entire history of each info type is loaded into the main memory, that is all info type records from the lowest to highest system date.
Data Retrieval
Structure PERNR contains standard selections for HR Master data reporting. The data of the previous personnel number is deleted when you select another personnel number.
Authorization Checks
The logical database executes an authorization check for personnel data. 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.
Authorization Checks
The system first checks whether the user has an authorization for the employee in accordance with the criteria of organizational assignment. 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. A list would be meaningless if the data were not evaluated completely.
Screening Criteria
Two types: Person Selection.
Data Selection.
Screening Criteria
Person Selection: Specifies those employees for whom the report is to be run. Selected by Personnel Number Range, Org Assignment, Status, etc. Selected Employees are processed in ascending order according to personnel number.
Screening Criteria
In the data selection field, you can define the period for which info type data is to be evaluated. Although the entire info type history is loaded into the main memory during data retrieval, the system processes only those info type records which either partly or completely are within the data selection period.
Report Class
Since the required selection criteria depend on the report, you must define the scope of the selection screen. You can do this by assigning the report to a report class.
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). If no report Class is assigned to a report, default report classes are used from T599C(Customer) and T599F(SAP Default Class).
Report Class
E.g.The time evaluation report RPTIME00 is assigned the report class __0001. The personnel number and Matchcode function key are the only permissible selection criteria in this report class.
Report Class
The report RPDEDTx0 (editing of payroll results;x is the country grouping) is assigned the report class X_M00002. The active selection criteria of this report are period defined/payroll area, personnel number and payroll area.
Example of an HR report
REPORT ZTEST_HR1. TABLES: PERNR. INFOTYPES: 0001. GET PERNR. PROVIDE * FROM P0001 BETWEEN PNPBEGDA AND WRITE: / P0001-PERNR, P0001-ENAME, P0001-BEGDA, P0001-ENDDA. ENDPROVIDE.
PNPENDDA.
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
JOINS are only possible for info types with time constraint 1 or 2.
JOIN
PROVIDE * FROM P0002 FROM P0006 FROM PNNNN BETWEEN PN/BEGDA & PN/ENDDA. ------------------------ENDPROVIDE.
JOIN
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.
JOIN
Any number of infotypes can be combined in a JOIN. Data to be JOINED must be UNIQUE for the validity period i.e. the time periods of the Infotype records should not overlap. To further obviate this problem the Infotype must be read using a sub-type.
JOIN
REPORT ZTEST_HR2. TABLES: PERNR. INFOTYPES: 0001, 0006. GET PERNR. PROVIDE * FROM P0001 * FROM P0006 BETWEEN PN/BEGDA AND PN/ENDDA WHERE P0006-SUBTY eq 1.
JOIN
WRITE: / PERNR-PERNR, P0001-STELL, P0006-STRAS, P0006-BE GDA,P0006ENDDA. ENDPROVIDE.
JOIN
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:
Variable Pnnnn_Valid
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.
Variable Pnnnn_Valid
IF P0006_VALID EQ X. WRITE: / PERNR-PERNR, P0002-BEGDA DD/MM/YYYY, P0002-ENDDA DD/MM/YYYY, P0002-NACHN, P0006-ORT01. ENDIF.
ENDPROVIDE.
PROJECTION
Selecting one or more infotype fields for processing is called Projection. The process of combining data records during projection is called contraction. Projection is only allowed for time constraints 1 and 2.
PROJECTION
REPORT ZTEST_HR. TABLES: PERNR. INFOTYPES: 0001, 0006. GET PERNR. PROVIDE STELL FROM P0001 BETWEEN PNPBEGDA AND PNPENDDA. ENDPROVIDE.
4) SPECIFIC COMMANDS
RMAC - MACROS
Like Subroutines and Function modules Macros can be used to modularize codes. They are in TRMAC Table. The first two letters are the application and the rest are freely assigned.
Changing Infotypes
RP-UPDATE macro update the database. RP-UPDATE OLD NEW. Parameters: Old Internal Table, New Internal Table. This macro calls the update routine of HR file.
Changing Infotypes
You cant make key changes, which means you cant create or delete data. 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.
Changing Infotypes
Three steps involved in changing Info types. Select the Info type to be changed. Make the required changes and store the records in an alternative table.
Changing Infotypes
REPORT ZTEST_HR. TABLES: PERNR. INFOTYPES: nnnn NAME OLD nnnn NAME NEW. GET PERNR. PROVIDE * FROM OLD.. NEW = OLD.
Changing Infotypes
APPEND NEW. ENDPROVIDE. RP-UPDATE OLD NEW.
PERNR =
INFTY = BEGDA= ENDDA=
SUBRC = <RETURN>
TABLES INFTY_TAB = P0002 EXCEPTIONS INFTY_NOT_FOUND = 1 OTHERS = 2.
5) Authorization Checks
Authorization Checks
Checks if a person starting the report has the required authorizations. LDB does this check automatically. HR makes a distinction between two types of authorization , one for person and another for data.
6) Time Data
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. Time data IT 2001 is determined on the basis of the validity period. The number of Absence days is calculated on the basis of absence period.
Time Data
Since the data depends on the validity period , time infotypes leads to incorrect data. PROVIDE statement is not used for time infotypes ( 2000- 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.
Time Data
To control this MODE N is assigned while declaring the time Infotypes.
RP_READ_ALL_TIME_ITY.
Program 1
INFOTYPES: 2001 MODE N. GET PERNR. RP-READ-ALL-TIME-ITY PN/BEGDA PN/ENDDA. LOOP AT P0021. If P0021-XYZ = ' '. A=B. Endif. ENDLOOP.
Program 2
DATA: BEGIN OF ITAB OCCURS 0, BUKRS LIKE P0001-BUKRS, "COMPANY WERKS LIKE P0001-WERKS, "PERSONNEL AREA AWART LIKE P2001-AWART, "ABS./ATTEND. TYPE ASWTG LIKE P2001-ASWTG, "ABS./ATTEND. DAYS END OF ITAB. GET PERNR. RP-PROVIDE-FROM-LAST P0001 SAPCE PN/BEGDA PN/ENDDA. CLEAR ITAB. ITAB-BUKRS = P0001-BURKS. ITAB-WERKS = P0001-WERKS. RP-READ-ALL-TIME-ITY PN/BEGDA PN/ENDDA. LOOP AT P2001. ITAB-AWART = P2001-AWART. ITAB-ASWTG = P2001-ASWTG. COLLECT ITAB. (OR: APPEND ITAB.) ENDLOOP.
Repetitive Structure
On some infotype entry screens like leave data is entered in Tables. All of the fields in this table structure are named and defined in the Infotype structure on which they are based. Table datas are stored in a linear structure.
Repetitive Structure
In some Infotypes data entered in screen tables is stored as repeat fields groups on the database. Loop Processing within DO/ENDDO or WHILE/ENDWHILE can be used to transport such data block by block to work area, where it continues to be processed.
0005 0008 0041 In the infotype structure, fields are grouped by the same name followed by sequence number. P0005-UARnn P0005-UANnn P0005-UBEnn P0005-UENnn P0005-UABnn
Repetitive Structure
DATA: BEGIN OF VACATION, UAR LIKE P0005-UAR01, "Leave type UAN LIKE P0005-UAN01, "Leave entitlement UBE LIKE P0005-UBE01, "Start date UEN LIKE P0005-UEN01, "End date UAB LIKE P0005-UAB01, "Leave accounted END OF VACATION. GET PERNR. RP-PROVIDE-FROM-LAST P0005 SPACE PN/BEGDA PN/ENDDA. DO 6 TIMES VARYING VACATION FROM P0005-UAR01 "Starting point NEXT P0005-UAR02. "Increment If p0005-xyz then ... endif. ENDDO.
List Display
Function Module HR_DISPLAY_BASIC_LIST. Used to display single-level lists.
8) Export/Import DB Tables in HR
Database Tables in HR. Pannnn (personnel data), PCL1(HR Work Areas), PCL2(Acctg Results & Payroll), PCL3(Applicant, Tracking Record) PCL4(Documents). 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
Export/Import Tables in HR
Data Clusters
Data Clusters have a two character code. Each HR subarea has its own cluster and its own key.
TX(Infotype Texts).
PC(Personal Calendar).
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
Table Management
EXPORT IMPORT Commands are used A Unique KEY ID is required to read or write from/to table. The field PCLn-RELID stores the basic relation type i.e the cluster (RX for payroll accounting, TE for Travel Expenses etc).
Cluster Definition
Data definitions of a work area are stored
in separate programs.
Naming convention for these programs is RPCnxxy0 ( n = 1 or 2, xx = Cluster Name, y = 0 for international). The key structure is stored in xx-KEY field string. The first component of this field string is PERNR.
REPORT ZHREXPRT. *Buffer definition INCLUDE RPPPXD00. INCLUDE RPPPXM00. "Buffer management DATA: BEGIN OF COMMON PART 'BUFFER'. INCLUDE RPPPXD10. DATA: END OF COMMON PART 'BUFFER'. ... RP-EXP-Cn-xy. IF SY-SUBRC EQ 0. PERFORM PREPARE_UPDATE USING 'V'.. ENDIF.
REPORT RPIMPORT. *Buffer definition INCLUDE RPPPXD00. DATA: BEGIN OF COMMON PART 'BUFFER'. INCLUDE RPPPXD10. DATA: END OF COMMON PART 'BUFFER'. *import data to buffer RP-IMP-Cn-xy.
9) HR ABAP Features
HR ABAP Features
Accessing Reports using Dynamic Action. 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.
HR ABAP Features
Accessing Feature from Reports. PERFORM RE549D USING par1 par2 par3 par4. Par1 Feature name.
THANK YOU