Learn about the two most popular ways to access Organizational Management data and discover when to use each method.
Key Concept
Two approaches are common with the retrieval process of most SAP information. The first is to access the data via a standard logical database. The other approach is based on using function modules along with more ABAP coding. The Organizational Management module uses the PCH logical database.
With SAP R/3, you can store the entire organizational hierarchy of your company along with relevant positions and job descriptions within the Organizational Management (OM) submodule. You may need to access data stored in OM to display in your reports and queries.
For example, a user may ask for a report that generates a list of all positions within a certain company department. Retrieving such field information may be confusing because OM data storage differs from that of the Personnel Administration (PA) module. SAP documentation does not fully explain how to access OM data.
Although SAP provides standard OM reports and Ad Hoc Query, you may need to develop custom reports to access your data when:
- You have a fixed report format (layout) that is too specific and you cannot use a standard SAP report or the Ad Hoc Query output
- Users demand a form-like or tabular output
- You face unique requirements (that Ad Hoc Query cannot fulfill) that call for more fields than what an SAP standard report contains
- Users want to view OM information along with other submodules or application information in one report
You could use two different approaches for accessing the information stored in OM. The first approach uses SAP-provided logical database PCH and involves coding within the GET OBJEC
event.
You can use the second one in programs and queries with or without this logical database. For more information about GET OBJEC
, refer to the sidebar “The GET OBJEC Event.”
I will start by explaining the storage architecture of OM data and the transaction that you can use to view them. Then, I’ll compare and discuss the two approaches and their advantages and limitations. I will also provide debugging tips for each of the two approaches. Functional analysts with the appropriate security and authorizations can use a custom ABAP program or query to access the relevant data by following these steps.
View Data from OM and PE
Before you access the data, you must be familiar with the underlying storage data structure. To view data pertinent to objects in OM (as well as Training and Event Management [PE]), use transaction PP01. This transaction reads the results from the involved infotype tables and displays them on the screen.
When you call transaction PP01, the screen in Figure 1 appears. At the top of the screen, fields Object type and Object ID allow you to choose the name of the object type and eight-digit code for the object. Enter suitable values in these fields and press Enter.

Figure 1
Transaction PP01
The lower part of the screen shows the names of the various infotypes that may exist for the object along with the date. Once you enter an existing object, the screen highlights the infotypes that contain data with a check mark icon (Figure 2). Select a name with a check mark in front of it and then click on the display icon at the top of the screen. This allows you to view any infotype data related to the object.

Figure 2
The lower part of the PP01 screen
Note
I use transaction PP01 for viewing OM data. However, you could use other transactions, for example, PPOSE.
Choose Your Approach
Use the approach that best suits your reporting requirements. The first approach for OM data uses logical database PCH, and the second does not. Table 1 compares the two approaches that I’ll describe.
Criteria |
Approach 1 (PCH) |
Approach 2 (Without PCH) |
PCH required |
Yes |
No |
User exits/Business Add-Ins (BAdIs) |
Yes |
Yes |
User exits/BAdIs |
Difficult |
Easy |
Built-in authorization |
Yes |
No |
|
Table 1 |
Compare the two approaches |
Approach 1: With Logical Database PCH
To create a program that uses PCH for finding OM-related data, follow these three steps. You must perform all the steps to write the code in Figure 3. The code displays the set of positions that a set of organizational units contains.
REPORT ZREAD_OM_DATA. TABLES : OBJEC, GDSET,GDSTR. INFOTYPES : 1000, 1001. DATA : POSITION_NAME LIKE P1000-STEXT. DATA : POSITION_ID LIKE PLOG-OBJID. START-OF-SELECTION. GET OBJEC. LOOP AT P1001 WHERE RSIGN EQ 'B' AND RELAT EQ '003' AND SCLAS EQ 'S'. POSITION_ID = P1001-SOBID. CALL FUNCTION 'RH_READ_OBJECT' EXPORTING PLVAR = P1001-PLVAR OTYPE = P1001-SCLAS OBJID = POSITION_ID LANGU = SY-LANGU IMPORTING STEXT = POSITION_NAME EXCEPTIONS NOT_FOUND = 1 OTHERS = 2. IF SY-SUBRC EQ 0. WRITE :/ POSITION_ID , POSITION_NAME(30). ENDIF. ENDLOOP. END-OF-SELECTION.
|
Figure 3 |
Code that allows you to display OM data |
Note
Custom ABAP programs often use logical database PCH because it offers features such as a selection screen and authorization checks and minimizes coding.
Click here to download the code in
Figures 3, 8, 9, and
10. Step 1. Make a custom program with transaction SE38. Give your program a meaningful name, such as Z_READ_OM_DATA, and click on the Create button. This brings you to the Attributes screen. Enter a description and the entries shown in Figure 4. Enter PCH
as the Logical database. The system checks the Fixed point arithmetic box to accurately compile data. Choose Status Customer production program because the production system needs to use your custom program later. Save your program, which takes you to an ABAP editor screen where you can enter the code in Figure 3.

