SAP ABAP HR

Programming in HR

HR-ABAP

SAP ABAP HR

Prerequisites
Knowledge of
ABAP Programming Logical Database Module pool programming SAP Scripts

SAP ABAP HR

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)

SAP ABAP HR Modules in SAP-HR Personnel Management (PA) Time Management (PT) Recruitment (PB) Organizational Management (OM) Personnel Development (PD) Training & Event Management (TM) .

.SAP ABAP HR Infotype Definition Units of information.

SAP ABAP HR Uses of Infotype • To group related data fields Name DOB Nationality Marital Status Street City Pin code State Personal Data INFOTYPES Addresses .

SAP ABAP HR Uses of Infotype • Maintaining Employee Information by Date .

SAP ABAP HR Infotype Numbers • • • Four digit number nnnn Unique identification 9000 to 9999 reserved for customer infotypes .

SAP ABAP HR 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 .

In accordance with the distribution of infotype name ranges.SAP ABAP HR 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. objects P9nnn . • Transparent table PAnnnn and/or transparent table PBnnnn Transparent table PAnnnn is required if you want to use an infotype within Personnel Administration. . transparent table PBnnnn is required. PS9nnn . • Structure Pnnnn Structure Pnnnn contains infotype key fields and all of the data fields from structure PSnnnn . PA9nnn and PB9nnn are assigned to the customer name range. If you want to use an infotype within Recruitment.

Where P stands for Human Resources (personnel) and nnnn is the four-digit infotype number. This module pool is the main program for the maintenance interface for the infotype.SAP ABAP HR Infotype Module Pool • A module pool should be used with each infotype. • The name of the program is MPnnnn00. .

If you create the main program using transaction PM01 Dialogs in HR. the system also creates the following four includes: Name of include MPnnnn10 The include contains The PROGRAM statement and the declaration of common data objects PBO modules for the screens PAI modules for the screens subroutines MPnnnn20 MPnnnn30 MPnnnn40 .SAP ABAP HR Infotype-specific Includes The main program only contains INCLUDE statements.

Declaration of common data objects Standard infotype modules Definition of infotype return codes Definition of two data objects that contain the number of reference personnel numbers in structure P0031 or P0121 MPPDAT00 MPPERS00 MPPIRC00 MPPREF00 . The variables specified in this area are used as export or import parameters when the infotype dialog module is accessed.SAP ABAP HR 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.

SAP ABAP HR Infotype Screens Each infotype has at least three screens: • • • An initial screen A single screen A list screen .

SAP ABAP HR 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 .

Preview .SAP ABAP HR Initial Screens .

.SAP ABAP HR Single Screens • • • Its an interface between the system and the user. display or maintain data records. It enables to create. Screen 2000 is used for single screen.

SAP ABAP HR Single Screen .Preview .

SAP ABAP HR List Screen • Unables to list all records in infotye • Screen 3000 is used for list screen .

SAP ABAP HR List Screen .Preview .

SAP ABAP HR 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. .

The following time constraint indicators are permissible: 1 No overlapping and no gaps. 3 Overlapping and and time gaps are permitted.SAP ABAP HR Infotype Time Constraint A time constraint indicates whether more than one infotype record may be available at one time. . 2 No overlapping but time gaps are permitted.

SAP ABAP HR

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.

SAP ABAP HR

Infotype Characteristics
The following tables must be maintained for each infotype: Name of table T582A Task Basic infotype characteristics (database tables, single screen, list screen, time constraint, dialog module, and so on) T582S T777A Infotype short texts Technical Characteristics of Infotype (database table, dialog module, and so on) Name of data field structure (PSnnnn)

T77ID

SAP ABAP HR

Creating PA infotypes
Transaction code

‘PM01’.

SAP ABAP HR Creating PA infotypes – PM01 .

SAP ABAP HR Creating PA infotypes – Maintain Structure .

SAP ABAP HR Creating PA infotypes – Infotype Table .

SAP ABAP HR Creating PA info types – Infotype Table (Primary Key) .

SAP ABAP HR Creating PA infotypes – Preview .

Enter the infotype number. . Start the Personnel Administration infotype copier (PM01) 2.SAP ABAP HR Enhancement of PA Infotype 1. Choose Enhance infotype. 3.

