KMK.SERVICE

Syntax

KMK.SERVICE service_id {EXPORT-NETCHG}{EXPORT-DELETES}{HEADERS "string"}

Description

This command can be used to execute a Kourier service from the command line or from within a UniBASIC program.

Options

service_id The name of a service in the KT_SERVICES file.
EXPORT-NETCHG Indicates that all exports listed in the service are to run in net change mode.
EXPORT-DELETES Indicates that all exports listed in the service are to run in net change with deletes mode. 
HEADERS Creates a substitution parameter as specified in "string" where "string" is a named value pair in the format of "name=value".  The substitution value can be referenced by using the %name syntax.

Example 1 - Using from TCL

KMK.SERVICE DEMO_KTLOG EXPORT-NETCHG

In this example, the service DEMO_KTLOG will be run in Net Change mode. The output from each export in the service will be saved in the target DSN as a message. Once the service completes, the messages will be de-queued automatically and delivered to the target DSN.

 

Example 2 - Calling a Service from UniBASIC

It is possible to call a Kourier Service from UniBASIC code.  To do this you must do the following:

  1. Include the item KT.STATUSCOM from the KORE-INCLUDES file.
  2. Check if the service was successfully completed or if an error was encountered.

Here is a UniBASIC fragment that shows how you can call a Kourier service and check on its execution status.

0001: *
0002: $INCLUDE KORE-INCLUDES KT.STATUSCOM
0003: *
0004: CMD = \KMK.SERVICE DEMO_KTLOG EXPORT-NETCHG\
0005: *
0006: EXECUTE CMD CAPTURING OUTPUT
0007: *
0008: CMD.STATUS = KT.GETSTATUS(CMD.ERR,CMD.PARAMS)
0009: IF CMD.STATUS THEN; * An error was encounterd
0010: PRINT 'Error=':CMD.ERR
0011: PRINT 'Params=':CMD.PARAMS
0012: CALL KT.GETMESSAGE(CMD.ERR,CMD.PARAMS,CMD.ERR.TEXT,'')
0013: PRINT 'ErrText=':CMD.ERR.TEXT
0014: END

Line 002 "includes" the common declarations used by the Kourier command status routines.

Line 008 uses the KT.GETSTATUS function to determine if the service ran successfully or if the service encountered an error.  If the KT.GETSTATUS function returns a non-zero value then the service encountered an error.  The details of the error are returned in the CMD.ERR and CMD.PARAMS variables.

Line 012 uses the KT.GETMESSAGE subroutine to format the error into a human readable format.  This text is returned in the CMD.ERR.TEXT variable.

See Also

Kourier Service Commands

Kourier Command Keywords

Kourier TCL Commands

 


User Guide - Table of Contents