figure 4
Create a custom ABAP program
Step 2. Define the logical database tables and create the custom program’s selection screen. This screen allows the user to choose the object type number along with the object IDs. The following code fragment allows you to generate the screen:
TABLES: OBJEC, GDSTR, GDSET.
The TABLES
statement displays the PCH screen in Figure 5.

Figure 5
PCH selection screen with Object type and Object ID options
This screen provides many fields that let users view the data for a number of objects over a certain time period. For example, if users want to view all the data relevant to the current year, they may select Current year.
On the other hand, if they want to see data for a particular date, they can click on the Key date button. The reporting section of the screen changes, as shown in Figure 6. Users enter the Key date in the field provided.

Figure 6
Enter a key date in the PCH selection screen
However, if users want to generate a list based on a set of objects and their data has different validity period ranges, they can click on the Other period button in Figure 5. The reporting section of the screen changes, as shown in Figure 7. This lets the user choose a different value for the Object selection period field and Data selection period field.

Figure 7
Enter different object and data selection periods
Note
You can set a default reporting period for when users run this custom program by assigning appropriate values to the PCHTIMED variable in the INITIALIZATION event. For example, you may assign a value of M for current month or D for today’s date to PCHTIMED.
You also need to identify the infotypes from which the program reads data. Enter the following code in the ABAP editor screen:
INFOTYPES: 1001 1005
Step 3. Retrieve data related to the object and display it. This involves coding within the GET OBJEC
event. You may need to use standard SAP function modules (I’ll discuss the details in the next section).
Approach 2: Without Logical Database PCH
Although the first approach is easier for developers, it has some restrictions and limitations (see Table 1). Approach 2 uses standard function modules to retrieve OM data. Table 2 shows some of these modules. You must perform the following steps to write the code shown in Figure 8.
Function module |
Purpose |
RH_READ_OBJECT |
Reads object’s name and validity dates |
RH_READ_INFTY |
Accesses data from object infotypes |
RH_READ_INFTY_1001 |
Reads data from infotype 1001 |
RH_READ_INFTY_NNNN |
Accesses data from infotypes other than 1000 and 1001 |
|
Table 2 |
Some function modules that access OM data |
CALL FUNCTION 'RH_READ_INFTY' EXPORTING AUTHORITY = SPACE WITH_STRU_AUTH = SPACE INFTY = '1001' SUBTY = 'B003' ISTAT = '1' TABLES INNNN = RELATIONS OBJECTS = MYORG_UNIT EXCEPTIONS ALL_INFTY_WITH_SUBTY = 1 NOTHING_FOUND = 2 NO_OBJECTS = 3 WRONG_CONDITION = 4 OTHERS = 5. LOOP AT RELATIONS. POSITION_ID = RELATIONS-SOBID. CALL FUNCTION 'RH_READ_OBJECT' EXPORTING PLVAR = RELATIONS-PLVAR OTYPE = RELATIONS-SCLAS OBJID = POSITION_ID LANGU = SY-LANGU IMPORTING STEXT = POSITION_NAME EXCEPTIONS NOT_FOUND = 1 OTHERS = 2. IF SY-SUBRC EQ 0. WRITE :/ POSITION_ID , POSITION_NAME(30). ENDIF. ENDLOOP . ………. ……….
|
Figure 8 |
Complete code for approach 2 |
To better understand this approach, consider a simple scenario. Suppose you need to display all the positions incorporated within a particular organizational unit. Figure 8 shows the complete code that reads and displays all positions within org unit 50001256.
Note
You may also use the function modules in Table 2 to read data from PE.
Step 1. Import infotype data. First, you need to define a variable for your object and fill it with the necessary object information. The code that defines the org unit with ID 50001256 is shown below. Insert this code in an ABAP program using transaction SE38 or within an SAP Query. You use this code to write the full code in Figure 8.
DATA : MYORG_UNIT LIKE HROBJECT OCCURS 0 WITH HEADER LINE.
DATA : RELATIONS LIKE P1001 OCCURS 0 WITH HEADER LINE.
DATA : POSITION_NAME LIKE P1000-STEXT.
DATA : POSITION_ID LIKE PLOG-OBJID.
CLEAR MYORG_UNIT.
REFRESH : MYORG_UNIT, RELATIONS.
MYORG_UNIT-PLVAR = '01'.
MYORG_UNIT-OTYPE = 'O'.
MYORG_UNIT-OBJID = '50001256'.
APPEND MYORG_UNIT.
DATA : MYORG_UNIT LIKE HROBJECT
OCCURS 0 WITH HEADERLINE.
MYORG_UNIT-PLVAR = '01'.
MYORG_UNIT-OTYPE = 'O'.
MYORG_UNIT-OBJID = '50001256'.
APPEND MYORG_UNIT.
Next, you need to define a suitable data object (an internal table in this case) to store the relevant infotype data. To read infotype 1001, use the following data object declaration:
DATA : RELATIONS LIKE P1001
OCCURS 0 WITH HEADER LINE.
Write this code in a custom ABAP program (with or without PCH logical database) or within an SAP Query. Use it to write the full code in Figure 8.
Then, use an appropriate function module to read the data and populate the infotype’s internal table. The function module you use depends on its purpose. If you want to read an object’s infotype, use RH_READ_INFTY; for the name of an object, use RH_READ_OBJECT. You can use the RH_READ_INFTY function module as shown in Figure 9.
CALL FUNCTION 'RH_READ_INFTY' EXPORTING AUTHORITY = SPACE WITH_STRU_AUTH = SPACE INFTY = '1001' SUBTY = 'B003' ISTAT = '1' TABLES INNNN = RELATIONS OBJECTS = MYORG_UNIT.
|
Figure 9 |
Use function module RH_READ_INFTY to read the object’s infotype |
As with the code above, write it in a custom ABAP program (with or without PCH logical database) or within an SAP Query. Use it to write the full code in Figure 8.
This function module passes the infotype number and subtype (including the relationship type and code) to parameters INFTY and SUBTY, respectively.
Note
While calling any of these function modules, make sure that you define the variables passed as parameters using the correct data types. Correct data types correspond to each parameter of the function. The programmer must make sure that for each parameter, the type of the variable used is compatible to the parameter type. For example, a string parameter value is read into a string variable, an amount into an amount. Otherwise, the system may generate a short data dump upon program execution: The program abnormally terminates and throws the user out of the
Step 2. Read names of related objects. The data stored in infotypes may contain object IDs. In certain cases, you may want to hide them from users. You may have to display the name of the related objects rather than their eight-digit code. To do this, use the function module RH_READ_OBJECT. You can use this code in a loop to read multiple object names.
Write the code in Figure 10 within an SAP Query or in a custom ABAP program (with or without PCH logical database). Use it to write the full code in Figure 8.
CALL FUNCTION 'RH_READ_OBJECT' EXPORTING PLVAR = RELATIONS-PLVAR OTYPE = RELATIONS-SCLAS OBJID = POSITION_ID LANGU = SY-LANGU IMPORTING STEXT = POSITION_NAME.
|
Figure 10 |
Use function module RH_READ_OBJECT to read the object’s names |
Note
The function module RH_READ_OBJECT only reads names of objects created within OM. If you want to read position texts in PA, access the table directly.
For multilingual SAP installations, it is a good practice to use the system language SY-LANGU for parameter LANGU. When you specify SY-LANGU, the system automatically reads the name in the language in which the user is logged in. This lets your program effectively read object names in a variety of languages.
You can also use the approach 2 code in SAP Query for accessing OM data. As I explained in my SAPexperts article “Use Clusters to Access Infotype Texts,” you can create an additional field and then insert the code in the additional field code.
You may use the function module RH_READ_OBJECT in programs and queries to read the texts related to a particular object.
Troubleshooting Hints
If you try to access the OM data in programs or queries based on either of the approaches and the system seems to display erroneous results, you need to check whether R/3 is correctly executing the code and passing the correct object IDs.
Step 1. Enter transaction SE38. In the Program field, enter the name of the program you created and click on the Display button. In case of a query, access the code of the additional field via the available code editor. For more information, refer to my December 2004 HR Expert article.
Step 2. Set a breakpoint. For approach 1, place the cursor on the line just after the GETOBJEC statement or the line after the ON CHANGE OF statement. If you use approach 2, place the cursor on the RH_READ_OBJECT or RH_READ_INFTY function call. Click on the stop icon to set a breakpoint. Otherwise, particularly in SAP Query, you may enter the statement BREAK
followed by the user name before the function call (for example, BREAK
JOHN
).
Step 3. Execute the custom program or query. As mentioned above, the program stops in the debugging mode if you’ve set a breakpoint.
Step 4. Execute each line of the program by pressing F5. This allows you to monitor the values of the variables involved during the data access, therefore helping you track the cause of the error. Use the debugger to view the contents of the involved data objects.
Sidebar: The GET OBJEC Event
While using logical database PCH to access OM data, you must understand the behavior of the
GET OBJEC
event. You should also become familiar with the information that is available while executing this event. The most important data object available during execution of the
GET OBJEC
event is
OBJEC (
Figure 1).

