Skip to main content  
        iSeries home   |   Easy400  
About it

AD-HOC program generation error

What are AD-HOC programs

In order to be able to access any iSeries database file, program WRKDBF generates a so called "AD-HOC" program every time it is asked to access a new database file.
An AD-HOC program is a simple ILE-RPG program just performing single I/O operations on a database file, depending on the order received from program WRKDBF.
  • On READ operations, it returns a buffer containing the record just read.
  • On ADD or UPDATE operations, it receives in an input buffer the image of the record to be added or updated.
The AD-HOC programs are created in library CGIWRKDBFD, and are given names like Pnnn (nnn being an integer number).
While a single AD-HOC program is generated for a given keyed database file, two AD-HOC programs (Pnnn and PnnnW) are generated for arrival database files.
Each AD-HOC program is compiled from a source member generated in source file CGIWRKDBFD/QRPGLESRC from program WRKDBF.
Once an AD-HOC program has been created, its name is associated with the file name in a WRKDBF control record, so that the next time the same file is asked to be accessed no program generation takes place.

What if an AD-HOC program fails to be created

Usually AD-HOC programs are generated without any problems. However, it may happen that for a given database file the AD-HOC program generation fails. This is shown on a pink error message from program WRKDBF.

As the CGI_WRKDBF author cannot walk to your terminal and fix the source of that AD-HOC program, you need locally some person knowledgeable of ILE RPG to understand what was the problem about it.
Of course the first thing to look for is the compile output, but there is no compile output from the original generation.
Therefore you have to compile again the AD-HOC program from its source in source file CGIWRKDBFD/QRPGLESRC. You have the AD-HOC program name in the error message, so it should be pretty easy for you to compile it again and check out the compile listing for errors.

Once you figured out the reason of the error and you had a nice compilation, that is not all, because still have to file the correct information into the WRKDBF control file.
Never run WRKDBF against that file, until the control information is set, otherwise your program source will be replaced by the previously generated WRKDBF source!

To file the control information expected by program WRKDBF, you have to run command cgiwrkdbf/crtadhocp:
  • the AD-HOC program name Pnnn (just specify the first program name for an arrival database file, you do not need to specify PnnnW)
  • the database file name and its library
and press the Enter key.

The following happens:
  • You are allow to review the AD-HOC program source (both the two sources, if an arrival file)
  • A batch job is submitted to compile the AD-HOC program(s)
  • If the compile(s) is/are successful, the WRKDBF control information for this database file is set
  • Messages on succesful/unsuccessful completion are sent to your workstation.
  • In case of unsuccessful completion, you have to go through the joblog and the compile output(s) of the submitted job.