Kourier Integrator Online Help
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.
SUBROUTINE int_id.Zseq(op,act,props,err.no,err.parms)
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.
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_nameKT.CATALOG KUST-PROGS subroutine-name
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 |
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. |
@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. |
This subroutine interface can be used from a Kourier export.
1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. 35. 36. 37. 38. 39. 40. 41. 42. 43. 44. 45. 46. 47. 48. 49. 50. 51. 52. |
* $INCLUDE KORE-INCLUDES KT.RMLISTCOM * ERR.NO = '' ERR.PARMS = '' OP = '' * EXPORT.TYPE = RAISE(PROPS<KEX$EXPORTTYPE>) * BEGIN CASE CASE ACT = 'INIT' GOSUB DoInit CASE ACT = 'HEADER' GOSUB DoHeader CASE ACT = 'DETAIL' GOSUB DoDetail CASE ACT = 'FOOTER' GOSUB DoFooter END CASE RETURN * DoInit: * RETURN * DoHeader: * RETURN * DoDetail: * IF @RECORD<11> # '' THEN CALL KT.RMLIST(EXPORT.TYPE,WRK) OP<-1> = WRK END RETURN * DoFooter: * RETURN * LoadFields: * CALL KT.LOADFIELDS(STMT, '', '', MSG.TXT, MSG.NO) IF MSG.NO NE '' THEN CALL KT.ERRMSG(0,0,MSG.NO,MSG.TXT,2) ERR.NO = "KT-001" ERR.PARMS = MSG.TXT END RETURN * END |