Question

BDC FOR HR ACTIONS

Asked by: thisismanjari

I have to write a BDC for a list of HR Actions like Hiring,Change in Pay Action etc. (every action consists of many Infotypes,) to upload  data for only Infotype 0000 and 0001 and rest all infotype data must be skipped. How to do that?

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2008-02-24 at 22:42:31ID23189513
Tags

SAP

,

ABAP-HR

,

4.6C

,

BDC

,

SAP HR HCM

Topic

Enterprise Software

Participating Experts
1
Points
500
Comments
7

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. BDC Not authenticating users.
    Situation: My domain spans a WAN, connected via T1's. At my location I have the PDC and a BDC. The other side has 2 bdc's. My network has net beui bridged, essentially making our expensive CISCO routers into B-Routers. This is another mess in-and-of itself. Anyway, My ...
  2. <hr>
    Simple question really.. There is the <hr> tag for horizontal rules is there anything for vertical rules? pg

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: apitbajpaiPosted on 2008-03-06 at 02:30:52ID: 21058855

may be this can help you
The aim in the Human Resources component is to be able to process employee related data according to business requirements in an effective structure.
The Human Resources module uses a system of data grouped together called infotypes.
Infotypes mirror a quantity of connected data records; infotypes are identifiable through a four character numerical string http://e.g. infotype Addresses (0006) and a complete listing is included.
You can save the infotypes as time-dependent to enable a retroactive evaluation of
Employee data
The infotypes appear as an entry screen for the user, through which you can maintain infotype records. Infotypes can be processed individually or in fast entry mode.

2.1.2 Difference from conventional ABAP
Advanced Business Application Programming ABAP is SAP's fourth generation language. All of R/3's applications and even parts of its basic system are developed in ABAP. ABAP is used for customization and modification of SAP applications.
In HR ABAP use of select statements significantly less than in other areas of ABAP development, Logical databases have limited applications in other modules but are very useful in HR. Also, you really need to understand the infotype time constraint concept, When you cannot get the information that you need out of the logical DB look at the function modules starting with HR* and RH*. These function modules will provide you with multiple ways of accessing data to save time. Worst-case scenario, use a select statement.

2.1.3 Overview of PA/PD/& Integration between PA & PD
This explains how to use the ABAP programs, which set integration between PA and PD/OM. They are mainly used after data conversion, bulk updates or to correct errors caused by other programs.
Each program is explained in detail so you can decide which ones you need to run. To set up/fix full integration between PA and PD, they should be run in this sequence:
1. RHINTE00  Transfer PA records into PD positions batch
2. RHINTE20  Create OM objects in PA tables  Online
3. RHINTE30  Bulk update of infotype 0001
4. RHINTECHECK  Program to check PA to PD
5. RHCHECKV - Checks all inverse relationships
Overview
It is important to realize that in PA, there are tables that contain objects from OM, i.e. for those items displayed on infotype 0001 Organizational Assignment. Sometimes the tables can get out of step with those in PD  table HRP1000.
The tables are:
T513, T513S Object type C (Job)
T528B, T528T Object types S (Position) and A (Work center)
T527X Object type O (Organizational unit)

RHINTE00
This loops through all employees in PA by looking at positions on infotype 0001. It checks the corresponding person to position relationship exists in PD (A008), if not it is created.

RHINTE10
Generally, the program RHINTE20 will be used instead of this one. This program loops through the PD table HRP1000. For each job, position, work centre and organization unit, corresponding entry is created in the PA tables, which are shown above. Run this with evaluation path o_s_p, which runs through Org units, jobs and positions or find a suitable alternative if you wish to update work centers also. The main difference with this program as opposed to RHINTE20 is that this one has the option to delete items from the PA tables, which no longer exist in PD.



RHINTE20
This program loops through the PD table HRP1000. For each job, position, work centre and organization unit, corresponding entry is created in the PA tables, which are shown above. Run this with evaluation path o_s_p, which runs through Org units, jobs and positions or find a suitable alternative if you wish to update work centers also. An example output will show:

Expand the tree items to display a list of objects that can be created:

RHINTECHECK
When the above programs have been run, use this check program, which looks through all employees and reports any inconsistencies found between PA and PD.

Tick each item that you wish to be created, or click on the text and click select subtree to select them all then click to perform multiple updates. This program can prove to be problematic. If difficulties arise with it, try using RHINTE10 instead.

RHINTE30
This will create an infotype 0001 record with correct entries for org unit, job, position and work centre by looking through the organization structure. It creates a batch job, which must be run via SM35. More details to follow.

RHCHECKV
This will check inverse relationships and create missing ones.

2.1.4 Concepts of Infotypes (Structure/Processing etc.)

Infotypes:

