Extended Selection in Interactive APO: APO interactive transactions for multiple products don’t usually have all the options for selection that the business may need. This article explains how to use ABAP Query functionality to extend and customize the selection for these transactions.

The article shows – as an example – how the receipts view can be selected by the ABC indicator of the products; a field not present in the standard selection screen. The technical details are explained so it should be easy to adjust the query for other fields and more complex selection requirements.

ABAP query is a powerful functionality that allows complex reporting. It can include ABAP code without the need for a developer key. In this example we combine the query selection with a transaction screen called directly from within the query.

Queries can be exported and shared easily. You can download a file with the definition of the query in this article in the original post in my professional blog (see my profile). You will also find instructions on how to load it into your system.

Interactive transactions

  • Receipt view                      (/SAPAPO/RRP4)
  • Requirement view              (/SAPAPO/RRP1)
  • Product planning Table     (/SAPAPO/PPT1)
  • Product overview               (/SAPAPO/POV1)

These are APO transactions that use the same selection screen. As you can see below the selection options are limited, even if we consider the additional tabs.

Selection screen of /SAPAPO/RRP4

“Other” tab in /SAPAPO/RRP4 selection screen

This is enough in most cases but the user may need a different selection field or approach.

Using the product-location free attributes fields in this way can be particularly useful as these fields can be populated with specific parameters from ECC not available in standard APO.

In the example presented the selection screen will look as follows and includes the ABC indicator as a selection option. The output result will depend on the interactive transaction extended. In this example it will be the receipts list for those product-locations matching the query selection.

Technical details of the interactive transactions

The transactions indicated in the previous chapter all have a similar internal structure. The transaction calls a program include that does the following:

  1. Calls function /SAPAPO/PT_SELSCREEN: This function encapsulates the selection screen and brings back a selection of pegging areas that will be used in the report. Some additional conditions – like the date range – are also returned. All 4 transactions call the same function passing only a different title in a variable so that it shows at the top of the selection screen.
  2. Some manipulation of the selection parameters is performed: For example converting dates into timestamps.
  3. A function is called to display the transaction main screen: This can be just the order list or more complex functionality like the production planning table. This function takes as input the list of pegging areas from the function in point 1.

The following table shows for the 4 transactions the program include where the functions are called and the function used to run the main transaction.



Program Include

Function to run/display

Receipt view




Requirement view




Product planning Table




Product overview




Implementing the query

The query selection substitutes the first function call with a customized extraction of the pegging areas that is then feed to the function that runs the transaction. In this way, we can make the selection much more complex, adding any field available in the product-location master data tables and filtering the combinations before calling the transaction.

For this article we are going to use a simplified selection of product, location and ABC indicator.

First of all we create an infoset by joining the tables indicated below.

Then select the fields to be used in the query.

The “from” and “to” dates are important parameters to reduce processing time. These transactions are usually slow even for a small set of materials and any additional restriction will help performance. Create them as parameters in the query infoset.

Additional selection parameters in query

Definitions for date and time fields

Query Code

ABAP code is required to call the transaction function with the parameters determined by the query.

The following is an explanation of the code logic by sections in the query code tab.


In this section the data variables and structures are defined.

TYPE /sapapo/pegid_tab,
TYPE /sapapo/rrp_pt_selection,
TYPE /sapapo/pegid,
TYPE timestamp,
TYPE timestamp,
TYPE /sapapo/vrsioid,
TYPE REF TO /sapapo/cl_confr_sel.

Record Processing

This is the code that is executed for each of the records returned by the query select of the data.

The query returns a list of pegging areas in table /SAPAPO/PEGKEY for those product-locations included in the selection. Each pegging area ID is copied and appended to the temporary tablelt_pegarea.

* Append the pegging area returned by the query
* in /SAPAPO/PEGKEY into temporary table lt_pegarea
APPEND ls_pegarea TO lt_pegarea.


After the query has collected the pegging areas for the product-locations in the selection, the function that runs the transaction is called.

In addition to the pegging areas, the FROM and TO date timestamps and the active version (000) are passed to the function.

* Fill selection for all order types
Data: ls_sel TYPE /sapapo/ordtype_rstr.
option = ‘CP’.
low = ‘*’.
sign = ‘I’.
APPEND ls_sel TO ls_selectionorder_type_rtab.
* Convert the FROM date and time in the selection
* into a timestamp format
= dtsta
= utimest
= lv_time_from.
* Convert the TO date and time in the selection
* into a timestamp format
= dtend
= utimend
= lv_time_to.
* Active version 000 is set as default
= ‘000’.
* Call the transaction function using the
* pegging area table collected by the query
* and other parameters
= lv_simid
= ls_selectionsource_locno_rtab
= lt_pegarea
= ls_selectionresnam_rtab
= ls_selectionprio_rtab
= ls_selectionorder_type_rtab
= lv_confr_sel
= lv_time_from
= lv_time_to
= ‘X’.

Query definition

The query itself (SQ01) is straightforward. The selection screen shows the parameters defined in the infoset. Add the others parameters as selection. This query will not have any list displayed as the transaction will be called first. Include the fields in the display anyway to make sure the code is executed.

Extended Selection in Interactive APO

It is also important that the query is set as ABAP List to make sure the code in the END-OF-SELECTION section is included and used in the query.

Extended Selection in Interactive APO

Stepping beyond

This basic query can be extended in different ways, for example:

  • Additional fields from the product-location can be added as well as complex checks to exclude pegging areas not needed. Even if the field is included in the transaction list and can be hidden with a layout; it is much more efficient to exclude it in the selection screen.
  • The planning version is hardcoded here to 000 but it can be part of the selection to allow the use of other planning versions.
  • You can have 4 different queries for the 4 different transactions or a single query with a radio button in the selection screen to choose.

Have fun.

(This post was first published on the author’s professional blog, see profile)


New NetWeaver Information at

Very Helpfull



User Rating: Be the first one !