SAP ABAP HR: Logical database PCH in Organization management

The logical databases are oftenly used in HR programming and their use reduces programming effort. The logical databases are special SAP programs created or maintained using transaction SE36 or SLDB though standard logical databases are not meant to be maintained/ edited except under rare circumstances. The source code of a logical database (<ldb>, say) resides in the program named SAPDB<ldb> e.g SAPDBPCH. They provide Selection-screen, mechanisms to access data and authorization handling.
The access to database is programmed inside the logical database so as to avoid explicit access, e.g using SELECT statement, in the report program. In case of PCH, the GET OBJEC event is used in the report program which has its corresponding PUT OBJEC in the logical database which can be checked using transactions SE36 or SLDB but the programmer need not be concerned with this detail. The OBJEC structure, after the GET OBJEC command in the program, is populated with the relevant record fetched from the database.

Next, the logical database provides for central authorization check. Since HR data is sensitive data, so validation of user authorizations is a must before the data can be made available to him/her. So if the programmer is using the logical database, authorization checks are taken care by it and there is no need to check user-authorizations. But if the report program is not using the one, then the programmer needs to take care of the relevant authorization-checks so that only the authorized users get access to the required data.

How to use the logical database PCH in a report program?

At the time of creating a new program or an already existing program in SE38 or SE80, the logical database to be used can be mentioned in the Program Attributes as follows :

In the case of already existing program, you can go to the menu-item Goto->Attributes to reach the above screen.

The logical database PCH can be used for evaluation of data from Organizational Management and Personnel Planning, using attributes like Object type, Evaluation path and relationships.

To start with, create a report program and assign the logical database PCH as discussed above. Now, add the following code :


    TABLES : objec, gdstr.

We will discuss about objec and gdstr structures later. For now, Activate the program and execute and you will see the following selection-screen:

This selection-screen belongs to the logical database PCH. Following a brief description of the fields in the above screen along with their technical names in PCH:

Plan version (PCHPLVAR) : A plan version contains information from Planning perspective and is a code that represents a specific plan. Plans versions are setup in custimzing. For most of the enterprises, "01" is the current plan version.

Object type (PCHOTYPE) : A code that represents different objects in Org Management (OM) & Personnel Planning (PP). For example, O represents an Org unit, S represents a position, Q represents a qualification, E represents a business event, and so on.

Object ID (PCHOBJID) : is the eight-character ID of the object.

Search term (PCHSEARK) : if you don't know the object id of an OM object.

Object status (PCHOSTAT) : All objects have one of the following statuses: Active, Planned, Submitted, Approved, or Rejected.

Data status (PCHISTAT) : You can press the push-button 'Data status' and make the entry in this field. You can use this field to confine the evaluation to infotypes that have a specific status. All infotypes have one of the following statuses: active, planned, submitted, approved, or rejected.

Reporting period : You can specify Object selection period (PCHOBEG, PCHOEND) and Data selection period (PCHBEGDA, PCHENDDA) here.

Evaluation path (PCHWEGID) : is used for structural evaluation e.g. standard evaluation path O-S-P is suitable if you are interested in the relationship construct: organizational unit (O) > position (S) > person (P).

Status Vector (PCHSVECT) : You can specify the status of relationship Infotypes (1001) e.g 1 active, 2 planned, and so on. The selection affects the evaluation of the objects according to the status of the relationship Infotypes (1001).

Status Overlap (PCHACTIV) : is used in conjunction with the Status vector field above and allows you to run a simulation showing the results of activating Relationship infotypes with status entered in the Status Vector field. The change in status is only temporary and will not affect your structure.

Display Depth (PCHDEPTH) : determines for how much levels of hierarchy, information is displayed in a report. For example if you enter 2 here, the top 2 levels are displayed in the report.

Technical Depth (TDEPTH) : generally empty. It represents the levels of the org structure that are evaluated for a query.

Recursion Check (RECURS) : A recursion as you know is an endless loop and happens here when the evaluation of a query doesn't reach an end. In this field, specify whether you want the object links to be checked for recursion.

Apart from it, as you can see a push-button in the screenshot above - Set Structure conditions. You can set additional conditions here.

The logical database can help you in evaluating the structure in 2 ways :
                    1- Sequential Evaluation
                    2- Structural Evaluation

In sequential evaluation, the OM objects (Org units, Positions, Jobs, etc.) are evaluated in a sequential manner one after the other according to their key. Use the TABLES statement in this case as follows :

                                REPORT z_pch_seqeval.
                                    TABLES : OBJEC.
                                    INFOTYPES : 1001.
                                    GET objec.
                                        PROVIDE * FROM p1001 BETWEEN pc-begda AND pc-endda.

In structural evaluation, the objects are evaluated as per the evaluation path entered on the selection-screen and the evaluation starts at the root object. Use the TABLES statement in this case as follows :

                                    REPORT z_pch_streval.

                                    TABLES : OBJEC, GDSTR.
                                    INFOTYPES : 1001, 0002.
                                    GET objec.


                                        CASE objec-otype.
                                            WHEN 'O'. 
                                                PROVIDE * FROM p1001 BETWEEN pc-begda AND pc-endda.

                                                WHEN 'P'. 

                                                PROVIDE * FROM p0002 BETWEEN pc-begda AND pc-endda.


Like in the PNP where structure PN is populated from the selection-screen, in PCH, it is the structure PC as you can see the example program above (pc-begda and pc-endda).

Macros in PCH

The most commonly used macros in the logical database PCH are as follows :
RH_SEL_ONE_OBJID is used in INITIALIZATION event to ensure that the user can enter only one object ID on the selection-screen.

RH_SEL_KEYDATE is used to limit the selection options for the user to key date instead of the date range and other options.

RH-GET-TBDATE is used to read the data of the table infotypes.


mysap HR Technical Principles and Programming, Book from SAP Press
Authors: Ewald Brochhausen, Jürgen Kielisch, Jürgen Scherring, Jens Staeck

Featured Post

Top 5 Reasons you should be on Google+: [1] Immersive Look-and-Feel

Updated on August 5, 2017  due to remarkable changes in the landscape of Google+ making the post up-to-date and current. Enjoy the updated...