Kourier Integrator Online Help

Export Subroutine (EXPORT-SUBNAME)

An export subroutine can be used to generate all output lines of an export. The INIT, HEADER and FOOTER actions will be called once. The DETAIL action will be called as each record is read from the source data file. The data for the record is read into @RECORD and @ID, however these variables are read-only from this subroutine.

The main reason for writing a subroutine of this type is to generate custom output files without needing to manage such features as net change tracking, checksums, and stamping which will be managed by KEXPORT automatically when this subroutine is called.

Declaration

SUBROUTINE int_id.Zseq(op,act,props,err.no,err.parms) 

Subroutine Naming/Storage

The subroutine name should consist of the integration_id, a period, the letter Z, followed by a two digit sequence number. For example, SQL.Z01 would be the first export subroutine associated with SQL integration. 

To create a new subroutine, either copy the item KMK.Z99 in the KORE-PROGS file to the KUST-PROGS file or copy an existing export subroutine using the naming convention described above and make changes as required.

Compiling and Cataloging the Subroutine

Before you can use an export subroutine in an export specification it must be complied and cataloged. To do this, use the following commands:

KT.BASIC KUST-PROGS subroutine_name
KT.CATALOG KUST-PROGS subroutine-name

Input Interface

op

Varies. This program should null this field.

act

Action code.  Possible values are INIT for initialize, HEADER for output heading, DETAIL for output detail FOOTER for output footing.

props

The props parameter allows the programmer to access useful run-time values (e.g. KEX$ICTR  which contains the number items processed) or to store values between calls to this routine (e.g. KEX$USER1).  For compatibility reasons, the properties should be accessed using the named constants as documented in the item KT.RMLISTCOM in the KORE-INCLUDES file.  See Accessible Variables (below) for a complete description.

err.no

Undefined

err.parms

Undefined

Output Interface

op

Export output, may be attribute delimited

act

Unchanged.

props

May be changed as needed.

err.no

If an error has occurred, set to a message number as defined in the KORE-MESSAGES file.

err.parms

Any parameters needed for the error message.

Accessible Variables (all variables are read-only unless specifically stated)

@ID

The item-id of the record currently being processed.

props<KEX$BYEXPVNO>

If the BY-EXP keyword was used in the export selection criteria, it contains the value number currently being processed otherwise this variable is set to zero.

@RECORD

The contents of the record currently being processed.

props<KEX$DATAFILE>

The name of the file from which records are being read.

props<KEX$SENTENCE>

The KEXPORT statement being executed.

props<KEX$EXPORTTYPE>

An internal code corresponding to the Export Format use in the export specification See example below for proper use of this variable.

props<KEX$ICTR>

Count of the number of records that have been processed.

props<KEX$RCTR>

Count of the number of rows that have been processed.

props<KEX$USER1>

User defined variable which may be read or written.  May not contain attribute marks.

props<KEX$USER2>

User defined variable which may be read or written.  May not contain attribute marks.

props<KEX$USER3>

User defined variable which may be read or written.  May not contain attribute marks.

props<KEX$USER4>

User defined variable which may be read or written.  May not contain attribute marks.

props<KEX$USER5>

User defined variable which may be read or written.  May not contain attribute marks.

Scope of Use

This subroutine interface can be used from a Kourier export.

Related Topics: 

Kourier TCL Commands Overview

Kourier Service Commands

Kourier Command Keywords