Array notations as filters

You use array notations to filter a set of data so that the script can retrieve a particular value or subset of values. You specify the required value or values by placing square brackets around the filter.

You can use filters to specify the value or values that the script must retrieve:

Array index

If multiple records exist for the same business object, you must specify the particular record for the script to retrieve. You specify the index of the record between the square brackets that represent an array.

Example of an array index

A script must retrieve the quantity declared on the distributed costs of a purchase order for a single PO line. The relationship expression uses an array filter:

POLINE[3].POCOST[4].quantity

An array is indexed from 0 and the expression is interpreted by the script in the following way:
  • From the PO business object, traverse to POLINE business object by using the ‘POLINE’ relationship and retrieve the fourth POLINE record.
  • Traverse to the POCOST business object from the retrieved POLINE record by using the POCOST relationship and retrieve the fifth POCOST record.
  • From the fifth POCOST record, retrieve the value of the quantity attribute and set the value into the launch point variable.

Retrieving values by using an array index uses business objects and sets of business objects already loaded into the memory by the business application. Using an array index is therefore in memory filtering.

Filter with WHERE clause

If multiple records have the same business object, you specify the particular record or subset of records that the script must retrieve. You specify a WHERE clause between the square brackets that represent an array.

Example of a filter with a WHERE clause

A script must retrieve the quantity declared on the distributed costs of a purchase order for a subset of PO lines. The relationship expression uses a filter:

POLINE[linecost>100].POCOST[percentage<100].quantity

The expression is interpreted by the script in the following way:
  • From the PO business object, traverse to those POLINE business objects whose line cost is greater than 100.
  • For each of the POLINE business objects, traverse only to the POCOST business objects whose percentage value is less than 100.
  • Retrieve the quantity of the first POCOST record that has a percentage value of less than 100.

The WHERE clause is appended to the existing relationship WHERE clause that is pre defined in the data dictionary for the POLINE relationship. Retrieving values by using the WHERE clause filter retrieves data from the database. The values are accessed by the script by applying the complete WHERE clause to the target table or view that the business object represents. This type of filtering involves more processing than retrieving values by index or by condition.

Filter with condition

If multiple records have the same business object, you specify the record or subset of records that the script must retrieve. You specify a condition between the square brackets that represent an array.

Example of a filter with a condition

A script must retrieve a quantity declared on the distributed costs of a purchase order for a subset of PO lines. The relationship expression uses a filter:

POLINE[linecost>100].POCOST[cond: PERCENTCOND].quantity

The expression is interpreted by the script in the following way:
  • From the PO business object, traverse to the POLINE business objects that have a line cost that is greater than 100.
  • For each of the POLINE business objects, traverse only to the POCOST business objects that meet the condition defined by PERCENTCOND.
  • Retrieve the quantity of the first POCOST record that meets the condition.

The condition PERCENTCOND is a condition expression configuration defined with Conditional Expression Manager. You define the configuration before using it in the relationship path. When specifying the condition in the relationship path, ensure that the condition is preceded by the keyword cond and the colon. Unlike a filter with a WHERE clause, retrieving values with the condition filter is done in memory.



Feedback