HR ABAP

Agenda
• • • • • • • • • • Overview and Features in HR programming Difference between Conventional ABAP Concepts of Infotypes Logical Databases in HR Macros in HR Clusters in HR Enhancement and creation of Infotype Reporting in HR User Exits and BAdIs Authorization Objects in HR

Overview and Features in HR Programming
• • The aim in the Human Resources component is to be able to process employee related data according to business requirements in an effective structure. The Human Resources module uses a system of data grouped together called infotypes. The Human Resources module uses a system of data grouped together called infotypes. And storing bulk data like time management and Payroll data in Cluster files. HR Programming involves data extraction and manipulation from these infotypes and clusters using LDB/MACRO and function modules. Infotypes mirror a quantity of connected data records; infotypes are identifiable through a four character numerical string [e.g. infotype Addresses (0006)] . You can save the infotypes as time-dependent to enable a retroactive evaluation of Employee data. The infotypes appear as an entry screen for the user, through which you can maintain infotype records. Infotypes can be processed individually or in fast entry mode.

• • •

Difference between Conventional ABAP
• Advanced Business Application Programming ABAP is SAP's fourth generation language. All of R/3's applications and even parts of its basic system are developed in ABAP. ABAP is used for customization and modification of SAP applications. In HR ABAP use of select statements significantly less than in other areas of ABAP development, Logical databases have limited applications in other modules but are very useful in HR. Also, you really need to understand the infotype time constraint concept since the data organization in HR is Employee-Time based, When you cannot get the information that you need out of the logical DB look at the function modules starting with HR* and RH*. These function modules will provide you with multiple ways of accessing data to save time. Worst-case scenario, use a select statement. In addition to the LDB, HR programming also involves the use of Macros for data extraction The storage an access of data is different Authorization checks

• • •

and allows time dependent storage. . Each infotype has a database table associated with it. 1. 3. Time constraint 2: No more than one valid data record of the infotype in question can exist at any one time. Time constraint 1: Exactly one valid data record of the infotype in question must exist for the entire time that the employee belongs to the enterprise. In other words we can say infotypes are information units used to enter the time dependent data of the employee. 2. Time constraint 3: Any number of valid data records of the infotype in question can exist at any one time. facilitates data entry. provide information structure. Time constraints: Enable you to determine how the validity periods of Infotype data records interact.Concepts of Infotypes An infotype represents a group of related data fields. Master data in HR is stored in infotypes .Each infotype pertains to a specific type of data.

One physical table is stored on the database for each transparent table. nnnn stands for the infotype number: PAnnnn for transparent tables in Personnel Administration PBnnnn for transparent tables in Recruitment HRPnnnn for transparent tables in Personnel Planning Example : For Infotype 0000.Concepts of Infotypes Transparent tables for infotype • • Each infotype has a transparent table. The names of the physical table and logical table definition in the Dictionary are compatible. The following naming convention applies to infotype tables. Each logical field for an infotype has a corresponding physical field on the database. the corresponding database table associated with it is PA0000 • • • • • .

CALL FUNCTION 'HR_INFOTYPE_DATABASETABLE_GET' EXPORTING INFTY = <INFTY> TCLAS = <TCLAS> “Transaction Class with values ‘A’ or ‘B’ or ‘T’ IMPORTING DBNAME = <DBTAB> EXCEPTIONS ENTRY_NOT_FOUND = 1 OTHERS = 2.It is better to use the Function module HR_INFOTYPE_DATABASETABLE_GET to get the Infotype table name for an infotype. You can also use the database table T777D to find the database table associated with an infotype. One such example is TEVEN table for IT 2011.Concepts of Infotypes Transparent tables for infotype It is not true always that a Personnel Administration/Recruitment/Personnel Planning etc has a transparent table like PAnnnn or PBnnnn or HRPnnnn. .

OBJPS: the object identification is used to make a distinction between records with the same infotype. subtype. Structure PAKEY: This is nothing but primary key of transparent table PAnnnn • PERNR: the personnel number is the only unique key within a client for identifying an employee. and end date. the child number in infotype 0021 Family/Related Person. It is used to access the display and maintenance screens for an employee’s master data and working time data (infotypes). start date. For example.Concepts of Infotypes Technical Data Structure of Info Types PA Infotypes The transparent table for PA Infotype is PAnnnn where nnnn is the infotype number. An infotype’s subtypes can have different time constraints and form their own histories. lock indicator. SUBTY: subtypes are subdivisions of infotypes. • • .

and the other user unlocks . BEGDA: start date. One of the users creates a locked infotype record. activates the data record.that is. SEQNR: The 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. ENDDA: end date. which enables the “double verification principle” to be put into practice. at least two users are involved in the process of writing an active data record to the database. In accordance with this principle. it is assigned by the system automatically Note: Structure PAKEY should never be changed • • • .Concepts of Infotypes • SPRPS: the lock indicator for HR master data is used to lock and unlock data records.

there is another basic structure that is identical for all infotypes in personnel administration – that is. the structure PSHD1.Concepts of Infotypes Structure PSHD1: In addition to structure PAKEY. Structure PSHD1 should never be changed .

. where PSHDR in turn contains the include structures PSKEY and PSHD1. Structure PSHDR should never be changed Structure Pnnnn: This structure contains the includes PSHDR and PS0002.Concepts of Infotypes Structure PSHDR: This is a meta structure and contains the structures PSHDR and PSKEY.

Concepts of Infotypes Element Definition Includes Can be changed by customer PAKEY PSHD1 PSHDR PSnnnn Structure Structure Structure Structure PSKEY PSHD1 No No No (field definitions) PS9nnn:Yes CI_Pnnnn PS0nnn-PS8nnn: No PSHDR PSnnnn P9nnn:Yes P0nnn-P8nnn:No Pnnnn Structure .

PA8nnn :No CI_nnnn Structure Yes .Concepts of Infotypes Element Definition Includes Can be changed by customer PAnnnn Transparent Table MANDT PAKEY PSHD1 PSnnnn - PA9nnn:Yes PA0nnn.

which is a maximum of two alphanumeric characters in length. SUBTY: Contains specification of sub type ISTAT: This field is one-digit numeric key in which the planning status is indicated.Concepts of Infotypes Technical Data Structure of Info Types Personnel Infotypes Structure: HRIKEY • • • • • • • • • • MANDT: This field contains the clients. 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. OTYPE: This field contains the object type key. . PLVAR: It is a two-character alphanumeric Key for the plan versions that enables us to differentiate between alternative plan versions. OBJID: This field contains an eight-digit key that represents a single object. There is a status for all objects and for the infotypes that describe them.

Concepts of Infotypes Structure HRIKEYL: The structure HRIKEYL is a variant of the structure HRIKEY. . This supports language-dependant infotypes.

Concepts of Infotypes Structure HRIADMIN: The structure HRIADMIN is a data structure contains administrative information on each infotype. .

the structure Pnnnn is also found in the infotypes of personnel planning. HRIADMIN and HRInnnn. HRADMIN and HRInnnn. Logical structure Pnnnn: Like the infotypes in Pa. as appropriate. It contains the includes HRIPKEY. Here nnnn stands for four-digit infotype number. Transparent Table HRPnnnn: The transparent table now contains the structures HRIKEY(key fields).Concepts of Infotypes Structure HRInnnn: The infotype-specific data fields for an infotype are defined in the structure HRInnnn. .

for example. be a course schedule with any number of days. This repetition part of the table part is described in the logical structure PTnnnn and stored in separate table HRTnnnn. The repetitive structures could be texts with any number of lines. In order to provide the option of saving repetitions of any length. the table infotype will be having the T777D-TBTAB field will be filled with HRTnnnn. or it could.Concepts of Infotypes Table Infotypes: Table infotypes are a special form of infotype used in personnel planning. Table infotypes are infotypes for which the data part has a repetitive structure of arbitary length. . While maintaining the entry in table T777D for infotypes. the data part must have repetitive structure and it must be saved in a separate data table.

the key structure of the external object type must be an eight-digit numeric string type NUMC of length 8). External Object types are limited in this respect. this means that data records on the relationship are only held in HRP1001. relationships can exist in two directions. Technically. It must be therefore be defined with the same type as the field object ID (HRPnnnnOBJID). Whether external object types have only one relationship – or if inverse relationships are also possible – is established for each object type in the table T77EO. top-down (B) and bottom-up (A). . External Object types are only referenced in the context of a relationship record. In order to create an inverse relationship for an external object type.Concepts of Infotypes External Object Types: External Object types refer to those object types that are not stored in the data structure of personnel planning. From a technical point of view there is no record in HRP1000 for external objects. For internal object types. This results in the creation of two records in IT 1001. relationships.

Concepts of Infotypes
External Infotypes:
Infotypes that are needed for planning purposes in personnel planning, but are not stored in transparent infotype tables of the type HRPnnnn are referred to as external infotypes. This information can be physically available, for example, in the tables of personnel administration. An identifier for an external infotype appears in table T777D in the field EXT_INFTY.

Concepts of Infotypes
Element Definition Includes Can be changed by customer

HRIKEY HRIKEYL HRIADMIN HRInnnn

Structure Structure Structure Structure

-

No No No

(field definitions) HRI9nnn:Yes CI_Pnnnn HRI0nnnHRI8nnn: No HRIPKEY HRIADMIN HRInnnn P9nnn:Yes P0nnn-P8nnn:No

Pnnnn

Structure

Concepts of Infotypes
Element Definition Includes Can be changed by customer

HRPnnnn

Transparent Table

HRIKEY or HRIKEYL and HRIADMIN -

HRP9nnn:Yes HRP0nnnHRP8nnn: No PT9nnn:Yes PT0nnn-PT8nnn: No HRT9nnn:Yes HRT0nnnHRT8nnn : No Yes

PTnnnn

Structure

HRTnnnn

Transparent Table Structure

PTnnnn

CI_nnnn

-

Logical Databases in HR
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 main objects of a LDB are Structure, Selection and Database Program. An LDB has another advantage for the option of central authorization checking. Logical Databases used In HR: 1. PAP 2. PNP 3. PNPCE - Enhanced version of PNP available form SAP Enterprise version onwards 4. PCH 5. PTRVP 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.

the first two letters stand for the application. • If you want to use these macros in reports that do not use the logical database PNP. RP-PROVIDE-FROM-FRST which is available in table TRMAC • . Macro modules are frequently used in HR. macro modules can be used to modularize programs. They can be used in any program that uses the logical database PNP. • Some macros are also stored in the Macros in ABAP Programs table (TRMAC) Example of Macros are 1. • These macros are defined in program SAPDBPNP (include DBPNPMAC) with the keyword DEFINE. RP_PROVIDE_FROM_LAST which is available in the include DBPNPMAC 2. • You can also define your own macros. you must include program DBPNPMAC with the keyword INCLUDE. In accordance with the naming convention.Macros in HR Like subroutines and function modules.

If you do not want to specify a particular subtype. If no entry is found. The macro return code PNP-SW-FOUND has the value 1 if a suitable entry exists in the infotype table for the specified period. enter SPACE. The parameters for RP_PROVIDE_FROM_LAST are: infotype. • • . start date.Macros in HR • • The RP_PROVIDE_FROM_LAST macro retrieves the last valid data record in the data selection period. but also the first valid data record using the RP_PROVIDE_FROM_FRST macro. and end date. subtype. You can process not only the last valid data record in the data selection period. the value is 0.

Clusters in HR D a ta b a s e T a b le s P C L n PCLn A1 A2 A3  S A P A G 1999 .

The PCLn database tables are a type of import/export database table. . Data clusters can be identified by their twocharacter IDs. The respective subareas within Human Resources work on their own cluster.Clusters in HR • • • • • Database tables of type PCLn are divided into subareas known as data clusters. A separate data key is defined for each subarea.

Clusters in HR .

B1 2.Clusters in HR Cluster table PCL1: PCL1 contains the following data areas B1 Time events/PDC G1 Group incentive wages L1 Individual incentive wages PC Personal calendar TE Trip costs/accounting results TC Trip costs/credit card data TX Infotype texts Z1 Interface PDC -> cost accounting/materials management This table is maily used for retrieving data from the following data areas: 1. TX .

