HR Programming

download HR Programming

of 81

Transcript of HR Programming

  • 7/30/2019 HR Programming

    1/81

    1

    HH 33 5050RR

    Programming in HR

  • 7/30/2019 HR Programming

    2/81

    2

    Content

    1) ABAP Programming v/s HR

    Programming.

    2) Logical Database PNP.

    3) Views Join and PROJECTION.

    4) Specific Commands.

    5) Authorization Check.

  • 7/30/2019 HR Programming

    3/81

    3

    6) Time Data.

    7) Repetitive Structure and List Display.

    8) Exporting/Importing DB Tables in HR.

    9) HR ABAP Features.

    Content

  • 7/30/2019 HR Programming

    4/81

    4

    1) ABAP Programming v/s

    HR Programming

  • 7/30/2019 HR Programming

    5/81

    5

    Storage and accessing of data.

    Use of the logical Database extensively.

    Use of Macros.

    Use of Info types to enter and store data.

    Use of Authorization Checks.

    ABAP Programming v/s HR

    Programming

  • 7/30/2019 HR Programming

    6/81

    6

    The INFOTYPE

    An Info type is just another way tohandle/store data.

    HR Data is huge and to enable easy data entry

    the concept of an Info type took birth.

  • 7/30/2019 HR Programming

    7/81

    7

    The existence of an Infotype implies that aninternal table (system defined) and adatabase table of same structure exist!.

    Infotype 0001 (Org. Assignment).

    Infotype 0002 (Personal Data).

    Infotype 0003 (Payroll Status).

    HR Time Record: Infotype 2010. (EmployeeRemuneration Info.).

    The INFOTYPE

  • 7/30/2019 HR Programming

    8/81

    8

    2) Logical Database PNP

  • 7/30/2019 HR Programming

    9/81

    9

    Logical Structure and DB Tables in

    PA

    Logical StructuresPnnnn: Key fields and Data fields.

    Psnnnn.

    Qnnnn : Special Screen fields.

    Database Tables

    PAnnnn : Data Records PA.

    PBnnnn: Data Records PB.

    PCLn: Data Clusters E.g. Time Management,Travel Management, Payroll.

  • 7/30/2019 HR Programming

    10/81

    10

    Structure for screen fields

    Fields for every Infotype (Header lines) arestored in RP50M.

    Additional Screen fields are stored in Qnnnnstructure.

    An employees form of Address is stored inP0002-ANRED with a numeric key.

    Additional field Q0002-ANREX is provided tostore the displayed and entered fields not itsnumeric key.

  • 7/30/2019 HR Programming

    11/81

    11

    Data Retrieval

    When you run your report, the logicaldatabase loads the personnel data for eachemployee into the main memory and makes itavailable for processing.

    The entire history of each info type is loadedinto the main memory, that is all info typerecords from the lowest to highest systemdate.

  • 7/30/2019 HR Programming

    12/81

  • 7/30/2019 HR Programming

    13/81

    13

    Authorization Checks

    The logical database executes an authorizationcheck for personnel data.

    It checks whether the master record of the

    user who starts the report contains theauthorizations for the data that is to be read inthe report.

    A distinction is made between a personnel anda data authorization.

  • 7/30/2019 HR Programming

    14/81

    14

    The system first checks whether the userhas an authorization for the employee inaccordance with the criteria of organizationalassignment. Employees for which the user

    has no authorization are not evaluated.

    The system then checks whether the user isauthorized to process the info types of the

    specified report. A list would be meaninglessif the data were not evaluated completely.

    Authorization Checks

  • 7/30/2019 HR Programming

    15/81

    15

    Screening Criteria

    Two types:

    Person Selection.

    Data Selection.

  • 7/30/2019 HR Programming

    16/81

    16

    Person Selection: Specifies those employeesfor whom the report is to be run.

    Selected by Personnel Number Range, OrgAssignment, Status, etc.

    Selected Employees are processed inascending order according to personnelnumber.

    Screening Criteria

  • 7/30/2019 HR Programming

    17/81

    17

    In the data selection field, you can define theperiod for which info type data is to beevaluated.

    Although the entire info type history isloaded into the main memory during dataretrieval, the system processes only those infotype records which either partly or completelyare within the data selection period.

    Screening Criteria

  • 7/30/2019 HR Programming

    18/81

    18

    Report Class

    Since the required selection criteria dependon the report, you must define the scope ofthe selection screen.

    You can do this by assigning the report to areport class.

  • 7/30/2019 HR Programming

    19/81

    19

    Assigning a report class can help inchanging the LDB selection screen.

    In Program Attributes Screen we useEDIT-HR Report Class while using thePNP database.

    Report Class

  • 7/30/2019 HR Programming

    20/81

    20

    Report Class assignments are stored intables T500B (Customer Class) andT599W(SAP Classes).

    If no report Class is assigned to a report,default report classes are used fromT599C(Customer) and T599F(SAP DefaultClass).

    Report Class

  • 7/30/2019 HR Programming

    21/81

    21

    E.g.The time evaluation report RPTIME00is assigned the report class __0001.

    The personnel number and Matchcodefunction key are the only permissibleselection criteria in this report class.

    Report Class

  • 7/30/2019 HR Programming

    22/81

    22

    The report RPDEDTx0 (editing of payrollresults;x is the country grouping) isassigned the report class X_M00002.

    The active selection criteria of this reportareperiod defined/payroll area,personnelnumberandpayroll area.

    Report Class

  • 7/30/2019 HR Programming

    23/81

    23

    The GET PERNR Event

    This event fills the data structures ofdeclared infotypes with all the recordsthat exist for a particular personnelnumber .

    The check select-options command.

  • 7/30/2019 HR Programming

    24/81

    24

    Processing the Infotype structures

    Infotype structures are internal tablesthat are processed using a PROVIDE-ENDPROVIDE loop.

  • 7/30/2019 HR Programming

    25/81

    25

    Flow control for LDB

    IMG enables you to determine the typeof data selection for your own reports.

    Options available for online and BatchProcessing.

    Opt 1: Selection fields of LDBforwarded directly to the database.

    Opt 2: Array fetch Active.

    Opt 3: A combination of opt1 and opt2.

  • 7/30/2019 HR Programming

    26/81

    26

    Flow control for LDB

  • 7/30/2019 HR Programming

    27/81

    27

    Example of an HR report

    REPORT ZTEST_HR1.TABLES: PERNR.INFOTYPES: 0001.GET PERNR.PROVIDE * FROM P0001

    BETWEEN PNPBEGDA AND PNPENDDA.WRITE: / P0001-PERNR,

    P0001-ENAME,P0001-BEGDA,P0001-ENDDA.

    ENDPROVIDE.

  • 7/30/2019 HR Programming

    28/81

    28

    3) Views Join and

    PROJECTION

  • 7/30/2019 HR Programming

    29/81

    29

    JOIN

    Personal Data:JAN 1960 MAY 1993 ABCD

    MAY 1993 DEC 1993 EFGH

    Address DataJAN 1993 DEC 1993 BOMBAY

    Result of JoinJAN 1960 DEC 1992 ABCD

    JAN 1993 APR 1993 ABCD/Bomb

    MAY 1993 DEC 1993 EFGH/Bomb

  • 7/30/2019 HR Programming

    30/81

    30

    Join and Time Constraint

    Time Constraint of an Infotype have an effecton JOIN.

    SE38: Utilities

    Help On.

    Table T591A.

    JOINS are only possible for info types withtime constraint 1 or 2.

  • 7/30/2019 HR Programming

    31/81

    31

    PROVIDE * FROM P0002FROM P0006

    FROM PNNNN

    BETWEEN PN/BEGDA &

    PN/ENDDA.

    -------------

    -------------

    ENDPROVIDE.

    JOIN

  • 7/30/2019 HR Programming

    32/81

    32

    Each Infotype can be processedindividually or several infotypes can beprocessed simultaneously.

    Join takes into account the validityperiod of the data.

    JOIN

  • 7/30/2019 HR Programming

    33/81

    33

    Personnel data is valid only for aparticular time period.

    JOIN represents one or more validityperiods during which that data of boththe infotypes is valid.

    JOIN

  • 7/30/2019 HR Programming

    34/81

    34

    Any number of infotypes can be combinedin a JOIN.

    Data to be JOINED must be UNIQUE for

    the validity period i.e. the time periods ofthe Infotype records should not overlap.To further obviate this problem theInfotype must be read using a sub-type.

    JOIN

  • 7/30/2019 HR Programming

    35/81

    35

    REPORT ZTEST_HR2.TABLES: PERNR.

    INFOTYPES: 0001, 0006.

    GET PERNR.PROVIDE * FROM P0001

    * FROM P0006

    BETWEEN PN/BEGDA AND PN/ENDDAWHERE P0006-SUBTY eq 1.

    JOIN

  • 7/30/2019 HR Programming

    36/81

    36

    WRITE: / PERNR-PERNR, P0001-STELL,P0006-STRAS, P0006-BE GDA,P0006-ENDDA.

    ENDPROVIDE.

    JOIN

  • 7/30/2019 HR Programming

    37/81

    37

    Sometimes no data is available for aparticular Info type in the selectedpartial period.

    Infotype validity periods may notoverlap but gaps are permitted.

    For example, gaps can occur whenpersonal data is joined with addressdata:

    JOIN

  • 7/30/2019 HR Programming

    38/81

    38

    REPORT ZTEST_HR3.TABLES: PERNR.

    INFOTYPES: 0002,0006

    GET PERNR.PROVIDE * FROM P0002

    * FROM P0006 BETWEEN PN/BEGDA ANDPN/ENDDA

    WHERE P0006-SUBTY = 1.

    Variable Pnnnn_Valid

  • 7/30/2019 HR Programming

    39/81

    39

    IF P0006_VALID EQ X.WRITE: / PERNR-PERNR,

    P0002-BEGDA DD/MM/YYYY,

    P0002-ENDDA DD/MM/YYYY,

    P0002-NACHN, P0006-ORT01.

    ENDIF.

    ENDPROVIDE.

    Variable Pnnnn_Valid

  • 7/30/2019 HR Programming

    40/81

    40

    PROJECTION

    Selecting one or more infotype fieldsfor processing is called Projection.

    The process of combining data

    records during projection is calledcontraction.

    Projection is only allowed for timeconstraints 1 and 2.

  • 7/30/2019 HR Programming

    41/81

    41

    PROJECTION

    REPORT ZTEST_HR.TABLES: PERNR.INFOTYPES: 0001, 0006.

    GET PERNR.PROVIDE STELL FROM P0001

    BETWEEN PNPBEGDA ANDPNPENDDA.ENDPROVIDE.

  • 7/30/2019 HR Programming

    42/81

    42

    4) SPECIFIC COMMANDS

  • 7/30/2019 HR Programming

    43/81

    43

    Like Subroutines and Function modulesMacros can be used to modularize codes.

    They are in TRMAC Table.

    The first two letters are the application andthe rest are freely assigned.

    RMAC - MACROS

  • 7/30/2019 HR Programming

    44/81

    44

    To access only the first or last records.

    RP-PROVIDE-FROM-LAST PNNN SPACE BEGDA

    ENDDA.

    RP-PROVIDE-FROM-FIRST PNNN SPACEBEGDA ENDDA.

    Parameters: Info type, Sub type, Begin dateand End date.

    Processing A Specific Infotype Record

  • 7/30/2019 HR Programming

    45/81

    45

    Macros are defined in program SAPDBPNP( Include DBPNPMAC() using the DEFINEKeyword.

    They are only available for programs that useLDB PNP.

    Processing A Specific Infotype Record

  • 7/30/2019 HR Programming

    46/81

    46

    Reading the Personnel Area/Subarea

    Table

    It is often necessary to read the groupingsstored in Personnel Area/ Subarea becausethey are required as keys for other tables.

    RP-READ-T001P P0001 P0001-WERKS P0001-BTRTL SPACE.

    SPACE = SY-SUBRC is set to 4.

  • 7/30/2019 HR Programming

    47/81

    47

    Changing Infotypes

    RP-UPDATE macro update the database.

    RP-UPDATE OLD NEW.

    Parameters: Old Internal Table, NewInternal Table.

    This macro calls the update routine ofHR file.

  • 7/30/2019 HR Programming

    48/81

    48

    Changing Infotypes

    You cant make key changes, whichmeans you cant create or delete data.

    In customer specific info types it may

    be useful to create utilities to changeHR data directly in Database tables.

    To ensure the consistency of the tableentries database changes should alwaysmade with batch reports whichautomatically execute online datachecks.

  • 7/30/2019 HR Programming

    49/81

    49

    Three steps involved in changing Infotypes.

    Select the Info type to be changed.

    Make the required changes and storethe records in an alternative table.

    Changing Infotypes

  • 7/30/2019 HR Programming

    50/81

    50

    REPORT ZTEST_HR.TABLES: PERNR.INFOTYPES: nnnn NAME OLD

    nnnn NAME NEW.

    GET PERNR.PROVIDE * FROM OLD..

    NEW = OLD.

    Changing Infotypes

  • 7/30/2019 HR Programming

    51/81

    51

    APPEND NEW.

    ENDPROVIDE.

    RP-UPDATE OLD NEW.

    Changing Infotypes

  • 7/30/2019 HR Programming

    52/81

    52

    Reading IT without LDB

    The Function Module HR_READ_INFOTYPErecords for a person. Values are returnedin an internal table.

    Function Module performs anauthorization check.

    The Return codes have the followingvalues: 0, 4, 8, 12.

  • 7/30/2019 HR Programming

    53/81

    53

    Reading IT without LDB

    REPORT ZTEST_HR6.INFOTYPES: 0002.

    CALL FUNCTION HR_READ_INFOTYPE

    EXPORTINGPERNR =

    INFTY =

    BEGDA=

    ENDDA=

  • 7/30/2019 HR Programming

    54/81

    54

    Reading IT without LDB

    IMPORTING

    SUBRC =

    TABLES

    INFTY_TAB = P0002

    EXCEPTIONS

    INFTY_NOT_FOUND = 1

    OTHERS = 2.

  • 7/30/2019 HR Programming

    55/81

    55

    5) Authorization Checks

  • 7/30/2019 HR Programming

    56/81

    56

    Checks if a person starting the report hasthe required authorizations.

    LDB does this check automatically.

    HR makes a distinction between two typesof authorization , one for person and

    another for data.

    Authorization Checks

  • 7/30/2019 HR Programming

    57/81

    57

    Authorization for Persons

    Checks if a person starting the report hasthe required authorizations.

    Employees for whom the user has noauthorization are skipped and then listed atthe end of evaluation.

  • 7/30/2019 HR Programming

    58/81

    58

    Authorization for DATA

    Checks if a person have all theauthorizations required for all of the infotypes used in the evaluation.

    If the user has no authorization for aparticular Info type, the evaluation iscanceled and an error message displayed.

  • 7/30/2019 HR Programming

    59/81

    59

    Deactivating the Authorization Check

    In certain programs it may be useful todeactivate the authorization check in order toimprove performance.

    For this reason HR Master data object issupplemented by the HR: Reportingauthorization object. If the appropriate

    authorization are available , a simplified andtherefore faster checks take place.

  • 7/30/2019 HR Programming

    60/81

    60

    6) Time Data

  • 7/30/2019 HR Programming

    61/81

    61

    Time Data

    A characteristic of the PROVIDE is that theValidity period of IT records is restricted to thedata selection period on the selection screen.

    Time data IT 2001 is determined on the basisof the validity period.

    The number of Absence days is calculated onthe basis of absence period.

  • 7/30/2019 HR Programming

    62/81

    62

    Time Data

    Since the data depends on the validity period ,time infotypes leads to incorrect data.

    PROVIDE statement is not used for timeinfotypes ( 2000- 2099).

  • 7/30/2019 HR Programming

    63/81

    63

    Time Data

    A principle of the LDB is that all of the ITrecords between the lowest to highest systemdates are read when GET PERNR event occurs.

    Bad performance issues because of memoryproblem while reading large time data.

  • 7/30/2019 HR Programming

    64/81

    64

    Time Data

    To control this MODE N is assigned whiledeclaring the time Infotypes.

    RP_READ_ALL_TIME_ITY.

  • 7/30/2019 HR Programming

    65/81

    65

    7) Repetitive Structure and

    List Display

  • 7/30/2019 HR Programming

    66/81

    66

    Repetitive Structure

    On some infotype entry screens like leavedata is entered in Tables.

    All of the fields in this table structure arenamed and defined in the Infotype structureon which they are based.

    Table datas are stored in a linear structure.

  • 7/30/2019 HR Programming

    67/81

    67

    Repetitive Structure

    In some Infotypes data entered in screentables is stored as repeat fields groups onthe database.

    Loop Processing within DO/ENDDO orWHILE/ENDWHILE can be used to transportsuch data block by block to work area, where

    it continues to be processed.

  • 7/30/2019 HR Programming

    68/81

    68

    List Display

    Function Module HR_DISPLAY_BASIC_LIST.

    Used to display single-level lists.

    Maximum no. of column is 20.

  • 7/30/2019 HR Programming

    69/81

    69

    8) Export/Import DB Tables in

    HR

  • 7/30/2019 HR Programming

    70/81

    70

    Database Tables in HR.Pannnn (personnel data),

    PCL1(HR Work Areas),

    PCL2(Acctg Results & Payroll),PCL3(Applicant,

    Tracking Record)PCL4(Documents).

    Export/Import Tables in HR

  • 7/30/2019 HR Programming

    71/81

    71

    Data Clusters have a two character code.

    Each HR subarea has its own cluster and itsown key.

    Data Clusters

  • 7/30/2019 HR Programming

    72/81

    72

    B1(Time Events).

    G1(Group Incentive Wages).

    TX(Infotype Texts).

    PC(Personal Calendar).

    Database Table PCL1

  • 7/30/2019 HR Programming

    73/81

    73

    B2(Time accounting results).

    CD(Cluster Directory).

    RX(Payroll AccountingResults/International).

    Rn(Country Specific Payroll Accounting.

    Database Table PCL2

  • 7/30/2019 HR Programming

    74/81

    74

    EXPORT IMPORT Commands are used

    A Unique KEY ID is required to read orwrite from/to table.

    The field PCLn-RELID stores the basic

    relation type i.e the cluster (RX forpayroll accounting, TE for Travel

    Expenses etc).

    Table Management

  • 7/30/2019 HR Programming

    75/81

    75

    Data definitions of a work area are storedin separate programs.

    Naming convention for these programs is

    RPCnxxy0 ( n = 1 or 2, xx = ClusterName, y = 0 for international).

    The key structure is stored in xx-KEY field

    string. The first component of this fieldstring is PERNR.

    Cluster Definition

  • 7/30/2019 HR Programming

    76/81

    76

    Rp-EXP-Cn-xy. And Rp-IMP-Cn-xy.

    These are the macros which are used forExporting/Importing results from the PCLntables.

    Import/Export with Macros

  • 7/30/2019 HR Programming

    77/81

    77

    9) HR ABAP Features

  • 7/30/2019 HR Programming

    78/81

    78

    HR ABAP Features

    Accessing Reports using Dynamic Action.Table T588Z is a control table thattriggers steps taken when an IT record ismaintained.

    Selection reports for fast entry.

    Reports that are used for fast entry are

    contained in table T588R.

  • 7/30/2019 HR Programming

    79/81

    79

    HR ABAP Features

    Accessing subroutines for specific periods.Table T596F enables you to access varioussubroutines for specific periods in order tosolve a task defined by a symbolic name.

  • 7/30/2019 HR Programming

    80/81

    80

    HR ABAP Features

    Accessing Feature from Reports.PERFORM RE549D USING par1 par2par3 par4.

    Par1 Feature name.

    Par2 Error handling type.

    Par3 Return value.

    Par4 The type of error.

    Eg: RPCPBSRC.

  • 7/30/2019 HR Programming

    81/81

    THANK YOU