An infotype represents a group of related data fields, provides information structure, facilitates data entry, and allows time dependent storage.
In other words we can say infotypes are information units used to enter the time dependent data of the employee.
Master data in HR is stored in infotypes. Each infotype pertains to a specific type of data.
Each infotype has a database table associated with it.
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.
Transparent tables for infotype
Each infotype has a transparent table. Each logical field for an infotype has a corresponding physical field on the database.
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 in Recruitment
" HRPnnnn for transparent tables in Personnel Planning
Example: For Infotype 0000, the corresponding database table associated with it is PA0000

Check and Control Tables for HR Infotypes



" 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 T582A Infotypes - Customer-Specific Settings is used for customer settings in Administration infotypes.
" Table T77CD Infotypes - Customer-Specific Settings is used for customer settings in planning infotypes.
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.
" 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.
Structure:
The Data Dictionary contains a Pnnnn structure for each infotype nnnn. The infotype structure Pnnnn corresponds to the table PAnnnn. The Pnnnn structure of the infotype is used as the field structure for the infotype entry screen (Transaction code PA30).

Basic form of an infotype:
Infotypes nnnn name c occurs m mode n valid from comp1 to comp2.
nnnn can be 0000 to 9999.

0000  0999 are HR Master Data infotypes.
1000  1999 are HR Planning data infotypes.
2000  2999 are HR time data infotypes.
3000  8999 are not used
9000  9999 are used for the custom infotypes

Effect of the above syntax is

It creates an internal table as below...

DATA BEGIN OF c OCCURS m.
INCLUDE STRUCTURE Pnnnn.
DATA END OF c VALID BETWEEN comp1 AND comp2

" If name option is not given in the syntax then the internal table will be created with the name p<nnnn>
" If occurs clause in not given then the size of an internal table would be 10 * size of the structure pnnnn. That is in the place of m it would be 10.
" If valid clause is not given then the comp1 and comp2 values will be 01/01/1800 and 31/12/9999 respectively.
" Mode n this clause can only be used with the LDBs PCH and PNP. This addition stops this infotype being automatically filled at the GET PERNR command.

The infotype records can be processed using the infotype structure when the report is run.


Processing Infotypes
Processing Single Infotype Record
We can process the Single records of an infotype using the following macros.
1. RP_PROVIDE_FROM_LAST Pnnnn SPACE PN-BEGDA PN-ENDDA.
This macro is used to retrieve the most recent record in the PN-BEGDA and PN-ENDDA data selection period available in the structure Pnnnn for infotype nnnn
2. RP_PROVIDE_FROM_FIRST Pnnnn SPACE PN-BEGDA PN-ENDDA
This macro retrieves the earliest record for the given selection period.
If the infotype has subtypes, then replace SPACE with the subtype so, the data is retrieved based on that subtype. If the retrieval is successful then the return code PNP-SW-FOUND will be 1.
Processing All Infotype Records

Processing of infotype records is time-dependent; by this we mean dependent on the data selection period entered on the selection screen. The data of several infotypes can be processed at the same time and made available for a specific partial period

To process all records of internal tables of an infotypes we use the PROVIDE statement


Syntax:
PROVIDE * FROM Pnnnn BETWEEN PN-BEGDA AND PN-ENDDA.
ENDPROVIDE

nnnn stands for 4-digit infotype number. The relationship between the data and the selection period is established using the PN-BEGDA and PN- ENDDA variables.

Infotype List

Infotype Number Infotype Text Description
0000 Actions
0001 Organizational Assignment
0002 Personal Data
0004 Challenge
0006 Addresses
0007 Planned Working Time
0008 Basic Pay
0009 Bank Details
0013 Social Insurance Deductions
0014 Recurring Payments/Deds
0015 Additional Payments
0019 Monitoring of Dates
0021 Family/Related Person
0022 Education
0025 Appraisals
0034 Corporate Function
0035 Company Instructions
0040 Objects on Loan
0041 Date Specifications
0048 Residence Status
0077 Additional Personal Data
0094 Residence Status
0105 Communication
0167 Health Plans
0168 Insurance Plans
0169 Savings Plans
0170 Flexible Spending Accounts
0171 General Benefits Information
0172 FSA Claims
0207 Residence Tax Area
0208 Work Tax Area
0209 Unemployment State
0210 Withholding info W4/W5 US
0377 Miscellaneous Plans
0378 Adjustment Reasons
9001 DOD/MWR Specific Data
9002 Payroll Import Data
9003 Retirement Plan Data at Termination
9005 KRONOS Information

2.1.5 Concepts of Clusters (Import/Export etc.), cluster directory
Definition

Each database object, for example, PCL1 or PCL2, with the type Import/Export file consists of related areas. These areas are known as clusters, for example. RX, RD. Cluster objects are dependent on the super ordinate database object.

Cluster objects RX, RD, B2 can be selected for the database PCL2. If the database object has the type master data then there will be no cluster object.

Import/Export files