ZL Personal work schedule .Clusters in HR Cluster table PCL2: PCL2 contains the following data areas: B2 Time accounting results CUCluster directory PS Generated schema PT Texts for generated schemas RX Payroll results/international Xy Payroll results/country-specific. This is from RELID field of table T500L for the country. whereby xy represents the relation ID.

The PCLn import/export database tables are managed by the ABAP commands IMPORT and EXPORT.on the database.Clusters in HR DB Table Adm inistration/ PCLn PCLn IM PORT A1 A2 EXPORT TABLES: PCLn. Data is read and written using a unique key. . structures or internal tables . or to read them from the database. 2. 3.such as fields. We can use these commands to store any data object . 1.

. .Clusters in HR T a b le S tru c tu re / P C L n F ie ld n a m e K E Y C L IE N T R E L ID SRTFD SRTF2 X X X X L e n g th 3 2 40 10 Text C lie n t R e la tio n ID W o rk a re a k e y S o rt fie ld fo r d u p lic a te k e y E x a m p le o f in te rn a tio n a l p a yro ll re s u lts : R E L ID S R T F D RX 00001911 00001 RX 00001911 00002 RX 00001911 00003 ..

The fields CLIENT and SRTF2 are filled by the system. A key structure must also be defined. 40 bytes are available in field SRTFD for this purpose. the RELID field must contain the cluster identifier and the SRTFD field must contain the cluster key. . In the international payroll results. The name of each subarea must include a two-character cluster name or relation ID. the field RELID contains the cluster name RX and the field SRTFD contains the eight-digit personnel number as well as a five-digit sequence number for each individual payroll result for a payroll period. To enable the import of a record from a PCLn database table.Clusters in HR The structure of PCLn database tables provides a basic structure for individual subareas. for example.

enable us to delete one or more records from any cluster. 3. 1.Clusters in HR U tilitie s /D e le tin g a C lu s te r U T IL IT Y PCLn PCLn Utility transaction PU00 enables us to delete payroll results in xy clusters for specific personnel numbers. Caution: The deletion utilities should only be used for testing.where n stands for database table PCL1 or PCL2 . . Utility programs RPUPnD00 and RPUPnD10 . Archiving takes place to reduce the amount of data in the database. 2. We can delete payroll results using the program RPUDEL20.

Enhancement and Creation of Infotypes Enhancement of Infotypes .

Start the transaction Enhance Infotype. Enhancement of PA Infotypes In PA we can enhance the Single screen as well as list screen. Enhancing the single screen • Procedure 1. (transaction code PM01). Before Enhancing any infotype. 2. Choose Enhance Infotype Tab . The Create Infotype screen appears. CI_ Include must be available.Enhancement and Creation of Infotypes Infotype needs to be enhanced sometimes to add our own fields to the existing infotype fields.

In the Infotype Number field. Note: It is not possible to enhance a single screen for the Actions infotype (0000).Enhancement and Creation of Infotypes 3. . remember to enter any leading zeros. enter the four-digit number of the infotype you want to enhance When you enter the infotype number. or the Time Management infotypes.

Choose the button ‘Create All’ The following screen appears: 5. In this case Train Route .Enhancement and Creation of Infotypes 4. Press Enter. Then create the fields required on the screen.

7. The following screen appears. .Enhancement and Creation of Infotypes 6. Now if we go to Infotype 0006 of any employee we can see the field added.

The single screen of an Infotype will be 2000 and the list screen will be 3000. We have to modify the screen number 0200 for adjusting the screen elements and appearance of the enhanced screen.Enhancement and Creation of Infotypes Note: While enhancing the single screen of an infotype a module pool program ZPnnnn00 will be created and that can be modified by ourselves. Here nnnn denotes 4-digit infotype number. It will be RP_nnnn for PA infotypes. For every infotype there is a dialog module associated with it. . The module pool program of a PA Infotype will be MPnnnn00.

Choose Enhance List screen Tab 3. Start the transaction Enhance Infotype. enter the four-digit number of the infotype you want to enhance the list screen. In the Infotype Number field.Enhancement and Creation of Infotypes Enhancing the single screen • Procedure 1. 2. (transaction code PM01). . The Create Infotype screen appears.

In this example Train Route . Choose the button ‘Create All’ The following screen appears: 5.Enhancement and Creation of Infotypes 4. Press Enter. Then create the fields required on the screen.

Enhancement and Creation of Infotypes 6. The following screen appears. . Now if we go to Infotype 0006 overview screen of any employee we can see the field added . 6.

.Enhancement and Creation of Infotypes Note: While enhancing the list screen of an infotype a module pool program ZPnnnn00 will be created (if it is not available already) with an include ZPnnnn40. We cannot modify the screen appearance of the added field since it will be directly added to the list screen 3000 of the module pool MPnnnn00.

Enhancement and Creation of Infotypes Enhancement of Personnel Infotypes Use the transaction PPCI to enhance Personnel Infotypes. Enter the 4 digit infotype number. Enhancing the single screen • Procedure 1. Start the transaction Enhance Infotype. (transaction code PPCI). . Click on extend button. The following screen appears.

. The following screen appears. Enter the fields and activate the include CI_Pnnnn and the fields entered will appear in the infotype. Click on ‘Create All’ Button. 3.Enhancement and Creation of Infotypes 2.

Select the menu Infotype Enhance list screen. Enter the 4 digit infotype number.Enhancement and Creation of Infotypes Enhancing the list screen • Procedure 1. . (transaction code PPCI). Start the transaction Enhance Infotype. The following screen appears.

Enter the fields and activate the structure ZPLISnnnn and these fields entered will appear in the infotype's overview screen.Enhancement and Creation of Infotypes 2. The following screen appears. Click on ‘Create All’ Button. 3. .

Enhancement and Creation of Infotypes Creation of Infotypes .

2. Enter the four digit Infotype number ( starting from 9000-9999). (transaction code PM01).Enhancement and Creation of Infotypes Infotype needs to be created when you cannot store the required information in any of the standard infotypes. Start the transaction Enhance Infotype. Then click on the ‘Create All’ button. . The Create Infotype screen appears. 3. Creation of PA Infotypes 1.

Press Enter. Activate the structure PSnnnn and the required infotype details are created.Enhancement and Creation of Infotypes 3. . 4. The following popup appears. The new screen for entering the required infotype field appears.

For that from the PM01 transaction select the button ‘Infotype Characteristics’. The characteristics can also be maintained through IMG or by using the customizing view V_T582A. Then our major duty is to maintain the infotype characteristics.Enhancement and Creation of Infotypes 5. New Infotype . Copy the entry from existing infotype to the newly created one and change the characteristics of our infotype accordingly.

Enhancement and Creation of Infotypes Details of customization .

Enhancement and Creation of Infotypes If you goto PA30 transaction for Infotype 9nnn you can find the infotype fields entered. .

Enhancement and Creation of Infotypes Creation of Personnel Infotypes Field Infotypes For Field infotypes we have to create the structure HRI9nnn though the transaction SE11 before we are creating the infotype. Table Infotypes For Table infotypes we have to create the structure HRI9nnn and PT9nnn though the transaction SE11 before we are creating the infotype. Other than these the creation of both types of Infotype remain the same. .

Enhancement and Creation of Infotypes Let us see the procedure of creating a table Infotype. Goto SE11 transaction and create the structures HRI9700 and PT9700 . 9700.

