Data retrieval
Alternatively, to offer compatibility with older KCM releases, it is possible to define data retrieval in the Data Backbone or templates to provide data to the templates. This is an older method that uses DID definitions to specify a data/database abstraction. Templates that use data retrieval retrieve the data directly from a data source: a database or an XML file. For more information on defining data retrieval and DIDs, see Work with Data in the KCM Repository User's Guide and Work with DIDs in KCM DID Developer's Guide.
In the following example, the entry Customer retrieves data from the database. KCM groups the retrieved fields in a record that can be referred to as Cust. This record is available between the Template scripts DO and OD. The fields that the record contains have been defined in the entry definition in the DID. As the method to retrieve the data is also defined in the DID, no more specifications are needed in a template script.
...
WITH Cust IN EXP.Customer DO
# Dear Ms. or Mr. @(Cust.Surname),
In reference to your writing...
#
OD
...
The construct WITH retrieves one record from the database. If KCM should retrieve multiple records, use the construct FORALL. The part DO ... OD of the FORALL construct is executed for each retrieved record.
...
WITH Cust IN EXP.Customer DO
#
Dear Ms. or Mr. @(Cust.Surname),
In reference to your writing....
A list of the ordered articles follows:
#
FORALL Art IN Cust.Ordered_articles DO
#
@(Art.Number_of_articles) @(Art.Article_description)
#
OD (* FORALL Art IN Cust.Ordered_articles *)
OD (* WITH Cust IN EXP.Customer *)
...
The relation between Customer and Ordered_articles is defined in the DID.
Be aware of some limitations that Data Retrieval has:
- In the document pack templates data retrieval can only be applied to the Data preparation template. All other templates must use a Data Backbone XML. The Data preparation template results in a Data Backbone XML that operates as input for all other templates in the document pack template.
- Data retrieval may require KEY parameters. These KEY parameters can only be passed with specific interfaces to the composition run. For this purpose, the contract manager offers the CCMCompatibility contract type, which is not added to any of the standard contracts by default.
- Next to the CCMCompatibility contract type the ITPRun core scripting command allows passing keys and executes data retrieval. The data retrieval will be executed only if no DBB_XMLInput parameter is passed.
Keys should be supplied in the same order in which the Data Retrieval statements are entered into the template.