You are on page 1of 81

H R 3 50

Programming in HR

Content
1) ABAP Programming v/s HR Programming. 2) Logical Database PNP. 3) Views Join and PROJECTION. 4) Specific Commands. 5) Authorization Check.

Content
6) 7) 8) 9) Time Data. Repetitive Structure and List Display. Exporting/Importing DB Tables in HR. HR ABAP Features.

1)

ABAP Programming v/s HR Programming

ABAP Programming v/s HR Programming


Storage and accessing of data. Use of the logical Database extensively. Use of Macros. Use of Info types to enter and store data. Use of Authorization Checks.

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

2) Logical Database PNP

Logical Structure and DB Tables in PA


Logical Structures Pnnnn: Key fields and Data fields. Psnnnn. Qnnnn : Special Screen fields. Database Tables PAnnnn : Data Records PA. PBnnnn: Data Records PB. PCLn: Data Clusters E.g. Time Management, Travel Management, Payroll.
9

Structure for screen fields


Fields for every Infotype (Header lines) are stored in RP50M. Additional Screen fields are stored in Qnnnn structure. An employees form of Address is stored in P0002-ANRED with a numeric key. Additional field Q0002-ANREX is provided to store the displayed and entered fields not its numeric key.

10

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.

11

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.

12

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. A distinction is made between a personnel and a data authorization.
13

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

Screening Criteria
Two types: Person Selection. Data Selection.

15

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

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.

17

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.

18

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.

19

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

20

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.

21

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.

22

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.

23

Processing the Infotype structures


Infotype structures are internal tables that are processed using a PROVIDEENDPROVIDE loop.

24

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. Opt 1: Selection fields of LDB forwarded directly to the database. Opt 2: Array fetch Active. Opt 3: A combination of opt1 and opt2.

25

Flow control for LDB

26

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.

27

3) Views Join and PROJECTION


28

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


29

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

JOIN
PROVIDE * FROM P0002 FROM P0006 FROM PNNNN BETWEEN PN/BEGDA & PN/ENDDA. ------------------------ENDPROVIDE.

31

JOIN
Each Infotype can be processed individually or several infotypes can be processed simultaneously. Join takes into account the validity period of the data.

32

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.

33

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.

34

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

JOIN
WRITE: / PERNR-PERNR, P0001-STELL, P0006-STRAS, P0006-BE GDA,P0006ENDDA. ENDPROVIDE.

36

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:
37

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.

38

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

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.

40

PROJECTION
REPORT ZTEST_HR. TABLES: PERNR. INFOTYPES: 0001, 0006. GET PERNR. PROVIDE STELL FROM P0001 BETWEEN PNPBEGDA AND PNPENDDA. ENDPROVIDE.

41

4) SPECIFIC COMMANDS

42

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.

43

Processing A Specific Infotype Record


To access only the first or last records. RP-PROVIDE-FROM-LAST PNNN SPACE BEGDA ENDDA. RP-PROVIDE-FROM-FIRST PNNN SPACE BEGDA ENDDA. Parameters: Info type, Sub type, Begin date and End date.
44

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.

45

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. SPACE = SY-SUBRC is set to 4.

46

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.

47

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

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.

49

Changing Infotypes
REPORT ZTEST_HR. TABLES: PERNR. INFOTYPES: nnnn NAME OLD nnnn NAME NEW. GET PERNR. PROVIDE * FROM OLD.. NEW = OLD.

50

Changing Infotypes
APPEND NEW. ENDPROVIDE. RP-UPDATE OLD NEW.

51

Reading IT without LDB


The Function Module HR_READ_INFOTYPE records for a person. Values are returned in an internal table. Function Module performs an authorization check. The Return codes have the following values: 0, 4, 8, 12.

52

Reading IT without LDB


REPORT ZTEST_HR6. INFOTYPES: 0002. CALL FUNCTION HR_READ_INFOTYPE EXPORTING PERNR = INFTY = BEGDA= ENDDA=
53

Reading IT without LDB


IMPORTING SUBRC = <RETURN> TABLES INFTY_TAB = P0002 EXCEPTIONS INFTY_NOT_FOUND = 1 OTHERS = 2.
54

5) Authorization Checks

55

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.

56

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.

57

Authorization for DATA


Checks if a person have all the authorizations required for all of the info types used in the evaluation. If the user has no authorization for a particular Info type, the evaluation is canceled and an error message displayed.

58

Deactivating the Authorization Check


In certain programs it may be useful to deactivate the authorization check in order to improve performance. For this reason HR Master data object is supplemented by the HR: Reporting authorization object. If the appropriate authorization are available , a simplified and therefore faster checks take place.
59

6) Time Data

60

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

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

62

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.

63

Time Data
To control this MODE N is assigned while declaring the time Infotypes.

RP_READ_ALL_TIME_ITY.

64

7) Repetitive Structure and List Display

65

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.

66

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.

67

List Display
Function Module HR_DISPLAY_BASIC_LIST. Used to display single-level lists. Maximum no. of column is 20.

68

8) Export/Import DB Tables in HR

69

Export/Import Tables in HR
Database Tables in HR. Pannnn (personnel data), PCL1(HR Work Areas), PCL2(Acctg Results & Payroll), PCL3(Applicant, Tracking Record)PCL4(Documents).

70

Data Clusters
Data Clusters have a two character code. Each HR subarea has its own cluster and its own key.

71

Database Table PCL1


B1(Time Events). G1(Group Incentive Wages). TX(Infotype Texts). PC(Personal Calendar).

72

Database Table PCL2


B2(Time accounting results). CD(Cluster Directory). RX(Payroll Accounting Results/International). Rn(Country Specific Payroll Accounting.

73

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

74

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

Import/Export with Macros


Rp-EXP-Cn-xy. And Rp-IMP-Cn-xy. These are the macros which are used for Exporting/Importing results from the PCLn tables.

76

9) HR ABAP Features

77

HR ABAP Features
Accessing Reports using Dynamic Action. Table T588Z is a control table that triggers steps taken when an IT record is maintained. Selection reports for fast entry. Reports that are used for fast entry are contained in table T588R.

78

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.

79

HR ABAP Features
Accessing Feature from Reports. PERFORM RE549D USING par1 par2 par3 par4. Par1 Feature name. Par2 Error handling type. Par3 Return value. Par4 The type of error. Eg: RPCPBSRC.
80

THANK YOU

You might also like