Also enter the description of the Infotype. The Create Infotype screen appears. In our example it is 9700). Enter the four digit Infotype number ( starting from 9000-9999. 3. (transaction code PPCI). 2.Enhancement and Creation of Infotypes 1. . Start the transaction Enhance Infotype. Then click on the ‘Create’ button. The following screen appears.

Finally an information message appears as follows: . Select the radio button ‘Table infotype and click on the ‘Create’ Button.Enhancement and Creation of Infotypes 4. 5. The following popup appears. Select ‘Yes’.

. Do it through IMG or by using the customizing table T777I.Enhancement and Creation of Infotypes 6. Then our major duty is to maintain the infotype characteristics. What we have to add is the Time constraint and Infotypes per object type.

Enhancement and Creation of Infotypes I have added this to Object type O and with time constraint 2. Similarly I can add the infotypes per object type as follows .

I can see the infotype.Enhancement and Creation of Infotypes Finally If I goto PP01 transaction for the maintenance of Organization Unit. .

Enhancement and Creation of Infotypes .

… MODE N 4.nnnn between 3000 and 8999: Not yet used .nnnn between 2000 and 2999: HR time data info types .Reporting in HR Special ABAP Statements for HR 1.nnnn between 0000 and 0999: HR master data info types . 1. … OCCURS n 3.nnnn between 1000 and 1999: HR planning data info types . 3.nnnn between 9000 and 9999: Customer-specific info types There are some variants for INFOTYPES statement 1. INFOTYPES PROVIDE ENDPROVIDE INFOTYPES The syntax for this statement is: INFOTYPES nnnn. 2. . … NAME c 2. … VALID FROM comp1 TO comp2 .

. DATA END OF c VALID BETWEEN BEGDA AND ENDDA. (eg) INFOTYPES 0006 NAME ADDRESS. DATA END OF Pnnnn VALID BETWEEN BEGDA AND ENDDA. (eg) INFOTYPES 0001. Variant 1: … NAME c .Reporting in HR The effect of ‘INFOTYPES’ statement is that it will create an internal table Pnnnn as follows: DATA BEGIN OF Pnnnn OCCURS 10. c 20 character field This will create an internal table with the name c DATA BEGIN OF c OCCURS 10. INCLUDE STRUCTURE Pnnnn. INCLUDE STRUCTURE Pnnnn.

(eg) INFOTYPES 0005 OCCURS 2. (eg) INFOTYPES 2001 MODE N. The effect of the INFOTYPES statement is then the same as the data declaration of an internal table (as described above). Variant 3: …MODE N Applies only to the HR logical databases PNP. INCLUDE STRUCTURE Pnnnn. n numeric value This will create an internal table as follows: DATA BEGIN OF Pnnnn OCCURS n. Generally used for Time Infotypes. .Reporting in HR Variant 2: … OCCURS n. The info type tables are not filled by GET PERNR (logical database PNP) or GET OBJEC (logical database PCH). DATA END OF Pnnnn VALID BETWEEN BEGDA AND ENDDA. PNPCE and PCH.

(eg) INFOTYPES 0007 VALID FROM 19910101 TO 19911231. .Reporting in HR Variant 4: … VALID FROM comp1 TO comp2 This should be used only with LDBs PNP and PNPCE GET PERNR retrieves only those info type records which are valid within the time range ( comp1 and comp2) specified. comp1 and comp2 are dates with the format YYYYMMDD.

PROVIDE The syntax for this statement is: PROVIDE f1 f2 … FROM itab1 g1 g2 … FROM itab2 … BETWEEN f AND g. This statement will retrieve the contents of the specified fields from the internal tables ( itab1. itab2.itab1.) and places them in the table header lines within the required range... . .We can use * instead of individual field names . .Reporting in HR 2. itab2 etc will be of structure Pnnnn . Also executes the processing block enclosed by the PROVIDE and ENDPROVIDE statements for each range.f and g are from and to dates.

ENDPROVIDE The syntax for this statement is: ENDPROVIDE. .Reporting in HR 3. .This statement will close the loop introduced by PROVIDE.

0002. Fill the data structures with the infotype records GET PERNR. "Organizational Assignment" "Personal Data" "Planned Working Time" 2.  SAP AG 1999 . Create data structures for infotypes INFOTYPES: 0001.Reporting in HR Data Retrieval 1. 0007.

The PERNR structure is fílled with the data from the above infotypes. You can access the data in this structure for processing. They consist of the personnel number. • . the data structures of declared infotypes are filled with all of the records that exist for a personnel number. the fields of infotypes 0000 and 0001. When the GET event occurs. and a number of additional fields.Reporting in HR • Structure PERNR contains standard selections for HR master data reporting.

...  SAP AG 1999 . WRITE. 0006. INFOTYPES: 0001.Reporting in HR Processing M aster Data TABLES: PERNR. PROVIDE * FROM P0002 BETWEEN PN-BEGDA AND PN-ENDDA... ENDPROVIDE. 0002.. "Actions "Personal Data "Addresses GET PERNR.

For example. PNBEGDA contains the first day of the year and PN-ENDDA contains the last day of the year. If you do not enter any data for the period in the selection screen. the contents of fields Pnnnn-BEGDA and Pnnnn-ENDDA are also reset in the header of the infotype table Pnnnn. The infotype records are imported to internal tables Pnnnn (for example. Pnnnn-ENDDA is given the value from PN-ENDDA. These tables are then processed in a PROVIDEENDPROVIDE loop. • • . The infotype records whose validity period overlaps the period selected in the selection screen (PN-BEGDA and PN-ENDDA) by at least one day are placed one after the other in the header of the respective infotype table Pnnnn. if you choose the current year in the selection screen. if the date in PnnnnENDDA is after the date in PN-ENDDA.Reporting in HR • • • Filled infotype structures are stored in the main memory for the GET PERNR event keyword. P0006 for infotype 0006). PN-BEGDA contains the low date (01/01/1800) amd PNENDDA contains the high date (31/12/9999). For example. Note: If you have entered period date in the selection screen.

. or: LOOP AT P0002 WHERE ENDDA GE PN-BEGDA AND BEGDA LE PN-ENDDA.. ENDPROVIDE. WRITE.  SAP AG 1999 Infotype loop Infotype loop Employee loop Infotype loop .. ENDPROVIDE.. WRITE. PROVIDE * FROM P0006 BETWEEN PN-BEGDA AND PN-ENDDA WHERE P0006-SUBTY = '1'.. END-OF-SELECTION.. ENDLOOP. PROVIDE * FROM P0002 BETWEEN PN-BEGDA AND PN-ENDDA.Reporting in HR Loop Nesting GET PERNR. WRITE.

• • • . END-OF-SELECTION. for the processing of all infotype records for the selected personnel number. you should note that the data for the Personal Data (0002) and Address (0006) infotypes is listed sequentially and is not linked. With this form of processing. It is concluded implicitly by the next event. You can also process the infotype tables with a LOOPENDLOOP.Reporting in HR • • HR data is processed in two nested loops: A GET PERNR loop for all of the personnel numbers selected. for example. Subordinate loops per infotype.

AUGUST Ms Y SEPTEM BER . .A P R IL M AY . each record has a start date and an end date. For this reason. in other words.DECEM BER  S A P A G 1999 Infotype data is period-based.Reporting in HR P e r io d -B a s e d D a ta (1 ) J A N U A R Y . The decision on how to retrieve data is made for each individual infotype. it is only valid for specific periods. This example shows the jobs that an employee has performed over the course of a year.

Reporting in HR REPORTS IN PERSONNEL ADMINISTRATION .

PERNR WERKS BTRTL PERSG PERSK ABKRS LGART BETRG ANZHL MOLGA BEGDA ENDDA MOABW Personnel Number Personnel Area Personnel Subarea Employee Group Employee Subgroup Payroll Area Wage Type Amount Number Country code Start Date End Date Personnel subarea grouping for absence and attendance types . 5. 10. 13. 9. 3. 2. 12. 8. 6. 11. 7. 4.Reporting in HR Some important fields 1.

Selection screen INITIALIZATION. INFOTYPES: 0002. .Reporting in HR Report which is based on reading data from infotypes and using LDBs REPORT zpsol010. pnptimed = 'D'.Declaration TABLES: pernr. *-. "Personal Data SELECT-OPTIONS: language FOR p0002-sprsl. *-.

p0002-sprsl. CHECK language. .Processing GET pernr. p0002-gbdat. PROVIDE * FROM p0002 BETWEEN pn-begda AND pn-endda. ENDPROVIDE. sy-vline. sy-vline.Reporting in HR *-. WRITE: / p0002-pernr. pernr-ename. sy-vline.

DO 20 TIMES VARYING s_wagetypes FROM p0008-lga01 NEXT p0008-lga02. ELSE. . unit TYPE p0008-ein01. EXIT. ENDDO. amount TYPE p0008-bet01. *** you have to declare a structure same as repetitive structure in the ** 0008 infotype DATA: BEGIN OF s_wagetypes. ENDIF. wagetype TYPE p0008-lga01. hours TYPE p0008-anz01. s_wagetypes-amount. INFOTYPES 0008. TABLES pernr.Reporting in HR Example for understanding the repetitive structure Say. ind TYPE p0008-opk01. END OF s_wagetypes. GET pernr. for an employee you want to know that for what all wage type an employee is eligible for the latest period you mentioned on the selection screen. WRITE: / s_wagetypes-wagetype. IF s_wagetypes-wagetype IS INITIAL. REPORT ZRP_REPETITIVE_STR NO STANDARD PAGE HEADING.

Reporting in HR Importance of Dates and Periods • • Here is a simple ABAP example of reading DATE types stored in infotype 0041. There can be a maximum of 12 dates stored in this infotype. Here is an example of an infotype 0041 record: .

Reporting in HR The date types are stored in PA0041-DAR01. . e.g. PA0041-DAR01 is “01”. PA0041-DAR02. PA0041DAT02. PA0041-DAR02 is “09”. Here is a simple demonstration ABAP: Note: to print the text of the date type. the easiest way is to use the DO VARYING statement. etc To read through this in ABAP. etc. “Leave year entry” select from table T548T. In the example above. The dates themselves are stored in PA0041-DAT01.

DAT LIKE P0041-DAT01. . WRITE: /. WRITE: PERNR-PERNR. GET PERNR. END OF MYDATES. *** Processing of repetitive structures ************* DO 12 TIMES VARYING mydates FROM p0041-dar01 NEXT p0041-dar02.MYDATES-DAR. INFOTYPES 0041. TABLES: PERNR. "show employee number and name RP-PROVIDE-FROM-LAST P0041 SPACE PN-BEGDA PN-ENDDA. DAR LIKE P0041-DAR01. PERNR-ENAME. IF PNP-SW-FOUND = 1. MYDATES-DAT. ENDDO.Reporting in HR REPORT ZDATES1 . ENDIF. DATA: BEGIN OF MYDATES. ENDIF. IF mydates-dar NE space.

EN D.OF -D EF IN IT IO N.  S A P A G 1999 . 0 006... . . I NFOTYP ES: 0 001. PN P. "Or ganiza tional Assig nment "Per sonal Data "Ad dresse s G ET PER NR. . * * * In cl ud e pr og ra m DB PN PM AC . 0 002.SW -F O U ND = ' 0' .. . DE FI NE R P_ PR OV ID E_ FR OM _L AS T.Reporting in HR M acro M o d u les T ABLES: PERNR . . R P_PROV IDE_FR OM_LA ST P00 01 SPA CE PN.BEGDA PN-EN DDA. . W RITE.

. S u b a re a 00 0 1 G ro u p in g s . INFOTYPES: 0001. RP-READ-T001P P0001-WERKS P0001-BTRTL SPACE.....Reporting in HR R e ad in g th e G ro u p T a b le U sin g th e P e rso n n e l A rea/S u b a re a F ie ld s TABLES: PERNR. CABB . . 01 01 GET PERNR.  S A P A G 1 99 9 . P e rs o n n e l Are a /S u b a re a T a b le P e rs Are a . T001P.... RP_PROVIDE_FROM_LAST P0001 SPACE PN-BEGDA PN-ENDDA. .

if you only want to determine the country indicator. This must take place individually for each personnel number to be processed. Alternatively.’ SPACE = SY-SUBRC is set to 4. • • • • • • • • .. Each employee's assignment to a personnel area and subarea is stored in infotype 0001.Reporting in HR • It is often necessary to read the groupings stored in the Personnel Area/Subarea table because they are required as keys for other tables. The parameters of the macro are: Personnel areas Personnel subareas Reaction. you can use the function module HR_COUNTRY_GROUPING_GET.. if no entry is found: X = Termination of report with error message ‘No entry found in table .

. However.  SA P AG 1999 You can also read infotype records for a particular personnel number without using the logical database. To do this. you must ensure that the internal table for the required infotype is declared with the INFOTYPE statement.. A H FOTYPES: <nnnn>. . use the function module HR_READ_INFOTYPE. . C ' N . LL FUNCTION R_READ_INFOTYPE'.Reporting in HR R e a d in g In fo t y p e s W ith o u t L o g ic a l D B (1 ) P Annnn I .

. 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 .  SAP AG 1999 .Reporting in HR Reading Infotypes Without Logical DB (2) INFOTYPES: 0002. . DATA: return LIKE SY-SUBRC.

you can call the subroutine READ-INFOTYPE directly in the database program SAPDBPNP (PERFORM READINFOTYPE(SAPDBPNP)). such tables can be declared with the INFOTYPES statement. Values are returned in an internal table. If you want to read an infotype separately in one of these reports. If this is the case. • • • . An infotype record is selected if its validity period overlaps with the specified period. however. The function module performs an authorization check. . . the structure of which corresponds to the appropriate infotype table.). In the calling program. The following specifications are possible for the return code: 0: The return table contains all required records 4: The return table contains all records.Reporting in HR • The function module reads the HR infotype records for a person (employee or applicant) in accordance with the specified selection criteria. it is incomplete due to missing authorization 8: The return table is empty because no records were found with the specified criteria 12: The return table is empty due to missing authorization Note: You should not use this function module in reports that use the logical database PNP. for example. you declare the infotypes in the statement INFOTYPES with supplement MODE N.

DATA: hire_date LIKE P0016-EINDT.  SAP AG 1999 .Reporting in HR Determining the Entry Date INFOTYPES: 0001. CALL FUNCTION 'RP_GET_HIRE_DATE' EXPORTING PERSNR = P0001-PERNR CHECK_INFOTYPES = '0000' * DATUMSART = '01' * STATUS2 = '3' * P0016_OPTIONEN = ' ' IMPORTING HIREDATE = hire_date EXCEPTIONS OTHERS = 1.

Most function modules in HR have the letters 'HR' or 'RP' in the first two characters of their name. the corresponding date type can be given in the transfer parameter DATUMSART.P0016 Contract Elements . You can take the following infotypes into account when you determine this date: . For infotype P0041. The date type '01' is usually used for the technical entry date. you can determine the initial start date of an employee. only the Entry data field (P0016-EINDT) is taken into account.P0041 Date Specifications The transfer parameter CHECK_INFOTYPES is used to determine which of these infotypes are taken into account. The employment status (parameter STATUS2) can also be specified for infotype P0000. To find additional modules. • • .P0001 Organizational Assignment . In infotype P0016.P0000 Actions . use the search function in the Function Builder.Reporting in HR • With this function module.

. .  SAP AG 1999 . . . ENDIF. . WRITE: / return_struc-TYPE. CALL FUNCTION 'BAPI_EMPLOYEE_DEQUEUE' EXPORTING NUMBER = PERNR-PERNR IMPORTING RETURN = return_struc. * Update Infotype Records . CALL FUNCTION 'BAPI_EMPLOYEE_ENQUEUE' EXPORTING NUMBER = PERNR-PERNR IMPORTING RETURN = return_struc. .. ..Reporting in HR Updating Infotype Records (1) DATA: return_struc TYPE BAPIRETURN1.. . IF NOT return_struc IS INITIAL.

If an error occurs.Reporting in HR • Before you change employee data.Message text (field MESSAGE). access is denied. the structure is blank. You can do this with the function module BAPI_EMPLOYEE_DEQUEUE. You can do this with the function module BAPI_EMPLOYEE_ENQUEUE.If the step is successful. For this reason. this structure contains the following information:. Messages are returned in the parameter RETURN. only the user who has locked the data can access the data records linked to the employee. you must lock the personnel number. • • . For other users. you must remove the lock after the data has been changed. If an employee's data has been locked.Message type (field TYPE).

. record_key TYPE bapipakey. GET PERNR. LOOP AT P0002 WHERE.Reporting in HR Updating Infotype Records (2) DATA: return_struc TYPE bapireturn1. . ENDLOOP. CALL FUNCTION 'HR_INFOTYPE_OPERATION' EXPORTING INFTY = '0002' NUMBER = P0002-PERNR LOCKINDICATOR = P0002-SPRPS VALIDITYEND = P0002-ENDDA VALIDITYBEGIN = P0002-BEGDA RECORDNUMBER = P0002-SEQNR RECORD = P0002 OPERATION = 'MOD' DIALOG_MODE = '1' IMPORTING RETURN = return-struc KEY = record_key. .  SAP A G 1999 . . .

