The format of the file may be fixed, 80-byte records or variable-length records. The input varies depending on the task being performed. The fourth and final step will compare the original 80-byte, fixed-length file created in the first task with the 80-byte, fixed length file created in the third task. The third task will read the file containing variable-length records and create a file containing 80-byte, fixed length records. The second task performed will read the fixed, 80-byte-record file and create a file containing variable-length records. To create fixed length records the record is padded with trailing spaces. The actual text string within the records will vary in size. The first task performed by the CRTF80J1.JCL or CRTF80E1.CMD routine is to create a file of fixed-length, 80 byte records.
The following is a list of the functions provided in this example.ĭemonstrate how to create a fixed-record-length, sequential file using mainframe JCL and the IEBGENER Utility program.ĭemonstrate how to read the fixed-record-length, sequential file and create a variable-record-length, sequential file.ĭemonstrate how to read the variable-record-length, sequential file and create a fixed-record-length, sequential file.ĭemonstrate how to compare the contents of two data files.įunctions Described and Demonstrated by this Suite of Programs The intent is to provide changes as the need arises and in a timeframe that is dependent upon the availability of resources. The function delivered in this version is based upon the enhancement requests from a specific group of users. We reserve the right to make changes without notice at any time.
We have made a significant effort to ensure the documents and software technologies are correct and accurate. The compare function that is used in this example uses the SimoLOGS and SimoHEX4 routines and will require the SIMOMODS technology package to be downloaded.Īdditional information is provided in the
A Windows Command (.CMD) file is provided to run the job on a PC with Micro Focus Net Express. A JCL member is provided to run the job as an MVS batch job on an IBM mainframe or as a project with Micro Focus Mainframe Express (MFE) running on a PC with Windows. The COBOL programs that do the conversion and comparison are generated to be compliant with the VS COBOL II dialect and also work with COBOL for MVS and COBOL/370. Additional detail about other tips, tricks and techniques used to manage files with variable length records are discussed in the following sections of this document. The preceding describes three of the methods that are commonly used by COBOL application programmers to create and access files with variable length records. Thus, the more elements in the array the longer the record and the fewer elements in the array the shorter the record.Īlternatives to Create, Access and Convert Data Files that use Variable-Length-Records For COBOL, the "OCCURS DEPENDING ON" (or ODO) is used to vary the number of elements in the array (or table). The technique of defining an array (or table) as the last part of a record may be used. Therefore, one way to create and access a file with variable length records is to use multiple record types where the different record types have a different record length. Each record format will have their own record layout (or copy file) and they may be the same length or a different length. For example, if position 1 is an "A" the record format "A" is used, If position 1 is a "B" then record format "B" is used. User logic is created to determine the record type. Usually each record in the file has a base segment that is identical. Note: When the file is accessed as input the length of the record just read will be placed in the "field-name-for-my-record-size" field.
This may be accomplished by scanning the field to determine the position of the last significant character or by counting the number of trailing spaces. Place this value in the field-name-for-my-record-size and write the record. Next, determine the length of the text string within the single field (my-data-field) that defines the record layout. On the FD and SELECT statements (in a COBOL program) use the "DEPENDING ON field-name-for-my-record-size" to define a field that will determine the size of the record to be written to a file. The examples provided in this suite of programs will focus on the first methodology.ĭefine the record as a single field (my-data-field) with the physical size equal to the maximum record length. The following list briefly describes three possible methodologies.
There are different ways to create and access files with variable length records. This document describes how to create, access and convert data files that use variable-length-records. Files with Variable Length Records, Processing with Standard COBOL Dialect Variable-Length Records