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
INFOTYPES: 0001. “This is the info type declaration area
TABLES: pernr. “Key fields for Personnel Admin infotypes
GET PERNR. “Get PERNR gets all data related to a PERNR
PROVIDE * FROM P0001 BETWEEN PN-BEGDA AND PN-ENDDA.
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
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.
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:
- All data belonging to PERNR = 00009001 (example) is read into the internal table p0001 for the date range specified in the selection screen.
- 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.
- 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.
- 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.
PROVIDE * FROM p0001
BETWEEN pn-begda AND pn-endda.
* ABAP statements to process data for infotype 0001