the system switches to dialog mode so that the user can correct the entries. the complete step is terminated and the module returns the corresponding error message in the structure 'RETURN'.Reporting in HR • With this function module. This means that some restrictions apply to the infotypes processed in that way (see documentation for module). INS (insert). The module returns the same error messages as in the online operation. '1' The changes are generally processed in the background. Possible values:'0' The changes are generally processed in the background. This means the error messages for the individual maintenance screens are displayed rather than interpreted. With the parameter DIALOG_MODE. LIS9 (delimit). '2' The changes are processed in the dialog mode. DEL (delete). You can specify one data record. If an error occurs (with an E or A message). If an error occurs. The update is carried out by a 'Call dialog' to the module pool for the infotype. All validations that would normally take place if the infotypes were maintained online with the individual maintenance screens are also carried out here. • • . you specify whether the action is generally run in the background or whether it only runs in the background until an error occurs. The following values are amongst those available for the parameter OPERATION: MOD (change). you can maintain the employee and applicant master data. or whether the changes are generally carried out in the dialog mode. COPY (copy).

SY-DBCNT. IF SY-SUBRC = 0. ENDIF. natio_n LIKE P0002-NATIO DEFAULT 'D'. * Update infotype records UPDATE PA0002 SET NATIO WHERE PERNR AND NATIO = natio_n = P0002-PERNR = natio_o.  S A P A G 1999 . WRITE: 'Modified records'.Reporting in HR U p d atin g In fo typ e R eco rd s (3 ) PARAMETERS: natio_o LIKE P0002-NATIO DEFAULT 'DE'.

0015 etc are stored for indirect valuation (ie the wagetype has to be valuated indirectly). The entries will not be stored in the infotype tables. We have to use any of the function modules for indirect valuation to read the data.Reporting in HR Indirect Valuation: Some times entries in Infotype 0008. 0014. (Eg) HR_INDVAL_READ_INFOTYPE .

in which a subtype is queried. If infotypes linked by a JOIN have subtypes.Reporting in HR Join and Projections Joins: • • • • Any number of infotypes can be linked by a JOIN. processing must be restricted to one subtype using a WHERE condition. . Note that changing data in any one of the infotypes linked by a join causes a split in the selection period. Joins are only possible for infotypes with time constraint 1 or 2.

. this variable is created for each Pnnnn infotype included in a join.. .. INFOTYPES: 0001. PROVIDE "Organizational "Personal Data "Addresses Assignment FROM P0002 FROM P0006 BETWEEN PN-BEGDA WHERE P0006-SUBTY = '1'. ENDIF. ENDPROVIDE. the system recognizes that one partial interval only contains incomplete data. 0006. * * AND PN-ENDDA  SAP A G 1999 Using variable Pnnnn_VALID. When the report is run. 0002. its Pnnnn_VALID variable is filled with X. GET PERNR.Reporting in HR J o in / S u b t y p e s TABLES: PERNR. If a partial interval for infotype Pnnnn contains data.. IF P0006_VALID = 'X'. WRITE. ..

The values stored in fields that are not included in the projection are in an undefined condition. which means they are no longer relevant to output. New validity periods are created when the contents of one of the projection fields change. are relevant to an evaluation. Using projection for specific fields enables you to specify that only the contents of these fields and time-based changes to the contents. JOIN and PROJECTION can be combined in a PROVIDE statement. If the contents of a field included in the projection remain unchanged in several data records. the validity periods of these data records are combined. The process of combining data records during projection is called contraction. Projection is also an operation performed on the time axis. Like joins. projections are logical data views concentrated on one or more fields within an infotype. • • • .Reporting in HR Projections: • • • • Selecting one or more infotype fields for processing is called PROJECTION.

INFOTYPES: 0001. 0002...Reporting in HR Jo in an d P ro jectio n / C o d in g TABLES: PERNR.  S A P A G 1999 . ENDPROVIDE. .. "Organizational Assignment "Personal Data GET PERNR... PROVIDE STELL ENAME FROM P0001 GBDAT FROM P0002 BETWEEN PN-BEGDA AND PN-ENDDA. WRITE.

"Return fields for dyn. . Field FC No S Variable function part 0008___ 0008___ 0008___ 0008___ 0008___ SPRPS SPRPS SPRPS SPRPS SPRPS 06 06 06 06 06 0 1 2 3 4 _ P F I W *----------. actions PRELP. TABLES: RP50D.  SA P AG 1999 .10 P0019-VTRMN=RP50D-DAT E1 REPORT zpform01. RP50D-DATE1 = PRELP-BEGDA -14. ENDFORM.0019.Reporting in HR Calling R eports U sing D ynam ic Actions Table of D ynam ic Actions IType STy. * Calculate date FORM compute_date.Lock indicator set?----------------* P0008-SPRPS<>SPACE COMPUT E_DATE(ZPFORM01) INS. "HR Master Data Buffer .

A stands for an action performed by the system. In an external routine. the name of the program is given in parentheses after the name of the routine. The values can be added. 04 for Insert. P = Check a condition. Such steps include maintaining another infotype record. W = Set default values when inserting a record. You cannot enter the USING parameter. The fields of the structure that is not used in the standard system (RP50D) are available to return the values from the routine. In this example. I = Maintain an infotype record. • . performing a routine. You can call internal (defined in the module pool) and external routines. and 08 for Delete a record. for example. F = Call a routine.Reporting in HR • • • • The 'Dynamic Actions' table (T588Z) is a control table that triggers steps taken when an infotype record is maintained. They can be filled by the routine and then used for default values (W statements). 06 means that an action is performed if the current record has been changed or inserted. or sending a mail. the routine COMPUTE_DATE calculates a date in the subroutine pool ZPFORM01 and places it in field RP50D-DATE1. This date is calculated by subtracting 14 days from the start date of the locked record. OP stands for a user operation where 02 stands for Change. This structure can be enhanced with customer fields in a customer include. for example.

. * Call feature CALL FUNCTION 'HR_FEATURE_BACKFIELD' EXPORTING FEATURE = 'ABKRS' STRUC_CONTENT = PME04 IMPORTING BACK = ret_value EXCEPTIONS ERROR_OPERATION = 2 NO_BACKVALUE = 3 FEATURE_NOT_GENERATED = 4.  SAP AG 1999 .Reporting in HR Calling Features from Reports TABLES: PME04. . . "Field string for feature ABKRS DATA: ret_value(2). "Return value for feature * Fill decision fields for feature with values. PME04-PERSK = P0001-PERSK.

In your program. use the function module HR_FEATURE_BACKTABLE. The field string PMEnn must be declared in the data declaration part of your program using a TABLES statement. Possible errors when processing the decision tree: a) An error occurred in the feature (ERROR_OPERATION) b) No return value is available for the current contents of the decision field (NO_BACKVALUE) c) The feature was no generated (FEATURE_NOT_GENERATED) If the return value for a feature consists of a table. enter values in the decision fields used in your feature. view the structure and decision tree in feature maintenance (transaction PE03). To identify which fields in the field string for the feature (PMEnn) are used for the decisions in the feature.Reporting in HR • • • • • • This function module reads the decision tree for a feature with the accompanying field contents and determines the return values for the field contents. The return value for the feature is transferred to the main program with the BACK parameter. • . Define a field to contain the return value of the feature. Call the function module and enter the name of the feature to be used and the name of the field string.

15 days  S A P A G 1999 Note: Don’t use PROVIDE statement for Time Infotypes ..Reporting in HR T im e D a ta a n d V a lid it y P e r io d D a t a s e le c t io n p e r io d Leave 15 days PROVIDE. ENDPROVIDE.. WRITE...

2002. the quantity of infotype records soon overloads the main memory. if positive recording has been implemented. Remuneration Info GET PERNR. 2005. "Absences "Attendances "Overtime "Employee P A nnnn  S A P A G 1999 A principle of the logical database is that all of the infotype records between the lowest and highest system date are read. irrespective of the data selection period.Reporting in HR Im p o r t in g T im e D a ta (1 ) D a ta s e le c tio n p e r io d INFOTYPES: 2001. . 2010. If there is a large number of time records. when the GET PERNR event occurs. In particular. this gives rise to problems with the main memory and bad performance times.

 S A P A G 1999 To control the amount of time required to read time infotypes. . only in the specified period. 0002.. .. .. GET PERNR. . . however. LOOP AT P2005. . MODE N is assigned to the infotypes in the declaration. .Reporting in HR Im p o rt in g T im e D a ta (2 ) INFOTYPES: 0001. RP_PROVIDE_FROM_LAST P0001 SPACE PN-BEGDA PN-ENDDA. The time infotype tables are subsequently filled using the RP_READ_ALL_TIME_ITY macro. WRITE. This ensures that infotype tables are not filled when GET PERNR occurs. . 2005 MODE N. RP_READ_ALL_TIME_ITY PN-BEGDA PN-ENDDA. . ENDLOOP. ..

(oder: APPEND tab. RP_PROVIDE_FROM_LAST P0001 SPACE PN-BEGDA PN-ENDDA. RP_READ_ALL_TIME_ITY PN-BEGDA PN-ENDDA. bukrs werks btrtl stdaz Work area(header line) Data area  SAP AG 1999 • If you want to evaluate absence data according to organizational units. MOVE-CORRESPONDING P2005 TO tab. LOOP AT P2005. werks LIKE P0001-WERKS. it is a good idea to use an internal table to group together the information from different database tables (PA0001 and PA2005).) ENDLOOP. stdaz LIKE P2005-STDAZ. bukrs LIKE P0001-BUKRS. DATA: tab TYPE TABLE OF overtime WITH HEADER LINE.Reporting in HR Importing Time Data to Internal Tables TYPES: BEGIN OF overtime. END OF overtime. btrtl LIKE P0001-BTRTL. GET PERNR. COLLECT tab. MOVE-CORRESPONDING P0001 TO tab. .

... L O O P A T ta b . . ENDAT. ENDLOOP. . ENDAT. . H ea d e r p ro c es sin g Single record processing A T E N D O F w e rk s .Reporting in HR P ro c e s s in g T im e D a ta w ith In te rn a l T a b le s END-OF-SELECTION.... ENDAT.. A T E N D O F b u kr s . AT NEW bukrs. ENDAT.. ta b BUKRS 0 0 01 0 0 01 0 0 02 0 0 02 W ERKS 0 0 01 0 0 01 0 0 02 0 0 02 BTRTL 0 0 01 0 0 02 0 0 03 0 0 04 AT NEW werks. A T F I R ST . ... F o o ter p ro ce ss in g  S A P A G 199 9 A T L A S T. ... ENDAT.. . ENDAT.

DATA: alv_fieldcat TYPE slis_t_fieldcat_alv.declaration TYPE-POOLS: slis. alv_layout TYPE slis_layout_alv. INFOTYPES: 0001. "Data table structure pernr LIKE pernr-pernr. DATA: filled_lines LIKE sy-index. ename LIKE p0001-ename.Reporting in HR Example report using ABAP List viewer REPORT zpsol060.Assignment "Date Specifications "Workarea for IT0041 TYPES: BEGIN OF data_struc. DATA: BEGIN OF dtype. dat LIKE p0041-dat01. dar LIKE p0041-dar01. stru_disvar TYPE disvariant. 0041. "Date Types "Org. t548t. eindt LIKE p0016-eindt. *-. dtext LIKE t548t-dtext. DATA: data_tab TYPE TABLE OF data_struc. data_tab_wa TYPE data_struc. END OF dtype. . END OF data_struc. dar LIKE p0041-dar01. TABLES: pernr. dat LIKE p0041-dat01.

ENDIF. IF dtype-dar IS INITIAL. IF filled_lines GT 0. ELSE. MOVE-CORRESPONDING p0001 TO data_tab_wa. DO 12 TIMES VARYING dtype FROM p0041-dar01 NEXT p0041-dar02. IF dtype-dar IN datetype. ENDIF. EXIT.Reporting in HR SELECT-OPTIONS: datetype FOR p0041-dar01 DEFAULT '01 *-. ENDDO. ELSE. . APPEND data_tab_wa TO data_tab. PERFORM re548t USING sy-langu dtype-dar. ENDIF. DESCRIBE TABLE p0041 LINES filled_lines. IF pnp-sw-found EQ 0. rp_provide_from_last p0001 space pn-begda pn-endda. MOVE t548t-dtext TO data_tab_wa-dtext.Processing GET pernr. PERFORM read_hiredate. rp_provide_from_last p0001 space pn-begda pn-endda CLEAR data_tab_wa. ENDIF. REJECT. MOVE-CORRESPONDING dtype TO data_tab_wa.