enter the four-digit number of the infotype you want to create. The Dictionary: Initial Screen is displayed. Choose Create All. Create the Cl include. • • • • • • Result You have included additional fields in the standard single field for an infotype . field. Return to the Create Infotype screen. In the Sub-Objects group box. flag CI Include.SAP ABAP HR Enhancing a Single Screen • • • • Start transaction PM01 You access the Create Infotype screen: Choose Enhance Infotypes. please remember to enter any leading zeros. In the Infotype no. Choose Activate. Choose Create. When you specify the infotype number.

SAP ABAP HR Enhancing a Single Screen – PM01 .

SAP ABAP HR Enhancing a Single Screen – Maintain Structure .

SAP ABAP HR Enhancing a Single Screen – Screen Preview Enhanced Field .

having structure CI Include CI_P0000 .SAP ABAP HR Enhancing PA Infotype – CI INCLUDE Only those PA Tables can be Enhanced.

SAP ABAP HR HR Macros RP_PROVIDE_FROM_LAST RP_PROVIDE_FROM_FIRST RP_SET_DATA_INTERVAL RP_READ_INFOTYPE .

. DEFINE RP_PROVIDE_FROM_LAST. RP_PROVIDE_FROM_LAST P0001 SPACE PN-BEGDA PN-ENDDA. WRITE. END-OF-DEFINITION. INFOTYPES: 0001... . . .. 0002.SAP ABAP HR Macros Modules M acro M odules TABLES: PERNR. " Organizational Assignment "Personal Data " Addresses GET PERNR.. PNP-SW-FOUND = '0'. 0006. . * * * Include program DBPNPMAC. .

R P_ PR O VI DE _F RO M _L AS T <P n nn n> S PA C E PN-B EG D A PN -E ND D A. W R IT E. . ..FO U ND = 1 . E ND IF . I F PN P -S W.SAP ABAP HR Infotype Record Processing P rocessing a S p ecific Infotype R ecord Data selection January Decem ber T a ble Pnnnn January Decem ber G ET P E RN R.

RP_SET_DATA_INTERVAL '< Pnnnn>' PN-BEGDA PN-ENDDA.SAP ABAP HR Infotype Record Importing Importing Specific Infotype Records Data selection M ay December PAnnnn START-OF-SELECTION. Table Pnnnn . GET PERNR.

. CALL FUNCTION 'HR_READ_INFOTYPE' .. . ..SAP ABAP HR Function HR_READ_INFOTYPE Reading Infotypes Without Logical DB (1) PAnnnn INFOTYPES: <nnnn>..

SAP ABAP HR Function HR_READ_INFOTYPE Reading Infotypes Without Logical DB (2) INFOTYPES: 0002. . . DATA: return LIKE SY-SUBRC. . PERNR = <person> INFTY = '0002' BEGDA = <begdat> ENDDA = <enddat> IMPORTING SUBRC TABLES INFTY_TAB EXCEPTIONS INFTY_NOT_FOUND OTHERS = return = P0002 = 1 = 2. CALL FUNCTION 'HR_READ_INFOTYPE' EXPORTING .

You can use the function module HR_READ_INFOTYPE to read the personnel data in reports which do not use an HR logical database.SAP ABAP HR HR Macro – Summary • Many HR reports use macros. 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. • • . Their program codes are stored in a table or defined locally using the DEFINE keyword.

within the validity period. . Two or more infotypes can be processed in a single PROVIDE – ENDPROVIDE loop. Combines JOIN and PROJECTION.SAP ABAP HR Use of PROVIDE Statement PROVIDE – ENDPROVIDE is a loop to process Pnnnn tables. Reads time-dependent table entries.

SAP ABAP HR Logical database PNP Functions of Logical Database PNP 1. Screening 3. Authorization check . Data retrieval 2.

Screening .SAP ABAP HR Logical database PNP .

. 0007. " Organizational Assignment " "Personal Data " " Planned Working Time" 2. Create data structures for infotypes INFOTYPES: 0001. Fill the data structures with the infotype records GET PERNR.SAP ABAP HR Functions of Logical database PNP Data Retrieval 1. 0002.

. PROVIDE * FROM P0002 BETWEEN PN-BEGDA AND PN-ENDDA....SAP ABAP HR Processing Master Data using PROVIDE Processing Master Data TABLES: PERNR.. . WRITE. 0006. ENDPROVIDE.. " Actions "Personal Data " Addresses GET PERNR. INFOTYPES:0001. 0002.