They are 4 types of files.
" PCL1: Basis for HR Work area data. Contains information from time data recording.
" PCL2: Contains derived information like payroll results and generated payroll schemas.
" PCL3: Contains Applicant Data
" PCL4: Contains change documents for HR master data and recruitment.

Importing and Exporting of data is managed with the commands IMPORT and EXPORT These commands store objects such as fields, field strings, or internal tables on the database, or read these from the database. Data is read from and written to the database using a unique key. RMAC provides two macros for importing and exporting data RP-IMP-Cn-xx and RP-EXP-Cn-xx; only these macros should be used.
Export Cluster data using standard include.
o The EXPORT command causes one or more 'xy' KEY data objects to be written to cluster xy.
o The cluster definition is integrated with the INCLUDE statement.

REPORT ZHREXPRT.
TABLES: PCLn.
INCLUDE: RPCnxxy0. "Cluster definition


Fill cluster KEY
xy-key-field = <value>.

Fill data object
....

Export record
EXPORT TABLE1 TO DATABASE PCLn (xy) ID xy-KEY.
IF SY-SUBRC EQ 0.
WRITE: / 'Update successful'.
ENDIF.

Export Cluster data using the macro
. Export data using macro RP-EXP-Cn-xy.
" When data records are exported using macro, they are not written to the database but to a main memory buffer.
" To save data, use the PREPARE_UPDATE routine with the USING parameter 'V'.

REPORT ZHREXPRT.
*Buffer definition
INCLUDE RPPPXD00. INCLUDE RPPPXM00. "Buffer management
DATA: BEGIN OF COMMON PART 'BUFFER'.
INCLUDE RPPPXD10.
DATA: END OF COMMON PART 'BUFFER'.
...
RP-EXP-Cn-xy.
IF SY-SUBRC EQ 0.
PERFORM PREPARE_UPDATE USING V.
ENDIF.

Importing Cluster Data using standard include
" The IMPORT command causes data objects with the specified key values to be read from PCLn.
" If the import is successful, SY-SUBRC is 0; if not, it is 4.

REPORT RPIMPORT.
TABLES: PCLn.
INCLUDE RPCnxxy0. "Cluster definition



Fill cluster Key


Import record
IMPORT TABLE1 FROM DATABASE PCLn (xy) ID xy-KEY.
IF SY-SUBRC EQ 0.
* Display data object
ENDIF.

Importing Cluster data using Macro
" Import data using macro RP-IMP-Cn-xy.
" Check return code SY-SUBRC. If 0, it is successful. If 4, error.
" Need include buffer management routines RPPPXM00

Example
REPORT RPIMPORT.
*Buffer definition
INCLUDE RPPPXD00.
DATA: BEGIN OF COMMON PART 'BUFFER'.
INCLUDE RPPPXD10.
DATA: END OF COMMON PART 'BUFFER'.
*Import data to buffer
RP-IMP-Cn-xy.
....
*Buffer management routines
INCLUDE RPPPXM00.

Cluster Authorization
Simple EXPORT/IMPORT statement does not check for cluster authorization.
Use EXPORT/IMPORT via buffer, the buffer management routines check for cluster
authorization.

How to read the Payroll Results
" Payroll results are stored in cluster Rn of PCL2 as field string and internal tables.
n - Country identifier.
" Standard reports read the results from cluster Rn. Report RPCLSTRn lists all payroll results;

" Report RPCEDTn0 lists the results on a payroll form.

" The cluster definition of payroll results is stored in two INLCUDE reports:
include: rpc2rx09. "Definition Cluster Ru (I)
include: rpc2ruu0.Definition Cluster Ru (II)
o This first INCLUDE defines the country-independent part; the second
INCLUDE defines the country-specific part (US).

o The cluster key is stored in the field string RX-KEY.

" All the field string and internal tables stored in PCL2 are defined in the ABAP/4 dictionary. This allows you to use the same structures in different definitions and nonetheless maintain data consistency.
" The structures for cluster definition comply with the name convention PCnnn
Unfortunately 'nnn' can be any set of alphanumeric characters.

*Key definition
DATA: BEGIN OF RX-KEY.
INCLUDE STRUCTURE PC200.
DATA: END OF RX-KEY.

*Payroll directory
DATA: BEGIN OF RGDIR OCCURS 100.
INCLUDE STRUCTURE PC261.
DATA: END OF RGDIR.

" How to retrieve Payroll results
o To read payroll results, you need two keys: pernr and seqno
o You can get SEQNO by importing the cluster directory (CD) first.

