ABAP HR Material

Embed Size (px)

DESCRIPTION

imp

Citation preview

  • SAP ABAP HR TRAINING

    *

  • What is HR and SAP-HR Concepts & Components

    Why HR ABAP is different from normal ABAP.

    Logical Databases and other HR related tables

    Overview on HR Macros

    Programming using Logical data bases and Macros

    Report Categories

    *Topics

  • *The task of Human Resource Management is to produce the organizational hierarchies , relationship between employees and to allow storage and administration of employee data

    PA Personnel Administration and Payroll AccountingPD Personnel Planning and Development.SAP HR ComponentsWhat is HR

  • *Components of PA (Personnel administration)

  • Organizational ManagementSeminar and Convention MgtPersonnel DevelopmentWork force PlanningRoom Reservation Planning*Components of PD (Plannning and Development)

  • Enterprise Structure Personnel Structure and Org.Plan

    *The Organizational Assignment in PAThe company structure or Enterprise Structure is divided into : Company codePersonnel areaPersonnel Sub-area

  • Employee Group,Employee SubgroupPayroll area.*The Components in Personnel Structure are administrative :Organizational :Job,Position and Organizational unit.

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

  • What is Infotype Why Infotype*

  • Introduction to HR Infotype ConceptAn infotype represents a group of related data fields, provide information structure, facilitates data entry, and allows time dependent storage. In other words we can say infotypes are information units used to enter the time dependent data of the employee.

    Master data in HR is stored in infotypes. Each infotype pertains to a specific type of data. Each infotype has a database table associated with it.

    For example, these are the frequently used infotypes. -Actions: Infotype 0000 stores all actions for an employee.

    -Org Assignment: 0001 stores all information on employees Organization Specific status

    -Personnel Data: 0002 stores all information on name, birth date, Sex etc.

    -Basic Pay: 0008 stores all information on pay for employee.

    For each employee, there can be many records stored in each infotype, each with a start and end date.

    *

  • Introduction to HR Infotype Concept

    The key of each infotype record is:

    - Client - Represents the system No.

    - Personnel number - 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).

    - Subtype - subtypes are subdivisions of infotypes. An infotypes subtypes can have different time constraints and form their own histories.

    - Object identification - the object identification is used to make a distinction between records with the same infotypeFor example, the child number in infotype 0021 Family/Related Person.

    *

  • Introduction to HR Infotype Concept

    The key of each infotype record is:

    - Lock Indicator - 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.

    - End Date - end date.

    - Start Date Start date

    - 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). Unlike the object identification, it is assigned by the system automatically

    Note: Structure PAKEY should never be changed

    *

  • Introduction to HR Infotype Concept Personnel Planning Infotypes

    Structure: HRIKEY

    MANDT: This field contains the clients.PLVAR: It is a two-character alphanumeric Key for the plan versions that enables us to differentiate between alternative plan versions.OTYPE: This field contains the object type key, 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 typeISTAT: This field is one-digit numeric key in which the planning status is indicated. There is a status for all objects and for the infotypes that describe them.BEGDA: This contains start date of the validity periodENDDA: This contains end date of the validity periodVARYF: This contains the target object of a relationshipSEQNR: This specifies a sequence number for Infotypes of time constraint class 3.

    *

  • Time constraints:

    Enable you to determine how the validity periods of Infotype datarecords interact.

    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 0001 Org.Assignment

    TC 2: No more than one valid data record of the infotype in question can exist at any one time.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: IT0022 - Education

    TC A: Infotype exists just once from Jan.1 1800 to Dec.12 9999 Ex: IT 0003 Payroll Status

    TC T :Time constraint is based on subtype or subtype table Ex: IT 0008 Basic pay

    Introduction to HR Infotype Concept*

  • Important core topic in HR programming.

    To reduce programming Efforts, it often helps to use the logical databases when creating reports. Logical databases are special ABAP Programs that provide selection screens, additional features and so on.

    The LDB usually consists of the following components. Structure 2. Selections 3. Database programs

    Functions of LDB:

    Data retrieval | Screening | Authorization check

    Logical Databases used In HR:PAPPNP PNPCE - Enhanced version of PNP available form SAP Enterprise version onwardsPCHPTRVP The LDB PAP is for Applicant administration, PNP and PNPCE for Personnel Management, PCH for Organisational Management and PTVRP for Travel Management. The Logical Databases PNP/PNPCE and PCH are mostly used.

    Programming using Logical Databases*

  • Programming using Logical Databases Default Selection Screen provided by PNP. *

  • Programming using Logical Databases In program attributes, enter the following under logical database. *

  • Programming using Logical Databases With out LDBYou 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.*

  • Programming using Logical Databases With out LDB*

  • Programming using Logical Databases Example of an HR report HR report that uses the logical database uses the following basic structure:Report zdemo01.Tables: PERNR.INFOTYPES: 0001.GET PERNR. PROVIDE * FROM P0001 BETWEEN PN-BEGDA AND PN-ENDDA.WRITE: / P0001-PERNR, P0001-STELL, P0001-BEGDA, P0001-ENDDA.ENDPROVIDE.The above report evaluates the Organizational assignment infotype records in the specified data selection period.

    *

  • Programming using Logical Databases Infotype Declaration.

    All infotypes to be processed in the report are listed in the ABAP INFOTYPES keyword.

    The database usually contains several records with different validity periods and not just one record for each infotype and personnel number. Infotypes are time-dependent since their data changes over time. For this reason, one structure or work are would not suffice for the provision of infotype data in the main memory.

    Therefore the INFOTYPES statement is used to create an internal table for each of the listed infotypes. The structure of this table corresponds to that of the relevant infotype.*

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

    GET PERNR fills the internal tables of infotypes that are declared for each employees using the INFOTYPES statement.The internal infotype table is filled with all records existing between the lowest and highest system date. The internal table has the name Pnnnn, where nnnn is the infotype number.

    The header of the internal table Pnnnn is undefined after the GET PERNR action.

    PERNR is a Data Dictionary structure without a database. You must declare this structure in the report using the TABLES statement.

    *

  • Programming using Logical Databases DATA STRUCTURES (PA-PAD). Structure of Infotypes.

    The Data dictionary contains Pnnnn corresponds to the table PAnnnn.

    The infotype is defined in the Data Dictionary as a structure without a database. The Pnnnn structure of the infotype is used as the field structure for the infotype entry screen.

    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. DATA END OF Pnnnn VALID BETWEEN BEGDA AND ENDDA. (eg) INFOTYPES 0001.

    The infotype records can be processed using the infotype structure when the report is run.

    PERNR structure.*

  • Programming using Logical Databases DATA STRUCTURES (PA-PAD). Event keywords for data retrieval from a logical database have the following syntax. GET .

    The logical HR database used the table PERNR. You must declare it in the TABLES statement.

    At the GET PERNR event, the PERNR structure contains the data for a personnel number chosen on the basis for selection screen entries.

    The PERNR-PERNR field contains the personnel number which is selected for processing.

    Only the PERNR-PERNR field should be read from the work area of the PERNR table. The other fields are intended for internal use only.

    *

  • Programming using Logical Databases JOINA join processes records from two or more infotypes. The data from these infotypes is provided for a specific partial period.To know in which time period an employee worked at which job at which address he or she resided during this time.The following addresses data is available: Jan - March California April - June StamfordThe following work center data is available: Jan - April DeveloperMay - November Team LeadIf the address and work center data are provided for specific partial periods, the following cases.Jan - Feb California / DeveloperMarch - October Stamford / Team Leader.The following program will fetch the results. *

  • Programming using Logical Databases JOINREPORT ZTEST_JOIN.TABLES: PERNR.INFOTYPES: 0001, 0006.GET PERNR.PROVIDE * FROM P0001 * FROM P0006 BETWEEN PN-BEGDA AND PN-ENDDA. WHERE P0006-SUBTY = 1.WRITE: / PERNR-PERNR,P0001-STELL,P0006-STRAS,P0006-BEGDA, P0006-ENDDA.ENDPROVIDE.

    Note: Changing data in any one of the infotypes linked by a join causes a split in the selection period.*

  • Programming using Logical Databases Projection An employee has worked as developed for 2 years in the three different personnel areas.

    The following organizational assignment data is available.

    Jan 2001- Dec 2001 Developer / Personnel area 1. Jan 2002- Dec 2002 Developer / Personnel area 2. Jan 2003-Dec 2003 Developer / Personnel area 3.*

  • 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, the following applies.

    January 2003toDec 2003 Developer.

    REPORT ZTEST_PROJECTION.TABLES: PERNR.INFOTYPES: 0001.GET PERNR.PROVIDE STELL FROM P0001 BETWEEN PN-BEGDA AND PN-ENDDA.WRITE: / PERNR-PERNR,P0001-STELL, P0001-BEGDA,P0001-ENDDA.ENDPROVIDE.

    *

  • Programming using Logical Databases Join and Projection.

    Data from Several Infotypes and the fields.

    Tables: pernr.

    Infotypes: 0001,0002.

    GET PERNR.

    PROVIDE STELL ENAME FROM P0001GBDAT FROM P0002BETWEEN PN-BEGDA PN-ENDDA.

    WRITE:..

    ENDPROVIDE.

    *

  • Programming using Logical Databases PAP applicant master data.

    Example of a report in HR recruitment.HR report which uses the logical database has the following basic structure:

    REPORT ZTEST_BASE_STRUCTURE.TABLES: APPLICANT.INFOTYPES: 0001.GET APPLICANT.PROVIDE * FROM P0001 BETWEEN PA$BEGDA AND PA$ENDDA.WRITE: / P0001-PERNR,P0001-ENAME, P0001-BEGDA,P0001-ENDDA.ENDPROVIDE.

    Data Retrieval.Data is retrieved at the GET APPLICANT event. The GET APPLICANT action is executed for all personnel numbers that were selected on the basis of selection screen entries. The event should therefore be viewed as a loop via the selected personnel numbers.

    *

  • Programming using Logical Databases

    GET APPLICANT fills the internal tables of infotypes that are declared for each employee using the INFOTYPES statement.

    The internal infotype table is filled with all records existing between the lowest and highest system date. The internal table has the name Pnnnn, where nnnn is the infotype number.

    The syntax is as follows:PROVIDE * FROM Pnnnn BETWEEN PA$BEGDA AND PA$ENDDA.WRITE: / Pnnnn-.ENDPROVIDE.

    The relationship between the infotype and the data selection period of the selection screen is established using the PA$BEGDA AND PA$ENDDA variables. Often only require the most recent or earliest infotype record, not all infotype records. In this case, use one of the following statements:

    PAP_PROVIDE_FROM_LAST Pnnnn SPACE PA$BEGDA PA$ENDDDA.(or)PAP_PROVIDE_FROM_FRST Pnnnn SPACE PA$BEGDA PA$ENDDA.

    These statements make the newest or oldest record in the PA$BEGDA TO PA$ENDDA data selection period available in the structure Pnnnn.

    *

  • Programming using Logical Databases

    If the infotype has subtypes, replace the SPACE parameter by the appropriate subtype number.When a record has been successfully read, the return code PAP-SW-FOUND = 1.Sample report:REPORT ZTEST_APPLICANT_DATA.TABLES: APPLICANT.INFOTYPES: 0001.GET APPLICANT.PAP_PROVIDE_FROM_FIRST P0001 SPACE PA$BEGDA PA$ENDDA.IF PAP_SW_FOUND eq 1.WRITE: / APPLICANT-APLNO,P0001-BUKRS, PA$BEGDA,PA$ENDDA. ELSE.REJECT.ENDIF.

    Structure of HR Recruitment tables:Recruitment data is stored in the transparent tables PBnnnn. Apart from the keys (client, applicant number, subtype, object ID, lock indicator, validity period, and sequential number), table PBnnnn only contains the data for the infotype in question.

    *

  • Programming using Logical Databases

    The APPLICANT-APPLNO field should be read from the work area of the APPLICANT TABLE. The other fields are intended for internal use only.Default screen for PAP logical database.

    *

  • Programming using Logical Databases ORGANIZATIONAL MANAGEMENT DATA.

    PCH Personnel Planning.Used to retrieve data from Org Management Infotypes.Sample Report:REPORT ZTEST_OM_PCH.TABLES: OBJEC.INFOTYPES: 1001.GET OBJEC. WRITE: / OBJEC-OBJID,OBJEC-STEXT.PROVIDE * FROM P1001 BETWEEN PCHBEGDA AND PCHENDDA. WRITE: / P1001-OBJID,P1001-RELAT, P1001-SOBID.ENDPROVIDE.To read up on Org Management Infotypes, go to HELP->SAP Library->Human Resources->HR Infotypes->Personnel Mgt->Org Management.

    *

  • Default screen for PCH Logical database.

    Programming using Logical Databases *

  • 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_LAST retrieves the last(latest) datarecord which is valid in the data selection period.The macro RP_PROVIDE_FROM_FRST retrieves the first(start)data record which is valid in the data selection period.The macro RP-READ-INFOTYPE retrieves the data record(s) which isvalid in the data selection period.For every macro, whether the operation was successful or notwill be checked with PNP-SW-FOUND.If PNP-SW-FOUND = 1 , then the operation is successful.*

  • Programming using Logical Databases MACROS*

  • Programming using Logical Databases MACROS Example Report: Report Ztest_Macro. Tables: PERNR. INFOTYPES: 0001. GET PERNR.RP_PROVIDE_FROM_LAST P0001 SPACE PN-BEGDA PN-ENDDA. PNP-SW-FOUND = 1.write: / PERNR-PERNR, P0001-STELL, PN-BEGDA, PN-ENDDA.ELSE.REJECT.ENDIF.*

  • Programming using Logical Databases Reading Time Data Infotypes 2000 to 2999 are time infotypes. They are 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 the infotype records from the earliest to most recent system dates into the main memory. This would quickly lead to memory overload, especially if a front-end time recording system is connected to the HR system.

    That 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 event.

    Time infotype tables are processed with the LOOP statement since the PROVIDE statement limits, and thus changes, the infotype start and end dates to the data selection 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, MODE NIs assigned to the infotypes in declaration.

    The time infotype tables are subsequently filled using the RP_READ_ALL_TIME_ITY macro, however, only in the specified period.*

  • Programming using Logical Databases Some important fields PERNR Personnel NumberWERKS Personnel AreaBTRTL Personnel SubareaPERSG Employee GroupPERSK Employee SubgroupABKRS Payroll AreaLGART Wage TypeBETRG AmountANZHL NumberMOLGA Country codeBEGDA Start DateENDDA End DateMOABW Personnel subarea grouping for absence and attendance types*

  • Report Categories You can create your own report categories for your report programmingUsing Logical Database PNP.

    Instead of standard PNP logical data base selection screen, your own selectionWill appear .*

  • Report Categories Go to Attributes click HR Report Category Button.

    *

  • Report Categories

    It takes you to report categories maintenance view, press new entries *

  • Report Categories

    It takes you to report categories maintenance view, press new entriesGive the Report Category Name and save. *

  • Report Categories

    Double click the Allowable Selection Criteria in left hand side.Give your own selection options.*

  • Report Categories

    Save the entries.*

  • Report Categories

    Go to SE38 and execute the program , you can see your own Selected Selection screen options.*

  • End of Session*

    *