PROVIDE * FROM P0002 BETWEEN PN-BEGDA AND PN-ENDDA. WRITE. PROVIDE * FROM P0006 BETWEEN PN-BEGDA AND PN-ENDDA..SAP ABAP HR Processing Master Data using PROVIDE Loop Nesting GET PERNR.. WRITE. ENDPROVIDE.. ENDPROVIDE. .. Infotype loop Employee loop Infotype loop END-OF-SELECTION.

SAP ABAP HR Joins in PROVIDE Join / Creating Intervals Personal Data (0002) Organizational Assignment (0001) Join .

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

. WRITE. PROVIDE STELL ENAME FROM P0001 GBDAT FROM P0002 BETWEEN PN-BEGDA AND PN-ENDDA. INFOTYPES:0001. .... 0002.SAP ABAP HR Joins and Projection in PROVIDE Join and Projection / Coding TABLES: PERNR.. ENDPROVIDE. "Organizational Assignment "Personal Data GET PERNR..

3. 4. Hiring / Appointment Letter Confirmation Letter Promotion Letter Transfer Letter Relieving Letter on Resignation Retirement Letter The generated letter should be modifiable and same is to be stored along with each employee and action. 5. .SAP ABAP HR PA Letters Infotype – Customer Defined Business Needs: A letter is to be generated after the following action in the prescribed format: 1. 6. 2.

On satisfactory completion of probation you will be confirmed in service. 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.01 Mr. Your salary & other benefits are stated in the attached compensation package sheet. You will report to [POSITION]. REC. Faithfully [Signatory] / SECRETARY [Designation] . You shall be governed by the Services rules of the Company. You will be on probation for a period of six months./Miss [Full name of Employee] [Position] [Grade] [Location] APPOINTMENT LETTER The management is pleased to appoint you as the [POSITION] in [GRADE] with effect from [DATE]. a copy of which is enclosed.SAP ABAP HR Sample format of Appointment Letter LETTER NO. A summary of Benefits & Leave Rules as applicable to you is also enclosed.

SAP ABAP HR Structure for PA letter Infotype Structure: PS9011 Component LDATE LTYPE SIGN1 DESGN MASSN EFFDT SUPER SBUNM APDAT RLDAT LETTERID Component Type ZLDATE ZLTYPE1 ZSIGN1 ZDESGN ZMASSN BEGDA ZSUPER ZSBUNM ZAPDAT ZRLDAT TDOBNAME Data Type DATS CHAR CHAR CHAR CHAR DATS CHAR CHAR DATS DATS CHAR Len 8 50 40 40 2 8 40 40 8 8 70 De c 0 0 0 0 0 0 0 0 0 0 0 Short Text Letter Date Letter Type Signatory Designation Action Type Start Date SBU / Functional Head SBU Name Appointment Date Relieving Date Name .

SAP ABAP HR ZHR_LTYPE Table ZHR_LTYPE created for help drop down of field LTYPE of structure PS9011. Table: ZHR_LTYPE Fields INFTY SUBTY LTYPE ACTION FRMNM Field Type INFTY SUBTY_591A Data Type CHAR CHAR CHAR CHAR CHAR Len 4 4 50 2 30 Dec 0 0 0 0 0 Short Text Infotype Subtype Letter Type Action Type Form Name ZLTYPE1 MASSN ZFRMNM .

SAP ABAP HR Screen Layout for PA Letters Infotype .

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

* * * * * P2 CC:..SAP ABAP HR STD Text for Appointmnet Letter – SO10 B You will be on probation for a period of six months. &pp9011-sign1& Faithfully .. a copy of which is enclosed. Management Systems and Information P2 .Chief Personnel Officer P2 . On satisfactory completion of probation you will be confirmed in service..Chief Manager. 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. A summary of Benefits & Leave Rules as applicable to you is also enclosed. * B You shall be governed by the Services rules of the Company.

SAP ABAP HR Clusters Definition Each database object. These areas are known as clusters. RX. PCL1 or PCL2. RD. for example. for example. . with the type Import/Export file consists of related areas.

SAP ABAP HR Display of Cluster data – Payroll Result .

SAP ABAP HR Display of Cluster data – Payroll Result .