Side 1
Data structure OBJEC
The code’s layout might look as follows:
INITIALIZATION.
START-OF-SELECTION.
……….
GET OBJEC
………
ON CHANGE OF GDSTR. " not always required
ENDON.
END-OF-SELECTION.
This is the template or basic structure of the program to help you understand how the GET
event behaves. The GET OBJEC
event runs once for every object selected during the program execution. This leads to the execution of the code between the GET OBJEC
and END-OF-SELECTION
events. During this iteration, the system populates the tables corresponding to infotypes specified in the program. You may insert the appropriate code between the GET OBJEC
and END-OF-SELECTION
statements to suit your user’s requirement.
For example, if you like to display the ID and name of the object that the system is currently processing, the code looks like this:
GET OBJEC.
WRITE :/ OBJEC-OBJID, OBJEC-STEXT.
END-OF-SELECTION.
Insert this code in an ABAP program using transaction SE38.
You may also use the PCH object selection start and end dates (PCHOBEG and PCHOEND) and the data selection start and end dates (PCHBEGDA and PCHENDDA) within the GET OBJEC
event to read data relevant to a particular period.
You may use the optional Evaluation path field provided on the PCH screen to enhance the reporting capability. In addition to the selected objects, this approach allows you to automatically run the code between the GET OBJEC …
for related objects, depending on the evaluation path. This allows you to have more power with less coding.
Evaluation paths are a set of objects and their relationships. They may or may not be recursive. For example, you can use the recursive O-O-S evaluation path to view all the positions within a company. The values entered on the PCH screen may look like those shown in Figure 2.

