Calculate aggregate number of packages

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.


See also: Berechne aggregierte Anzahl Packstücke (Bestellung), Berechne aggregierte Anzahl Packstücke (Sendung)

images/download/attachments/78252867/image2021-7-29_16-26-47-version-1-modificationdate-1627568810494-api-v2.png

The event action Berechne aggregierte Anzahl Packstücke performs the following steps for all or selected Line item types (see Line item type) in a reference object of the Allgemeines Geschäftsobjekt type:

  1. 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.

  2. 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'.

  3. 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.

  4. 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 Allgemeines Geschäftsobjekt of the type 'Package deal' (PACKAGE_DEAL):

images/download/attachments/78252867/image2021-7-30_11-32-7-version-1-modificationdate-1627637529069-api-v2.png

  • 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

images/download/attachments/78252867/image2021-7-29_16-37-49-version-1-modificationdate-1627569472258-api-v2.png

The event action Berechne aggregierte Anzahl Packstücke expects a Allgemeines Geschäftsobjekt 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 Berechne aggregierte Anzahl Packstücke for the displayed reference object is executed within a data input form for a fictitious Allgemeines Geschäftsobjekt of the 'Package deal' (PACKAGE_DEAL) type by clicking on a Button.

For the Button, a behaviour is created with a Client workflow behaviour 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.

images/download/attachments/78252867/image2021-7-29_16-40-36-version-1-modificationdate-1627569639453-api-v2.png

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:

images/download/attachments/78252867/image2021-7-30_11-33-35-version-1-modificationdate-1627637617508-api-v2.png

  • 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.