COMPOSITE

A Composite field is composed of two or more fields. For example in the case of a Monetary field, we need information about the amount and the currency. This is stored in two columns in the database but defined as one field in the model. In the BookStore module, Price field on the Book is a Monetary Field which is a composite field type. Price Monetary field is split as two columns in the database price_amount and price_uom in the database.

To configure a composite field in filter criteria, you start by defining the individual components as hidden fields. After that, you can define a field of type COMPOSITE and reference the components in the CompositeFieldType element as shown in the example below.

and ${filterIfNotNull:PRICE_AMOUNT,price_amount = $PRICE_AMOUNT$}
and ${filterIfNotNull:PRICE_UOM,price_uom = $PRICE_UOM$}

The filter should be defined as follows:

<CustomFilterField>
<FieldRef category="PDF" levelType="ZBKS.Book">
<FieldName>Price Amount</FieldName>
</FieldRef>
<Hidden>true</Hidden>
<Type>CURRENCY</Type>
<Optional>true</Optional>
<SimpleMapping sqlName="PRICE_AMOUNT"/>
</CustomFilterField>
<CustomFilterField>
<FieldRef category="PDF" levelType="ZBKS.Book">
<FieldName>PriceUOM</FieldName>
</FieldRef>
<Hidden>true</Hidden>
<Type>STRING_ENUMERATION</Type>
<EnumerationType>CurrencyCode</EnumerationType>
<Optional>true</Optional>
<SimpleMapping sqlName="PRICE_UOM"/>
</CustomFilterField>
<CustomFilterField>
<FieldRef category="PDF" levelType="ZBKS.Book">
<FieldName>Price</FieldName>
</FieldRef>
<Type>COMPOSITE</Type>
<CompositeFieldType>
<Component name="Price Amount" type="DOUBLE"/>
<Component name="PriceUOM" type="STRING_ENUMERATION"/>
</CompositeFieldType>
</CustomFilterField>

To configure a composite field in retrieval criteria, along with setting field type as COMPOSITE, the retrieval criteria should also contain the individual fields the composite field should define the composite mapping.

Following is an example of display a composite field.

Include the database columns related to the composite fields in the select clause. In the following example, Price which is a composite field from the book model is illustrated.

select price_amount price_amount, price_uom price_uom FROM ZBKS_Book


The retrieval should be defined as follows:

<CustomRetrievalField>
<FieldRef levelType="ZBKS.Book" category="PDF">
<FieldName>price_amount</FieldName>
</FieldRef>
<Hidden>true</Hidden>
<Type>CURRENCY</Type>
<SimpleMapping sqlName="price_amount"/>
</CustomRetrievalField>
<CustomRetrievalField>
<FieldRef levelType="ZBKS.Book" category="PDF">
<FieldName>price_uom</FieldName>
</FieldRef>
<Hidden>true</Hidden>
<Type>STRING</Type>
<SimpleMapping sqlName="price_uom"/>
</CustomRetrievalField>
<CustomRetrievalField>
<FieldRef levelType="ZBKS.Book" category="PDF">
<FieldName>Price</FieldName>
</FieldRef>
<Type>COMPOSITE</Type>
<CompositeFieldType name="CurrencyCode">
<Component name="price_amount" type="DOUBLE"/>
<Component name="price_uom" type="STRING"/>
</CompositeFieldType>
<SimpleMapping sqlName="price_amount"/>
</CustomRetrievalField>

Following are the key points to note:

  • LevelType in the FieldRef is pointed to Book, which is where the Price field is defined.

  • Field Category is set to PDF(PreDefined Field)

  • Field name is the same as the one defined in the Book model.

  • Individual database columns should have their respective CustomretrievalFields and they are hidden to avoid duplication in the columns

  • For the composite CustomRetrievalField, the field type is set to be COMPOSITE

  • CompositeFieldType should be defined.

  • SimpleMapping contains sqlName as an attribute whose value references to the SQL parameter defined in the select clause of the SQLDef