Custom HR Reports and Performance
|
This content was generated with the assistance of AI and should be verified against the official documentation before being relied on in production. |
Sooner or later somebody asks for a list that no standard report delivers: "all basic pay records of the warehouse team, sortable, with a column for the wage type". A custom HR report answers such a request. It reads employee data in the way the standard HR reports do, collects the rows in an internal table and shows them as an ALV list, the interactive table with sorting, filtering and export that users know from everywhere in SAP. The same report can become slow when the company has tens of thousands of employees and the report reads far more data than it shows. After reading this page you can build that report, you know the few places where an HR report spends its time, and you can decide which technique to use first: read less data, read it in another way, or process it in parallel. The page is written for classic ABAP in SAP S/4HANA 2025 FPS02 on premise and Private Edition with SAP HCM for SAP S/4HANA (H4S4), a separately licensed component. ALV needs SAP GUI, so everything here is classic ABAP. SAP SuccessFactors has a different data model and other reporting tools that are not covered here.
Before you read
-
Infotypes: what Basic Pay (0008) holds and why an employee has several records of one infotype.
-
HR Data Structures and Tables: the
PAnnnntables and thePnnnnstructures. -
Time Constraints and Validity Periods: how records of one infotype follow each other.
-
The page Logical Databases PNP/PNPCE and HR Macros of this section: it introduces
NODES,INFOTYPES,GET PERAS,PROVIDEand the reportZEXP_BASIC_PAY_LISTthat this page extends. -
ALV (SAP List Viewer): the object model
CL_SALV_TABLEthat the listing uses. -
Internal Tables: the report collects its rows in one.
-
Performance and SQL Trace: how to measure before changing anything.
Key terms
-
ALV: the SAP List Viewer, which shows an internal table as an interactive table.
-
PNPCE: the logical database that reads HR master data for reports and supports concurrent employment.
-
Evaluation period: the date range of the selection screen that tells the report which records it wants.
-
Person selection period: the period in which a person must meet the selection conditions to be selected at all.
-
Data selection period: the period for which the records of the selected persons are read.
-
MODE N: an addition of the
INFOTYPESstatement that detaches an infotype table from the logical database, so the program reads it itself. -
Parallel processing: splitting the work of one report into packages that several work processes run at the same time.
The running example and what this page adds
All HR pages use one fictitious business, Example Trading Co. Every personnel number, wage type and amount is an invented example value, not a
value delivered by SAP. This page reuses the Basic Pay (0008) data of the page on the logical databases: Ana Torres (00001234) with wage type
1000 "Monthly salary" and 4,000.00 EUR, Ben Okoye (00001235) with wage type 1000 and 2,400.00 EUR, and Chloe Martin (00001236) with the
invented wage type 2000 "Hourly pay" and an hourly rate of 14.00 EUR. All three records are valid from the hiring date of the employee to
31.12.9999. The page extends that example in one way: the ALV report below is a second report, named ZEXP_BASIC_PAY_ALV, that shows the same
lines in an interactive list instead of a WRITE list. The name is invented for this site.
Choosing the tool for a custom HR report
Before writing a report, check whether one is needed. SAP delivers standard HR reports, and the system has query tools, covered on the page
SAP Query and QuickViewer, that let a key user build a list without ABAP. A custom
report is the right tool when the list needs logic that a query cannot express, for example a join of several infotypes with a calculation, or
when the same report must run on a schedule with fixed variants. The book SAP ERP HCM: Technical Principles and Programming, 1st edition (2013),
describes the same split and also advises considering SELECT statements or function modules instead of a logical database for high-volume programs
such as interfaces and data conversions, because a logical database can be slow for a large employee population. This page treats that as the
author’s advice from 2013; the section on reading less data below says what the SAP Help pages confirm.
The report pattern: collect at the GET event, show at the end
A report on a logical database is driven by events. The logical database raises GET peras once for every selected personnel assignment, and the
WRITE list of the previous page prints inside that event. An ALV list works differently: ALV needs the whole table before it draws anything. The
pattern is therefore always the same three steps.
-
At
GET peras, read the records of the person and append one row per result line to an internal table of your own. -
After the last person, at
END-OF-SELECTION, the internal table is complete. -
Hand the table to
cl_salv_table=>factory, set the columns and calldisplay, exactly as on the ALV page.
A complete report: basic pay as an ALV list
The report below reads the Basic Pay records in the evaluation period, as the earlier report ZEXP_BASIC_PAY_LIST does, but appends each wage type
line to a table instead of writing it. The logical database PNPCE is entered in the attributes of the program, not in the source. The statement
forms for the data part (TABLES, NODES, INFOTYPES, PROVIDE, DO VARYING) are the ones of the previous page. The ALV methods
(factory, get_columns, set_optimize, get_column, set_medium_text, set_currency_column, get_sorts, add_sort, get_functions,
set_all, get_display_settings, set_striped_pattern, set_list_header) are the ones shown on the ALV page.
Requires an SAP system; not run here.
REPORT zexp_basic_pay_alv.
TABLES pernr.
NODES peras.
INFOTYPES 0008.
TYPES: BEGIN OF ty_line,
pernr TYPE p0008-pernr,
begda TYPE p0008-begda,
endda TYPE p0008-endda,
lgart TYPE p0008-lga01,
betrg TYPE p0008-bet01,
waers TYPE waers,
END OF ty_line.
DATA lines TYPE STANDARD TABLE OF ty_line WITH EMPTY KEY.
DATA: BEGIN OF wagetypes,
lga LIKE p0008-lga01,
bet LIKE p0008-bet01,
END OF wagetypes.
GET peras.
PROVIDE * FROM p0008 BETWEEN pn-begda AND pn-endda.
DO 20 TIMES VARYING wagetypes FROM p0008-lga01 NEXT p0008-lga02.
IF wagetypes-lga IS INITIAL.
EXIT.
ENDIF.
APPEND VALUE #( pernr = peras-pernr
begda = p0008-begda
endda = p0008-endda
lgart = wagetypes-lga
betrg = wagetypes-bet
waers = 'EUR' ) TO lines.
ENDDO.
ENDPROVIDE.
END-OF-SELECTION.
IF lines IS INITIAL.
MESSAGE 'No basic pay records in the evaluation period' TYPE 'S'.
RETURN.
ENDIF.
TRY.
cl_salv_table=>factory(
IMPORTING r_salv_table = DATA(alv)
CHANGING t_table = lines ).
CATCH cx_salv_msg INTO DATA(factory_error).
MESSAGE factory_error TYPE 'I' DISPLAY LIKE 'E'.
RETURN.
ENDTRY.
TRY.
DATA(columns) = alv->get_columns( ).
columns->set_optimize( abap_true ).
columns->get_column( 'PERNR' )->set_medium_text( 'Personnel no.' ).
columns->get_column( 'BEGDA' )->set_medium_text( 'Valid from' ).
columns->get_column( 'ENDDA' )->set_medium_text( 'Valid to' ).
columns->get_column( 'LGART' )->set_medium_text( 'Wage type' ).
DATA(amount) = CAST cl_salv_column_table( columns->get_column( 'BETRG' ) ).
amount->set_medium_text( 'Amount' ).
amount->set_currency_column( 'WAERS' ).
alv->get_sorts( )->add_sort( 'PERNR' ).
alv->get_functions( )->set_all( abap_true ).
DATA(display_settings) = alv->get_display_settings( ).
display_settings->set_striped_pattern( abap_true ).
display_settings->set_list_header( 'Basic pay, Example Trading Co.' ).
CATCH cx_salv_error.
" a column name that does not exist, or a column sorted twice
RETURN.
ENDTRY.
alv->display( ).
Source: Repetitive Structures (PA-PAD) (SAP Help), PROVIDE - Short Form (ABAP Keyword Documentation 7.51), SAP NetWeaver 7.3 help: Getting and Modifying Subobjects of a Main Class
Three details of the listing are choices of this example. The currency column WAERS holds the constant EUR because the example has one
currency and the page does not name the currency field of the infotype, which no page read for it names; a real report takes the currency
from the record. The column names of the table row are written in capital letters because ALV identifies columns by the field names of the row
type. The headings are set in code because the local type has no data elements, so ALV would otherwise show the field names.
What the user sees follows from these rules. It was derived by hand and was not produced by a system. For the selection of Ana alone and the evaluation period 01.03.2026 to 31.03.2026, the table holds one row. For all three employees it holds three rows, sorted by personnel number:
| Personnel no. | Valid from | Valid to | Wage type | Amount | Currency |
|---|---|---|---|---|---|
00001234 |
01.03.2026 |
31.03.2026 |
1000 |
4,000.00 |
EUR |
00001235 |
01.03.2026 |
31.03.2026 |
1000 |
2,400.00 |
EUR |
00001236 |
01.03.2026 |
31.03.2026 |
2000 |
14.00 |
EUR |
The report sets no total on purpose. A total of the amount column would add 4,000.00, 2,400.00 and 14.00, but the last value is an hourly rate and
the other two are monthly salaries, so the sum of all three means nothing. The user can still filter on wage type 1000 and add up the amount in
the toolbar, which gives 4,000.00 + 2,400.00 = 6,400.00. The point is general: an ALV total adds whatever the column holds, so the report author
decides which columns may be summed.
Where an HR report spends its time
An HR report on a logical database does three kinds of work, and each has its own remedy.
| Work | What makes it expensive | First remedy |
|---|---|---|
Selecting persons |
The logical database must find every personnel number that matches the selection screen in the person selection period. |
Narrow the selection: personnel area, organizational unit, a shorter period, a saved variant. |
Reading and checking records |
Every infotype named in an |
Declare only the infotypes the report needs, and read the others for a short period or only when needed. |
Processing and displaying |
The report copies rows around, loops over large internal tables or hands ALV a table far wider and longer than the user needs. |
Fill the output table once, avoid copying rows, and show only the columns and rows the user asked for. |
Measure before changing anything. The page Performance and SQL Trace shows how to find the slow part; without a measurement it is easy to optimize a part that costs little.
Read less data
Four settings, each confirmed by SAP documentation, decide how much data the report reads.
-
The evaluation period. On a PNP or PNPCE report the selection screen holds a person selection period and a data selection period. Persons are first selected by the selection conditions in the person selection period, and then the records of those persons are read for the data selection period. A report for one month of 2026 therefore reads one month of records, not the whole history, as long as the user enters that month. The book describes the same two periods; the SAP Help page on the report selection screen lists the other narrowing functions: further selections, a search help, an organizational structure selection, a multiple selection, selection options and, for PNPCE only, selection IDs defined in Customizing.
-
The data selection period per infotype. The macro
RP_SET_DATA_INTERVALchanges the data selection period of one infotype. SAP Help says to use it at theINITIALIZATIONevent and gives it three values: the infotype, the start and the end of the interval. The ABAP Keyword Documentation adds that for PNPCE the macrosRP_SET_DATA_INTERVAL_INFTYandRP_SET_DATA_INTERVAL_ALLset the period as well. A report that needs the current organizational assignment of everybody, whatever period the user entered, narrows infotype 0001 to today and leaves the rest alone. -
MODE N. An infotype declared without
MODE Nis filled by the logical database at theGETevent for every person. WithMODE Nthe table is not associated with the logical database and is not filled at theGETevents, so the program decides when and for which period to read it. The Keyword Documentation says this for the statementINFOTYPES nnnn MODE N. Use it for infotypes that only some persons need, for example time data that the report reads only for employees with a certain wage type. -
The reading macro. To read the records of one infotype for one person in a period, SAP Help names the macro
RP_READ_INFOTYPE. It takes the personnel number, the infotype number, the name of the internal infotype table and the start and end of the period. After the call, the fieldsPNP-SW-FOUNDandPNP-SW-AUTH-SKIPPED-RECORDsay whether a record was found and whether the authorization check withheld a record. The page says that in the logical database PNP an infotype is normally read withGET PERNR, and that this macro is the exception. A second option named there is the function moduleHR_READ_INFOTYPE, whose documentation is in the system (transactionSE37); the page on reading infotypes in this section covers it.
Requires an SAP system; not run here. The fragment below combines the two settings. The macro line is written in the form of the SAP Help example; the exact macro spelling and its include are checked in the system.
INFOTYPES: 0008,
0001 MODE N.
INITIALIZATION.
RP_SET_DATA_INTERVAL 0008 sy-datum sy-datum.
Source: INFOTYPES (ABAP Keyword Documentation 7.51), Definition of the Data Selection Period (SAP Help), Read the Infotype for One Person in a Period (SAP Help)
The fragment makes the Basic Pay table of the report show only the records valid today, and leaves infotype 0001 to be read by the program on demand. Narrowing the period also changes the result, so the report must say so to the user: a list of "current basic pay" is a different report from a list of "basic pay in March 2026".
Authorization checks are part of the cost and of the result. A report that reads through the logical database gets the standard checks; a report that
declares an infotype with MODE N and reads it itself must check the authorizations itself. The page Authorization and skipped personnel numbers on
the logical database page describes the check and the function module that the documentation names for it.
Read in a different way, or process fewer copies
Two techniques concern the program rather than the data.
-
Avoid copying rows. A
LOOP AT itab INTO wacopies every row into a work area.LOOP AT itab ASSIGNING <fs>points a field symbol at the row in place. The page Internal Tables: Processing and Grouping explains both. The book reports a clear difference in run time for a table of about 200,000 records of infotype 2010; the exact figure belongs to its test system, so measure in your own. -
Do not hand ALV more than it needs. A report that selects 50 fields of a wide table and shows 6 uses memory and network time for nothing. Fill the output table with the columns that are shown, as the listing above does.
ALV with IDA, described on the ALV page, shows a database table or a CDS view without an internal table. It is not a replacement for the logical database in an HR report: it would read the table directly and so skip the checks that the logical database performs for each infotype record, as the page on logical databases describes them. In an HR report the logical database stays the reading path that applies the authorization checks for you.
Parallel processing for large populations
When even the narrowest sensible selection is too much for one work process, the work can be split. SAP Help describes parallel processing as a
technique implemented in ABAP reports, not in the background processing system: a report parcels out its work to the available dialog work processes
of the system and collects the results, and a job runs in parallel only if the report is programmed for it. The pattern is: divide the data into work
packets, start one asynchronous function module call per packet with the keyword CALL FUNCTION ... STARTING NEW TASK ... DESTINATION IN GROUP, and
collect the results. The same page warns that only this variant of asynchronous RFC should be used, because the other variants bypass the built-in
safeguards and can overload the system. It names the optional function module SPBT_INITIALIZE for checking the availability of work processes so that
the packets can be sized.
For an HR report the packets are groups of personnel numbers. The standard programs for payroll and evaluations use the same idea with their own scheduler programs, which the book describes: it says that employees are split into separate background jobs that run at the same time. A custom report can follow the pattern, but only when its logic for one person does not depend on another person. A list of basic pay lines does not; a report that ranks employees against each other does.
A rough model helps to decide whether splitting pays off. With the run time of the report in one process, the number of packets that really run at the same time and the extra time for splitting and collecting, the expected run time is:
As an illustration with invented numbers, not a measurement: a report on 12,000 personnel numbers takes minutes in one process. In packets of 3,000 personnel numbers there are packets. With an assumed overhead minutes, the model gives minutes. The arithmetic was checked by script, and the model shows only the shape of the gain: it never reaches because of , and it assumes that enough work processes are free, which on a system shared with dialog users they often are not.
Requires an SAP system; not run here. The SAP Help page gives the keyword and the function modules; the complete pattern with its function module for one packet is in that page and in the in-system documentation, and is not reproduced here.
Common mistakes
-
Showing everything and filtering in ALV. The user filters 5 rows out of 500,000 after waiting for all of them. Narrow the selection instead.
-
Summing a column that mixes units. The example above shows a monthly salary and an hourly rate in one column; a total is meaningless.
-
Using
MODE Nand forgetting the authorization check. The logical database no longer checks what the program reads itself. -
Reading with the whole history by default. A report for "now" should say "now" in its data selection period.
-
Optimizing without a measurement. Run the measurement first and change the part that costs the most.
-
Parallel processing of work that depends on other persons. Packets run independently and in no fixed order.
What older books show, and what has changed
The book SAP ERP HCM: Technical Principles and Programming, 1st edition (2013), by Dirk Liepold and Steve Ritter, covers custom HR reports in its chapter on reports and in its chapter on HCM performance programming. It shows a world before H4S4:
-
It builds ALV samples with the object model and also with the reuse function modules. The object model remains what SAP recommends for new code; the function-module style is legacy, as the ALV page of this site explains.
-
It advises parallel processing for custom logical database programs and describes the standard parallel schedulers for payroll and evaluations. The SAP Help page used on this page confirms the general parallel pattern; it does not describe those schedulers, so check their documentation in the system.
-
It advises
SELECTstatements or function modules for high-volume programs. This page keeps that as the author’s advice and does not repeat it as an SAP rule; the logical database stays the path that applies the authorization checks. -
It describes SAP ERP HCM as the HR product of the SAP Business Suite. What changed is the product: the same infotype and logical database concepts now belong to H4S4, which is licensed separately. Another change is SAP SuccessFactors, which has its own data model, so a custom report there is not an ABAP report on
PAtables. -
Its performance figures come from systems of 2013. SAP HANA changes the cost of database reads, so measure on the system you use.
Summary
-
A custom HR report reads through a logical database such as PNPCE, collects its rows in an internal table at the
GETevent and shows them with ALV atEND-OF-SELECTION. -
The report
ZEXP_BASIC_PAY_ALVof this page lists the Basic Pay lines of Ana, Ben and Chloe and sets no total, because one column mixes monthly salaries and an hourly rate. -
The first remedy for a slow report is to read less: a narrow selection, a short evaluation period,
RP_SET_DATA_INTERVALper infotype, andMODE Nfor infotypes that only some persons need. -
MODE NandRP_READ_INFOTYPEmove the reading into the program, and with it the responsibility for the authorization check. -
Splitting the work into packets that run in parallel helps only when the work for one person does not depend on another; a simple model shows the gain but never reaches the ideal.
-
Measure before and after, and treat the figures of older books as examples, not as promises.