SAP ABAP HR Display of Cluster data – Payroll Result .

SAP ABAP HR Display of Cluster data – Payroll Result .

SAP ABAP HR Display of Cluster data – Payroll Result .

SAP ABAP HR Display of Cluster data – Payroll Result .

DATA: COUNTRY LIKE T001P-MOLGA.SAP SAP ABAP HR ABAP HR Reading Cluster Directory Reading the Cluster Directory *Table containing directory of payroll results DATA: BEGIN OF RGDIR OCCURS 100. CALL FUNCTION 'CU_READ_RGDIR' EXPORTING PERSNR = PERNR-PERNR IMPORTING MOLGA = country TABLES IN_RGDIR = RGDIR EXCEPTIONS NO_RECORD_FOUND = 1 OTHERS = 2.. INCLUDE STRUCTURE PC261. DATA: END OF 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. . . . . . . .SAP ABAP HR Determining Last Payroll Result Determining Current Payroll Result (1) DATA: number LIKE PC261-SEQNR. . CALL FUNCTION 'CU_READ_RGDIR' . . GET PERNR.

DATA: rt_header TYPE LINE OF HRPAY99_RT.. . . . LOOP AT result-INTER-RT INTO rt_header. CHANGING PAYROLL_RESULT =result EXCEPTIONS .SAP ABAP HR Determining Last Payroll Result Determining Current Payroll Result (2) DATA: result TYPE PAY99_RESULT. WRITE: / rt_header-LGART. . CALL FUNCTION 'PYXX_READ_PAYROLL_RESULT' EXPORTING CLUSTERID ='RX' EMPLOYEENUMBER =p0001-pernr SEQUENCENUMBER =number * READ_ONLY_BUFFER = ' ' * READ_ONLY_INTERNATIONAL = ' ' * CHECK_READ_AUTHORITY = 'X' . . ENDLOOP.. . . .

WRITE: / rt_header-LGART. ENDLOOP. * Access to payroll result data WRITE: result-INTER-VERSC-FPPER. .SAP ABAP HR Structure for Payroll Result Structure for Payroll Results Structure: PAY99_RESULT EVP Structure PC261 INTER Structure PAY99_INTERNATIONAL VERSC Type PC202 NAT BT Dummy for national part RT Type HRPAY99_RT CRT Type HRPAY99_CRT DATA: result TYPE PAY99_RESULT . DATA: rt_header TYPE LINE OF HRPAY99_RT . . . . . . . . . LOOP AT result-INTER-RT INTO rt_header. .

Income Tax certificate of last employer f. Copy of latest qualification certificate.SAP ABAP HR EXERCISE (1) 1. it is mandatory to provide certain documents. which will form a checklist on joining the organization. Graduation certificate d. Relieving letter from last employer b. The joining checklist are as follows: a. . specify e. Others specify – (3 lines) Create a customer defined infotype where above details are maintained. Whenever an employee is hired. Salary Slip of last employer c.

i.SAP ABAP HR EXERCISE (2) 2.e. (Infotype Enhancement to IT 0015) If LTA claim is not of current year. • • Provide and additional field to maintain year for LTA claim. LTA is one time payment and maintained in IT 0015. . it can be claimed in the current year. If last year it is not claimed. Built a validation for the same. then LTA reduces to 80% of the current basic. Additional payments & deductions. Eligibility for LTA allowance is one basic for a financial year.

Display following fields: a. Generate a report to list employee with the latest action in the given date range. Action Text e. Employee Name c. Action Type d. Employee Number b.SAP ABAP HR EXERCISE (3) 3. Action Start Date Tips: Make use of HR macros .

Generate a report to list an employment history in a given date range. Action Text Tips: Make use of provide – endprovide loop . Employee Name c. Action Type e. Display following fields: a. Employee Number b.SAP ABAP HR EXERCISE (4) 4. Action Start Date d.

No. Tips: Refer to SAP standard programs in T. 00001 00002 00100 Basic HRA Conv Spl.Pay Read data from Payroll Cluster and display it in the above format.SAP ABAP HR EXERCISE (5) 5.Code PC00_M99_CLGA09 and PC_M99_CLGV09 . Generate a Salary register which will list following fields in matrix format. Emp.

Sign up to vote on this title
UsefulNot useful