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

The following SQL statement uses two character fields, each of which has a sqlDataCode value to state that the related column is of type DATE:
get myrec with #sql{ 
   SELECT COL1 FROM TBL WHERE :dateChar1 = '2010-04-01' }
   into dateChar2;
The query is constructed as follows:
  1. Get the value of the dateChar1 field.
  2. Pass that value to the ELADT2DB exit program.
  3. When interacting with the database, use the new date value that was returned by the exit program.
Here are the events when you fetch example data:
  1. Get the value of COL1 from the database.
  2. Pass the value to the ELADT2PG program.
  3. Assign the value that was returned from that program to the dateChar2 field.

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.

When you enable the use of these exits, the EGL generator generates an INCLUDE SELALMD(exitpgm) statement in the link edit control cards for each of the required exits:
  • 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.

Feedback