VSAM Macros
The history of these macros is that my TAPEMAN3 utility tools use a keyed VSAM database, and I was effectively copying the VSAM file access code from utility to utility without any real changes being made to it, which was a wasted overhead.
Add to that the two issues of (1) the code was not working 100% correctly anyway and and me not really wanting to try to fix multiple programs, plus (2) I have started working on another application that needs a keyed VSAM database that would result in the same code being effectively copied again.
Obviously it was time to replace all that common code in each of the many programs with a simple one-line macro invocation that would generate all the code and data areas required for keyed VSAM I-O operations on a single VSAM file. As a bonus I have fixed the code so it is now functioning 100% as expected.
Much of the program code used in this macro has been copied from
from Jay Moseleys cobol/vsam interface code (v1) but I retained only the
code needed for keyed access, and got it working correctly for my needs
thanks to the VS1 VSAM programmers manual available on bitsavers.
In making sure the link was still valid so I could correctly attribute
the code I see that Jay has now updated his code to allow multiple VSAM files to be
used from a cobol program so if you have a requirement for more
that one VSAM file to be opened by your program you may want to look at that.
The origional (and now updated to v2) code link is
http://www.jaymoseley.com/hercules/vsam_io/vscobol.htm
But I only currently only need one VSAM file per program so that is
all the macro here supports at present.
My VSAMCODE macro
My implementation of a macro to generate all code needed by an assembler program to perform keyed I-O is currently provided as a JCL deck here which will
- create an install file containing the macros
- an example assembler program showing how simple it is to use the macro
- a test job to create a test vsam file, exercise the test program, and delete the test file. The program 'exercises' are defined by a SYSIN card deck so you can easily create your own complex tests to make sure it can do what you want.
The test program and example test job provide enough functionality to be able to perform batch database maintenance on any keyed VSAM file, just by changing the record definition at the start of the test program (as long as the keyoffset is at 0), so may be a useful download for you even if you do not need the macro for programming use.
Enhancements planned, and not planned
- first priority is no changes to the macro, I will be updating all TAPEMAN3 utilities to use it as replacing the code in those with 100% working code is one of the main reasons the macro was created
- low priority enhancement, to update the VSAMOPEN code block
to query the system catalogues to retrieve the attributes
for the VSAM cluster (recordlength, keyoffset, keylength) to
avoid the need for them to be provided in the macro invocation.
Note: if you need dynamic settings immediately you can alter
the test program to get that info from parm values instead of
a record definition (and tweak the code as it expects them to be EQU values).
Low priority as I use database record layouts in my programs so so not need it; but it would make the example program a 100% generic batch maintenance utility as the program would no longer need a record template; but on the todo list as it would be an interesting exercise - not planned, to support multiple VSAM files from one program.
Probably not a major macro change actually, although the ACB/RPL entries
would probably have to become DSECTS rather than being inline which means
they would have to be generated by a seperate macro rather than live
in code space as generated by my current macro.
But I have no need for it yet.