Example
REPORT ZHRIMPRT.
TABLES: PERNR, PCL1, PCL2.
INLCUDE: rpc2cd09. "Definition cluster CD
PARAMETERS: PERSON LIKE PERNR-PERNR.
...
RP-INIT-BUFFER.
*Import cluster Directory
CD-KEY-PERNR = PERNR-PERNR.
RP-IMP-C2-CU.
CHECK SY-SUBRC = 0.
LOOP AT RGDIR.
RX-KEY-PERNR = PERSON.
UNPACK RGDIR-SEQNR TO RX-KEY-SEQNO.
*Import data from PCL2
RP-IMP-C2-RU.
ENDLOOP.
o Reading records from the Payroll directory
after importing the payroll directory, which record to read is up to the programmer
o Each payroll result has a status.
'P' - previous result
'A' - current (actual) result
'O' - old result
o Function module CD_EVALUATION_PERIODS will restore the payroll result status for a period when that payroll is initially run. It also will select all the relevant periods to be evaluated.

Example
Call function 'CD_EVALUATION_PERIODS'
exporting
bonus_date = ref_periods-bondt
inper_modif = pn-permo
inper = ref_periods-inper
pay_type = ref_periods-payty
pay_ident = ref_periods-payid
tables
rgdir = rgdir
evpdir = evp
iabkrs = pnpabkrs
exceptions
no_record_found = 1.

Authorization Check
Authorization for Persons
" In the authorization check for persons, the system determines whether the user has the authorizations required for the organizational features of the employees selected with GET PERNR.
" Recruits for which the user has no authorization are skipped and appear in a list at the end of the report.
" Authorization object: 'HR: Master data'

Authorization for Data
" In the authorization check for data, the system determines whether the user is authorized to read the infotypes specified in the report.
" If the authorization for a particular infotype is missing, the evaluation is terminated and an error message is displayed.

Deactivating the Authorization Check
" In certain reports, it may be useful to deactivate the authorization check in order to improve performance. (E.g. when running payroll)
" You can store this information in the object 'HR: Reporting'.

2.1.6 Concepts of Macros (Import/Export etc.)
Macros:

Introduction
Programs that process the cluster data (for example, RX) do not access the cluster independently. The data is accessed using a defined interface created with macros.

Macro contains some part of source code, which it will be useful for number of applications. Macro is module, which is stored

Naming Conventions of Macro:
RP-aaa-bb-cc

" aaa is the type of Macro. It takes two values
o IMP Import Macro
o EXP Export Macro

" bb is the Database table where the data is saved:
o C1 Database object PCL1
o C2 Database object PCL2
o C3 Database object PCL3
o C4 Database object PCL4
" Cc is the cluster, it may take
o RX Cluster object RX
o RD Cluster object RD
o B2 Cluster object B2 and so on.


Defining and Calling the Macros

Defining:

There are two options for defining the Macros

" Macros are defined using the ABAP Commands DEFINE&. END-OF-DEFINITION. A macro can be used within a report or within include. If a macro is used in a report, and the macro is defined in include with the DEFINE command, include must be integrated.


" Macros can also be defined as RMAC macros. The source code of these modules is stored in the function section of the control table TRMAC. The coding is grouped under a specific name in the table key.
According to conventions, the first two letters of the name must stand for the application. The rest of the name is freely definable.


Difference between the two methods is:

" If a macro is changed, each report using this macro is automatically regenerated when it is executed.

" When you change a RMAC macro in the table TRMAC, the reports that use this macro are not regenerated automatically. You must regenerate them manually.

Standard HR Macros

o The macro RP-PROVIDE-FROM-FRST retrieves the first (start) data record, which is valid in the data selection period.
o The macro RP-PROVIDE-FROM-LAST retrieves the last (latest) data record, which is valid in the data selection period.
o The macro RP-READ-INFOTYPE retrieves the data record(s), which is valid in the data selection period.

How to check whether the macro operation is successful or not

For every macro, whether the operation was successful or not will be checked with
PNP-SW-FOUND.

If PNP-SW-FOUND = 1, then the operation is successful.

Where exactly the Macrocode is stored

The program code pertaining to this macro is stored in the control table RMAC

Guidelines for how and when to use the Standard Macros
o RP_PROVIDE_FROM_FRST
Use macro RP_PROVIDE_FROM_FRST in programs for the logical databases PNP and PAP where the first data record for a period (can be a subtype) is read from an infotype table. The infotype table has been filled earlier (for example, with GET PERNR or RP_READ_INFOTYPE). This macro is only helpful if the infotype has time constraint 1 or 2.
Prerequisites
" The validity begin date of the time period must be before or the same as the validity end date.
" Validity start and end dates are correct (preferably of the type DATE).
" The infotype table is sorted in ascending order. Otherwise, you would receive the first fitting table entry that might not necessarily correspond to the first time entry.
Features
The first entry for a specified period is placed in the table header entry from an internal infotype table.
Parameters
RP_PROVIDE_FROM_FRST inftytab subty beg end
IN: 1) Name of the internal table
2) Subtype required or SPACE if no subtype is being specified
3) Validity start date of the time interval
4) Validity end date of the time interval
OUT: 1) PNP-SW-FOUND: has the value 0 if there is no matching entry in the infotype table in the given time period. Otherwise it has the value 1.
2) The matching table header entry if PNP-SW-FOUND = 1 or
the initial table header entry if PNP-SW-FOUND = 0