alv_layout-zebra = 'X'. alv_layout-colwidth_optimize = 'X'. CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' EXPORTING * I_INTERFACE_CHECK ='' * I_BUFFER_ACTIVE ='' i_callback_program = 'ZPSOL060' * I_STRUCTURE_NAME = * I_BACKGROUND_ID ='' I_GRID_TITLE = 'Date Specifications' * I_GRID_SETTINGS = is_layout = alv_layout it_fieldcat = alv_fieldcat * I_DEFAULT = 'X' I_SAVE = 'A' IS_VARIANT = stru_disvar IT_EVENTS = IT_EVENT_EXIT = IS_PRINT = IS_REPREP_ID = I_SCREEN_START_COLUMN = 0 I_SCREEN_START_LINE =0 I_SCREEN_END_COLUMN =0 I_SCREEN_END_LINE =0 IT_ALV_GRAPHICS = IT_ADD_FIELDCAT = IT_HYPERLINK = IMPORTING E_EXIT_CAUSED_BY_CALLER = ES_EXIT_CAUSED_BY_USER = TABLES t_outtab = data_tab EXCEPTIONS program_error =1 OTHERS = 2. * * * * * * * * * * * * * * .Reporting in HR END-OF-SELECTION. PERFORM fieldcat_init USING alv_fieldcat.

ENDFORM.Reporting in HR *-------------------------------------------------------------* * FORM READ_HIREDATE *-------------------------------------------------------------* * Retrieving hiredate from infotype 0000 *-------------------------------------------------------------* FORM read_hiredate. SELECT SINGLE * FROM t548t WHERE sprsl EQ language AND datar EQ dtype. . CALL FUNCTION 'RP_GET_HIRE_DATE' EXPORTING persnr = p0001-pernr check_infotypes = '0000' IMPORTING hiredate = data_tab_wa-eindt EXCEPTIONS OTHERS = 1. IF sy-subrc NE 0. ENDIF. CHECK t548t-sprsl NE language OR t548t-datar NE dtype. ENDFORM. *-------------------------------------------------------------* * FORM RE548T * Read date specification texts *-------------------------------------------------------------* * --> VALUE(LANGUAGE) * --> VALUE(DTYPE) *-------------------------------------------------------------* FORM re548t USING value(language) value(dtype). CLEAR t548t.

CLEAR ls_fieldcat. ls_fieldcat-fieldname = 'PERNR'. ls_fieldcat-ref_tabname = 'PERNR'. CLEAR ls_fieldcat. APPEND ls_fieldcat TO p_fieldcat. ls_fieldcat-fieldname = 'DAR'. CLEAR ls_fieldcat. APPEND ls_fieldcat TO p_fieldcat. ls_fieldcat-ref_fieldname = 'DAT01'. CLEAR ls_fieldcat. ls_fieldcat-fieldname = 'ENAME'. ls_fieldcat-ref_tabname = 'P0016'. ls_fieldcat-ref_tabname = 'P0001'. ls_fieldcat-ref_tabname = 'T548T'. APPEND ls_fieldcat TO p_fieldcat. ENDFORM. APPEND ls_fieldcat TO p_fieldcat. APPEND ls_fieldcat TO p_fieldcat. CLEAR ls_fieldcat. . ls_fieldcat-key = 'X'. CLEAR ls_fieldcat. ls_fieldcat-ref_tabname = 'P0041'. ls_fieldcat-fieldname = 'EINDT'. ls_fieldcat-ref_tabname = 'P0041'.Reporting in HR *-------------------------------------------------------------* * FORM FIELDCAT_INIT *-------------------------------------------------------------* FORM fieldcat_init USING p_fieldcat TYPE slis_t_fieldcat_alv. APPEND ls_fieldcat TO p_fieldcat. ls_fieldcat-fieldname = 'DTEXT'. ls_fieldcat-fieldname = 'DAT'. ls_fieldcat-ref_tabname = 'PERNR'. DATA: ls_fieldcat TYPE slis_fieldcat_alv.

Reporting in HR REPORTS IN PERSONNEL PLANNING .

Reporting in HR D a ta M o d e l re p o rts to / is lin e s u p e rv is o r of C o s t C e n te r A llo c a tio n O rg a n iz a tio n a l b e lo n g s t o in c o rp o ra te s is d e s c rib e d by d e s c rib e s is d e s c rib e d by is d e s c rib e d by C o s t c e n te r C o s t C e n te r A llo c a tio n b e lo n g s t o in c o rp o ra te s Job d e s c rib e s P o s itio n o c c u p ie s H o ld e r W o rk c e n te r d e s c rib e s Task P e rs o n /u s e r  S A P A G 1999 .