Side 2
Executing PCH program for evaluation path O-O-S
In this case, the system allows you to navigate through a root organizational unit and its positions, then the organizational units contained in it and the positions within, and so on. The system follows this parent-child link until it has sorted through all the positions.
After using the evaluation path, the
GET OBJEC
event’s behavior changes. The system runs the
GET OBJEC
event and populates the
OBJEC
structure for each related object (in my example, all org units and positions). The
GDSTR
structure (which keeps track of the primary object when using an evaluation path). only contains the data of the primary object. The system follows a parent-child relationship, so the organizational units are primary in this case. The system lists all the positions contained in the respective units (organizational units in our example). You may use the
ON CHANGE OF
event to track the value of the parent organizational unit at any given instant. The code to insert into ABAP Editor that displays all the positions IDs as well as the unit to which they belong is shown:
………..
………..
GET OBJEC.
IF OBJEC-OTYPE EQ 'S'.
WRITE :/ OBJEC-OBJID.
ENDIF.
ON CHANGE OF GDSTR.
WRITE :/ GDSTR-OBJID.
ENDON.
END-OF-SELECTION.
Rehan Zaidi
Rehan Zaidi is a consultant for several international SAP clients (both on-site and remotely) on a wide range of SAP technical and functional requirements, and also provides writing and documentation services for their SAP- and ABAP-related products. He started working with SAP in 1999 and writing about his experiences in 2001. Rehan has written several articles for both SAP Professional Journal and HR Expert, and also has a number of popular SAP- and ABAP-related books to his credit.
You may contact the author at erpdomain@gmail.com.
If you have comments about this article or publication, or would like to submit an article idea, please contact the editor.