Example
(RP_PROVIDE_FROM_FRST inftytab subty beg end)
RP_PROVIDE_FROM_FIRST P0021 '1' PN-BEGDA PN-ENDDA.
IF PNP-SW-FOUND EQ '1'.
...
ENDIF.
or
RP_PROVIDE_FROM_FRST P0001 SPACE PN-BEGDA PN-ENDDA.
IF PNP-SW-FOUND EQ '0'.
WRITE: / 'Error: Org. assignment is missing' REJECT.
ENDIF.

o RP_PROVIDE_FROM_LAST
You use macro RP_PROVIDE_FROM_LAST in programs for the logical databases PNP and PAP where the last data record for a period (can be a subtype) is read from an infotype table. The infotype table has been filled earlier (for example, with GET PERNR or RP_READ_INFOTYPE). This macro is only helpful if the infotype (or subtype) has time constraint 1 or 2.
Prerequisites
" The validity begin date of the time period must be before or the same as the validity end date.
" Validity start and end dates are correct (preferably of the type DATE).
" The infotype table is sorted in ascending order. Otherwise, you would receive the last fitting table entry that might not necessarily correspond to the last time entry.
Features
The macro RP_PROVIDE_FROM_LAST makes sure that the last entry for a specified period is placed in the table header entry of the report output list.
Parameters
RP_PROVIDE_FROM_LAST inftytab subty beg end
IN: 1) Name of the internal table
2) Subtype required or SPACE if no subtype is being specified
3) Validity begin date of the time interval
4) Validity end date of the time interval
OUT: 1) PNP-SW-FOUND: has the value 0 if there is no matching entry in the infotype table in the given time period. Otherwise it has the value 1.
2) The matching table header entry if PNP-SW-FOUND = 1 or
the cleared table header entry if PNP-SW-FOUND = 0
Example:
RP_PROVIDE_FROM_LAST P0021 '1' PN-BEGDA PN-ENDDA.
IF PNP-SW-FOUND EQ '1'.
...
ENDIF.
OR

RP_PROVIDE_FROM_LAST P0001 SPACE PN-BEGDA PN-ENDDA.
IF PNP-SW-FOUND EQ '0'.
WRITE: / 'Error: Org. assignment is missing'. REJECT.
ENDIF.
" RP_READ_INFOTYPE
You can use the macro in all programs at any point. You can also use it in function modules. In database PNP, an infotype is usually read with GET PERNR. Using macro RP_READ_INFOTYPE is an exception.
You can also use the function module HR_READ_INFOTYPE. For information on how to use the function module, see the documentation on Function Modules.
Prerequisites
" The validity begin date of the time period must be before or the same as the validity end date.
" Validity begin and end are correct date specifications (preferably of the type DATE).
" The infotype table must match the infotype number.
" The program using the macro must contain the include DBPNPMAC.
Features
The macro RP_READ_INFOTYPE makes sure that all data records for a person for the specified period are placed in an internal infotype table.
Parameters
RP_READ_INFOTYPE pernr infty inftytab beg end
IN: 1) Personnel number of the person requested
2) Infotype number of the required infotype
3) Name of the internal infotype table
4) Validity start date of the time interval
5) Validity end date of the time interval
OUT: 1) PNP-SW-FOUND = 0, if there is no matching record in the dataset
PNP-SW-FOUND = 1, if there is no matching record in the dataset
2) PNP-SW-AUTH-SKIPPED-RECORD = 0, if the HR authorization check has not retained any records due to incorrect authorizations.
PNP-SW-AUTH-SKIPPED-RECORD = 1 , if the HR authorization check has retained at least one record due to lack of authorization
3) Internal infotype table, containing all matching records for which the user is authorized (this table can also be empty).
Example
(RP_READ_INFOTYPE pernr infty inftytab beg end)
INFOTYPES: 0001.
RP-LOWDATE-HIGHDATE.
DATA: PERNR LIKE P0001-PERNR.
DATA: BEGDA LIKE P0001-BEGDA, ENDDA LIKE P0001-ENDDA.
PERNR = '12345678'.
BEGDA = LOW-DATE + 15
ENDDA = HIGH-DATE - 5.
RP-READ-INFOTYPE PERNR 0001 P0001 BEGDA ENDDA.
IF PNP-SW-AUT-SKIPPED-RECORD EQ '1'.
WRITE: / 'Insufficient authorization'. STOP.
ENDIF.
IF PNP-SW-FOUND EQ '0'.
WRITE: / 'Infotype 0001 missing'. STOP.
ENDIF.
2.1.7 Retrieval of data using LDBs (PNP/PAP/APP/PCH) without LDBs.
Logical database
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.