• • • . projections. Relationships are used to link one to the other (see graphic). qualification catalog). Customizing enables you to enhance the existing data model by defining new object types. such as Training and Event Management (business event hierarchies) and Personnel Development (for example. and establishing new relationships between the various object types. This data model (object types and relationships) also constitutes the basis of other applications within Personnel Planning. These objects are created and maintained separately.Reporting in HR • Organizational Management is based on the idea of representing each element within an organization as a separate object with its own characteristics. whereas the customer namespace is 00 to 99. The cost center is an external object type because it is not maintained in Organizational Management. and evaluations. Each standard object type consists of two letters. This gives rise to a network that is flexible enough to facilitate personnel planning. for example.

The position "is described by" the job.Reporting in HR Relationship Betw een Jobs and Positions The job "describes" the position. Relationship A/B 007 Adm inistrative assistant for m arketing departm ent Adm inistrative assistant for executive board Job: Adm inistrative assistant Adm inistrative assistant for research departm ent  SAP AG 1999 .

Reporting in HR
• • "Job" is used as a general classification, such as secretary or head of department. More than one employee can have the same job. For example, twenty employees can have the job of secretary. A position is the assignment of an individual employee in your enterprise, for example, sales manager, secretary in the marketing department. You form the structure of your enterprise by creating positions and linking them to each other.

Reporting in HR
O b je c t/In fo ty p e S ta tu s

O b je c t R e la tio n s h ip

(In fo typ e 1 0 0 0 ) (In fo typ e 1 0 0 1 )

P la n n e d S u b m itte d

R e je c te d A c tiv e A p p ro v e d

 S A P A G 1999

Reporting in HR
A status is assigned to each object/infotype. • Active means that an object or infotype record can be used at this time. • Planned means that an object or infotype record has been proposed but is not yet active, which means it cannot be used. • Submitted means that an object or infotype record is currently being checked by a person or group of persons before it is approved or rejected. • Approved means that a submitted object/infotype record has been accepted. • Rejected means that a submitted object/infotype record has not been approved. • You can create objects with the status "planned" or "active".

Reporting in HR
Evaluation Paths

Organizational unit Job Position Person

O C S P Org.unit

O Org.unit S
Position

O Org.unit S Position

Position

P

Person

P

Person

Employee

 SAP AG 1999

Evaluation path O-S-P. The standard selection screen enables you to choose evaluation paths. The report only evaluates objects that it finds in the specified evaluation path. for example. Evaluation paths are used to select objects for structural evaluations. You can also create new evaluation paths to meet the particular requirements of your enterprise. They are predetermined in the system and must not be changed. and the system evaluates the structure along the evaluation path. Report RHWEGID0 displays all possible evaluation paths between the starting object type and the target object type. describes the set of relationships found between organizational units. Every standard report has a defined standard evaluation path.Reporting in HR • An evaluation path describes a set of relationships between objects in a hierarchical structure. positions. You choose an evaluation path. • • • . and persons.

Reporting in HR
Available In ternal In form ation

TABLES: OBJEC, GDSTR. INFOTYPES: nnnn. . . . GET OBJEC. LOOP AT Pnnnn . . .

Pnnnn

Internal infotype table

O B JE C O bject inform ation

G D STR R oot of structure ENDLOOP.

STR U C Structure inform ation

 S A P A G 1999

Reporting in HR
Sequential Evaluations-Coding

TABLES: OBJEC. INFOTYPES: 0002, 1003, .... GET OBJEC. LOOP AT Pnnnn WHERE BEGDA LE PC-ENDDA AND ENDDA GE PC-BEGDA. WRITE... ENDLOOP.

"Personal Data "Addresses

 SAP AG 1999

Reporting in HR
S t r u c t u r a l E v a lu a t io n s - C o d in g
TABLES: OBJEC, GDSTR. INFOTYPES: 0002, 1003, .... GET OBJEC. LOOP AT Pnnnn WHERE BEGDA AND ENDDA WRITE... ENDLOOP.

"Personal Data "Addresses

LE GE

PC-ENDDA PC-BEGDA.

 S A P A G 1999

The only difference between a structural and sequential evaluation is the additional GDSTR entry in the TABLES statement.

Reporting in HR
E va lu a tin g T a b le In fo ty p e s

INFOTYPES: 1002. "Description TABLES: OBJEC. DATA: ipt1002 LIKE PT1002 OCCURS 0 WITH HEADER LINE. . . . GET OBJEC. WRITE: / OBJEC-OTYPE, OBJEC-OBJID. LOOP AT P1002. RH-GET-TBDAT P1002-INFTY P1002-TABNR ipt1002. LOOP AT ipt1002. WRITE: / ipt1002-TLINE. ENDLOOP. ENDLOOP.

 S A P A G 1999

• • . Please note that you cannot use macros for logical databases PCH and PNP at the same time. With this macro.Reporting in HR • RH-GET-TBDAT is a macro for logical database PCH. See also Table Infotypes. These macros are defined in include DBPCHCOM. The parameters for macro RH-GET-TBDAT are: Parameter 1 : Infotype Parameter 2 : Reference field Parameter 3 : Table for structure PTnnnn Macros for logical database PCH must not be confused with macros for logical database PNP. you can import the data for an infotype with a repetitive structure.

CA L L F UN C TI O N ' RH _ RE A D_ I NF T Y' EX P OR T IN G . . . " Re l at i on s hi p s DA T A: ih r ob j ec t L I KE HR O BJ E CT OC C UR S 1 0 . .  S A P A G 1999 .Reporting in HR R ea d in g In fo typ e s W ith F u n c tio n M o d u les IN F OT Y PE S : 1 00 1 . . . I NF T Y = ' 1 00 1 ' B EG D A = < b eg d at > E ND D A = < e nd d at > TA B LE S I NN N N = P 1 00 1 O BJ E CT S = i h ro b je c t EX C EP T IO N S A L L_ I NF T Y_ W IT H _S U BT Y = 1 N O TH I NG _ FO U ND = 2 N O _O B JE C TS = 3 W R ON G _C O ND I TI O N = 4 O T HE R S = 5.

With this macro. The parameters for macro RH-GET-TBDAT are: Parameter 1 : Infotype Parameter 2 : Reference field Parameter 3 : Table for structure PTnnnn Macros for logical database PCH must not be confused with macros for logical database PNP. • • . See also Table Infotypes.Reporting in HR • RH-GET-TBDAT is a macro for logical database PCH. you can import the data for an infotype with a repetitive structure. Please note that you cannot use macros for logical databases PCH and PNP at the same time. These macros are defined in include DBPCHCOM.

0006. INFOTYPES: 0002. TABLES: objec. pchotype = 'O'. DATA: stabs LIKE p1003-stabs.Reporting in HR Example Report REPORT zhsol010. . INITIALIZATION. 1003. gdstr. name LIKE p0001-ename. pchwegid = 'O-S-P'.

ENDIF. objec-stext. ENDIF. CLEAR stabs. IF objec-otype = 'S'. . PROVIDE vorna nachn FROM p0002 subty telnr FROM p0006 BETWEEN pc-begda and pc-endda WHERE p0006-subty = '1'. IF p1003-stabs = 'X'. p0006-telnr. IF objec-otype = 'P' AND stabs = 'X'. IF p0006_valid = 'X'. ENDPROVIDE. WRITE: / name. LOOP AT p1003 WHERE begda LE pc-endda AND endda GE pc-begda. stabs = 'X'.Reporting in HR GET objec. objec-short. ENDLOOP. WRITE : / objec-objid. SKIP. CONCATENATE p0002-vorna p0002-nachn INTO name SEPARATED BY SPACE. ENDIF. ENDIF.

Reporting in HR READING CLUSTER DATA .

Reporting in HR Export The syntax for exporting the data to cluster table is EXPORT var1…varn itab1 itab2…itabn TO DATABASE dbtab(ID) [FROM wa] ID key. . Import The syntax for exporting the data to cluster table is IMPORT var1…varn itab1 itab2…itabn FROM DATABASE dbtab(ID) [TO wa ] ID key.

If the export is successful. . . WRITE: / 'Update ENDIF. successful'. the return code is 0. . .Reporting in HR E x p o r tin g D a ta TABLES: PCLn. The EXPORT command writes one or more data objects with xy-KEY to cluster xy. * Fill data object * Export record TO DATABASE PCLn(xy) ID xy-KEY. . EXPORT IF TABLE1 SY-SUBRC EQ 0. INCLUDE: RPCnxxy0. * Fill cluster-KEY "Import/export table "Cluster definition xy-KEY-FIELD = <VALUE>.  S A P A G 1999 The cluster definition is included using the INCLUDE statement.

INCLUDE RPPPXD10. RP-EXP-Cn-xy. DATA: END OF COMMON PART buffer. . DATA: BEGIN OF COMMON PART buffer. . * Buffer Administration Routines INCLUDE: RPPPXM00. . * Save PERFORM PREPARE_UPDATE USING 'V'.Reporting in HR E x p o rt U s in g B u ffe r * Buffer definition INCLUDE: RPPPXD00. . . . M a in m e m o ry b u ffe r PCLn xy  S A P A G 1999 . . . . * Data export to buffer RP-EXP-Cn-xy.

which accesses a buffer administration routine.Reporting in HR • If data is exported using macros. If data is exported successfully. • • • . The data is diverted by a USING parameter in the EXPORT statement. the buffered records must be saved on a PCLn database. they are written to a main memory buffer. At the end of the program. the PREPARE_UPDATE routine is accessed with USING parameter V. the RP-IMP-xySUBRC = 0 return code is set. Instead. To save the data. the data records are not written directly to the database.

. END OF xy-key.  S A P A G 1999 . DATA: BEGIN OF table2 OCCURS 10. * Definition of Data Objects DATA: BEGIN OF table1 OCCURS 10. FIELDn. COLUMN1. FIELD1. . END OF table1. COLUMNn. .Reporting in HR C L U S T E R .D e fin itio n in P r o g r a m R p c n x y z 0 * KEY-Definition DATA: BEGIN OF xy-key.

n = 1 or 2 for PCL1 or PCL2 xy = Cluster. Their names follow convention RPCnxyz0. the database table PCL1 contains the texts stored for infotypes. RX z = 0 for international clusters or country indicator from table T500L for country-specific clusters. The data objects (field strings and tables) are named individually per cluster. for example. • • . Example: The program RPC1TX00 contains the data definition of cluster TX. They are defined as INCLUDE programs.Reporting in HR • • • • • • The data definitions of a work area are stored in separate programs using a fixed naming convention. The key structure of the cluster is stored in a field string xyKEY where the personnel number is the first element. where. In this cluster.

* Import Record IMPORT table1 table2 FROM DATABASE PCLn(xy) ID xy-KEY. If a record is read successfully. . LOOP AT table1.Reporting in HR Im p o r t in g D a ta TABLES: PCLn. . . If a record is not read successfully. . the return code is 4. . "Import/export table "Cluster definition * Fill Cluster-KEY xy-KEY-FIELD1 = <VALUE>. . * Display Data object IF SY-SUBRC EQ 0. the return code is 0.  S A P A G 1999 The IMPORT command reads data objects with the specified key values from the import/export database table. INCLUDE: RPCnxyz0. ENDIF. ENDLOOP. WRITE.

IMPORT table1 table2 .  SAP AG 1999 . . END-OF-DEFINITION.. . ..Reporting in HR Importing/Exporting With Macros Macro H ic PAYM ACRO DEFINE RP-IMP-Cn-xy. FROM DATABASE PCLn(xy) ID xy-KEY USING PCLn_EXP_IMP. .. . RP-IMP-Cn-xy. .. .

The macros use routines that carry out two tasks: 1. The macros for the import of payroll results are defined in include programs for the payroll driver with the name HicPAYMACRO (ic = ISO code. Data buffering 2.Reporting in HR • • • • To ensure consistency when data is exported and imported. HUSPAYMACRO for the USA) using the DEFINE keyword. the IMPORT/EXPORT commands are defined as macros. It is possible to import only a portion of the data objects in a cluster. Cluster authorization check • • . The naming conventions for the macros are RP-IMP-Cn-xy and RP-EXP-Cn-xy. where n is the file name and xy is the cluster name. The macro for importing infotype texts to cluster TX is contained in the table Macros in ABAP Programs. These include programs are generated and must not be changed manually. for example.

Reporting in HR Im p o r t in g /E x p o r t in g U s i n g a B u f f e r P ro g ra m E x p o rt UPDATE PCLn Im p o r t B u ffe r  S A P A G 1999 .

the payroll results of the previous period form the basis of the calculation used to determine the results of the subsequent period.Reporting in HR • To minimize the number of times that the database is accessed. However. import and export data is buffered in the main memory. For this reason. If a test run is performed. Using the buffer enables you to access the required results from the previous period. the database is not updated. • • . a difference arises between the results of a live payroll run and the results of a test run if test runs are performed for several periods.

INCLUDE RPPPXD10. * Fill cluster KEY . . DATA: BEGIN OF COMMON PART BUFFER. * Buffer Administration Routines INCLUDE: RPPPXM00. . DATA: END OF COMMON PART buffer. * Data import RP-IMP-Cn-xy.Reporting in HR Im p o rtin g U s in g a B u ffe r * Buffer definition INCLUDE: RPPPXD00. . . M a in m e m o ry b u ffe r PCLn xy  S A P A G 1999 . .

Reporting in HR • If data is imported using macros. If this is not the case. The standard import programs follow the RPCLSTxy naming convention. • . where xy = cluster name. If data is read using a buffer. the record is read from PCLn to the buffer. the buffer directory is checked to determine whether the main memory already contains a record with the same key. Instead. the data records are not read directly from table PCLn. the system checks the cluster authorization. and retrieved from the buffer by the report.

tx-key-subty = qualifications-subty. tx-key-objps = qualifications-objps. rp_provide_from_last qualifications space pn-begda pn-endda. ENDLOOP. rp-imp-c1-tx. LOOP AT ptext. REPORT ZRP_READ_PCL1_TX. tx-key-begda = qualifications-begda. . INFOTYPES 0024 NAME qualifications. tx-key-pernr = qualifications-pernr. TABLES: pernr.Reporting in HR Example program to read data from PCL1 Cluster This example reads long text data from Infotype 0024. WRITE ptext-line. INCLUDE rpc1tx00. tx-key-seqnr = qualifications-seqnr. GET pernr. tx-key-infty = qualifications-infty. tx-key-sprps = qualifications-sprps. tx-key-endda = qualifications-endda. START-OF-SELECTION.

START-OF-SELECTION.Reporting in HR Example program to read data from PCL1 Cluster This example reads data from PCL1 for RELID B1. GET pernr. b1-key-pernr = pernr-pernr. REPORT ZRP_READ_PCL1_B1. * rp-imp-c1-b1. INCLUDE rpc1b100. IMPORT nt1 nt2 ift1 ift2 ert nct qt st itp1 itp7 itp50 pdppm FROM DATABASE pcl1(b1) ID b1-key. . TABLES: pernr.

b2-key-pabrj = pn-begda+0(4). INCLUDE rpc2b200. GET pernr.. *** ZL --> Time Wage Types (Table ZL) IMPORT zl FROM DATABASE pcl2(b2) ID b2-key.Reporting in HR Example program to read data from PCL2 Cluster This example reads data from PCL2 for RELID B2.. b2-key-pabrp = pn-begda+4(2). b2-key-cltyp = '1'. REPORT ZRP_READ_PCL2_B2. *** Process the itab zl. TABLES: pernr.. START-OF-SELECTION. b2-key-pernr = pernr-pernr. ENDLOOP. . LOOP AT zl.

Reporting in HR Payroll International Payroll driver program: RPCALCX0 .

. RPCALCU0 for USA 7.Reporting in HR The international payroll driver program is RPCALCX0. RPCALCE0 for Spain 5. RPCALCD0 for Germany 4. HINCALC0 for India 8. RPCALCA0 for Austria 2. We are having customized payroll driver programs for most of the countries viz: 1. RPCALCC0 for Switzerland 3. RPCALCG0 for Great Britain 6. HBRCALC0 for Brazil etc.

Reporting in HR Display Payroll results Program: RPCLSTRX .

Reporting in HR .

Reporting in HR .

Reporting in HR P a y r o ll R e s u lts REPORT H99_DISPLAY_PAYRESULT P a y r o ll r e s u lt K a th y C a lc W T01 W T02 W T03 /1 0 1 . . . J a n u a ry 1 9 x x UNI UNI UNI UNI S t a n d a r d s a la r y 5 0 0 0 Bonus 300 O v e r tim e 200 T o ta l g r o s s a m t 5 5 0 0  S A P A G 1999 . .

Reporting in HR • With this report. Green: Results exist Red: No results exist Gray: No authorization for displaying personnel numbers Payroll results are stored as structures and internal tables on the database. 2. 3. The indicator behind each name shows whether results exist in the selected period. you can display the payroll results for any country. Each payroll result has a status indicator: 1. A P O = = = Current result Previous result All other results • • .

Reporting in HR D a ta F lo w in P a y ro ll S c h e m a s & ru le s PAnnnn RPC ALCn0 PCL2 PCL2 xy xy H 9 9 _ D IS P L A Y _ P A Y R E S U L T R PCE D Tn0  S A P A G 1999 .

The payroll result generated by the payroll driver is stored in cluster xy of the database table PCL2. replaces reports RPCLSTxy and HxyCLSTR. Report H99_DISPLAY_PAYRESULT displays the payroll results for PCL2 and. lists the formatted result as a payroll form (n = HR country indicator from table T500L).Reporting in HR • The payroll driver. In many cases. from Release 4. The schema contains functions that call the subroutines contained in the payroll driver. Report RPCEDTn0. for example.6C. the function is enhanced by rules for specific control of the subroutines. RPCALCn0. • • • • . uses HR data (stored in the database tables PAnnnn) and the last payroll result (stored in the database table PCL2) to run the payroll for the specified period The program (payroll driver) imports the processing logic in the form of a schema. The report is used in all country versions and the overview of payroll results is automatically displayed according to the particular country.

 S A P A G 1999 . INCLUDE STRUCTURE PC261. CALL FUNCTION 'CU_READ_RGDIR' EXPORTING PERSNR = PERNR-PERNR IMPORTING MOLGA = country TABLES IN_RGDIR = RGDIR EXCEPTIONS NO_RECORD_FOUND = 1 OTHERS = 2... DATA: COUNTRY LIKE T001P-MOLGA. DATA: END OF RGDIR.Reporting in HR R e a d in g th e C lu s te r D ir e c to ry *Table containing directory of payroll results DATA: BEGIN OF RGDIR OCCURS 100. .

the function module returns the HR country indicator. If the MOLGA parameter is active. in-period. The personnel number whose payroll directory is to be read is transferred to the function module. A directory entry with the payroll area. together with the personnel number. and the five-digit sequence number is required.Reporting in HR • Table RGDIR contains the directory (cluster directory) for all of an employee's payroll results and is contained in cluster CU. forperiod. The function module CU_READ_RGDIR reads table RGDIR from cluster CU. status indicator. • • . to construct the key for each payroll result for an employee.

. . .Reporting in HR D eterm in in g C u rren t P a yro ll R esu lt (1 ) DATA: number LIKE PC261-SEQNR. . 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. CALL FUNCTION 'CU_READ_RGDIR' . . . . GET PERNR. .  S A P A G 1999 .

To determine the correct start date and end date of the for-period. the payroll period is entered and the start date (PNBEGDA) and the end date (PN-ENDDA) are determined using the Payroll Periods table (T549Q). You can also use the following function modules: CD_READ_PREVIOUS (reads the record that precedes the payroll record) CD_READ_PREVIOUS_ORIGINAL (reads the last original result that precedes the original payroll result) • • .Reporting in HR • The function module CD_READ_LAST determines the current payroll result for a for-period to be evaluated. The function module then gives you the sequential number (OUT_SEQNR) for the current (A) result of the for-period. you specify the period by entering the payroll period in the selection screen. If you specify report class XXM00004 in the attributes of your report. You enter the start and end date of the for-period for the evaluation as well as table RGDIR.

. . LOOP AT result-INTER-RT INTO rt_header. CHANGING PAYROLL_RESULT = result EXCEPTIONS .. ENDLOOP. . DATA: rt_header TYPE LINE OF HRPAY99_RT. 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' . . . .. .  S A P A G 1999 .Reporting in HR D e te r m in in g C u r re n t P a y r o ll R e s u lt (2 ) DATA: result TYPE PAY99_RESULT.

This mmust be declared in the calling report as a complex structure that corresponds to structure PAYic_RESULT (ic = ISO code).Reporting in HR • With the function module PYXX_READ_PAYROLL_RESULT. you can specify that only the international part is imported. Anonymous evaluations can then be carried out by users without cluster authorizations. the cluster authorization check is deactivated. you can read a complete payroll result from the database table PCL2 or from the buffer. The READ_ONLY_BUFFER means that the database is not accessed. The payroll result is then transferred to parameter PAYROLL_RESULT. • • . If the parameter CHECK_READ_AUTHORITY is active and set to blank. With the READ ONLY INTERNATIONAL parameter.

ENDLOOP. * Access to payroll result data WRITE: result-INTER-VERSC-FPPER. DATA: rt_header TYPE LINE OF HRPAY99_RT. . . .Reporting in HR D a ta S tru c tu re fo r P a yro ll R e s u lts S tru ctu re : P A Y 9 9 _ R E S U L T EVP S tru c tu re P C 26 1 IN T E R S tru c tu re P AY 9 9_ IN T E R N A T IO N A L N AT BT D um m y fo r n a tio n a l p a rt VERSC Type P C 202 RT Type H R P AY99_R T CRT Type H R P AY99_C R T DATA: result TYPE PAY99_RESULT. . WRITE: / rt_header-LGART. . . . LOOP AT result-INTER-RT INTO rt_header.  S A P A G 1999 . . .

If you want to evaluate payroll results. for example. and NAT (country-specific part). PAYUS_RESULT for the USA) exist for the country-specific results. The components INTER and NAT also contain the tables (for example. In cluster RX. Here. The structure contains the components EVP (directory information). you need a header with the type HRPAYic_table name (for example. INTER (international). you need a data structure with the type PAYic_RESULT. The structures PAYic_RESULT (ic = ISO code. For each table in the payroll results to be processed.Reporting in HR • The data structures for the international payroll results (RX) are described in the Dictionary in structure PAY99_RESULT. the component NAT contains the substructures for the country-specific results. • • . RT. NAT consists of a dummy field. and so on) and field strings (for example. HRPAY99_RT for the results table RT). CRT. VERSC) for the payroll results as substructures.

ENDLOOP. . D A T A : t a b l e _ h e a d e r T Y P E L I N E O F H R P A Y ic _ t a b l e . . .  S A P A G 1999 . LOOP AT result_header-NAT-table INTO table_header. . . WRITE..Reporting in HR C o u n tr y -S p e c ific P a y ro ll R e s u lts L in e typ e : P A Y ic _ R E S U L T EVP S tr u c tu re P C 2 6 1 IN T E R S tru c tu re P A Y 9 9 _ IN T E R N A T IO N A L N AT BT VERSC Type P C 202 RT Type H R P AY99_R T CRT Type H R P AY99_C R T s tru c tu re P A Y ic _ N A T IO N A L ta b le T y p e H R P A Y ic _ ta b le D A T A : r e s u l t _ t a b T Y P E P A Y ic _ R E S U L T OCCURS 0 WITH HEADER LINE. r e s u l t _ h e a d e r T Y P E P A Y ic _ R E S U L T . LOOP AT result_tab INTO result_header. ENDLOOP.. .

t549a. TABLES: pernr. t512t. "Payroll areas INFOTYPES: 0001.1 REPORT zpsol090. "Organizational Assignment DATA: result_tab TYPE hrpay99_tab_of_results. result_header TYPE pay99_result. .Reporting in HR Example program for reading and processing of payroll results .

Reporting in HR DATA: rgdir LIKE pc261 OCCURS 0 WITH HEADER LINE. period = pn-paper. SELECT-OPTIONS: p_status FOR result_header-evp-srtza DEFAULT 'A'. SELECT SINGLE * FROM t549a WHERE abkrs = pnpxabkr. DATA: period LIKE pc261-inper. START-OF-SELECTION. .

. CALL FUNCTION ‘PYXX_GET_EVALUATION_PERIODS’ EXPORTING clusterid = 'RX' employeenumber = p0001-pernr inper_modif = t549a-permo inper = period TABLES rgdir = rgdir evaluated_periods = result_tab EXCEPTIONS no_payroll_results = 1 no_entry_found_on_cu = 2 import_error =3 OTHERS = 4. rp_provide_from_last p0001 space pn-begda pn-endda.Reporting in HR GET pernr.

PERFORM print_rx. pn-paper. LOOP AT result_tab INTO result_header. WRITE: / 'No payroll result found for'(001).Reporting in HR IF sy-subrc NE 0. . ENDLOOP. CHECK p_status. ENDIF. ELSE.

(15) p0001-ename. SKIP 1. WRITE: 'Results table: '(005). FORMAT INTENSIFIED OFF. 30 result_header-inter-versc-fpper+4(2). . p0001-werks. SKIP 1. result_header-inter-versc-fpper+0(4). p0001-btrtl. SKIP 1. WRITE: / p0001-pernr. FORMAT INTENSIFIED ON. WRITE: / 'For period/payroll area: '(003). / 'In-period/payroll area: '(004). 30 result_header-inter-versc-inper+4(2). result_header-inter-versc-abkrs. result_header-inter-versc-iabkrs. result_header-inter-versc-inper+0(4).Reporting in HR *-------------------------------------------------------------* * FORM PRINT_RX *-------------------------------------------------------------* * Print Payroll Result *-------------------------------------------------------------* FORM print_rx.

CHECK t512t-sprsl NE sy-langu OR t512t-molga NE country_grouping OR t512t-lgart NE wtype. rt_header-betrg CURRENCY rt_header-amt_curr. IF sy-subrc NE 0. CLEAR t512t. ENDFORM. T512T-LGTXT. SELECT SINGLE * FROM t512t WHERE sprsl EQ sy-langu AND molga EQ country_grouping AND lgart EQ wtype. . ENDLOOP. WRITE: / rt_header-lgart.Reporting in HR LOOP AT result_header-inter-rt INTO rt_header. ENDIF. PERFORM re512t USING result_header-inter-versc-molga rt_header-lgart. *-------------------------------------------------------------* * FORM RE512T *-------------------------------------------------------------* * Read Wage Type Texts *-------------------------------------------------------------* FORM re512t USING value(country_grouping) value(wtype). ENDFORM.

SELECTION-SCREEN BEGIN OF BLOCK 1 WITH FRAME TITLE text-h00. bukrs LIKE p0001-bukrs. 0001. sname LIKE p0001-sname. pernr LIKE p0000-pernr. lgart LIKE t511-lgart. END OF gt_data. * Declare internal tables TABLES: pernr. 0002. INFOTYPES: 0000. SELECT-OPTIONS: s_stat2 FOR p0000-stat2.Reporting in HR Example program for reading and processing of payroll results – 2 Reading RT results REPORT zhpyr00134 NO STANDARD PAGE HEADING LINE-SIZE 130 LINE-COUNT 60. perid LIKE p0002-perid. . DATA: BEGIN OF gt_data OCCURS 0. SELECTION-SCREEN END OF BLOCK 1. t511. SELECT-OPTIONS: s_lgart FOR t511-lgart OBLIGATORY. betrg LIKE pc207-betrg.

REJECT. ENDIF. rp-provide-from-last p0002 space pn-begda pn-endda. ENDIF. GET pernr. IF pnp-sw-found NE '1'. rp-provide-from-last p0001 space pn-begda pn-endda. END-OF-SELECTION. PERFORM disp_result. REJECT.Reporting in HR START-OF-SELECTION. rp-provide-from-last p0000 space pn-begda pn-endda. REJECT. ENDIF. IF pnp-sw-found NE '1' OR NOT p0000-stat2 IN s_stat2. . PERFORM get_payroll. IF pnp-sw-found NE '1'.

gt_data-bukrs = p0001-bukrs. lt_rt LIKE pc207 OCCURS 0 WITH HEADER LINE. CLEAR gt_data. gt_data-pernr = pernr-pernr. gt_data-perid = p0002-perid. **************************************************************** DATA: ls_hrpy_rgdir LIKE hrpy_rgdir. ENDIF. . IF sy-subrc NE 0. DATA: lt_payresult TYPE payus_result. ELSE. CONCATENATE pnpdispj pnpdispp INTO lw_fpper. gt_data-sname = p0001-sname. DATA: lw_fpper LIKE hrpy_rgdir-fpper. EXIT. SELECT SINGLE * INTO ls_hrpy_rgdir FROM hrpy_rgdir WHERE pernr = pernr-pernr AND fpper = lw_fpper AND abkrs = p0001-abkrs AND srtza = 'A'. IF pnppabrp IS INITIAL.Reporting in HR **************************************************************** FORM get_payroll. CONCATENATE pnppabrj pnppabrp INTO lw_fpper. ENDIF.

lt_rt[] = lt_payresult-inter-rt[]. ENDLOOP. APPEND gt_data. IF sy-subrc NE 0. EXIT. ENDIF. "get_payroll . gt_data-betrg = lt_rt-betrg. LOOP AT lt_rt WHERE lgart IN s_lgart.Reporting in HR CALL FUNCTION 'PYXX_READ_PAYROLL_RESULT' EXPORTING clusterid = 'RU' employeenumber = ls_hrpy_rgdir-pernr sequencenumber = ls_hrpy_rgdir-seqnr CHANGING payroll_result = lt_payresult EXCEPTIONS illegal_isocode_or_clusterid = 1 error_generating_import =2 import_mismatch_error =3 subpool_dir_full =4 no_read_authority =5 no_record_found =6 versions_do_not_match =7 OTHERS = 8. ENDFORM. APPEND gt_data. gt_data-lgart = lt_rt-lgart.

10 gt_data-perid USING EDIT MASK '___-__-____'. 50 gt_data-bukrs. ELSE. 65 gt_data-lgart. 60 'Company Code'. 15 'S. IF p_dwnld = 'X'. WRITE:/1(130) 'Employee#'. . ENDLOOP. 30 'Name'. 71 gt_data-betrg.S#'. LOOP AT gt_data. FORMAT COLOR COL_HEADING INTENSIFIED ON. WRITE:/1(130) sy-uline. 22 gt_data-sname(25). **************************************************************** SORT gt_data BY pernr.Reporting in HR **************************************************************** FORM disp_result. WRITE:/1 gt_data-pernr.

FORMAT COLOR COL_HEADING INTENSIFIED OFF. 15 'Wage type/Amount >>>'. WRITE:/1(130) ''. 40 gt_data-lgart. 30 gt_data-sname. SKIP 2. IF gt_data-lgart IS NOT INITIAL. ENDLOOP. WRITE:/1(130) gt_data-pernr. WRITE:/1(130) '>>> End of Report <<<' CENTERED. ENDIF. 60 gt_data-bukrs. READ TABLE gt_data INDEX sy-tabix. ENDIF. FORMAT COLOR COL_BACKGROUND INTENSIFIED OFF. ENDAT.Reporting in HR LOOP AT gt_data. SKIP 1. AT NEW pernr. ENDFORM. FORMAT COLOR COL_NORMAL INTENSIFIED OFF. 60(15) gt_data-betrg. "disp_result . 15 gt_data-perid USING EDIT MASK '___-__-____'.

User Exits and BAdIs Some of the user Exits available are: 1. 2.Admin. 4. 5. PBAS0001 PA: Pers./Recruitment: Default values and checks HRCTRCU0 Enhancement for Customer Exits for RPCTRCU0. 3. RHALE001 HR-CA: Enhancement for ALE functionality in HR PCMP0009 Compensation Management: Calculation Base PCMP0010 Compensation Management: Activate Compensation Adjustments .

PBAS0001 PA: Pers./Recruitment: Default values and checks This is mainly used for validation of infotype entries when maintaining data through PA40 or PA30 transactions. . The first one is called in PBO module and second one in PAI module.Admin.User Exits and BAdIs 1. Two Function modules EXIT_SAPFP50M_001 and EXIT_SAPFP50M_002 are associated with this Enhancement.

Reporting in HR Goto transaction CMOD .

Reporting in HR .

Reporting in HR
The function exit EXIT_SAPFP50M_001 allows you to enter Defaultvalues in the single screen when you are creating or copying infotypes. The following are available for determining these default values: TCLAS INNNN the transaction class (A= employees, B= applicants) the infotype created

IPSYST workfields for dialog control and selected fields for organizational assignment (IT 0001) that are valid on the start date of the current record (INNNN-BEGDA). I001P Table T001P (Personnel Subareas) determined with the current organizational assignment (IPSYST-WERKS, IPSYST-BTRTL), I503 Table T503 (Employee Subgroups) determined with the current organizational assignment (IPSYST-PERSG, IPSYST-PERSK). IPREF Assignment values for HR objects

Reporting in HR
Based on this data, the additional data can be returned to parameter INNNN. Error messages or exceptions are not provided for in this function exit. Note the following: 1 The function exit is executed when you Create or Copy a record. 2 As long as the enhancement is active, the function exit is called up for every infotype, as the following steps are necessary: - declaration of structure with desired infotype structure (I0008 LIKE P0008) - infotype query in CASE statement - temporary storage of transfer parameter INNNN in infotype structure - an example of the coding for this function exit is stored in include LXPADF01.

Reporting in HR
The function exit EXIT_SAPFP50M_002 allows you to execute an additional check after entries have been made on the single screen and the fields have been verified. The following are available for determining these default values: TCLAS the transaction class (A= employees, B= applicants) INNNN the infotype created PSAVE Infotype prior to modification IPSYST workfields for dialog control and selected fields for organizational assignment (IT 0001) that are valid on the start date of the current record (INNNN-BEGDA). I001P Table T001P (Personnel Subareas) determined with the current organizational assignment (IPSYST-WERKS, IPSYST-BTRTL), I503 Table T503 (Employee Subgroups) determined with the current organizational assignment (IPSYST-PERSG, IPSYST-PERSK). IPREF Assignment values for HR objects

Reporting in HR
Created infotype records will be returned INNNN. Error messages can be returned. Note: 1. You can still change the created infotype record in function exit. Whoever is responsible for the enhancement project must make sure that the field contents are consistent! In order to that field values can be displayed again, Show_data_again must be switched on. 2. As soon as the enhancement is active, the function exit will be called up for each infotype. The following steps are required in order to do this: - Declaration of a field string with the desired infotype structure (I0008 LIKE P0008) - Query of infotype in a case statement - Store transfer parameter INNNN temporarily in the infotype field string - Determine the default value - Return infotype to transfer parameter INNNN 3. There is an example of the coding for this function exit in include LXPADF01.

Reporting in HR Function Module EXIT_SAPFP50M_001 .

Reporting in HR .

Reporting in HR Function Module EXIT_SAPFP50M_002 .

Reporting in HR .

Reporting in HR .

Enhancements created using business add-ins can be implemented either exactly once. customers. They do not need to be registered in SSCR. Business add-ins can be created at any level of the system landscape. without modifying the original object. and tables. and so on). and so on) can add their own code. or for an infinite number of customers simultaneously. customers. country versions. customers). partners. In addition.Reporting in HR Business Add-Ins (BAdI) Business add-ins are programmer-defined places in source code where software customers (industry sectors. GUI interfaces. . screens. an add-in could be implemented according to "country" or other criteria). Business add-ins can also be defined according to a filter (for example. The interface of a business add-in is forward compatible. but are needed often. partners. business add-ins are designed for use in a multiple-level system landscape (SAP. Interfaces are required to execute a task are combined in one business add-in. While customer exits (enhancements using SMOD/CMOD) are designed for use in a twolevel system landscape (SAP. IS solutions. business add-ins can be created and delivered at all software levels. thus ensuring that these add-ins and their interface still function after a release upgrade. A user who wants to use a business add-in can create their own during implementation. Customers can then add their own enhancements to the standard system. or use one of the delivered standard solutions. and therefore have been designed to be integrated into the R/3 System. Interfaces can be designed for ABAP source code. Business add-ins are designed for users who require certain functions in the R/3 System that are too specialized to be included in the standard system.

Reporting in HR BAdI for PA Infotypes Now let me explain the method of creating implementation/s for a BAdI with the example of HRPAD00INFTY. Go to Transaction: SE18 Enter the definition name as HRPAD00INFTY. .

Reporting in HR Click on the display button. The following screen appears. .

The enhancement PBAS0001 can be completely avoided by the BAdI. . The following screen will appear which suggests that PY_UPD_T5RIC is the active implementation for the BAdI which is a standard one.Reporting in HR By seeing the attributes we can make out that this is a Multiple use BAdI which means there can be more than one active implementation at a time. Choose the menu Implementation Overview. Is this BAdI a complete replacement for the enhancement PBAS0001? Yes.

Click on the create button The following popup appears. Enter the description of the implementation and save it. The following screen will appear. The following screen will appear.Reporting in HR How to implement our own Implementation of the BAdI Definition? Choose the menu Implementation Overview. . Enter the new implementation name as ZRAJESH_P_NAIR_INFTY (for Example) and press enter.

Reporting in HR Now select the interface tab .

Reporting in HR .

let us take a scenario.Equivalent to EXIT_SAPFP50M_001 of the enhancement PBAS0001. In Info Type 0001 if the employee subgroup is “1A” then the payroll area entered should be only “01”. .Reporting in HR Here we are having three methods viz: BEFORE_OUTPUT (PBO) . For Example. Let us how can we implement this using BADI. AFTER_INPUT (PAI) . Obviously. we have to write the code in the method “AFTER_INPUT”. IN_UPDATE (While Saving the Infotype) We can write our code inside any of the methods depending upon the requirement.Equivalent to EXIT_SAPFP50M_002 of the enhancement PBAS0001.

IF p0001-persk = '1A' AND p0001-abkrs NE '01'. MESSAGE e000(fv) WITH 'Only payroll area 01 is allowed' ' for emp subgroup 1A’. WHEN '0001'. p0001 = new_innnn. CASE new_innnn-infty. ENDIF. ENDCASE. DATA p0001 TYPE p0001. .Reporting in HR The code is as follows: METHOD if_ex_hrpad00infty~after_input. ENDMETHOD.

Screen with signature option . we can use the “Signature” button in the application toolbar.Reporting in HR For viewing the parameters which can be accessed inside the method.

Reporting in HR Screen without signature option .

For activating. We will get a message “BAdI implementation ZRAJESH_P_NAIR_INFTY has been activated!” upon activation. Now the final step is activating the BAdI. we can go to the transaction SE19 and enter the implementation name as ZRAJESH_P_NAIR_INFTY and click on the activate icon in the application toolbar. . As discussed earlier. we can deactivate it. If we do not want the existing active implementation. ours is a multiple use BAdI that means the activation of our implementation will not affect the existing active implementations.Reporting in HR Activating the BAdI: So far we have identified the BAdI definition created our own implementation and written our own code.

Reporting in HR .

. Now let us see how this is affected in PA30 transaction for Info Type 0001. but if we want to activate it again we need the access key.Reporting in HR You can even do the activation of the implementation from the BAdI definition itself. then we can deactivate it easily. Note: If the active implementation is of standard SAP.

Enter the Personnel Number as 92510(Example).Reporting in HR Now let us see how this is affected in PA30 transaction for Info Type 0001. . Go to Transaction PA30.

Reporting in HR Click on change icon and goto the next screen. . Enter the payroll area as W0.

Reporting in HR Now we will get the error message as follows: .

enter the implementation name as ZRAJESH_P_NAIR_INFTY. we can go to the transaction SE19. . and click on the Deactivate icon in the application toolbar.Reporting in HR De-activating the BAdI: For de-activating.

.Reporting in HR We will get a message “BAdI implementation ZRAJESH_P_NAIR_INFTY has been deactivated!” upon deactivation.

Authorization Objects in HR All the HR related Authorization objects are included in the Authorization Class HR. . Goto SU21 transaction select the authorization class HR (Human Resources) and it will list all the authorization objects associated with it.

Reporting in HR .

.Authorization Objects in HR Some of the important HR authorization Objects are described below: Object: PLOG Personnel Planning Fields: PLVAR Plan Version OTYPE Object Type INFOTYP Infotype SUBTYP Subtype ISTAT Planning Status PPFCODE Function Code Definition: The present object is used by the authorization check for PD data.

Consequently. Relationships are special subtypes for infotype 1001. only Display is allowed. which infotypes.Object type This field defines which object types the user may access. that is. The possible values are defined in table T77FC.Planning status This field determines in which planning status the user may access information. Consequently. Two types of function codes are distinguished in HR management. Without this authorization. OKCODE . you can only display structures. Change ) the user is authorized. the relationships for which a user should have access authorization can also be limited in this field. INFOTYP . Otherwise. .Infotype This field defines.Authorization Objects in HR Field Details: PLVAR .Plan version This field defines which plan version(s) the user may access. attributes. SUBTYP . with which objects may be maintained within the structure. authorization profiles can be indicated which are to have maintenance authorization for the structure. the overall authorization results from the intersection between basis authorization and structural authorization.Function code This field defines for which type of information processing (Display. By marking the processing method Maintenance in table T77FC the function codes are indicated.Subtype This field determines which subtypes the user may access for given infotypes. ISTAT_D . OTYPE . This protection against unauthorized access is extended by the structural authorization check. of an object the users (generally) may access. The function code has effects in connection with the structural authorization. In table T77PR.

Authorization Objects in HR Object: P_ABAP HR: Reporting Fields: REPID ABAP Program Name COARS Degree of simplification for authorization check Definition: The authorization object HR reporting (P_ABAP) is used in many ways: HR Reporting with HR Reporting are reports with the SAPDBPNP logical database PNP . This can be useful for functional reasons or to improve performance at runtime of the corresponding reports. you can carry out a fine-tuned control on reports for infotype authorization. specify the report name(s) and the degree of simplification to be used for the authorization check. P_ORGXX HR: Master data . For this object. . Report: RPUAUD00 Logged changes in infotype data Processing person-related data using payment medium programs from Accounting. To 1.extended check (P_ORGXX) are used in specified reports to check the authorization for INFTY HR infotypes . In this way. You can use the relevant authorization for these objects to control how the objects P_ORGIN HR: Master data (P_ORGIN).

with the result that the authorization checks are weakened or completely switched off. Object HR: Master data (P_ORGIN) Fields are: INFTY Infotype SUBTY Subtype AUTHC Authorization level PERSA Personnel Area PERSG Employee Group PERSK Employee Subgroup VDSK1 Organizational Key . overrides the HR infotype authorization check for selected reports.Authorization Objects in HR Note: HR: Reporting . however.

Authorization Objects in HR Object: P_ORGXX HR: Master Data .Extended Check Fields: INFTY Infotype SUBTY Subtype AUTHC Authorization level SACHA Payroll Administrator SACHP Administrator for HR Master Data SACHZ Administrator for Time Recording SBMOD Administrator Group Definition: The object HR: Master data .Extended check (P_ORGXX) can be used to check authorization for personal data INFTY (HR infotypes) This check is not active in the standard system. The main switch settings can be processed using transaction HR: Authorization switch (OOAC) . The program switch HR: Master data .Extended check (ORGXX) can be used to add this check in the standard system or set it as an alternative to P_ORGIN HR: master data .

The values which can be entered here are R (read).Authorization Objects in HR Object: P_PCLX HR: Clusters Fields: RELID Area identifier for cluster in tables PCLx AUTHC Authorization level Definition: This object is used in the authorization check when accessing PCLx (x = 1. 3. Authorization level: in this field you must specify the operation to be carried out on the cluster along with the cluster ID specified above. . Field Details: Cluster ID: enter the cluster name in this field. U (update database) and S (export data to PCLx buffer without database update). 2.4) HR files using the PCLx buffer (interface supported by HR).