Skip to Content

Logical databases is a differentiating factor in ABAP-HR since it is used extensively here. These logical databases are special ABAP programs that provide fundamental functionality required for reading and processing data related to HR.


SAP HR is divided into different sub-modules and most widely used of these sub-modules are Personnel Administration and Organizational Management. We have PNP and PNPCE logical database for Personnel Administration and PCH logical database for Organizational Management.


I will be covering the programming basics for using PNP (Personnel Administration) logical databases.


PNP for Personnel Administration – This logical database provides standard selection screen based on HR report category that is selected while creation. The data is selected based on the selection made on the selection screen. It also checks if the user who has started the report has the necessary rights/authorization required to read/process the data.


By default there are some report categories while having a pre-defined set of selection screen elements. But we can create our new HR report category to define custom selection screen elements. We can also add our custom selection screen elements in addition to the standard selection screen elements which exist in a pre-defined HR report category.


Sample structure of basic ABAP-HR report program


REPORT zreport.

INFOTYPES: 0001.       “This is the info type declaration area

TABLES: pernr.         “Key fields for Personnel Admin infotypes

START-OF-SELECTION.

GET PERNR.             “Get PERNR gets all data related to a PERNR

PROVIDE * FROM P0001 BETWEEN PN-BEGDA AND PN-ENDDA.

WRITE:/ P0001-PERNR,

        P0001-STELL,

        P0001-BEGDA.

ENDPROVIDE.

Infotypes are basically used to group related together. They provide information and store data for specific time periods. In the above sample program the INFOTYPE statement declares an internal table which is populated at the GET PERNR event.

For example if we have

INFOTYPE: 0001.

This instruction creates an internal table with structure p0001 and which is filled at the GET PERNR event. We also add MODE N to this instruction.

INFOTYPE: 0001 MODE N.

The addition of MODE N restricts data from filling into the internal table at GET PERNR.

GET PERNR statement is basically an event which triggers the data read operation into respective infotypes which have declared by using the INFOTYPES statement for each PERNR (Personnel Number) that satisfies the selection criteria.


Program Flow for GET PERNR event.

/wp-content/uploads/2013/08/1_271524.jpg

The flow of this program is completely dependent on the GET PERNR statement. It acts as a loop and processes all data related to each PERNR one by one. In the above example following sequence of steps occur:

  1. All data belonging to PERNR = 00009001 (example) is read into the internal table p0001 for the date range specified in the selection screen.
  2. All the statements below are executed and data related to above PERNR only exists in the internal tables which were defined at the infotype statement.
  3. After all the statements have been executed the program control goes back to GET PERNR statement, refreshes all the internal tables (like p0001) and reads new data related to the next PERNR = 00009002 into the respective internal tables.
  4. This process continues till all the valid PERNR are processed.

While each PERNR is processed we may need to process individual infotype depending on some constraints. A PROVIDE-ENDPROVIDE loop is used to evaluate individual infotypes.

For example:


PROVIDE * FROM p0001

                   BETWEEN pn-begda AND pn-endda.


* ABAP statements to process data for infotype 0001


ENDPROVIDE.

To report this post you need to login first.

3 Comments

You must be Logged on to comment or reply to a post.

  1. Chris Paine

    Whilst this is an excellent example of a legacy HR ABAP report code, it could be reasonably suggested that PNP logical db shouldn’t be used anymore. If a LDB did need to be used, then the PNP-CE LDB should be used.

    I’d also note that the use of the PROVIDE statement in the form very often found in these legacy HR reports is marked as obsolete if you check the keyword in your ABAP system. Using tables with header lines (as automatically created by the INFOTYPES statement) is also a practice to be discouraged.

    These days if I use the logical databases at all (which I manage to avoid in most cases as I’m coding with WDA or building web applications) then I’d just use them for their selections screens, loop around the LDB, return a list of selected employees and then process that in a separate bit of logic. That way if I do build some WDA or web service which needs to access the same logic, it’s nice and easy – just call it with a list of employee numbers.

    This all said – there is a heap of legacy code that look exactly like the above, so it’s certainly worth understanding what it is attempting to do!

    (0) 
    1. Karan Ranawat Post author

      Thanks for sharing your insights about LDB’s and legacy code.

      I totally agree with all the points made you. But most of the legacy code which exists in most of the HR systems uses most of the above constructs. I just wanted to highlight the process flow and uniqueness for GET PERNR like events which are not very intuitive at the first look for a programmer who hasn’t been coding in HR.

      (0) 
      1. Chris Paine

        I remember teaching the HR350 (ABAP coding for HR) course for SAP many years ago. None of the things we taught were great coding practice, but really just info on how HR was so “special”.

        I like to think that HR is still “special”. Certainly many of us who work with it are 😉 .

        Thanks for writing the blog and taking the time to respond to my comment.

        (0) 

Leave a Reply