Event action – Abstract
Purpose: Populates the fields for 'Aggregate number of packages' across line item levels of all or selected line item types in a general business object and optionally (additionally) summarizes the 'Number of packages' of the direct line items as on the header level.
Tooltip
Usage: The event action must be executed with a common business object as the reference object. The calculation optionally takes into account selected or all Line item types. Depending on the Calculate summary option, the 'Number of packages' in the header level is also updated.
Parameter:
The optional multiple selection for Line item types defines line item types for which the 'Aggregate number of packages' should be calculated. By default (without a selection), the 'Aggregate number of packages' is updated in line items of all types.
The Calculate summary option defines whether the sum over the 'Number of packages' of the direct line items of all relevant Line item types should be assigned to the 'Number of packages' field in the header of the common business object.
Output:
Updates the 'Aggregate number of packages' field of all relevant Line item types.
Optional: Updates the 'Number of packages' in the header level as a summary over the 'Number of packages' in direct line items of the relevant Line item types.
See also: Calculate aggregate number of packages (Order), Calculate aggregate number of packages (Shipment)

The event action Calculate aggregate number of packages performs the following steps for all or selected Line item types (see Line item type) in a reference object of the Common business object type:
Within the line item hierarchy for each relevant Line item type, the field 'Number of packages' (
numberOfPackages) is assigned the value 1 for each line item if it is empty or filled with 0.Within the line item hierarchy for each relevant Line item type, the field 'AggregateNumberOfPackages' (
aggregateNumberOfPackages) is filled for each line item according to the procedure described in the section 'Calculation logic'.If the option Calculate summary is selected (default), then the total is additionally calculated via the field 'Number of packages' (
numberOfPackages) in all direct line items for all relevant Line item types.This total number is assigned to the field 'Number of packages' (
numberOfPackages) of the reference object.
Runtime example:
The following screenshot shows schematically the effect per step within a multi-level line item hierarchy on the basis of a simple input form for a fictitious Common business object of the type 'Package deal' (PACKAGE_DEAL):

In step 1, the default value 1 for the Number of packages is added for 'incomplete' items in order to prepare the subsequent steps.
In step 2, the Aggregate number of packages is calculated and assigned for each relevant item.
In step 3, the Number of packages is summarized for the direct line items.
In step 4, the 'summary' from step 3 is assigned to the Number of packages in the header data of the reference object.
â–ºNOTEâ—„ The visualized calculations and assignments take place, of course, completely independently of the representation of the elements concerned in an input form. They directly affect the volatile data of the reference object, which is not saved by the event action.
Calculation logic
Within the line item hierarchy for each of the selected Line item types, the 'Number of packages' (numberOfPackages) of each parent line item is taken as a scalar for the 'Number of packages' of each direct or indirect child line item.
For top-level line items, the 'Aggregate number of packages' (
aggregateNumberOfPackages) is taken directly from the 'Number of packages' (numberOfPackages).For a child item, the 'Aggregate number of packages' (
aggregateNumberOfPackages) is calculated as the product of 'Number of packages' (numberOfPackages) of the child item with 'Aggregate number of packages' (aggregateNumberOfPackages) of the parent item.This scheme is applied within a multi-level hierarchy from top to bottom over all levels, so that with each step in the hierarchy an additional scalar is added as a factor in the multiplication.
Example:
Line item hierarchy | Goods description | Number of packages | Calculation | Aggregate number of packages | ||
|---|---|---|---|---|---|---|
1 | Mixed pallet of beer | 2 | = | 2 Packages (pallets) | ||
â”” | 1.1 | Crate of beer (Lager) | 30 | 2 x 30 = | 60 Packages (crates) | |
â”” | 1.1.1 | Bottle of beer (Lager) | 20 | (2 x 30) x 20 = | 1200 Packages (bottles) | |
â”” | 1.2 | Crate of beer (Celebr8or) | 6 | 2 x 6 = | 12 Packages (crates) | |
â”” | 1.2.1 | Bottle of beer (Celebr8or) | 24 | (2 x 6) x 24 = | 288 Packages (bottles) | |
â”” | 1.1.2 | Beach towel 'Celebr8or' | 1 | (2 x 6) x 1 = | 24 Packages (beach towel) | |
2 | Float 'Celebr8or' | 3 | = | 3 Packages (float) | ||
Calculate total (optional) | 5 Packages | ∑ = 2 + 3 | ||||
Configuration

The event action Calculate aggregate number of packages expects a Common business object as the reference object. In the context of another object type, the event action has no effect without an error occurring at runtime.
The Calculate summary option (set by default) controls whether the 'Number of packages' field in the reference object header data should be updated based on the information for Direct line items of the relevant Line item types.
Without this option, step 3 and step 4 (see flowchart/runtime example above) are omitted without replacement.
Multiple selection for Line item types can be used to define a positive list for relevant Line item types (see Line item type).
If no Line item types are selected, all line items in the reference object are evaluated regardless of the Line item type.
Example
In accordance with the runtime example (above), the event action Calculate aggregate number of packages for the displayed reference object is executed within a data input form for a fictitious Common business object of the 'Package deal' (PACKAGE_DEAL) type by clicking on a Button.
For the Button, a behavior is created with a Client Workflow behavior type, which is configured as shown on the right:
â–ºNOTEâ—„ If the calculations are triggered not only manually but also, for example, automatically when saving, an event handling can be configured instead of the Client Workflow, which then has to be addressed by the Button via a Custom action event. |
|
Runtime example:
Based on the entries in the input form shown in the previous runtime example (above), the following image results after clicking the button:

In items 2.1 and 3, the value 1 for Number of packages has been added.
The Aggregrate number of packages was calculated and assigned for all line items.
The Number of packages in the header data has been calculated and assigned.
