technical document on hr programming.pdf

Upload: sutaarson-murugesh

Post on 05-Feb-2018

236 views

Category:

Documents


1 download

TRANSCRIPT

  • 7/21/2019 Technical Document on HR Programming.pdf

    1/100

    Technical Document on HR ProgrammingBy Amar Chintam

  • 7/21/2019 Technical Document on HR Programming.pdf

    2/100

    Programming in Human Resource

    ______________________________________________________________________

    Introduction on SAP HR module-:

    The SAP HR module enables companies to effectively manage information about the

    people in their organization. It is integrated with other SAP modules and externalsystems. From the Organization Management perspective, companies can model a

    business hierarchy, the relationships of employees to various business units and the

    reporting structure among employees. The Personnel Administration (PA) sub module

    helps employers to track employee master data, work schedules, salary and benefits

    information. The Personnel Development(PD) functionality focuses on employees' skills,

    qualifications and career plans. Finally, the Time Evaluation and Payroll sub modules

    process attendance and absences, gross salary and tax calculations, and payments to

    employees and third party vendors.

    Document by:- Amar Chintam2

  • 7/21/2019 Technical Document on HR Programming.pdf

    3/100

    Programming in Human Resource

    ______________________________________________________________________

    What is HR ?

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

    data .

    Organization :

    We can define an organization as an individual enterprise(company or industry) in whichsomeone is leading it and with some departments like HR, Marketing, Finance, R&D etc.

    For any organization employees are the most powerful resource. So to maintain theemployee related data we require one system which ensures accuracy and consistentwithin the organization.

    Why HR is different from other modules ?

    The following concepts are defined in HR which differs this module with other modules

    1. Use of Infotypes

    2. The use of Logical Database

    3. Use of Macros

    4. Storage and Access of data

    5 Authorization checks

    Document by:- Amar Chintam3

  • 7/21/2019 Technical Document on HR Programming.pdf

    4/100

    Programming in Human Resource

    ______________________________________________________________________

    Logical Database:

    The use of logical database is very important in HR ABAP Programming. Being an

    ABAP programmer you may be knowing about Logical Database (LDB). But I will give

    a brief description about the LDB keeping in mind the novice.

    Introduction:

    A logical database is a special ABAP/4 program which combines the contents of certain

    database tables. Using logical databases facilitates the process of reading database tables.

    A logical database is linked to an ABAP report program as one of the program attributes.

    It supplies the report program with a set of hierarchically structured table entries derived

    from different database tables. This saves the developer from having to program the data

    retrieval.For example The HR PA has the logical database PNP. The program behind this

    LDB will be SAPLDBPNP.

    HR Logical Databases:

    In Human Resources (HR), the following logical databases can be used

    1) PNP

    2) PAP

    3) PCH

    Logical Database PNP: Use logical database PNP to report on HR master data. It is

    possible to use logical database PCH( this facility can be used only to access this data,

    but PNP meets such reporting requirements more quickly because it is best suited to the

    task of selecting persons. To use logical database PNP in your program, specify in your

    program attributes. Main functions of the logical database PNP

    Standard Selection screen

    Data Retrieval

    Authorization check

    Document by:- Amar Chintam4

  • 7/21/2019 Technical Document on HR Programming.pdf

    5/100

    Programming in Human Resource

    ______________________________________________________________________

    Standard Selection Screen :

    Date selection

    Date selection delimits the time period for which data is evaluated. GET PERNR

    retrieves all records of the relevant infotypes from the database. When you enter

    a date selection period, the PROVIDE loop retrieves the infotype records whose

    validity period overlaps with at least one day of this period.

    Person selection

    Person selection is the 'true' selection of choosing a group of employees for whom

    the report is to run.

    Sorting Data

    The standard sort sequence lists personnel numbers in ascending order.

    SORT function allows you to sort the report data otherwise. All the sorting fields

    are from infotype 0001.

    Report Class

    You can suppress input fields which are not used on the selection screen by

    assigning a report class to your program.

    If SAP standard delivered report classes do not satisfy your requirements, you

    can create your own report class through the IMG.

    GET PERNR event:

    The GET PERNR event is executed for all personnel numbers where selected on the basis

    of selection screen entries. Data is retrieved at the GET PERNR point. GET PERNR fills

    the internal tables of the infotypes that are declared for each employee using the infotypes

    statement. The time point should be viewed as a loop via the selected personnel numbers.

    Note: PERNR is a data dictionary structure without a database. You must declare this

    structure using the TABLES statement

    Document by:- Amar Chintam5

  • 7/21/2019 Technical Document on HR Programming.pdf

    6/100

    Programming in Human Resource

    ______________________________________________________________________

    Data Retrieval from LDB

    1. Create data structures for infotypes.

    INFOTYPES: 0001, "ORG ASSIGNMENT0002, "PERSONAL DATA0008. "BASIC PAY

    2. Fill data structures with the infotype records.

    Start-of-selection.GET PERNR.

    End-of-selection.

    Read Master Data

    Infotype structures (after GET PERNR) are internal tables loaded with data. The infotype records (selected within the period) are processed sequentially by

    the PROVIDE - ENDPROVIDE loop.

    GET PERNR.PROVIDE * FROM PnnnnBETWEEN PN-BEGDA AND PN-ENDDA

    If Pnnnn-XXXX = ' '. write:/ Pnnnn-XXXX. endif.ENDPROVIDE.

    Period-Related DataAll infotype records are time stamped.

    IT0006 (Address infotype)01/01/1990 12/31/9999 present

    Which record to be read depends on the date selection period specified on theselection screen. PN-BEGDA PN-ENDDA.

    Current DataIT0006 Address - 01/01/1990 12/31/9999 present

    RP-PROVIDE-FROM-LASTretrieves the record which is valid in the data selection

    period.

    For example, pn-begda = '19990931' pn-endda = '99991231'IT0006 subtype 1 is resident addressRP-PROVIDE-FROM-LAST P0006 1 PN-BEGDA PN-ENDDA.

    W e W i l l d i sc u s s a b o u t R e a d m a st e r d a t a u n d e r p r o c e s si n g

    i n f o t y p e s .

    Document by:- Amar Chintam6

  • 7/21/2019 Technical Document on HR Programming.pdf

    7/100

    Programming in Human Resource

    ______________________________________________________________________

    This is the attributes screen of the program. Look at the field Logical database. You needto declare your required logical database at this place. I have declared the LDB as PNP.

    Logical Database PCH: This logical database generally enables you to report on all HR

    infotypes. However, you are advised not to use this logical database unless you want to

    report on Personnel Planning data.

    Logical Database PAP: Logical database PAP enables you to access data from

    Recruitment.

    Document by:- Amar Chintam7

  • 7/21/2019 Technical Document on HR Programming.pdf

    8/100

    Programming in Human Resource

    ______________________________________________________________________

    This is the PNP selection screen. You can customize the selection screen with your own

    fields by change or create to HR report category.

    Document by:- Amar Chintam8

  • 7/21/2019 Technical Document on HR Programming.pdf

    9/100

    Programming in Human Resource

    ______________________________________________________________________

    We are going todiscuss thefollowing areas in HR.

    1) Personnel Administration

    2) Personnel Development

    3) Time Management

    4) Payroll

    Document by:- Amar Chintam9

  • 7/21/2019 Technical Document on HR Programming.pdf

    10/100

    Programming in Human Resource

    ______________________________________________________________________

    Personnel Administration: PA involves administrating employee data, commonly

    referred to Master Data. Master Datacontains all employee data used in HR processing.

    Master Data includes Personal (Eg. address), Organizational (Position description),

    Benefits (Insurance, Pension), Time & Payroll.

    Master Data is stored in Infotypes.Infotypes are tables (for user Data entry screen) that

    contain logically related employee data. Data can be stored for specific periods, which

    includes current and historical.

    Components of PA:

    Personnel Area:represents a division of a company code into subunits. It is an

    organizational entity representing an area within an organization defined by

    specific aspects of personnel administration, time management and payroll.

    Personnel areas are subdivided into personnel subareas. Personnel area is specific

    to HR and is a four character alphanumeric identification. Eg. Personnel area 100

    is for employees in Karnataka, 200 is for Chennai.

    Personnel Subarea: is a further subdivision of Personnel area. It may represent

    geographical locations. Functions include:1. Set groupings for Time Management, so that work schedules, substitution

    and absence and leave types can be setup for individual personnel subareas.

    2. Generate default pay scale type and area for an employee's basic pay.

    3. Define public holiday calendar.

    Employee Groups: divides or groups employees into various categories. Eg.

    Active employees, Retired employees, Contractors. Employee groups are used to

    generate default values for payroll accounting area and basic pay.

    Employee Subgroups:are further differentiated within the employee group. Eg.

    Salaried employees, Hourly employees, Unionized employees, Executives. The

    employee subgroup grouping for the payroll rule allows you to define different

    payroll procedures for different employee subgroups. For eg. you can specify

    whether an employee's pay should be determined on hourly or monthly basis.

    Document by:- Amar Chintam10

  • 7/21/2019 Technical Document on HR Programming.pdf

    11/100

    Programming in Human Resource

    ______________________________________________________________________

    The employee subgroup grouping for the work schedule defines the validity of

    work schedule, and the attendance or absence quota type determines the validity

    of time quotas.

    Document by:- Amar Chintam11

  • 7/21/2019 Technical Document on HR Programming.pdf

    12/100

    Programming in Human Resource

    ______________________________________________________________________

    Infotypes: Infotypes are units of information in the Human Resource System. They are

    used to group data fields together that all relate to the same subject matter. Infotypes

    structure information, and facilitate data entry and time-dependent data storage. From the

    users perspective, infotypes are data entry screens. From the database perspective,

    infotypes are a data structure and a set of data records that belong together. The ability to

    create histories for infotypes is ensured by time-dependent infotype storage. The system

    records a validity period for each infotype record. Each infotype entered for an employee

    usually has several data records that are distinguished one from the other by their validity

    periods.

    Time constraints: Enable you to determine how the validity periods of infotype data

    records interact:

    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.

    Time constraint 2:No more than one valid data record of the infotype in question

    can exist at any one time.

    Time constraint 3:Any number of valid data records of the infotype in question

    can exist at any one time.

    The prerequisites for the existence of a personnel or applicant number are infotypes 0000

    Actions, 0001 Organizational Assignment, 0002 Personal Data, and 0003 Payroll Status.

    Document by:- Amar Chintam12

  • 7/21/2019 Technical Document on HR Programming.pdf

    13/100

    Programming in Human Resource

    ______________________________________________________________________

    One physical table is stored on the database for each 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; nnnn stands for the infotype

    number:

    PAnnnn for transparent tables in Personnel Administration

    PBnnnn for transparent tables inRecruitment

    HRPnnnn for transparent tables in Personnel Planning

    Document by:- Amar Chintam13

  • 7/21/2019 Technical Document on HR Programming.pdf

    14/100

    Programming in Human Resource

    ______________________________________________________________________

    The primary key of transparent table PAnnnn consists of the following key fields:

    PERNR: the personnel number is the only unique key within a client for

    identifying an employee. It is used to access the display and maintenance screens

    for an employees master data and working time data (infotypes).

    SUBTY:subtypes are subdivisions of infotypes. An infotypes subtypes can have

    different time constraints and form their own histories.

    OBJPS: the object identification is used to make a distinction between records

    with the same infotype, subtype, lock indicator, start date, and end date. For

    example, the child number in infotype 0021 Family/Related Person.

    SPRPS:the lock indicator for HR master data is used to lock and unlock data

    records, which enables the double verification principle to be put into practice.

    In accordance with this principle, at least two users are involved in the process of

    writing an active data record to the database. One of the users creates a locked

    infotype record, and the other user unlocks - that is, activates - the data record.

    ENDDA:end date.

    BEGDA:start date.

    Document by:- Amar Chintam14

  • 7/21/2019 Technical Document on HR Programming.pdf

    15/100

    Programming in Human Resource

    ______________________________________________________________________

    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, it is

    assigned by the system automatically.

    Table T777D Infotypes - Dialog/Database Assignment is the central check table

    (domain INFOTYP) for all HR infotypes (Administration and Planning

    infotypes). It is used to store the names of all infotype-dependent repository

    objects (tables, structures, programs, and so on).

    Table T77ID Infotypes: Enhancements to T777D is simply an enhancement of

    table T777D that exists for reasons of memory space.

    Table T582AInfotypes - Customer-Specific Settings is used for customer settings

    in Administration infotypes.

    Table T77CDInfotypes - Customer-Specific Settings is used for customer settings

    in Planning infotypes.

    Document by:- Amar Chintam15

  • 7/21/2019 Technical Document on HR Programming.pdf

    16/100

    Programming in Human Resource

    ______________________________________________________________________

    INFOTYPE PROCESSING:

    After the Event GET PERNRpoint, the internal tables of the infotypes contain records

    and ready for processing.

    *Provide statementPROVIDE * from pnnnn between PN-BEGDA and PN-ENDDA.

    Write: / pnnnn-.ENDPROVIDE

    Pnnnn stands for internal table for infotype nnnn. It is similar to normal

    select statement.

    PROCESING A SPECIFIC INFOTYPE RECORD:

    RP-PROVIDE-FROM-LAST Pnnnn SPACE PN-BEGDA PN-ENDDA.

    RP-PROVIDE-FROM-FRST Pnnnn SPACE PN-BEGDA PN-ENDDA.

    These statements make the newest or oldest record in the PN-BEGDA to PN-ENDDAdata selecting period available in the structure Pnnnn for infotype nnnn.

    STANADARD HR PROGRAM STEPS:Attach PNPLogical Database name in Attributes.Declare PERNRstructure in tables.Includes if required.Selection-screen formatting.Start-of-Selection.

    ...required Validations.GET PERNR Event starts here

    Perform retrievePerform Populate..All Performs

    END-OF-SELECTION event ends hereWrite/Download.

    Document by:- Amar Chintam16

  • 7/21/2019 Technical Document on HR Programming.pdf

    17/100

    Programming in Human Resource

    ______________________________________________________________________

    Using the logical database and reading master data.

    Look at theexample below

    Suppose you want to create a report which generates a list of employees with the

    following information

    Personnel number Name Language Date of birth

    REPORT zamar.*-- DeclarationTABLES: pernr.INFOTYPES: 0002. "Personal DataSELECT-OPTIONS: language FOR p0002-sprsl.

    *-- Selection screenINITIALIZATION.pnptimed = 'D'.

    *-- ProcessingGET pernr.

    PROVIDE * FROM p0002 BETWEEN pn-begda AND pn-endda.CHECK language.WRITE: / p0002-pernr,

    sy-vline,pernr-ename,sy-vline,p0002-sprsl,sy-vline,p0002-gbdat.

    ENDPROVIDE.

    Document by:- Amar Chintam17

  • 7/21/2019 Technical Document on HR Programming.pdf

    18/100

    Programming in Human Resource

    ______________________________________________________________________

    Supposeyou require additional reports that combine data from different infotypesThen you need to join one or more infotypes.

    Any number of infotypes can be linked by a JOIN

    Note that changing data in any one of the infotypes linked by a join causes a

    split in the selection period.

    Document by:- Amar Chintam18

  • 7/21/2019 Technical Document on HR Programming.pdf

    19/100

    Programming in Human Resource

    ______________________________________________________________________

    If infotypes linked by a JOIN have subtypes, processing must be restricted to onesubtype using a WHERE condition, in which a subtype is queried.

    In this example, the first partial interval only contains personal data. The record isnot meaningful because the join's task of retrieving data from all of the infotypesin question has not been performed.

    Using variable Pnnnn_VALID, the system recognizes that one partial interval

    only contains incomplete data. When the report is run, this variable is created for each Pnnnn infotype included

    in a join.

    If a partial interval for infotype Pnnnn contains data, its Pnnnn_VALID variableis filledwith X.

    Document by:- Amar Chintam19

  • 7/21/2019 Technical Document on HR Programming.pdf

    20/100

    Programming in Human Resource

    ______________________________________________________________________

    The * in the PROVIDE statement, which stands for all of the fields in theinfotype, is replaced by the five-digit field name of the infotype included in theprojection.

    The * in a simple PROVIDE means that all of the fields in the infotype are

    included in the projection. JOIN and PROJECTION can be combined in a PROVIDE statement.

    Infotype records are not allowed to overlap for projection. Data must be unique,which means that projection is only allowed for time constraints 1 and 2.

    The logical validity of the activity period is stored in the infotype's BEGDA andENDDA fields.

    Document by:- Amar Chintam20

  • 7/21/2019 Technical Document on HR Programming.pdf

    21/100

    Programming in Human Resource

    ______________________________________________________________________

    Join and Projection Joining Infotypes

    Look at theexample below

    At the end of this exercise, you will be able to:

    Process the Personal Data infotype (0002) and Addresses infotype (0006) using aJOIN.

    Make the processing of data dependent on the content of variable Pnnnn_VALID.

    Suppose you want to create a report in which period the employee lived at which addressunder which name. The created list should contain the following information:

    Start date

    End date

    Name

    Place of residence

    Only process the records from Infotype 0006 which have subtype 1.

    Only print data for the periods for which address information is available.

    Use a variable with the characteristics of field P0001-ENAME, so that the firstand last name are only separated by one space. Use the statementCONCATENATE.

    Enter a width of 100 characters for the list (addition LINE-SIZEfor keywordREPORT).Restrict the length of the name to 30, and the length of the city to 20characters.Separate the resulting field contents in your list by a vertical line (SY-VLINE).

    REPORT zpamar1 LINE-SIZE 100.*-- declarationTABLES: pernr.INFOTYPES: 0002, "Personal Data

    0006. "AddressDATA: name LIKE p0001-ename.

    *-- ProcessingGET pernr.

    Document by:- Amar Chintam21

  • 7/21/2019 Technical Document on HR Programming.pdf

    22/100

    Programming in Human Resource

    ______________________________________________________________________

    PROVIDE * FROM p0002* FROM p0006 BETWEEN pn-begda AND pn-enddaWHERE p0006-subty = '1'.

    IF p0006_valid EQ 'X'.CONCATENATE p0002-nachn p0002-vorna INTO nameSEPARATED BY SPACE.PERFORM print_data.

    ENDIF.ENDPROVIDE.

    *-------------------------------------------------------------** FORM PRINT_DATA

    rint_data.

    *-------------------------------------------------------------*FORM p WRITE: / p0002-pernr NO-ZERO,

    sy-vline,p0002-begda,sy-vline,p0002-endda,sy-vline,(30) name,sy-vline,(20) p0006-ort01.

    ENDFORM.

    Document by:- Amar Chintam22

  • 7/21/2019 Technical Document on HR Programming.pdf

    23/100

    Programming in Human Resource

    ______________________________________________________________________

    Join and Projection Projection to Infotype Fields

    Look at theexample below

    At the end of this exercise, you will be able to:

    Project to particular fields by joining two infotypes.

    Read texts from time-dependent table entries.

    Suppose you want to create a report which documents how an employees job hasdeveloped. The created list should contain the following information:

    Name Date of birth Start date End date Job key Job title

    Project to the fields P0001-STELLand P0001-ENAMEfor infotype 0001.Project to field P0002-GBDATfor infotype 0002.

    Only print data for the periods in which organizational assignment informationis available.

    Before reading table T513S, check that the table entry to be read for the jobkey in question is already in the work area. To do this, use the statementCHECK.If the required table entry does not exist, print the personnel number, an errortext, and the job key text.End further processing with the REJECTstatement.

    Enter a width of 100 characters for the list (addition LINE-SIZEfor keywordREPORT).Restrict the length of the name to 20, and the length of the job title to 15characters.Separate the resulting field contents in your list by a vertical line (SY-VLINE).

    Document by:- Amar Chintam23

  • 7/21/2019 Technical Document on HR Programming.pdf

    24/100

    Programming in Human Resource

    ______________________________________________________________________

    REPORT zpsol030 LINE-SIZE 100.*-- DeclarationTABLES: pernr,

    T513S. "Job TitlesINFOTYPES: 0001, "Organ. Assignment

    0002. "Personal Data

    *-- ProcessingGET pernr.PROVIDE stell ename FROM p0001

    gbdat FROM p0002 BETWEEN pn-begda and pn-endda.

    IF p0001_valid EQ 'X'.IF p0001-stell NE space.PERFORM re513s.WRITE: / pernr-pernr,

    sy-vline,

    (20) p0001-ename,sy-vline,p0002-gbdat,sy-vline,p0001-stell,sy-vline,(15) t513s-stltx,sy-vline,p0001-begda,sy-vline,p0001-endda.

    ENDIF.ENDIF.

    ENDPROVIDE.

    *-------------------------------------------------------------** FORM RE513S*-------------------------------------------------------------** Read Job Title*-----------------------------------------------------------

    --*FORM re513s.CHECK sy-langu NE t513s-sprsl OR

    p0001-stell NE t513s-stell ORp0001-begda LT t513s-begda ORp0001-begda GT t513s-endda.

    SELECT * FROM t513sWHERE sprsl EQ sy-langu

    AND stell EQ p0001-stell

    Document by:- Amar Chintam24

  • 7/21/2019 Technical Document on HR Programming.pdf

    25/100

    Programming in Human Resource

    ______________________________________________________________________

    AND endda GE p0001-begdaAND begda LE p0001-begda.

    ENDSELECT.IF sy-subrc NE 0.CLEAR t513s.WRITE: / pernr-pernr,

    No entry in T513S for job key (001),p0001-stell.

    REJECT.ENDIF.

    ENDFORM.

    Document by:- Amar Chintam25

  • 7/21/2019 Technical Document on HR Programming.pdf

    26/100

    Programming in Human Resource

    ______________________________________________________________________

    HR Macros and Function Modules:

    At the conclusion of this chapteryou will be able to use HR macros and read infotypeswithout using logical database.

    Like subroutines and function modules, macro modules can be used to modularizeprograms. Macro modules are frequently used in HR.

    These macros are defined in program SAPDBPNP (include DBPNPMAC) with thekeyword DEFINE. They can be used in any program that uses the logical databasePNP.

    If you want to use these macros in reports that do not use the logical database PNP,you must include program DBPNPMAC with the keyword INCLUDE.

    You can also define your own macros. In accordance with the naming convention, thefirst two letters stand for the application.

    Some macros are also stored in the Macros in ABAP Programs table (TRMAC)

    Document by:- Amar Chintam26

  • 7/21/2019 Technical Document on HR Programming.pdf

    27/100

    Programming in Human Resource

    ______________________________________________________________________

    The RP_PROVIDE_FROM_LAST macro retrieves the last valid data record in thedata selection period.

    The parameters for RP_PROVIDE_FROM_LAST are: infotype, subtype, start date,

    and end date. If you do not want to specify a particular subtype, enter SPACE.

    You can process not only the last valid data record in the data selection period, butalso the first valid data record using the RP_PROVIDE_FROM_FRST macro.

    The macro return code PNP-SW-FOUND has the value 1 if a suitable entry exists inthe infotype table for the specified period. If no entry is found, the value is 0.

    Document by:- Amar Chintam27

  • 7/21/2019 Technical Document on HR Programming.pdf

    28/100

    Programming in Human Resource

    ______________________________________________________________________

    When the START-OF-SELECTION event occurs, the RP_SET_DATA_INTERVALmacro ensures that the only records imported from database table PAnnnn to internaltable Pnnnn are those which are valid in the data selection period.

    Document by:- Amar Chintam28

  • 7/21/2019 Technical Document on HR Programming.pdf

    29/100

    Programming in Human Resource

    ______________________________________________________________________

    It is often necessary to read the groupings stored in the Personnel Area/Subarea tablebecause they are required as keys for other tables. This must take place individuallyfor each personnel number to be processed.

    Each employee's assignment to a personnel area and subarea is stored in infotype0001.

    The parameters of the macro are:

    Personnel areas

    Personnel subareas

    Reaction, if no entry is found:

    X = Termination of report with error message No entry found in table ...

    SPACE = SY-SUBRC is set to 4.

    Alternatively, if you only want to determine the country indicator, you can use thefunction module HR_COUNTRY_GROUPING_GET.

    Document by:- Amar Chintam29

  • 7/21/2019 Technical Document on HR Programming.pdf

    30/100

    Programming in Human Resource

    ______________________________________________________________________

    You can also read infotype records for a particular personnel number without using

    the logical database. To do this, use the function module HR_READ_INFOTYPE. However, you must

    ensure that the internal table for the required infotype is declared with the INFOTYPEstatement.

    Document by:- Amar Chintam30

  • 7/21/2019 Technical Document on HR Programming.pdf

    31/100

    Programming in Human Resource

    ______________________________________________________________________

    The function module reads the HR infotype records for a person (employee orapplicant) in accordance with the specified selection criteria. Values are returned in aninternal table, the structure of which corresponds to the appropriate infotype table. In

    the calling program, such tables can be declared with the INFOTYPES statement, forexample. An infotype record is selected if its validity period overlaps with thespecified period.

    The function module performs an authorization check.

    The following specifications are possible for the return code:0: The return table contains all required records4: The return table contains all records, however, it is incomplete due tomissing authorization8: The return table is empty because no records were found with thespecified criteria12: The return table is empty due to missing authorization

    Note: You should not use this function module in reports that use the logical databasePNP. If you want to read an infotype separately in one of these reports, you can callthe subroutine READ-INFOTYPE directly in the database program SAPDBPNP(PERFORM READ-INFOTYPE(SAPDBPNP)). . .). If this is the case, you declarethe infotypes in the statement INFOTYPES with supplement MODE N.

    Document by:- Amar Chintam31

  • 7/21/2019 Technical Document on HR Programming.pdf

    32/100

    Programming in Human Resource

    ______________________________________________________________________

    With this function module, you can determine the initial start date of an employee.You can take the following infotypes into account when you determine this date:- P0000 Actions- P0001 Organizational Assignment- P0016 Contract Elements- P0041 Date Specifications

    The transfer parameter CHECK_INFOTYPES is used to determine which of theseinfotypes are taken into account. The employment status (parameter STATUS2) canalso be specified for infotype P0000. In infotype P0016, only the Entry data field(P0016-EINDT) is taken into account. For infotype P0041, the corresponding datetype can be given in the transfer parameter DATUMSART. The date type '01' isusually used for the technical entry date.

    Most function modules in HR have the letters 'HR' or 'RP' in the first two characters oftheir name. To find additional modules, use the search function in the Function

    Builder.

    Document by:- Amar Chintam32

  • 7/21/2019 Technical Document on HR Programming.pdf

    33/100

    Programming in Human Resource

    ______________________________________________________________________

    Before you change employee data, you must lock the personnel number. You can dothis with the function module BAPI_EMPLOYEE_ENQUEUE.

    Messages are returned in the parameter RETURN. If an error occurs, this structurecontains the following information:- Message type (field TYPE)- Message text (fieldMESSAGE).If the step is successful, the structure is blank.

    If an employee's data has been locked, only the user who has locked the data canaccess the data records linked to the employee. For other users, access is denied. Forthis reason, you must remove the lock after the data has been changed. You can dothis with the function module BAPI_EMPLOYEE_DEQUEUE.

    Document by:- Amar Chintam33

  • 7/21/2019 Technical Document on HR Programming.pdf

    34/100

    Programming in Human Resource

    ______________________________________________________________________

    With this function module, you can maintain the employee and applicant master data.You can specify one data record. All validations that would normally take place if the

    infotypes were maintained online with the individual maintenance screens are alsocarried out here. The module returns the same error messages as in the onlineoperation. This means the error messages for the individual maintenance screens aredisplayed rather than interpreted. The update is carried out by a 'Call dialog' to themodule pool for the infotype. This means that some restrictions apply to the infotypesprocessed in that way (see documentation for module).

    The following values are amongst those available for the parameter OPERATION:MOD (change), COPY (copy), DEL (delete), INS (insert), LIS9 (delimit).

    With the parameter DIALOG_MODE, you specify whether the action is generallyrun in the background or whether it only runs in the background until an error occurs,or whether the changes are generally carried out in the dialog mode. Possible

    values:'0' The changes are generally processed in the background. If an error occurs(with an E or A message), the complete step is terminated and the module returns thecorresponding error message in the structure 'RETURN'.'1' The changes are generally processed in the background. If an error occurs, thesystem switches to dialog mode so that the user can correct the entries.'2' The changes are processed in the dialog mode.

    Document by:- Amar Chintam34

  • 7/21/2019 Technical Document on HR Programming.pdf

    35/100

    Programming in Human Resource

    ______________________________________________________________________

    If you cannot use the function module HR_INFOTYPE_OPERATION, you can usethe UPDATE statement. Note that the system does not check the correctness of thenew field contents when a direct DB update takes place.

    In this example, the field P0002-NATIO (nationality) in DB table PA0002 is updated

    directly. The field contents is changed from DE' to D'. The incorrect value 'D' infield PA0002-NATION then triggers an error message when the infotype record ischanged or copied in dialog mode.

    The system field SY-DBCNT contains the number of changed records.

    Authorization checks are not supported by the UPDATE statement and should becarried out on the program level.

    Many HR reports use macros. Their program codes are stored in a table or definedlocally using the DEFINE keyword.

    The RP_PROVIDE_LAST macro writes the last valid record in the data selection

    period to the header line of the internal Infotype table. You can use the function module HR_READ_INFOTYPE to read the personal data

    in reports which do not use an HR logical database.

    Document by:- Amar Chintam35

  • 7/21/2019 Technical Document on HR Programming.pdf

    36/100

    Programming in Human Resource

    ______________________________________________________________________

    Specific Commands Macros

    Look at theexample below

    At the end of this exercise, you will be able to:

    Use the macro RP_PROVIDE_FROM_LAST to retrieve the lastvalid record in the data selection period.

    Use the macro RP-READ-T001P to read the PersonnelArea/Personnel Subarea table.

    Suppose you need to create a report that will generate a list of the recurring payments anddeductions for each employee.The list should contain the following information for each employee:

    Personnel number

    Name

    Personnel area

    Personnel subarea text

    In the following lines, print:

    Wage type

    Wage type text

    Amount

    Start date

    End date

    Employees who have no recurring payments or deductions should notappear on the list. If employees do not have a record for infotype 0014, theinternal table P0014 is empty at the GET PERNR event. Use the keywordDESCRIBEto query the characteristics of this table.

    Document by:- Amar Chintam36

  • 7/21/2019 Technical Document on HR Programming.pdf

    37/100

    Programming in Human Resource

    ______________________________________________________________________

    To place the last infotype 0001 record valid in the data selection period inthe header of internal table P0001, use the macroRP_PROVIDE_FROM_LAST.

    To read table T001P (Personnel Area/Subarea), use the macro RP-READ-T001P. The country indicator is assigned to each personnel area/subareain the field T001P-MOLGA. The country indicator is part of the key fortable T512T (Wage Type Texts). The personnel area text is taken fromfield T001P-BTEXT.

    Read the accompanying wage type texts for the wage types for infotype0014 from table T512T. Before reading table T512T, check that the tableentry to be read is already in the workarea. To do this, use the statementCHECK.Restrict the length of the name to 20 characters.

    REPORT zpamar2 .*-- DeclarationTABLES: pernr,

    t512t, "Wage type textt001p. Plant section

    INFOTYPES: 0001, "Organ. Assignment0014. "Recurr. Earn. &

    Deduc.DATA: filled_lines LIKE sy-index.

    *-- Processing

    GET pernr.DESCRIBE TABLE p0014 LINES filled_lines.IF filled_lines GT 0.rp_provide_from_last p0001 space pn-begda pn-endda.rp-read-t001p p0001-werks p0001-btrtl space.SKIP 2.WRITE: / pernr-pernr,

    (20) p0001-ename,p0001-werks,t001p-btext.

    PROVIDE * FROM p0014 BETWEEN pn-begda AND pn-endda.CHECK p0014-betrg NE 0.

    PERFORM print USINGp0014-lgartp0014-betrgp0014-begdap0014-endda.

    ENDPROVIDE.ENDIF.

    Document by:- Amar Chintam37

  • 7/21/2019 Technical Document on HR Programming.pdf

    38/100

    Programming in Human Resource

    ______________________________________________________________________

    *-------------------------------------------------------------** FORM PRINT*-------------------------------------------------------------** Print List*-------------------------------------------------------------*FORM print USING

    value(wtype)value(amount)value(begda)value(endda).

    PERFORM re512t USING t001p-molga wtype.WRITE: / wtype UNDER p0001-ename,

    T512T-LGTXT,

    amount,begda,endda.

    ENDFORM.

    *-------------------------------------------------------------** FORM RE512T*-------------------------------------------------------------** Read Wage Type Texts*-------------------------------------------------------------*FORM re512t USING value(country_grouping)

    value(wtype).CHECK t512t-sprsl NE sy-langu

    OR t512t-molga NE country_groupingOR t512t-lgart NE wtype.

    SELECT SINGLE * FROM t512tWHERE sprsl EQ sy-langu

    AND molga EQ country_groupingAND lgart EQ wtype.

    IF sy-subrc NE 0.CLEAR t512t.

    ENDIF.ENDFORM.

    Document by:- Amar Chintam38

  • 7/21/2019 Technical Document on HR Programming.pdf

    39/100

    Programming in Human Resource

    ______________________________________________________________________

    Few things need to be known about INFOTYPE:

    An Infotype has an entry in check table T777D, and several infotype-dependent

    elements in the Repository. In addition to the structures and database tables discussed in unit 2 (Data Structures

    in HR), each Infotype has a module pool containing the Infotype-specific entry andlist screens with their validations, and a dialog module.

    When you create individual elements, take careful note of the following:

    Some Infotype-dependent Infotype objects must be processed using the DataDictionary.

    Some Infotype elements must be processed using the Infotype copy functionswithin Personnel Planning and Personnel Administration. These functions havebeen created for this specific purpose.

    Some Infotype-dependent settings must be made using Customizing for

    infotypes. If you follow these instructions, inconsistencies will not affect your Infotype-

    dependent objects and table entries. Creating and enhancing infotypes isdiscussed in more detail later in this unit.

    Document by:- Amar Chintam39

  • 7/21/2019 Technical Document on HR Programming.pdf

    40/100

    Programming in Human Resource

    ______________________________________________________________________

    When working with infotypes, it is important to comply with the above namespaceconventions.

    Other namespace conventions for standard infotypes:

    Time Management infotypes are assigned to namespace 2000-2999

    Recruitment infotypes are assigned to namespace 4000-4999

    There are three different ways of storing customer-specific information in infotypes:

    You can use the fields that already exist in standard infotypes. For example, you can storethe required information in a specific field of a standard infotype that you have not usedbefore.

    You can enhance a standard Infotype, which means creating the fields that you require ina cluster include.

    You can create a new Infotype with the fields that you require.

    Before you enhance standard infotypes or create new infotypes, you should always determinewhether the infotypes included in the standard system meet your requirements.

    Document by:- Amar Chintam40

  • 7/21/2019 Technical Document on HR Programming.pdf

    41/100

    Programming in Human Resource

    ______________________________________________________________________

    Problem: You want to store specific information in the system.

    Procedure: Check all of the standard infotypes to determine whether one of the fields in astandard Infotype can be used to store this information.

    Situation: You find an Infotype that contains a suitable field.

    Procedure: Use this Infotype to store your specific information.

    Example: You want to store the following item of information: position entitled to companycar.

    Use standard Infotype 1010 (Authorities/Resources).

    Note: Information on specific fields is obtained from Infotype-specific structure Pnnnn(or from structure PSnnnn or HRInnnn).

    Document by:- Amar Chintam41

  • 7/21/2019 Technical Document on HR Programming.pdf

    42/100

    Programming in Human Resource

    ______________________________________________________________________

    These are some of the most important HR Infotypes

    0000 Events0001 Org assignment

    0002 Personal info0003 Payroll data0007 Work time0008 Basic pay0014 Reoccurring pay0015 1 X pay0027 Cost Center0041 Event Dates0057 Membership dues0165 Over ride to limits on deductions0167 Health

    0168 Insurance0169 Savings0170 Spending0194 Garnishment reduction0195 Garnishment order0207 Residence Tax0208 Work Tax0209 Unemployment Tax0210 Withholding0216 Garnishment adjustment0221 Adjustment

    0267 Off cycle2005 OT2010 Catts direct to cluster1000 Infotypes 1000 1999 are PD Relationship infotypes

    Document by:- Amar Chintam42

  • 7/21/2019 Technical Document on HR Programming.pdf

    43/100

    Programming in Human Resource

    ______________________________________________________________________

    PD ( Planning and Development) : You can use the Personnel Development

    component to maximize employees utility within your company. You can plan and

    implement specific personnel and training measures to promote the professional

    development of your employees. A companys personnel development needs are

    determined by comparing current or future work requirements with employees

    qualifications, preferences and aspirations.

    Organizational Units: describe the different business areas within yourcompany. Org. Units must exist in a company organization structure and be linkedto one another in order to create a hierarchical structure for your company and alink between the objects. Use transaction PP02 to create Org.Units. Object type'O'. Following is a three level hierarchy. Table HRP1000. One Org. Unit can be

    related to another Org. Unit.

    Jobs:A job is the general classification for a set of tasks. Eg. manager, customerservice representative. Each Job identifies a unique classification of activity.Employees hold positions and not Jobs. Jobs are linked to Positions, which areheld by employees. Equal number of positions should be created for each Job.Use transaction PP02 to create Org.Units. Object type 'C'. Table HRP1000.

    Positions: are specific jobs performed by individuals in a company. Eachposition is occupied by one employee. Eg. HR Manager. Positions not assigned toemployees are known as vacancies.One Position can be assigned to more than one

    person. Eg. the first employee may work 50% and the other will work theremainder 50%. Position belongs to a Job which describes the Position. Usetransaction PP02 to create Org.Units. Object type 'S'. Table HRP1000

    Manager

    HR Manager Accounting Manager

    Relationship between objects:Table HRP1001. Transaction PP02 (Infotype 1001)

    Document by:- Amar Chintam43

  • 7/21/2019 Technical Document on HR Programming.pdf

    44/100

    Programming in Human Resource

    ______________________________________________________________________

    In the Dictionary, each HRPnnnn infotype table is defined using the following three includestructures:

    HRIKEY: contains the key fields of the infotype table

    HRIADMIN: contains administrative information on the infotype record (including thedate on which it was last changed, and the user name of the person who made this lastchange)

    HRInnnn: contains the infotype-specific fields with the actual infotype data or information

    To ensure that transparent table HRPnnnn and logical structure Pnnnn always remainmutually consistent, structure HRInnnn is also included by structure Pnnnn.

    Document by:- Amar Chintam44

  • 7/21/2019 Technical Document on HR Programming.pdf

    45/100

    Programming in Human Resource

    ______________________________________________________________________

    The primary key of transparent table HRPnnnn consists of the following key fields:

    MANDT: legally and organizationally independent participants in the system.

    PLVAR: a one or two-character alphanumeric plan version key that is used to make adistinction between different organizational plans.

    OTYPE: a one or two-character alphanumeric object key (such as S for position, Q forqualification, and E for business event).

    OBJID: an eight-digit, non-mnemonic key that represents a single object (such as anorganizational unit, qualification, or business event).

    SUBTY: subtypes are subdivisions of infotypes. An infotypes subtypes can havedifferent time constraints and form their own histories.

    ISTAT: a one-digit key that stands for a planning status. All objects and their defininginfotypes have a status. This enables you to put objects and infotypes through a planningcycle.

    BEGDA: end date. ENDDA: start date.

    VARYF: variation field of the PLOG file (that contains the target object for relationships).

    SEQNR: the sequential number is used to make a distinction between infotype recordsthat have the same key and time constraint '3' (any number of valid infotype data recordsat any one time). It is assigned by the system automatically.

    Document by:- Amar Chintam45

  • 7/21/2019 Technical Document on HR Programming.pdf

    46/100

    Programming in Human Resource

    ______________________________________________________________________

    Report RHMOVE00 transports Planning data records from the R/3 System to asequential file.

    This sequential dataset can be displayed and edited using report RHMOVE40.

    Report RHALTD00 uses a sequential dataset to create a batch input session. Structure E1Pnnn must be used for records of infotype Pnnnn. This is the IDoc

    segment structure of the infotype.

    Structure E1Pnnnn is expandedfor table infotypes - that is, it contains the primaryrecord and the table division of the table infotype.

    Structure E1PADnn must be used for relationships with additional data ofstructure PADnn. For the assignment, see table T77AD.

    Document by:- Amar Chintam46

  • 7/21/2019 Technical Document on HR Programming.pdf

    47/100

    Programming in Human Resource

    ______________________________________________________________________

    Reporting in PD using PCH Logical database:

    At the end of this chapter , you will be able to: Explain the functions and data structures of logical database PCH Create reports for sequential evalutions of the organizational structure Create reports for structural evalutions of the organizational structure Evaluate additional data on relationships

    Relationships are stored on the database in two directions.

    Document by:- Amar Chintam47

  • 7/21/2019 Technical Document on HR Programming.pdf

    48/100

    Programming in Human Resource

    ______________________________________________________________________

    "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 thejob of secretary.

    A position is the assignment of an individual employee in your enterprise, for example, salesmanager, secretary in the marketing department. You form the structure (organigram) of yourenterprise by creating positions and linking them to each other.

    Document by:- Amar Chintam48

  • 7/21/2019 Technical Document on HR Programming.pdf

    49/100

    Programming in Human Resource

    ______________________________________________________________________

    Positions must be linked to an organizational unit. However, if you want to view theposition hierarchy, you must create a reporting structure by relating positions to eachother.

    An organizational unit can incorporate one or more positions. A position belongs toan organizational unit.

    Example:The organizational unit Personnel incorporates the positions Head of Departmentand Secretary.The position Secretary belongs tothe organizational unit Human Resources.

    Document by:- Amar Chintam49

  • 7/21/2019 Technical Document on HR Programming.pdf

    50/100

    Programming in Human Resource

    ______________________________________________________________________

    If Organizational Management is integrated with master data, the holder relationship betweenposition and person is also stored for the person in the Organizational Assignment infotype(0001), despite the fact that the data is redundant.

    Document by:- Amar Chintam50

  • 7/21/2019 Technical Document on HR Programming.pdf

    51/100

    Programming in Human Resource

    ______________________________________________________________________

    The Objectinfotype performs key functions. It enables you to create new objects, such asorganizational units and jobs, and determines the validity period of other infotypes thatdescribe the characteristics of existing objects.

    Once you have used this infotype to create an object, its characteristics can be describedusing other infotypes such as the RelationshipsInfotype (1001) and the DescriptionInfotype(1002).

    The Object Infotype (1000) defines an object's existence. You can use it to store a short textand a long text on the object.An object is uniquely identified by its:- Plan variant- Object type- Object identification

    Records stored in the RelationshipsInfotype (1001) serve as a descriptive and functional linkbetween objects. For example:

    A person is the holder of a positionA position belongs to an organizational unitAn organizational unit is assigned to a cost center in CO

    Document by:- Amar Chintam51

  • 7/21/2019 Technical Document on HR Programming.pdf

    52/100

    Programming in Human Resource

    ______________________________________________________________________

    The relationships between basic object types are defined in the standard system and shouldnot be changed.

    Each standard relationship has a three-digit code. The customer namespace is from AAA toZZZ.

    Relationships between objects are reciprocal. If a job describes a position, for example, thenthe position is described by the job. When you assign a relationship, the system automaticallycreates its inverse relationship. This enables you to carry out reporting from eitherperspective.

    Document by:- Amar Chintam52

  • 7/21/2019 Technical Document on HR Programming.pdf

    53/100

    Programming in Human Resource

    ______________________________________________________________________

    The Pnnnn structure contains an infotype's key fields and data fields.

    The PTnnnn structure contains the table infotype data fields for some infotypes.

    The PADnn structure defines additional data for particular relationships.

    The transparent HRPnnnn tables contain the infotypes used in Personnel Planning. Tableinfotypes are stored in the HRTnnnn tables. Additional data on relationships is stored in theHRPADnntables.

    Transparent table PLOGIcontains an index of all objects on the Personnel Planning database.They can be displayed and created with report RHPLOGI0. This object directory is the basisof all evaluations using logical database PCH.

    Document by:- Amar Chintam53

  • 7/21/2019 Technical Document on HR Programming.pdf

    54/100

    Programming in Human Resource

    ______________________________________________________________________

    For each selected object, internal table Pnnnnis filled per infotype with all available infotyperecords.

    The infotypes from Personnel Administration can also be imported.

    Document by:- Amar Chintam54

  • 7/21/2019 Technical Document on HR Programming.pdf

    55/100

    Programming in Human Resource

    ______________________________________________________________________

    The only difference between a structural and sequential evaluation is the additional GDSTRentry in the TABLES statement. This ensures that the structure parameters are shown on thestandard selection screen.

    Note:If you do not specify an evaluation path before starting the program, a sequential evaluationis performed.

    Document by:- Amar Chintam55

  • 7/21/2019 Technical Document on HR Programming.pdf

    56/100

    Programming in Human Resource

    ______________________________________________________________________

    When the INITIALIZATIONevent occurs, you can set default values for the selectionscreen.

    The fields for the object ID are defined in include DBPCHSEL.This is an internal table(PCHOBJID) that must be filled with APPEND.

    Document by:- Amar Chintam56

  • 7/21/2019 Technical Document on HR Programming.pdf

    57/100

    Programming in Human Resource

    ______________________________________________________________________

    For each selected object, internal table Pnnnn is filled per infotype with all available infotyperecords.

    For each selected object, the OBJEC structure contains the most important information frominfotype 1000 (plan version, object type, object ID, short text, and long text).

    The GDSTR structure contains information on the current hierarchy, such as the root objectand the number of objects within the hierarchy. The value of the structure does not changeunless the system reaches a new hierarchy root when a structural evaluation is performed formore than one root object.

    For each selected object, the STRUC structure contains internal structure information. Inparticular, it includes information on the relationship used by the system to select the currentobject along the evaluation path.

    Document by:- Amar Chintam57

  • 7/21/2019 Technical Document on HR Programming.pdf

    58/100

    Programming in Human Resource

    ______________________________________________________________________

    RH-GET-TBDAT is a macro for logical database PCH. These macros are defined in includeDBPCHCOM. With this macro, you can import the data for an infotype with a repetitivestructure. See also Table Infotypes.

    The parameters for macro RH-GET-TBDAT are:Parameter 1 : Infotype

    Parameter 2 : Reference fieldParameter 3 : Table for structure PTnnnn

    Macros for logical database PCH must not be confused with macros for logical database PNP.Please note that you cannot use macros for logical databases PCH and PNP at the same time.

    Document by:- Amar Chintam58

  • 7/21/2019 Technical Document on HR Programming.pdf

    59/100

    Programming in Human Resource

    ______________________________________________________________________

    Function module RH_READ_INFTYcan be used to read Personnel Planning infotyperecords (function group RHDB) in programs without logical database PCH (module pools,reports of other logical databases).

    The function module reads all of the infotype records for a specific infotype or (parameterINFTY = SPACE) all of the infotypes for the specified set of objects.

    Depending on the AUTHORITY and WITH_STRU_AUTH parameters, the function moduleperforms an authorization check.

    Document by:- Amar Chintam59

  • 7/21/2019 Technical Document on HR Programming.pdf

    60/100

    Programming in Human Resource

    ______________________________________________________________________

    Logical Database PCH Exercise

    Look at theexample below

    At the end of this exercise, you will be able to:

    Program a structural evaluation.

    Select administration infotypes using the logical database PCH.

    Understand the evaluation principle search to depth.

    Suppose you require an overview of the staff positions with the name of the employees

    holding these positions and their telephone numbers.

    Write a report that lists the staff positions in the organization structure along withthe persons assigned to these positions.Use the evaluation path O-S-P.

    For the personal data (first name, last name), use the infotype 0002 records forthe person. For the telephone number, use subtype 1 from infotype 0006.

    The staff position information is contained in infotype 1003 for the position. Ifthe position is flagged as a staff position, the field P1003-STABS has the valueX.

    Process the records from infotypes 0006 and 0002 with a join. For theseinfotypes, project to the First name, Last name, Telephone number, and Subtypefields.

    For holders of staff positions only, display the object ID, the object identifier,and the object name. Display this in one line. In the following line, display thename and the telephone number.

    The object type Oand the evaluation path should appear in the selection screenas default values.

    REPORT zhsol010.TABLES: objec, gdstr.INFOTYPES: 0002, 0006, 1003.

    DATA: stabs LIKE p1003-stabs,name LIKE p0001-ename.

    INITIALIZATION.pchotype = 'O'.

    Document by:- Amar Chintam60

  • 7/21/2019 Technical Document on HR Programming.pdf

    61/100

    Programming in Human Resource

    ______________________________________________________________________

    pchwegid = 'O-S-P'.

    GET objec.IF objec-otype = 'S'.CLEAR stabs.LOOP AT p1003 WHERE begda LE pc-endda

    AND endda GE pc-begda.IF p1003-stabs = 'X'.stabs = 'X'.WRITE : / objec-objid, objec-short, objec-stext.

    ENDIF.ENDLOOP.

    ENDIF.IF objec-otype = 'P' AND stabs = 'X'.PROVIDE vorna nachn FROM p0002

    subty telnr FROM p0006BETWEEN pc-begda and pc-endda

    WHERE p0006-subty = '1'.IF p0006_valid = 'X'.CONCATENATE p0002-vorna p0002-nachn INTO nameSEPARATED BY SPACE.WRITE: / name, p0006-telnr.SKIP.

    ENDIF.ENDPROVIDE.

    ENDIF.

    Document by:- Amar Chintam61

  • 7/21/2019 Technical Document on HR Programming.pdf

    62/100

    Programming in Human Resource

    ______________________________________________________________________

    Time Management

    SAP HR Time Management functionality includes time collection, evaluation of time and

    absence data for payroll, leave management and reporting. It also automaticallycalculates leave accruals, overtime, shift premiums and bonuses.

    Time data is used to process Payroll, internal & external reporting. Payroll needs Timedata to process:

    Hours worked Overtime Shift times Vacation Absence to be paid

    Time is also used for

    Internal reporting - by management to evaluate and project costs. External reporting - tracking of time data for Labor Union requirement etc. For

    eg. Labor union requires statistical data concerning the amount of overtime spenton certain shifts etc.

    Document by:- Amar Chintam62

  • 7/21/2019 Technical Document on HR Programming.pdf

    63/100

    Programming in Human Resource

    ______________________________________________________________________

    Time data is stored in various infotypes. This data is evaluated according to various rulesduring time evalution and the processed data is transferred to payroll.

    Time data is generally collected by a third party recording terminal. Time data is

    recorded in various ways. eg. Punch cards, Manual time sheets that stores hours workedfor each day alongwith any absenses.

    All the absence's and attendance in a day are uploaded into SAP and analysed using thepre-defined times in the employees Work Schedule rule. After processing the time events,the system generates wage types and time types based on pre-defined rules within thetime evaluation program. These wage types and time types are then used for Interfacingto payroll, reporting etc.

    Document by:- Amar Chintam63

  • 7/21/2019 Technical Document on HR Programming.pdf

    64/100

    Programming in Human Resource

    ______________________________________________________________________

    The employee work schedule is an integral part ofR/3 Time Management containing theplanned specifications for employee working time.

    An employees planned working time is represented in a work schedule. The workschedule is generated from a period work schedule and a public holiday calendar. Theperiod work schedule comprises a set sequence of daily work schedules. The daily workschedule contains information on a days working time including breaks. The sequencecan reflect regular and variable working times. The period work schedule is applied to thecalendar, taking into account specifications in the public holiday calendar. The workschedule rule encompasses all the specifications required to define the work schedule.

    The work schedule is used as the basis for time data evaluation.Examples: The work schedule shows how many hours salaried employees must work to be entitled

    to their full salary. Depending on the specifications defined for the individual employee,any additional hours worked are identified as overtime inR/3 Time Evaluation.

    If you only record deviations to the work schedule, planned working time is used as thebasis for time evaluation.

    You assign a work schedule to an employee in the Planned Working Time infotype

    (0007) using work schedule rules.

    Document by:- Amar Chintam64

  • 7/21/2019 Technical Document on HR Programming.pdf

    65/100

    Programming in Human Resource

    ______________________________________________________________________

    The standard R/3 System already contains public holiday calendars that includeregional public holidays. You can change existing and define new public holidaysin the public holiday list. In addition, you can change existing or define newpublic holiday calendars. You assign a public holiday calendar to a personnelsubarea.

    Public holidays are taken into account when determining bonuses or calculatingleave, for example.

    Document by:- Amar Chintam65

  • 7/21/2019 Technical Document on HR Programming.pdf

    66/100

    Programming in Human Resource

    ______________________________________________________________________

    InR/3 Time Management, there are certain infotype records that you must create forevery employee. Time management data is stored in the same master data recordsused by other HR areas, such asR/3 Payroll Accounting orR/3 Personnel Planningand Development.

    The following master data infotypes are required for Time Management: OrganizationalAssignment (0001) PersonalData (0002) Planned Working Time (0007):

    You must have entered the appropriate Time Management status, determiningwhether the employees time data is processed inR/3 Time Evaluation or inR/3Payroll Accounting.

    Time RecordingInfo (0050):This infotype is used inR/3 Time Evaluation. It can contain interface data on thesubsystem and additional data on the employee that is relevant for time evaluation.

    Employees leave entitlement is managed in theAbsence Quotasinfotype (2006).

    Document by:- Amar Chintam66

  • 7/21/2019 Technical Document on HR Programming.pdf

    67/100

    Programming in Human Resource

    ______________________________________________________________________

    If an employee records his or her actual times at a time recording system, you can view therecorded time events in the TimeEvents infotype (2011).

    You can use the TimeEvents infotype (2011) to enter or correct time events that were notuploaded or that were incorrectly uploaded to the SAP R/3 System. You can use list entry toenter several time events for one personnel number at the same time.

    The infotype contains information on the origin of the record (whether it was recordedmanually or by a subsystem) and on the terminal ID, for instance.The infotype can also store information on a different payment (premium, different pay scalegroup, and so on) or a different cost center. The information can either be entered manuallyor by a time recording system.

    Document by:- Amar Chintam67

  • 7/21/2019 Technical Document on HR Programming.pdf

    68/100

    Programming in Human Resource

    ______________________________________________________________________

    Time evaluation is performed by the time evaluation driver RPTIME00. It evaluatesemployees' time data that has been recorded either at the time recording terminals or in thetime management infotypes.

    Time evaluation generally runs once daily, overnight, and is started using a batch job. It isnormally used for large groups of employees.

    You can also run time evaluation for individual employees or groups of employees, or forparticular past evaluation periods. This function is particularly useful for test purposes, forexample.

    The time evaluation report can also be run for future periods. A future evaluation can beuseful in the following situations: You want time evaluation to determine an employees anticiapted absence entitlements

    when absence quotas are built up automatically. You want to evaluate planned times in shift planning while taking anticipated overtime

    income into account, for example.

    Document by:- Amar Chintam68

  • 7/21/2019 Technical Document on HR Programming.pdf

    69/100

    Programming in Human Resource

    ______________________________________________________________________

    Reading DataInfotypes 2000 to 2999 are time infotypes. The time data in these infotypes stored intables PA2000 to PA2999. Infotypes are declared with the INFOTYPE statement, anddata is made available for processing in the internal infotype tables (infotype 2011 is an

    exception).

    You should not load all time infotype records from the lowest to highest system datesinto the main memory. This would quickly lead to a memory overload, especially if afront-end time recording system is connected to your HR system.This is why time data should be read only for a specific period.Use the infotype declaration supplement MODE N to define that the internal timeinfotype tables should be declared but not filled at the GET PERNR time point.Later you can fill these tables using a statement with selection period parameters.Use the following report to read time data:

    REPORT RPABAP05.TABLES: PERNR.INFOTYPES: 2001 MODE N.GET PERNR.RP-READ-ALL-TIME-ITY PN/BEGDA PN/ENDDA.LOOP AT P2001.WRITE: / P2001-ABWTG.ENDLOOP.

    An ABAP/4 macro reads the time data. This macro uses the data selection periodparameter of the selection screen.

    Due to the time constraint of infotypes, several special features must be taken intoaccount when processing time data. Views of time data are generally not practical.In time infotypes, data is determined on the basis of the validity period.When you enter an absence record, the number of days of absence is calculated on thebasis of the absence period.In a view, new partial periods are created without any changes being made to infotypedata. This would lead to incorrect results in time infotypes, since this data depends on thevalidity period.For example, if, a leave record extends from the middle of January to the middle ofFebruary and 20 days of leave are calculated for this period, then a view for the month of

    February would result in a leave record which extends from the beginning to the middleof February. The number of days of leave would not have changed and the informationwould be incorrect.In master data, the time constraint is a definite feature of the infotype or subtype. Thereare no time dependencies between infotypes and subtypes.Time data is basically different. Let us assume that an employee becomes sick duringvacation. The leave record is then delimited on the first day of the sickness, and thesickness record follows.

    Document by:- Amar Chintam69

  • 7/21/2019 Technical Document on HR Programming.pdf

    70/100

    Programming in Human Resource

    ______________________________________________________________________

    Likewise, the system prohibits the entry of a leave record that coincides with a sicknessrecord. The same also applies to overtime during a sickness.The time dependency of time infotype records is not limited only to dependenciesbetween records of one and the same infotype, but covers all infotypes and subtypes.

    The time constraint of time infotypes is not an attribute but is defined by therelationships between infotypes.

    Moreover, certain time infotype records have specific clock-in/clock out times. Severalrecords may therefore exist for one infotype on a particular day.Since views require explicit data and this prerequisite is not fulfilled by time infotypes,you should not use joins and projections for time data.

    Time infotype tables are processed with the LOOP statement since the PROVIDEstatement limits, and thus changes, the infotype begin and end dates to the data selectionperiod.

    Processing 'Time Data'. Dependence of time data on validity period Importing time data Processing time data using internal tables

    Time Data and Validity Period Time data always applies to a specific validity period. The validity periods of different types of time data are not always the same as the dateselection period specified in the selection screen.

    Date selection period |---------------|Leave |-------------|

    PROVIDE in this case is therefore not used for time infotypes.

    Importing Time Data GET PERNR reads all time infotypes from the lowest to highest system data, not onlythose within the date selection period. To prevent memory overload, add MODE N to the infotype declaration. This prevents

    the logical database from importing all data into infotype tables at GET PERNR. Use macro RP-READ-ALL-TIME-ITY to fill infotype table.

    INFOTYPES: 2001 MODE N.GET PERNR.

    RP-READ-ALL-TIME-ITY PN/BEGDA PN/ENDDA.LOOP AT P0021.

    If P0021-XYZ = ' '. A=B. Endif.ENDLOOP.

    Document by:- Amar Chintam70

  • 7/21/2019 Technical Document on HR Programming.pdf

    71/100

    Programming in Human Resource

    ______________________________________________________________________

    Processing Time Data

    Once data is imported into infotype tables, you can use an internal table to process theinterested data.DATA: BEGIN OF ITAB OCCURS 0,

    BUKRS LIKE P0001-BUKRS, "COMPANYWERKS LIKE P0001-WERKS, "PERSONNEL AREA

    AWART LIKE P2001-AWART, "ABS./ATTEND. TYPEASWTG LIKE P2001-ASWTG, "ABS./ATTEND. DAYS

    END OF ITAB.GET PERNR.RP-PROVIDE-FROM-LAST P0001 SAPCE PN-BEGDA PN-ENDDA.CLEAR ITAB.ITAB-BUKRS = P0001-BURKS. ITAB-WERKS = P0001-WERKS.RP-READ-ALL-TIME-ITY PN/BEGDA PN/ENDDA.LOOP AT P2001.

    ITAB-AWART = P2001-AWART. ITAB-ASWTG = P2001-ASWTG.COLLECT ITAB. (OR: APPEND ITAB.)

    ENDLOOP.

    Document by:- Amar Chintam71

  • 7/21/2019 Technical Document on HR Programming.pdf

    72/100

    Programming in Human Resource

    ______________________________________________________________________

    Cluster Tables andPayroll :

    Cluster tables combine the data from several tables with identical (or almost identical)

    keys into one physical record on the database. Data is written to a database in compressed form. Retrieval of data is very fast if the primary key is known. Cluster tables are defined in the data dictionary as transparent tables. External programs can NOT interpret the data in a cluster table. Special language elements EXPORT TO DATABASE, IMPORT TO DATABASE

    and DELETE FROM DATABASE are used to process data in the cluster tables.

    PCL1 - Database for HR work area;PCL2 - Accounting Results (time, travel expense and payroll);PCL3 - Applicant tracking data;

    PCL4 - Documents, Payroll year-end Tax data

    Database Tables PCLn

    PCLn database tables are divided into subareas known as data clusters. Data Clusters are identified by a two-character code. e.g RU for US payroll result,

    B2 for time evaluation result...Each HR subarea has its own cluster.Each subarea has its own key.

    Database Table PCL1

    The database table PCL1 contains the following data areas:B1 time events/PDCG1 group incentive wagesL1 individual incentive wagesPC personal calendarTE travel expenses/payroll resultsTS travel expenses/master dataTX infotype textsZI PDC interface -> cost account

    Database Table PCL2

    The database table PCL2 contains the following data areas:B2 time accounting resultsCD cluster directory of the CD managerPS generated schemasPT texts for generated schemasRX payroll accounting results/internationalRn payroll accounting results/country-specific ( n = HR country indicator )ZL personal work schedule

    Document by:- Amar Chintam72

  • 7/21/2019 Technical Document on HR Programming.pdf

    73/100

    Programming in Human Resource

    ______________________________________________________________________

    Database Table PCL3

    The database table PCL3 contains the following data areas:

    eduleAP action log / time sch TY texts for applicant data infotypes

    Data Management of PCLn

    The ABAP commands IMPORT and EXPORT are used for management of read/write todatabase tables PCLn.

    gth Text

    ..)

    rea Key

    A unique key has to be used when reading data from or writing data to the PCLn.Field Name KEY Len

    MANDT X 3 ClientRELID X 2 Relation ID (RU,B2

    SRTFD X 40 Work A SRTF2 X 4 Sort key for dup. key

    Cluster DefinitionThe data definition of a work area for PCLn is specified in separate programs which

    ming conventions.tion

    lation ID (e.g. RX)rs or country indicator (T500L) for different country cluster

    comply with fixed naThey are defined as INCLUDE programs (RPCnxxy0). The following naming convenapplies:

    n = 1 or 2 (PCL1 or PCL2)xx = Re

    y = 0 for international cluste

    Document by:- Amar Chintam73

  • 7/21/2019 Technical Document on HR Programming.pdf

    74/100

    Programming in Human Resource

    ______________________________________________________________________

    Payroll is used to calculate the remuneration for work done for each employee. SAPPayroll delivers powerful and efficient gross-to-net, net-to-gross, regular and off-cyclepayroll processing. SAP's complex Payroll process handles everything includingvacation policies, compensation programs, work schedules, Holidays, overtime pay etc.

    SAP's ESS (Employee Self Service) function allows employees to view, create andmaintain data anytime, anywhere, via Web-based technology and interactive voiceresponse functionality. ESS is an effective means for providing real-time access and datamaintenance capabilities to the source or owner of the data. It has the ability to offloadmuch of the data entry and related customer service activities that may be typicallyperformed in an organization's human resources, payroll, benefits and purchasingdepartments.

    Payroll accounting calculates the payment of work done by an employee. Payroll

    function does the following:

    Compute employees gross salary Make necessary deductions Calculate Net salary Generate Checks or direct deposits.

    Payroll components include:

    Payroll area - groups employees based on the frequency of their paydates. eg. Z1for salaried staff paid monthly.

    Control Record - It determines the current payroll period for a payroll area. Period Modifier - Period in which payroll accounting is carried out. eg. 10 - for

    monthly pay periods. Date Modifier - Distinguishes periods with same frequency but different date.

    Eg. 10 - for monthly pay period but with the pay date being 5th of every month. Payroll Calendar - Generating calendars for cumulating wage types to get

    monthly, quaterly or yearly sum totals. Payscale type - used for segregation of employees payscales based on the type of

    union contracts in a company. Eg. 10 - non union workers 20 - collectiveagreement for secretaries contract.

    Payscale area - Differentiates payscales based on geographical area. Eg. 10 -

    California. Payscale group - Differentiates employees payscales based on functionality. Eg.

    GR01 - grouping for junior clerks, GR02 - for senior clerks. Payscale level - Subdivision of employees payscales. Eg. L1 - level 1 clerk, L2 -

    level 2 clerk. Wage types - The payments and deductions for an employee are coded as wage

    types. Eg. A001 - salary payment, B001 - 401K deduction.

    Document by:- Amar Chintam74

  • 7/21/2019 Technical Document on HR Programming.pdf

    75/100

    Programming in Human Resource

    ______________________________________________________________________

    Payroll Infotypes: Payroll data is stored in various infotypes, which includes, 0001,0007, 0008, 0009, 0207, 0208, 0209, 0210, 0234. These infotypes maintain personaldetails, payment and deduction info, benefits data, garnishment data, tax data, etc.

    Payroll Process involves:

    Maintaining payroll related infotypes Periodic payroll run Transferring data to FI/CO Transferring third party remittance data to Accounts Payable Tax reporting Standard reporting

    Payroll program name: RPCALCx0

    Document by:- Amar Chintam75

  • 7/21/2019 Technical Document on HR Programming.pdf

    76/100

    Programming in Human Resource

    ______________________________________________________________________

    Broadly speaking, payroll accounting is the calculation of payment for workperformed by each employee. More specifically, however, payroll accountingcomprises a number of work processes including the generation of payroll results andremuneration statements, bank transfers and check payments.

    Payroll accounting also includes a number of subsequent activities: transfer of payroll results to Accounting various evaluations, such as evaluating the payroll account. etc.

    Document by:- Amar Chintam76

  • 7/21/2019 Technical Document on HR Programming.pdf

    77/100

    Programming in Human Resource

    ______________________________________________________________________

    The calculation of payment comprises two main steps: Calculation of remuneration elements Statutory and voluntary deductions (country-specific)

    Both the remuneration elements and the statutory and voluntary deductions consist ofindividual payments and deductions, which are calculated for an employee during apayroll period. These payments and deductions are included in the paymentcalculation by means of different wage types.

    The employee is usually paid by bank transfer or check and the payment amount isprinted in a form for the employee.

    Document by:- Amar Chintam77

  • 7/21/2019 Technical Document on HR Programming.pdf

    78/100

    Programming in Human Resource

    ______________________________________________________________________

    The remuneration elements for an employee are formed from individual wage andsalary types that are used during a payroll period. Payments such as basic pay, variousbonuses and gratuities are included in the remuneration calculation. Deductions canbe made for items such as a company-owned flat, company-sponsored day care orsimilar benefits. Different factors determine whether such benefits increase or reducethe taxable income. This is determined by country-specific regulations and, in somecountries, the philosophy of the company.

    An employee's remuneration consists of all wage types calculated for him or herduring a payroll period.

    Document by:- Amar Chintam78

  • 7/21/2019 Technical Document on HR Programming.pdf

    79/100

    Programming in Human Resource

    ______________________________________________________________________

    Voluntary and statutory deductions, such as tax and social insurance contributions,are taken from the gross calculation to determine the payment amount. Differentgross values, for example, total gross amount, and gross tax amount, are used tocalculate the deductions. For this reason, different totals are formed during the payrollrun, and these totals are be used for subsequent processing.

    The Payroll Run steps

    Document by:- Amar Chintam79

  • 7/21/2019 Technical Document on HR Programming.pdf

    80/100

    Programming in Human Resource

    ______________________________________________________________________

    The payroll program is usually run separately for different employee groups. Atypical example is that of salaried employees and hourly employees, for whompayroll is performed using two different payroll periods. The payroll area determineswhen payroll is run.

    The payroll area serves two functions, both of which are prerequisites for running thepayroll. The payroll area groups together personnel numbers that must be processedin the same payroll run

    The payroll area determines the payroll period.

    Employees for whom payroll is performed at the same time and for the same payroll

    period are assigned to the same payroll area. Personnel numbers are assigned to apayroll area in the Organizational Assignment infotype (0001).

    Document by:- Amar Chintam80

  • 7/21/2019 Technical Document on HR Programming.pdf

    81/100

    Programming in Human Resource

    ______________________________________________________________________

    The personnel numbers to be included in the payroll run are selected by specifying a

    payroll area in the payroll driver selection screen. The payroll period is transferreddirectly from the payroll control record to the payroll program. In a live run, the payroll period is determined by the system. The last period to be

    included in a payroll run is stored in the payroll control record for each payroll area.The current payroll period is, therefore, the last period to be included in a payroll run,plus one.

    Hint: Payroll driver should be started by Personnel Number or Payroll Area only.

    Document by:- Amar Chintam81

  • 7/21/2019 Technical Document on HR Programming.pdf

    82/100

    Programming in Human Resource

    ______________________________________________________________________

    The structure of PCLn database tables provides a basic structure for individualsubareas.

    The name of each subarea must include a two-character cluster name or relation ID. A key structure must also be defined; 40 bytes are available in field SRTFD for this

    purpose. In the international payroll results, for example, the field RELID contains the cluster

    name RX and the field SRTFD contains the eight-digit personnel number as well as afive-digit sequence number for each individual payroll result for a payroll period.

    To enable the import of a record from a PCLn database table, the RELID field mustcontain the cluster identifier and the SRTFD field must contain the cluster key. Thefields CLIENT and SRTF2 are filled by the system.

    Document by:- Amar Chintam82

  • 7/21/2019 Technical Document on HR Programming.pdf

    83/100

    Programming in Human Resource

    ______________________________________________________________________

    If data is imported using macros, the data records are not read directly from tableory

    on. The=

    PCLn. Instead, the buffer directory is checked to determine whether the main memalready contains a record with the same key. If this is not the case, the record is readfrom PCLn to the buffer, and retrieved from the buffer by the report.If data is read using a buffer, the system checks the cluster authorizatistandard import programs follow the RPCLSTxy naming convention, where xycluster name.

    Document by:- Amar Chintam83

  • 7/21/2019 Technical Document on HR Programming.pdf

    84/100

    Programming in Human Resource

    ______________________________________________________________________

    With this report, you can display the payroll results for any country. The indicatorbehind each name shows whether results exist in the selected period.

    Green: Results existRed: No results existGray: No authorization for displaying personnel numbers

    Payroll results are stored as structures and internal tables on the database. Each payroll result has a status indicator:

    A = Current result P = Previous result O = All other results

    Document by:- Amar Chintam84

  • 7/21/2019 Technical Document on HR Programming.pdf

    85/100

    Programming in Human Resource

    ______________________________________________________________________

    The payroll driver, 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 schema contains functions that call the subroutines contained in the payrolldriver. In many cases, t