SAP System Setup Training Course
Reveals How To Setup A Free SAP Developer System.
Learn SAP & Practice For Certification. Developer Tips Included:

How To Create SAP ABAP HR Reports Using A Logical Database (LDB)

Key Concepts: This is step by step guide for those SAP consultants new to HR ABAP programming who want to create a SAP HR Report or just access HR Infotype data using a Logical Database (LDB).

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
PNPCE HR-Administration, Time Management, Payroll with concurrent employment functions
PCH Personnel Development, Organizational Management, Training and Event 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.

SAP SE38 Create a Program

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.

SAP LDB PNPCE Create A Program

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:

ABAP Program Attributes

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

Details of Added Entries

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

Details of Added Entries 2

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.

Declasre SAP ABAP Nodes and InfoTypes

Set the initial values in INITIALIZATION event.

SAP ABAP - INITIALIZATION of values

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.

  • Was it clear enough?
  • Do you still have questions?

About the Author:

Pete has been working with SAP technologies for over 10 years. He started out as an ABAP consultant and then moved on to BW where he has worked many different clients covering a wide variety of industries. "I love introducing SAP technology (especially BI) to new clients and showing them how they can go from zero to hero within their business in super fast time". Contact me on twitter @PeterMoxon

  • Syed Pasha

    Very nicely presented.

    • vinoth

      Very good one…..
      I tried this….it’s working fine.
      One request ..Kindly post some other ABAP Hr’s functional..

  • ATif

    Hi,
    Thanks for such a nice posting, since I am new to ABAP and this is my first ABAP hr code.
    what type-pools is doing in the code?
    Can’t find the get perform definition.
    it_output is not defined?

    thanks

  • Bobby John

    Awesome piece of work. So simple and to the point.

    Great jobs

  • daniel

    hie how do u view sort fields in the program that would have been selected if u had a sort fields button on the example?

  • Atul Mule

    Can we do Where-Used List for Report Category if it is getting used in multiple programs?

x

Free SAP Training Course