Você está na página 1de 10

SAP HR Logical Database (LDB for short)

A LDB provides read-only access on a group of related database tables


to ABAP programs. There are various advantages of creating HR Reports
using LDB such as the automatic use of Central Authorizations, High
performance, In-built validation to check user input and Meaningful data
access through standard selection-screen .

There are four LDBs available in HR ABAP:


LDB Used for
PNP HR-Administration, Time Management, Payroll
HR-Administration, Time Management, Payroll with concurrent employment
PNPCE
functions
Personnel Development, Organizational Management, Training and Event
PCH
Management
PAP Recruitment:
In this tutorial we will create a report using the LDB PNPCE and I strongly
suggest you to use PNPCE over PNP in all your new developments
because it includes all the functions of the PNP logical database and
offers additional evaluation options. Also it provides us an improved
selection screen and your report benefits from this even if your programs
do not use the functions for evaluating Concurrent Employment.
Step 1: Create a new Executable Program
Go to transaction code SE38. Give a name to your program and then
press the create button.
Go ahead and give your program a good descriptive title. Select
Executable program from the ‘Type’ dropdown field and then
enter PNPCE in the ‘Logical Database’ field. Click on the save button.
Step 2: Assigning the HR Report Category
For SAP HR reports that use a Logical database we have to specify
the Report Category. This determines the type and number of fields that
will appear on the selection screen of the report.
Go back to the initial screen and select the radio button ‘Attributes’ and
then click on the Change button.
Now you can see the ‘HR Report Category‘ button. Click on the button to
assign the appropriate report category to your program:
You can use any of the standard report categories which are provided
with the LDB PNPCE by selecting the F4 help. But for this example we
will create a new custom category to show you how you can create your
own new report categories.

Step 3: Create a new Custom Report Category


Click on create ‘Report category’ push button.
Click on New Entries to create a new ‘Report Category’

 Give a new name to your ‘Report Category’.


 Provide a good description.
 Select the required check boxes from ‘General Data’ and ‘Selection Period’.
 Uncheck all the unwanted fields.
Here I have selected from the General data box:
 ‘Data selection period = Employee selection period’
 ‘Matchcode allowed’
 ‘Org. str allowed’

Now click on ‘Allowable selection criteria’ option on the right hand side of
the screen as shown below.

Click on ‘New Entries’ and select all the required select options from the
F4 help option.
These are the fields which will be shown on the selection screen of your
report.
Click on ‘Save’ to save the newly created ‘Report Category’. Now go back
and save and activate all your work. Press F8 to test the newly created
selection screen using the Logical Database and HR Report Category.

How awesome and simple is that!!

Step 4: ABAP Coding For Our Program


The first thing we have to do is declare the events using the NODES
statement. Note, you can declare NODES ‘PERSON’, ‘NODES GROUP’
or ‘NODES PERAS’ in your program but we have used the GET PERAS
event in this tutorial so we will be declaring NODES PERAS. If you are
not familiar with the Nodes statement check Sap Help here for more
details.
Then we have to declare all the Infotypes from which we are going to
process data using the INFOTYPE statement. This statement creates an
internal table for each Infotype declared.

Set the initial values in INITIALIZATION event.

To fetch the data from the database we use the GET PERAS event.
When the program is executed the LDB reads the selected data and the
internal table of each declared Infotypes is filled with all the records which
are available for a specific personnel number.
Field PERNR-PERNR contains the personnel number for which the
records are being fetched.

Note that the GET event has no ENDGET statement, so the code block
started by the GET event can only be ended with next event statement
we define in our program.
Other useful HR related ABAP Statements
 The PROVIDE…..ENDPROVIDE is useful when you want to work with employee data at
a specific point in time. Because HR data is time dependant it can be difficult/laborious to
create the code that selects all the data you need from specific Infotypes. By using
the Provide statement you can cut out a lot of coding and make use of this inbuilt loop
designed specifically for time dependant data selection.
 RP_PROVIDE_FROM_LAST Macro provides last entry from the Infotype according to the
data selection period. More details here.

 RP_PROVIDE_FROM_FIRST Macro provides first entry from the infotype according to


the data selection period. More Details here.

By using these statements you can fetch and process all the required
data. After adding the required code ensure you save your program.
Step 5: Activate and Test
Activate and test your program to see the output.

I hope you find this quick guide useful. It has helped demonstrate how
easy you can generate HR reports using the SAP delivered Logical
Databases.

Write a comment below and tell me what you though of the article.