Configure the distribution functionality

In KCM B&OM, you can call scripts to adjust the distribution of KCM B&OM output print files. This functionality is implemented by exit points that you can modify on the Distribution component. The installation includes a sample exit point called DistributeStack used by default.

The exit point is called during the distribution of stacks to be processed by CCM_Distribution.

To configure the context for the exit points, follow these steps:

  1. In the Navigator lower pane, find and double-click CCM_Distribution.

    The process appears in the central pane.

  2. Click Distribution in the lower central pane.
  3. In the Action section on the right, set the OnStackDistribute parameter to a script that has the StackDistribution context.

    When this parameter is set, the configured script is called automatically whenever a stack with type "Distribute (7)" is processed.

To create and modify the script, use the functions and variables listed in Properties of the StackDistribution context.

Example script

;The StackDistribution context supplies necessary information
;It is also possible to retrieve the content of the organisational metadata
Key1Value = Stack.GetOrganisationalMetadata("key1");
Key2Value = Stack.GetOrganisationalMetadata("key2");

;The output folder can be changed 
GetObject("Dos","MLDos")
ChannelPrinter = Stack.Channel + Stack.Printer
Stack.NewOutputFolder = Dos.Combine(Stack.OutputFolder,ChannelPrinter)
if (Dos.DirectoryExists(NewOutputFolder) = False)
   Dos.CreateDirectory(NewOutputFolder)
end-if
Stack.OutputFolder = NewOutputFolder
Protocol("New Output Folder = " + Stack.OutputFolder,5)

;The names of the print file and the description file can be changed
Stack.OutputPrintFile = Stack.Channel+ "_" + Stack.Printer + "_" + Stack.OutputPrintFile
Stack.OutputDescriptionFile = Stack.Channel + "_" + Stack.Printer + "_" + Stack.OutputDescriptionFile
Protocol("New Output Print File Name = " + Stack.OutputPrintFile,5)
Protocol("New Output Description File Name= " + Stack.OutputDescriptionFile,5)

;Check if the files already exist before saving
DestinationPrintFile = Dos.Combine(Stack.OutputFolder,Stack.OutputPrintFile)
DestinationDescriptionFile = Dos.Combine(Stack.OutputFolder,Stack.OutputPrintFile)
if (Dos.FileExists(DestinationPrintFile)) 
   ErrorMessage = "Cannot distribute " + Stack.OutputPrintFile + " to OutputFolder " + Stack.OutputFolder + " because the files already exist."
   Raise("UnrecoverableDistributionError",ErrorMessage)
end-if 

if (Dos.FileExists(DestinationDescriptionFile)) 
   ErrorMessage = "Cannot distribute " + Stack.OutputDescriptionFile + " to OutputFolder " + Stack.OutputFolder + "because the files already exist."
   Raise("UnrecoverableDistributionError",ErrorMessage)
end-if 

try
  ;Copies the print file and the description file to the output folder
  Stack.Save()
OnError
  ;Clean up already distributed files to facilitate reruns
   Dos.DeleteFile(DestinationPrintFile)
   Dos.DeleteFile(DestinationDescriptionFile)
   Raise("UnrecoverableDistributionError",Error.Message)
End-try