Calculated Attributes and Method Hooks

In case attribute implementations are derived from the method implementation input arguments or attribute implementations are used to calculate the method implementation output arguments then the related attribute implementations are also available as input/output.

Note: It is not needed to specify the related protected attribute implementations as method argument implementations explicitly. The only case in which protected attribute implementations must be used as method argument implementations is for the identifying attributes of subcomponents. For example, an orderNumber attribute implementation in an orderLine component.

Table columns cannot be used directly, unless the table is not mapped to the component, but read or updated within the hook.

Let’s assume a method has orderNumber and businessPartner as input, and deliveryAddress and numberOfPackages as output. The attribute implementations are defined, as shown in the following figure:

In that case the following parameters for attribute implementations are available in the method hooks:

Hook Parameters
before execute i.orderNumber, i.stringColumn, i.businessPartner, i.bpPart1, i.bpPart2

i.orderNumber.isSet, i.stringColumn.isSet, i.businessPartner.isSet, i.bpPart1.isSet, i.bpPart2.isSet

on execute i.orderNumber, i.stringColumn, i.businessPartner, i.bpPart1, i.bpPart2, o.deliveryZipCode, o.deliveryStreet, o.deliveryCity, o.nrOrPackages, o.orderQuantity

i.orderNumber.isSet, i.stringColumn.isSet, i.businessPartner.isSet, i.bpPart1.isSet, i.bpPart2.isSet o.deliveryZipCode.isSet, o.deliveryStreet.isSet, o.deliveryCity.isSet, o.nrOrPackages.isSet, o.orderQuantity.isSet

after execute i.orderNumber, i.stringColumn, i.businessPartner, i.bpPart1, i.bpPart2, i.deliveryZipCode, i.deliveryStreet, i.deliveryCity, i.nrOrPackages, i.orderQuantity

i.orderNumber.isSet, i.stringColumn.isSet, i.businessPartner.isSet, i.bpPart1.isSet, i.bpPart2.isSet i.deliveryZipCode.isSet, i.deliveryStreet.isSet, i.deliveryCity.isSet, i.nrOrPackages.isSet, i.orderQuantity.isSet

Note: When values are set, avoid redundancy. For example, when setting o.orderQuantity, do not set o.nrOfPackages and vice versa.

When setting an output value (or an input/output value that was not yet set), also set the corresponding o.<attribute>.isSet (or io.attribute.isSet) to true. If desirable, you can use a define for this, such as:

#define setValue(attr_impl, value)	attr_impl = value 
^										attr_impl##.isSet = true

You can use for example:

  • setValue(o.deliveryStreet, some.street)
  • setValue(o.deliveryCity, some.city)

In some cases, the same protected attribute implementations are used for multiple attributes. And each of these attributes can be input, output or input/output. An example is shown in the following figure:

In case attribute a is input, attribute b is input/output and attribute c is output, the following parameters will be available in the method hooks:

Hook Parameters
before execute i.a, i.b, i.x, i.y

i.a.isSet, i.b.isSet, i.x.isSet, i.y.isSet

on execute i.a, io.b, o.c, io.x, io.y, o.z

i.a.isSet, i.b.isSet, o.c.isSet, i.x.isSet, io.y.isSet, o.z.isSet

after execute i.a, i.b, i.c, i.x, i.y, i.z

i.a.isSet, i.b.isSet, i.c.isSet, i.x.isSet, i.y.isSet, i.z.isSet

There won’t be any duplicate attribute implementations in the parameters. Two or three of the following variants

will not occur at the same time. Instead, a single io.something will be used. The LN Implementation Generator will simply merge the method arguments and their derived attributes. In the example earlier, if the developer explicitly (and incorrectly) adds x as an output argument, this will cause ‘i.x’ in the on execute hook to be changed to io.x.

Note: Again, do not forget to set the isSet parameters as applicable.

For example:

ppmmmdll1234.calculate(i.a, i.b, io.c, o.d)

  • io.c.isSet = true
  • o.d.isSet = true