This action might not be possible to undo. Are you sure you want to continue?
1. What is HR and SAP-HR Concepts & Components 2. Why HR ABAP is different from normal ABAP. 3. Logical Databases and other HR related tables 4. Overview on HR Macro‟s 5. Programming using Logical data bases and Macro‟s
6. Report Categories
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
SAP – HR Components
• • PA – Personnel Administration and Payroll Accounting PD – Personnel Planning and Development.
Components of PA (Personnel administration)
• • Personnel Administration - Master Data: Administration of all personnel data • Hire data • Organization assignment data • Leave Administration • Compensation & Benefits • Payroll & Time Data • Work Schedule • Planning Data • Salary Administration • Appraisal
Components of PD (Plannning and Development)
• • • • • Organizational Management Seminar and Convention Mgt Personnel Development Work force Planning Room Reservation Planning
Plan The company structure or Enterprise Structure is divided into : • • • Company code Personnel area Personnel Sub-area 6 .The Organizational Assignment in PA • • Enterprise Structure Personnel Structure and Org.
The Components in Personnel Structure are administrative : • • • Employee Group. Organizational : • • • Job. Employee Subgroup Payroll area. Position and Organizational unit. 7 .
Why HR is different from other modules ? 8 .
The following concepts are defined in HR which differs this module with other Modules 1. Storage and Access of data 5 Authorization checks 9 . Use of Macros 4. The use of Logical Database 3. Use of Infotypes 2.
What is Infotype Why Infotype 10 .
and allows time dependent storage. For example. each with a start and end date.Introduction to HR Infotype Concept An infotype represents a group of related data fields. Master data in HR is stored in infotypes. In other words we can say infotypes are information units used to enter the time dependent data of the employee. these are the frequently used infotypes. provide information structure. there can be many records stored in each infotype. -Basic Pay: 0008 stores all information on pay for employee. facilitates data entry. Each infotype pertains to a specific type of data. Each infotype has a database table associated with it. -Org Assignment: 0001 stores all information on employee‟s Organization Specific status -Personnel Data: 0002 stores all information on name. -Actions: Infotype 0000 stores all actions for an employee. birth date. Sex etc. For each employee. 11 .
the personnel number is the only unique key within a client for identifying an employee.Client Represents the system No. subtypes are subdivisions of infotypes. 12 .Subtype - . .Object identification . It is used to access the display and maintenance screens for an employee‟s master data and working time data (infotypes).Personnel number .the object identification is used to make a distinction between records with the same infotype For example. An infotype‟s subtypes can have different time constraints and form their own histories. the child number in infotype 0021 Family/Related Person.Introduction to HR Infotype Concept The key of each infotype record is: . .
which enables the “double verification principle” to be put into practice. Unlike the object identification. .the lock indicator for HR master data is used to lock and unlock data records. In accordance with this principle.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). .end date.End Date .Sequential Number .Introduction to HR Infotype Concept The key of each infotype record is: . One of the users creates a locked infotype record.Lock Indicator . activates the data record.Start Date – Start date . at least two users are involved in the process of writing an active data record to the database. and the other user unlocks . it is assigned by the system automatically Note: Structure PAKEY should never be changed 13 .that is.
OTYPE: This field contains the object type key. There is a status for all objects and for the infotypes that describe them. PLVAR: It is a two-character alphanumeric Key for the plan versions that enables us to differentiate between alternative plan versions. which is a maximum of two alphanumeric characters in length. OBJID: This field contains an eight-digit key that represents a single object. SUBTY: Contains specification of sub type ISTAT: This field is one-digit numeric key in which the planning status is indicated. BEGDA: This contains start date of the validity period ENDDA: This contains end date of the validity period VARYF: This contains the target object of a relationship SEQNR: This specifies a sequence number for Infotypes of time constraint class 3.Introduction to HR Infotype Concept Personnel Planning Infotypes Structure: HRIKEY MANDT: This field contains the clients. 14 .
12 9999 Ex: IT 0003 – Payroll Status TC T :Time constraint is based on subtype or subtype table Ex: IT 0008 – Basic pay 15 . TC 1: Exactly one valid data record of the infotype in question must exist for the entire time that the employee belongs to the enterprise. Ex: IT 0032 – Internal Data TC 3: Any number of valid data records of the infotype in question can exist at any one time. Ex: IT 0001 – Org.Introduction to HR Infotype Concept Time constraints: Enable you to determine how the validity periods of Infotype data records interact.1 1800 to Dec. EX: IT0022 .Education TC A: Infotype exists just once from Jan.Assignment TC 2: No more than one valid data record of the infotype in question can exist at any one time.
Logical databases are special ABAP Programs that provide selection screens. PNP and PNPCE for Personnel Management. The Logical Databases PNP/PNPCE and PCH are mostly used.Enhanced version of PNP available form SAP Enterprise version onwards PCH PTRVP The LDB PAP is for Applicant administration. Selections 3. 1.Programming using Logical Databases Important core topic in HR programming. The LDB usually consists of the following components. it often helps to use the logical databases when creating reports. Database programs Functions of LDB: Data retrieval | Screening | Authorization check Logical Databases used In HR: PAP PNP PNPCE . PCH for Organisational Management and PTVRP for Travel Management. 16 . Structure 2. additional features and so on. To reduce programming Efforts.
17 .Programming using Logical Databases Default Selection Screen provided by PNP.
18 . enter the following under logical database.Programming using Logical Databases In program attributes.
Programming using Logical Databases With out LDB Reading Infotypes Without Logical DB (1) PAnnnn INFOTYPES: <nnnn>. you must ensure that the internal table for the required infotype is declared with the INFOTYPE statement. 19 . SAP AG 1999 You can also read infotype records for a particular personnel number without using the logical database... . CALL FUNCTION 'HR_READ_INFOTYPE'. use the function module HR_READ_INFOTYPE. To do this. However...
INFOTYPES: <nnnn>.. CALL FUNCTION 'HR_READ_INFOTYPE' . . SAP AG 1999 20 .Programming using Logical Databases With out LDB Reading Infotypes Without Logical DB (1) Reading Infotypes Without Logical DB (2) INFOTYPES: 0002. PERNR = <person> INFTY = '0002' BEGDA = <begdat> ENDDA = <enddat> SAP AG 1999 IMPORTING SUBRC TABLES INFTY_TAB EXCEPTIONS INFTY_NOT_FOUND OTHERS = return = P0002 = 1 = 2. PAnnnn DATA: return LIKE SY-SUBRC.. . EXPORTING CALL FUNCTION .. 'HR_READ_INFOTYPE'..
The above report evaluates the Organizational assignment infotype records in the specified data selection period. 21 . P0001-STELL. Tables: PERNR. GET PERNR.Programming using Logical Databases Example of an HR report HR report that uses the logical database uses the following basic structure: Report zdemo01. P0001-ENDDA. PROVIDE * FROM P0001 BETWEEN PN-BEGDA AND PN-ENDDA. P0001-BEGDA. WRITE: / P0001-PERNR. INFOTYPES: 0001. ENDPROVIDE.
22 . • Therefore the INFOTYPES statement is used to create an internal table for each of the listed infotypes. Infotypes are time-dependent since their data changes over time. • All infotypes to be processed in the report are listed in the ABAP INFOTYPES keyword. The structure of this table corresponds to that of the relevant infotype. • The database usually contains several records with different validity periods and not just one record for each infotype and personnel number.Programming using Logical Databases Infotype Declaration. For this reason. one structure or work are would not suffice for the provision of infotype data in the main memory.
where nnnn is the infotype number. • GET PERNR fills the internal tables of infotypes that are declared for each employees using the INFOTYPES statement. • The header of the internal table Pnnnn is undefined after the GET PERNR action. •PERNR is a Data Dictionary structure without a database. 23 .Programming using Logical Databases Data Retrieval • Data is retrieved at the GET PERNR event. The GET PERNR action is executed for all personnel numbers that were selected on the basis of selection screen entries. The internal table has the name Pnnnn. You must declare this structure in the report using the TABLES statement. The internal infotype table is filled with all records existing between the lowest and highest system date.
Structure of Infotypes. The Pnnnn structure of the infotype is used as the field structure for the infotype entry screen. • The infotype is defined in the Data Dictionary as a structure without a database. 24 . • The Data dictionary contains Pnnnn corresponds to the table PAnnnn.Programming using Logical Databases DATA STRUCTURES (PA-PAD). DATA END OF Pnnnn VALID BETWEEN BEGDA AND ENDDA. • PERNR structure. • The effect of „INFOTYPES‟ statement is that it will create an internal table Pnnnn as follows: DATA BEGIN OF Pnnnn OCCURS 10. INCLUDE STRUCTURE Pnnnn. (eg) INFOTYPES 0001. The infotype records can be processed using the infotype structure when the report is run.
• The logical HR database used the table PERNR. The other fields are intended for internal use only. • At the GET PERNR event. GET <TABLE>. the PERNR structure contains the data for a personnel number chosen on the basis for selection screen entries. •Only the PERNR-PERNR field should be read from the work area of the PERNR table. You must declare it in the TABLES statement.Programming using Logical Databases DATA STRUCTURES (PA-PAD). 25 . •The PERNR-PERNR field contains the personnel number which is selected for processing. • Event keywords for data retrieval from a logical database have the following syntax.
To know in which time period an employee worked at which job at which address he or she resided during this time. the following cases. The following program will fetch the results. The data from these infotypes is provided for a specific partial period. 26 . Jan Feb California / Developer March October Stamford / Team Leader.Programming using Logical Databases JOIN A join processes records from two or more infotypes. The following addresses data is available: Jan March California April June Stamford The following work center data is available: Jan April Developer May November Team Lead If the address and work center data are provided for specific partial periods.
Programming using Logical Databases JOIN REPORT ZTEST_JOIN. 27 . TABLES: PERNR.P0006-BEGDA. INFOTYPES: 0001. P0006-STRAS. P0001-STELL. P0006-ENDDA. WRITE: / PERNR-PERNR. ENDPROVIDE. PROVIDE * FROM P0001 * FROM P0006 BETWEEN PN-BEGDA AND PN-ENDDA. 0006. GET PERNR. Note: Changing data in any one of the infotypes linked by a join causes a split in the selection period. WHERE P0006-SUBTY = 1.
The following organizational assignment data is available. -Dec 2003 Developer / Personnel area 3.Dec 2002 Developer / Personnel area 2.Dec 2001 Developer / Personnel area 1.Programming using Logical Databases Projection An employee has worked as developed for 2 years in the three different personnel areas. Jan 2001 Jan 2002 Jan 2003 . . 28 .
REPORT ZTEST_PROJECTION. January 2003 to Dec 2003 Developer. PROVIDE STELL FROM P0001 BETWEEN PN-BEGDA AND PNENDDA.Programming using Logical Databases If we only require the time period during which an employee performs a specific job and not the personnel area for an evaluation. INFOTYPES: 0001. P0001-BEGDA. P0001-ENDDA. GET PERNR. WRITE: / PERNR-PERNR. TABLES: PERNR. P0001-STELL. the following applies. ENDPROVIDE. 29 .
PROVIDE STELL ENAME FROM P0001 GBDAT FROM P0002 BETWEEN PN-BEGDA PN-ENDDA. Tables: pernr.Programming using Logical Databases Join and Projection. 30 . ENDPROVIDE. 0002. GET PERNR.. Infotypes: 0001. Data from Several Infotypes and the fields. WRITE:……….
P0001-BEGDA.Programming using Logical Databases PAP – applicant master data. The GET APPLICANT action is executed for all personnel numbers that were selected on the basis of selection screen entries. GET APPLICANT. INFOTYPES: 0001. PROVIDE * FROM P0001 BETWEEN PA$BEGDA AND PA$ENDDA. 31 . P0001-ENDDA. HR report which uses the logical database has the following basic structure: REPORT ZTEST_BASE_STRUCTURE. TABLES: APPLICANT. Example of a report in HR recruitment. Data Retrieval. P0001-ENAME. WRITE: / P0001-PERNR. Data is retrieved at the GET APPLICANT event. ENDPROVIDE. The event should therefore be viewed as a loop via the selected personnel numbers.
(or) PAP_PROVIDE_FROM_FRST Pnnnn SPACE PA$BEGDA PA$ENDDA. The internal table has the name Pnnnn. not all infotype records. where nnnn is the infotype number. ENDPROVIDE. Often only require the most recent or earliest infotype record. The syntax is as follows: PROVIDE * FROM Pnnnn BETWEEN PA$BEGDA AND PA$ENDDA. use one of the following statements: PAP_PROVIDE_FROM_LAST Pnnnn SPACE PA$BEGDA PA$ENDDDA. In this case. • The relationship between the infotype and the data selection period of the selection screen is established using the PA$BEGDA AND PA$ENDDA variables.Programming using Logical Databases • GET APPLICANT fills the internal tables of infotypes that are declared for each employee using the INFOTYPES statement. These statements make the newest or oldest record in the PA$BEGDA TO PA$ENDDA data selection period available in the structure Pnnnn. 32 . • The internal infotype table is filled with all records existing between the lowest and highest system date. WRITE: / Pnnnn-<FIELD>.
validity period. PA$BEGDA. REJECT. WRITE: / APPLICANT-APLNO. 33 . When a record has been successfully read. IF PAP_SW_FOUND eq „1‟. PA$ENDDA. ELSE. applicant number. replace the SPACE parameter by the appropriate subtype number. object ID. subtype. P0001-BUKRS. PAP_PROVIDE_FROM_FIRST P0001 SPACE PA$BEGDA PA$ENDDA. ENDIF. table PBnnnn only contains the data for the infotype in question. GET APPLICANT.Programming using Logical Databases If the infotype has subtypes. Structure of HR Recruitment tables: Recruitment data is stored in the transparent tables PBnnnn. the return code PAP-SW-FOUND = 1. TABLES: APPLICANT. INFOTYPES: 0001. Sample report: REPORT ZTEST_APPLICANT_DATA. and sequential number). lock indicator. Apart from the keys (client.
Default screen for PAP logical database. The other fields are intended for internal use only. 34 .Programming using Logical Databases The APPLICANT-APPLNO field should be read from the work area of the APPLICANT TABLE.
P1001-SOBID. GET OBJEC.Programming using Logical Databases ORGANIZATIONAL MANAGEMENT DATA. OBJEC-STEXT. ENDPROVIDE. 35 . Used to retrieve data from Org Management Infotypes. P1001-RELAT. To read up on Org Management Infotypes. INFOTYPES: 1001. PCH – Personnel Planning. Sample Report: REPORT ZTEST_OM_PCH. WRITE: / OBJEC-OBJID. PROVIDE * FROM P1001 BETWEEN PCHBEGDA AND PCHENDDA. TABLES: OBJEC. WRITE: / P1001-OBJID. go to HELP->SAP Library->Human Resources->HR Infotypes->Personnel Mgt->Org Management.
36 .Programming using Logical Databases o Default screen for PCH Logical database.
Programming using Logical Databases MACROS Macro contains some part of source code which it will be Useful for number of applications. The macro RP_PROVIDE_FROM_FRST retrieves the first(start) data record which is valid in the data selection period. The macro RP_PROVIDE_FROM_LAST retrieves the last(latest) data record which is valid in the data selection period. then the operation is successful. 37 . If PNP-SW-FOUND = 1 . For every macro. The macro RP-READ-INFOTYPE retrieves the data record(s) which is valid in the data selection period. whether the operation was successful or not will be checked with PNP-SW-FOUND.
SAP AG 1999 38 . 0006. WRITE. * * * Include program DBPNPMAC. INFOTYPES: 0001. . 0002.. . "Organizational Assignment "Personal Data "Addresses GET PERNR.. DEFINE RP_PROVIDE_FROM_LAST... END-OF-DEFINITION. RP_PROVIDE_FROM_LAST P0001 SPACE PN-BEGDA PN-ENDDA. .. PNP-SW-FOUND = '0'.Programming using Logical Databases MACROS Macro Modules TABLES: PERNR. .
INFOTYPES: 0001. PNP-SW-FOUND = 1. 39 . RP_PROVIDE_FROM_LAST P0001 SPACE PN-BEGDA PN-ENDDA. write: / PERNR-PERNR. ELSE. GET PERNR.Programming using Logical Databases MACROS Example Report: Report Ztest_Macro. PN-BEGDA. ENDIF. P0001-STELL. REJECT. Tables: PERNR. PN-ENDDA.
Programming using Logical Databases Reading Time Data • Infotypes 2000 to 2999 are time infotypes. 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 event. That is why time data should be read only for a specific period. and data is made available for processing in the internal infotype tables (infotype 2011 is an exception). This would quickly lead to memory overload. and thus changes. especially if a front-end time recording system is connected to the HR system. They are stored in tables PA2000 to PA2999. You should not load all the infotype records from the earliest to most recent system dates into the main memory. • • • • 40 . Infotypes are declared with the INFOTYPE statement. Time infotype tables are processed with the LOOP statement since the PROVIDE statement limits. the infotype start and end dates to the data selection period.
41 . only in the specified period.Programming using Logical Databases Importing Time Data Using Macro „ RP_READ_ALL_TIME_ITY PN-BEGDA PN-ENDDA To control the amount of time required to read time infotypes. however. “MODE N” Is assigned to the infotypes in declaration. The time infotype tables are subsequently filled using the RP_READ_ALL_TIME_ITY macro.
Programming using Logical Databases Some important fields PERNR Personnel Number WERKS Personnel Area BTRTL Personnel Subarea PERSG Employee Group PERSK Employee Subgroup ABKRS Payroll Area LGART Wage Type BETRG Amount ANZHL Number MOLGA Country code BEGDA Start Date ENDDA End Date MOABW Personnel subarea grouping for absence and attendance types 42 .
Instead of standard PNP logical data base selection screen. your own selection Will appear .Report Categories You can create your own report categories for your report programming Using Logical Database PNP. 43 .
44 .Report Categories Go to Attributes click „HR Report Category‟ Button.
Report Categories It takes you to report categories maintenance view. press new entries 45 .
46 .Report Categories It takes you to report categories maintenance view. press new entries Give the Report Category Name and save.
Report Categories Double click the ‘Allowable Selection Criteria’ in left hand side. 47 . Give your own selection options.
Report Categories Save the entries. 48 .
Report Categories Go to SE38 and execute the program . you can see your own Selected Selection screen options. 49 .
End of Session 50 .
This action might not be possible to undo. Are you sure you want to continue?
We've moved you to where you read on your other device.
Get the full title to continue reading from where you left off, or restart the preview.