Writing exits for DB2® and COBOL generation
This topic extends "Writing exits for EGL access of DB2®" and is specific to COBOL generation.
Source code
To see the source for the delivered exits, review the members in the SELASAMP PDS that is included with Rational® COBOL Runtime for z/Series installation on z/OS®. The following table lists the members of interest.
| Member name | Purpose | Type for input and output |
|---|---|---|
| ELADT2DB | Before database input, revise the value that will be assigned to the database from a host variable of type DATE. | Pointer to CHAR(10) |
| ELADT2PG | After database output, revise the value that will be placed in a host variable of type DATE. | Pointer to CHAR(10) |
| ELATI2DB | Before database input, revise the value that will be assigned to the database from a host variable of type TIME. | Pointer to CHAR(8) |
| ELATI2PG | After database output, revise the value that will be placed in a host variable of type TIME. | Pointer to CHAR(8) |
| ELATS2DB | Before database input, revise the value that will be assigned to the database from a host variable of type TIMESTAMP. | Pointer to CHAR(26) |
| ELATS2PG | After database output, revise the value that will be placed in a host variable of type TIMESTAMP. | Pointer to CHAR(26) |
The masks that you set for date, time, and timestamp have no effect on the data sent to or received from those exits. You can set masks in your code by setting the StrLib.defaultDateFormat, StrLib.defaultTimeFormat, and StrLib.defaultTimeStampFormat functions, which can receive default values from the build descriptor options of the same name.
Example and logic flow
get myrec with #sql{
SELECT COL1 FROM TBL WHERE :dateChar1 = '2010-04-01' }
into dateChar2;
- Get the value of the
dateChar1field. - Pass that value to the ELADT2DB exit program.
- When interacting with the database, use the new date value that was returned by the exit program.
- Get the value of
COL1from the database. - Pass the value to the ELADT2PG program.
- Assign the value that was returned from that program to the
dateChar2field.
Load modules
The delivered load modules are members in the SELALMD PDS that is included with the Rational® COBOL Runtime for z/Series installation on z/OS®.
- If you do not modify the exits, the sample exits will be linked in and run. These make no modifications to the values.
- If you modify the exits and place them in a new dataset, you must reference the new dataset in the link-edit step of the build script. Specifically, you must add the reference to the SELALMD DD statement, previous to the entry that was in the delivered JCL.
- If your modified exits are changed at some future time, you must regenerate or relink the programs to obtain the changes.