Creating COBOL Test Data in RowGen
This article explains how to use IRI RowGen to create test files for prototyping COBOL applications running on, or off, the mainframe.
RowGen generates synthetic test data for file, database, and custom report targets. It uses the CoSort SortCL program for data generation, transformation and mapping on the back-end, and the IRI Workbench GUI, built on Eclipse™, to design and manage the jobs on the front-end.
For any given field in a file, RowGen can randomly select real data (from set files or database tables) at random, or generate random data values according to specified single and multi-byte data types, including:
- ASCII
- EBCDIC
- Numeric
- various MF and RM COBOL data types.
Numeric data types, such as MF_CMP3 and UMF_CMP3, are generated in a specified range, then converted into the COBOL format in the same generation job (script and I/O pass).
RowGen also generates COBOL-related file targets in several formats, including:
- Record Sequential (default)
- Line Sequential (LS)
- Variable Sequential (VS)
- Micro Focus Variable Length (MFVL) Small
- MFVL Large
Record Sequential (RS)
RECORD is the default text process type, which can be fixed or delimited rows with no length information pre-pended.
Line Sequential (LS)
When you specify /PROCESS=LS on output, RowGen produces variable-length records that are strings of characters where each low-value data byte (x00 through x1f) is protected (or prepended) by a null byte (x00). The terminating line feed character is not protected.
Variable Sequential (VS)
With /PROCESS=VS specified on output, RowGen produces variable-length records that are a string of characters prepended by a short integer. The value of the short is the length of the record; for example, ABC is (x03 x00 x41 x42 x43). The format of the short integer is machine-dependent. Therefore, VS data between dissimilar computers may be incompatible (e.g., between RISC and SPARC).
MFVL SMALL (or LARGE)
When you specify /PROCESS=MFVL_SMALL (or /PROCESS=MFVL_LARGE) on output, Micro Focus variable-length records are produced.
Using Your COBOL Metadata
RowGen provides different tools to generate the field descriptions that define test target layouts. One of them is cob2ddf, a utility which converts COBOL copybook layouts into a Data Definition File (.ddf) for RowGen (and other IRI) jobs.
Its command line (execution) syntax is:
cob2ddf cobol.cpy copybook.ddf
where cobol.cpy is the original copybook and copybook.ddf is the target DDF equivalent. By using this metadata, RowGen test files will match the production file layout and data types.
You can easily modify RowGen metadata in both the generation (input) and formatting (output) sections of your jobs, and add transformation functions and additional outputs, as needed.
Building Your RowGen Job
Step 1. Read the Copybook
We’ll begin in the IRI Workbench GUI for RowGen, and convert the COBOL copybook into a ddf file (rather than using the command-line method above).
Select Import from the File Menu, select IRI File Metadata, and click Next (see screen below).
On the Import File Metadata screen, browse to open your original copybook file. Select COBOL Copybook for the Source Format, and click Finish.
Once the steps above are completed, the data definition file (.DDF) layout will be created:
RowGen DDF in the IRI Workbench editing window. Note that a .DDF form editor view is also available.
Step 2. Define the Generation and Target Layouts
To define the RowGen job that generates the test data, we can either write a RowGen Control Language (.rcl) script manually (in the GUI or any external editor), or use the GUI’s custom test data wizard (from the GUI’s RowGen menu). In this case, I just wrote the script.
As mentioned, RowGen can either randomly generate, or randomly select data from set files. IRI provides several sets, or you can create them in the Workbench. In this example, I used the RowGen-supplied set files: names_last_comma_first.set, states.set, countries.set, PhoneNumbers.set, credit.set, and tax.set.
To create the CM_CREDIT_LIMIT, CM_TAX_NUMBER fields, I need to convert them. They are defined in the ‘input’ (generation) section of the script as numeric, but re-defined (converted) to MF_CMP3, UMF_CMP3 in the output to produce the values in the target COBOL data types.
My RowGen job in the IRI Workbench script editing window. Note the interactive outline view on the right. This and all IRI product metadata are supported by GUI dialogs that allow script sections to be created or modified in visual dialogs, precluding the need to learn the 4GL.
Step 3. Run The Job and Examine the Output
If you noticed in the job script above, I defined two test targets (output files) from the same generation (input) process: a COBOL Variable Sequential file, and an ASCII text file (where the numeric fields are not converted). There is no limit to the number of target files, tables, or formatted reports you can create from a single generation; each with its own subset of the generated data and layout.
RowGen jobs run on the command line where the executable is licensed, but can also be invoked from several Workbench ‘Run’ options. Ultimately the command is:
rowgen /spec=JobName.rcl
View the output file results however you like, including in the IRI Workbench:
Any hex editor can validate the variable sequential results, where each record is prepended with a short integer to specify its length. In this case, all of the records have the same length; x 9F 00, or 159. We also see that the ASCII -55 value was converted to HEX 05 5D, and ASCII 33 becomes HEX 03 3C. D bit represents a negative and C bit represents a positive. In the field that has UMF_COMP3, the sign is represented by F bit. 868F is the HEX for unsigned 868.
Please feedback on this article below, or email rowgen@iri.com if you need help creating COBOL test data.