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. These are older methods that use DID definitions to specify a data abstraction. Templates use this to retrieve the data directly from a database or to read it from 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:

  • For document pack template compositions, data retrieval is only supported for the data preparation template that is defined in the document pack template. All other templates in the document pack template must use a data backbone as input. The data preparation template executes the data retrieval and prepares the data backbone for all other templates.

    Alternatively, XML File data input is supported both for the data preparation template and for all other templates in the document pack template. Each template has access to the same XML file data.

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