HR Logical Database is PNP

Main Functions of the logical database PNP:
" Standard Selection screen
" Data Retrieval
" Authorization check
To use logical database PNP in your program, specify in your program attributes.

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.
Data Retrieval from LDB
1. Create data structures for infotypes.
INFOTYPES: 0001, "ORG ASSIGNMENT
0002, "PERSONAL DATA
0008. "BASIC PAY
2. Fill data structures with the infotype records.
Start-of-selection.
GET PERNR.
End-0f-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 Pnnnn BETWEEN PN/BEGDA AND PN/ENDDA
If Pnnnn-XXXX = ' '. write:/ Pnnnn-XXXX. Endif.
ENDPROVIDE.
" Period-Related Data
All 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 the
selection screen. PN/BEGDA PN/ENDDA.
" Current Data
IT0006 Address - 01/01/1990 12/31/9999 present
RP-PROVIDE-FROM-LAST retrieves the record, which is valid in the data selection period.

For example, pn/begda = '19990931' pn/endda = '99991231'
IT0006 subtype 1 is resident address
RP-PROVIDE-FROM-LAST P0006 1 PN/BEGDA PN/ENDDA.
2.2 Personnel Administration (PA)
PA involves administrating employee data, commonly referred to Master Data. Master Data contains all employee data used in HR processing. Master Data includes Personal (E.g. 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. E.g. 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. E.g. 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. E.g. 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 e.g. you can specify whether an employee's pay should be determined on hourly or monthly basis. 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.
Here a Data Model

2.2.1 Importance of Dates and periods in payroll

Here is a simple ABAP example of reading DATE types stored in infotype 0041.
There can be a maximum of 12 dates stored in this infotype. Here is an example of an infotype 0041 record:



The date types are stored in PA0041-DAR01, PA0041-DAR02, etc.

In the example above, PA0041-DAR01 is 01, PA0041-DAR02 is 09.

The dates themselves are stored in PA0041-DAT01, PA0041-DAT02, etc

To read through this in ABAP, the easiest way is to use the DO VARYING statement. Here is a simple demonstration ABAP:

Note: to print the text of the date type, e.g. Leave year entry select from table T548T.


REPORT ZDATES1.
TABLES: PERNR.

DATA: BEGIN OF MYDATES,
DAR LIKE P0041-DAR01,
DAT LIKE P0041-DAT01,
END OF MYDATES.

INFOTYPES 0041.

GET PERNR.

WRITE: PERNR-PERNR, PERNR-ENAME. "Show employee number and name

RP-PROVIDE-FROM-LAST P0041 SPACE PN-BEGDA PN-ENDDA.
IF PNP-SW-FOUND = 1.
DO 12 TIMES VARYING MYDATES
FROM P0041-DAR01
NEXT P0041-DAR02.
If mydates-dar ne space.
WRITE: /, MYDATES-DAR, MYDATES-DAT.
Endif.
ENDDO.
ENDIF.

2.2.2 Overview of date fields and period-Ex. for period/in-period/ payroll
FOR-PERIOD: Payroll period (start and end date of a period) for which a payroll result is created or generated.

IN-PERIOD: The payroll period (start and end date of a period) in which a payroll result is created or generated.
Example: For every employee payroll should be run, it may be bi-weekly, monthly, or quarterly. Say it is monthly, then for an employee a payroll should be run for this month and it is run next month then. For-period start date is 01/9/2003 and end date is 30 and in-period end date will be the date it is run 15/10/2003.
In-Period View
An in-period view is a selection of payroll results from the payroll directory (for example, RPCLSTRD Payroll Result for Germany,) for a number of in-periods. The payroll results that were generated for the required number of payroll periods in the selected period are selected.
Payroll Result
For-Period View
A for-period view is a selection of payroll results from the payroll directory (for example, RPCLSTRC Payroll Result for Switzerland) for a number of for-periods. The payroll results that were generated in the required number of payroll periods for the selected period are selected.
Example: For-Period View / In-Period View
Payroll
result For-period
view Start date
for-per. view End date
for-per. view In-period
view End date
in-per. view
1 01/1997 01.01.1997. 31.01.1997 02/1997 28.02.1997
2 02/1997 01.02.1997 28.02.1997 02/1997 28.02.1997
Explanation
The payroll result 1 for the payroll period (for-period) 01/1997 has the start date 01.01.1997 and the end date 31.01.1997. This payroll result was generated in the payroll period (in-period) 02/1997.

2.2.3 Repetitive Structures processing
In many master data infotypes the data is stored in the form of repetitive structures. For example infotype 0008, the structure wage type line is available for 20 times, that is an employee is eligible for having 20 different wage types based on his benefits. When evaluating repeat structures, you must ensure that all fields are entered. In the case of the Basic Pay infotype, 20 * 5 = 100 fields are queried.

To use this method of evaluation, define a field string whose structure corresponds to the fields in one line of the repetitive structure.

Example for understanding the repetitive Structure

Say, for an employee you want to know that for what all wage types an employee is eligible for the latest period you mentioned on the selection screen.

Using LDB (PNP)

Program:

Report zhk_repstru.

Tables Pernr.

Infotypes 0008.

" You have to declare a structure same as repetitive structure in the 0008 infotype

Data: begin of s_wagetypes,
Wagetype type p0008-lga01,
Amount type p0008-bet01,
Hours type p0008-anz01,
Unit type p0008-ein01,
Ind type p0008-opk01,
End of s_wagetypes,

" Selecting data from the Data base Get pernr

" Getting the latest record based on the selection period.
RP_PROVIDE_FROM_LAST P0008 SPACE PN-BEGDA PN-ENDDA.

" Now knowing for what all wage types the employee is eligible.
Do 20 times varying s_wagetypes from p0008-lga01 next p0008-lga02. If s_wagetypes-wagetype is initial.

o Here the data is stored sequentially, i.e., if the employee is eligible for 5 wage types then all the 5 wage types are stored sequentially in lga01 to lga05 respectively. So, if say the lga05 is initial then it is understood that, employee is eligible for only 4 wage types and from lga05 to lga20 structures will be empty so, we need not process further

Exit.
Else.
Write: / s_wagetypes-wagetype,
S_wagetypes-amount.
Endif.
Enddo.



2.2.4 Guidelines to retrieve Payroll data (Mainly US/UK/Ireland)

Before directly going into the Guidelines to retrieve Payroll Data let us look in to the basic concepts of the Payroll.

Introduction to Payroll
To calculate the remuneration for work done for each employee

Payroll does not just involve the calculation of remuneration, but consists of a variety of processes that are becoming increasingly important due to the employers increased obligation to supply benefits and medical welfare. These benefits are products of:

" Labor law

" Tax law

" Contribution law

" Benefits law

" Civil law

" Reporting law

" Information law

" Statistics law


Payroll in the SAP System: In the SAP Human Resources Management System, payroll accounting is executed using the Payroll driver.


Process Flow:

When you access Payroll, the payroll driver calls the accompanying payroll schema, which consists of a sequence of functions. For each activity, the individual functions import data from internal tables and payroll relevant files.

Payroll Integration:

Payroll can be integrated in Personnel Administration, Time Management, Incentive Wages and Accounting:
Standardized data retention enables you to use master data and other payroll relevant data from Personnel Administration.
Time data, entered via Time Management, is automatically included in the Payroll and is valuated during the payroll run. Data from the Incentive Wages component is used to calculate piecework wages and premium wages directly in Payroll.
Information on expenses and payables from Payroll is posted for accounting directly in Financial Accounting, and you assign the costs to the appropriate cost center. You can also control the financial system of third-party providers.

Payroll Driver
Payroll driver is a special report for Payroll.
SAP has developed country-specific payroll drivers, which are based on report RPCALCx0.
The country-specific net calculation of pay must be developed explicitly for every country.

Separate country programs, which meet the tax and insurance requirements of the respective country, can be created from the basic report RPCALCx0. Since the payroll driver has a modular structure, you can use the Customizing functions to quickly modify the payroll procedure to meet the particular requirements of your enterprise.

Integration
Calculation rules and other reports are stored in an accompanying schema, which also contains the activities carried out by the payroll driver during payroll. All data is stored in internal tables and saved in files with a cluster structure.
When you access Payroll, the payroll driver calls the accompanying payroll schema, which consists of a sequence of functions. For each activity, the individual functions import data from internal tables and payroll relevant files.

Payroll Schema:
It contains calculation rules to be used by the payroll driver during payroll.
SAP has developed country-specific schemas, which are based on schema X000.
With country-specific reports, the first character in the name refers to the country indicator.
For example,
D for Germany
F for France
U for USA

Schema Structure A schema consists of the following parts:
1. Initialization
Where system performs the following steps:
Updates the databases
Imports required infotypes
2. Gross calculation of pay
Where system performs the following steps:
Processes basic data and time data
Reads payroll account of the last period accounted
Processes time data and calculate the individual gross values
Performs factoring
3. Net calculation of pay
where system performs the following steps:
Calculates net remuneration
Performs bank transfers

Example:
The classic example is the payroll for salaried employees at the end of the month in contrast to the wage accounting of hourly workers in the middle of the following month.

Enter the organizational assignment of employees to a payroll accounting area (ABKRS) in Infotype 0001. Payroll accounting area also determines the two functions necessary for payroll accounting:
" The summarization of personnel numbers to be accounted and
" The determination of the exact payroll period.

Select Personnel Numbers:
Personnel numbers are selected for payroll accounting by specifying a payroll area in the payroll driver. Infotype 0001 Organizational Assignment enables you to assign an employee to the appropriate payroll area.
These Pernrs are locked during Payroll Run.

Determine Payroll Period:

On the Selection screen, you can give Payroll Period Parameter as per the requirement else you can give Payroll Area, by which system calculates the payroll period.

Finding Payroll Results for a Specific Query:

Payroll results are stored in cluster Rx of the PCL2. The cluster key is not mnemonic; it contains only the PERNR (personnel number) and SEQNO (sequential number) fields.
The internal table RGDIR (PC261 - Cluster Directory for Export and Import of Payroll Results) contains a directory entry for each payroll result.

This entry is a sequential number (RGDIR-SEQNR), which uniquely identifies the payroll result.

Payroll results can only be imported if the payroll cluster key (PC200) contains the personnel number and sequential number.

Function Modules for Selecting Payroll Results
You will probably always have the same queries when importing payroll records. For example, "Which payroll results (original and retroactively accounted records) were written for a specific payroll run (defined by IN payroll category, IN payroll area, IN period)"? To save programmers from having to write their own reports for this functionality, standard modules are available for the most important queries. The employee's payroll directory is always transferred to the function modules using the table RGDIR (PC261). The modules then transfer the payroll records, which satisfy the specified selection criteria using a table whose type corresponds to that of the RGDIR (PC261) but which has a different name.

Exporting Pernr  Personal Number
Importing Molga  Country
Tables Rgdir  Payroll Results Directory

This Function Module populates payroll results of all employees with PERNR & SEQNR as key.
Macro Modules:
We have populated Results Directory & retrieved Sequential Number, we need to call an import macro module for retrieving the required payroll results. For this we need to pass the unique identification of an Employee payroll Result i.e. rx-key-pernr = v_pernr.
rx-key-seqno = v_seqnr.
To that import macro.
Calling Import Module: RP-imp-c2-RU.

This Macro populates all the cluster tables required for Payroll, by importing from PCL2 Cluster Directory. After that we can loop through these cluster tables for required fields.

Guideline to write a program, which retrieves the data for, specified country

" Use Logical Database As per the Requirement.

" Include Payroll Driver with reference to Country- Specific modules which inturn includes Country-specific Schemas etc.

" Get the PERNRs for which you want to obtain payroll results.

" Populate Results Directory RGDIR with PERNR & Molga (Country) calling FM CU_READ_RGDIR.

" Get the Unique Sequential Number with PERNR, From Date & Last Date calling CD_READ_LAST.

" Pass these KEY Field (PERNR, SEQNR) to IMPORT MACRO
RP-IMP-C2- RU to import all the relevant field entries from PCL2
DIRECTORY to all the cluster tables

" Get the required fields by looping through cluster tables.


Integration
All data is stored in internal tables and saved in files with a cluster structure.

Internal Tables: Internal tables store data during payroll.

The system imports data to these tables and used them to calculate new data. This data is then also saved in internal tables.

At the start of the payroll run, the system reads the values from the results tables to the old results table (ORT). Data from the previous period is, therefore, available in the current payroll period.

The most important internal tables are:
" Input table (IT)
Table IT contains data that can be edited. The table exists only during processing.
"" Output table (OT)
Table OT contains the results of an activity. These results are written to the input table for further processing. The table exists only during processing.
"" Results table (RT)
Table RT contains the results of the period for which payroll has been run. The system saves this data in the PCL2 file in cluster RX.

Interaction of IT, OT and RT:
The necessary data for the respective processing step is loaded into the input table and is thus available for various processing procedures. The results of a processing step are stored either in the output table or the results table. At the end of a processing step, the data from the OT is loaded back into the IT, where it is available for further processing steps. The IT and OT are only temporarily filled, whereas the RT is stored on the database. In one of the first processing steps, the RT of the last payroll accounting period is imported into the old results table (ORT) and can consequently be used for further processing.

Payroll Relevant Files:
Payroll files contain data for payroll and payroll results.
Structure
The system requires the following files for payroll:

" Pnnnn (nnnn = number of the infotype)
The Pnnnn files contain data that has been entered in the respective infotypes for an employee.
Example
P0000 - Actions Infotype
P0008 - Basic Pay Infotype


" PCL1
The PCL1 file contains primary information, in other words, data from the master data and time recording systems.

" PCL2
The PCL2 file contains secondary information, in other words, derived data and all generated schemas

Integration

When you start payroll, the system imports the relevant master data from the Pnnnn files (for example, basic pay and tax class) and imports the time data from the PCL1 file to the IT table.
The system imports the payroll results from the previous month from table ORT (for example, to form averages).
The system processes this data and saves the payroll results and generated schemas in the PCL2 file.

Payroll Control

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...