Alternate Index VSAM, Keyed-Sequential-Data-Set |
The SimoTime Home Page |
This suite of sample programs describes how to create, populate and access a VSAM cluster for a Key Sequenced Data Set (KSDS) with a Primary Key and an Alternate Index (or alternate record keys). This example uses a five (5) step process to create the necessary components of a VSAM cluster. JCL members are provided to perform the five steps as a single job or as five separate jobs. This process uses IDCAMS (Access Method Services) to define the various components and a COBOL program to do an ordered (or sequential) load of the KSDS with data. This is usually faster than a random add but requires the records to be added in sequence. It is important to note that the primary key must be unique (i.e. no duplicate keys allowed). The alternate index may be define to contain duplicate keys.
A number of ancillary programs are provided to validate the creation of the VSAM cluster and to do updates to the existing cluster. The first program will access the KSDS sequentially by the primary key and produce a report in sequence by the customer number or primary key. The second program will access the KSDS using the alternate index and produce a report that is sequenced by the telephone number or alternate key. The third program will read a sequential file and then update an existing record or add a new record to the KSDS depending on whether a matching primary key is found. The fifth program is just a JCL member that uses IDCAMS to delete the VSAM cluster.
The techniques used in this example may be applied when transferring a file from a mainframe to a Wintel platform. For example, to transfer a VSAM, KSDS using File Transfer Protocol (FTP) it would be necessary to reproduce (IDCAMS and REPRO) the VSAM, KSDS as a flat, sequential file and then FTP the sequential file. Once the sequential file resides on the Wintel platform it is then necessary to create a Micro Focus Keyed Indexed file with a primary key and an alternate index. This example describes how to read a sequential file and populate (or load) a VSAM, KSDS with a primary key and an alternate index.
The COBOL programs are written using the IBM COBOL for OS/390 dialect and will work with IBM Enterprise COBOL. A suite of JCL members is provided to run the jobs as MVS batch jobs on an IBM Mainframe System or as a project with Micro Focus Mainframe Express (MFE) running on a Windows System. A suite of Windows batch or command files is provided to run the jobs using Micro Focus Net Express.
This example illustrates the following functions.
| ||||||||||||||||
A List of Functions Described in this Suite of Sample Programs |
We have made a significant effort to ensure the documents and software technologies are correct and accurate. We reserve the right to make changes without notice at any time. The function delivered in this version is based upon the enhancement requests from a specific group of users. The intent is to provide changes as the need arises and in a timeframe that is dependent upon the availability of resources.
Copyright © 1987-2025
SimoTime Technologies and Services
All Rights Reserved
This suite of sample programs will run on the following platforms.
| ||||||||
Operating System Alternatives |
The programs have been tested using a mainframe with z/OS, Micro Focus Mainframe Express (MFE) and Micro Focus Net Express. The programs were easily downloaded from the mainframe z/OS system to a Windows/XP system. With Micro Focus Mainframe Express (MFS) it was a simple process to set up a project, compile the programs and execute the JCL. For Micro Focus Net Express the requirements were to run in an ASCII environment from a command line. Creating a Net Express project to compile the programs was a simple task. Creating the CMD files to perform the tasks of creating and managing a Keyed-Indexed file was a manual task. One program (CBLALTC2.CBL) needed to be changed to execute properly and this is documented in the source code.
For the Mainframe z/OS and Micro Focus MFE environments the JCL should be executed in the following order.
| ||||||||||||||||
Sequence of Jobs for a Mainframe Oriented Environment |
For the Net Express and Windows Command Line environments the CMD files should be executed in the following order.
| ||||||||||||||||
Sequence of Jobs for a Windows Oriented Environment |
The example has a number of JCL members that perform the various steps to create, load and access a VSAM, Keyed Sequential Data Set with a primary key and an alternate index. The JCL may execute on an IBM Mainframe with z/OS or a Windows System with Micro Focus Mainframe Express.
The following (CBLALTJ8.jcl) is a sample of the mainframe JCL needed to run IEBGENER and create a sequential file. The records to be placed in the sequential file are included in the job stream. The records are intentionally loaded into the sequential file in an out of sequence arrangement.
The second step in the job will sort the file and create a sequential file that is in sequence by the customer number. This file will be used to do the initial loading (or populating) of the VSAM, KSDS. Since the initial load will be done as a sequential add (or ordered load) the records must be in sequence.
The third step will create a smaller file that will be used to randomly add or update records in an existing VSAM, KSDS.
//CBLALTJ8 JOB SIMOTIME,CLASS=1,MSGCLASS=0,NOTIFY=CSIP1 //* ******************************************************************* //* CBLALTJ8.JCL - a JCL Member for Batch Job Processing * //* This JCL Member is provided by SimoTime Technologies * //* (C) Copyright 1987-2019 All Rights Reserved * //* Web Site URL: http://www.simotime.com * //* e-mail: helpdesk@simotime.com * //* ******************************************************************* //* //* Text - Create a Sequential Data Set on disk using IEBGENER. //* Author - SimoTime Technologies //* Date - January 24, 1996 //* //* The 1st job step will delete any previously created file. //* The second job step (CRTQNAME) will create a new file. //* The third job step (SORTST03) will sort the file. //* //* This set of programs will run on a mainframe under MVS or on a //* Personal Computer with Windows and Micro Focus Mainframe Express. //* //* ************ //* * CBLALTJ8 * //* ********jcl* //* * //* * //* ************ ************ //* * IEFBR14 ******* ALTQSMD1 * //* ********utl* ***delete*** //* * //* * //* ************ ************ ************ //* * SYSIN ******* IEBGENER ******* ALTQSMD1 * //* ********jcl* ********utl* *******qsam* //* * //* * //* ************ ************ ************ //* * ALTQSMD1 ******* SORT ******* ALTQSMD2 * //* ********jcl* ********utl* *******qsam* //* * //* * //* ************ ************ ************ //* * SYSIN ******* IEBGENER ******* ALTQSMD3 * //* ********jcl* ********utl* *******qsam* //* * //* * //* ************ //* * EOJ * //* ************ //* //* ******************************************************************* //* Step 1 of 4, Delete any previously created file... //* //CLEANUP1 EXEC PGM=IEFBR14 //ALTQSMD1 DD DSN=SIMOTIME.DATA.ALTQSMD1,DISP=(MOD,DELETE,DELETE), // STORCLAS=MFI, // SPACE=(TRK,5), // DCB=(RECFM=FB,LRECL=80,BLKSIZE=800,DSORG=PS) //ALTQSMD2 DD DSN=SIMOTIME.DATA.ALTQSMD2,DISP=(MOD,DELETE,DELETE), // STORCLAS=MFI, // SPACE=(TRK,5), // DCB=(RECFM=FB,LRECL=80,BLKSIZE=8000,DSORG=PS) //ALTQSMD3 DD DSN=SIMOTIME.DATA.ALTQSMD3,DISP=(MOD,DELETE,DELETE), // STORCLAS=MFI, // SPACE=(TRK,5), // DCB=(RECFM=FB,LRECL=80,BLKSIZE=8000,DSORG=PS) //* //* ******************************************************************* //* Step 2 of 4, Create and populate a new QSAM file... //* //QSAMCRT1 EXEC PGM=IEBGENER //SYSPRINT DD SYSOUT=* //SYSIN DD DUMMY //* Number..Name, Last First Middle Telephone //* :....1....:....2....:....3....:....4....:....5....:....6....:....7....:....8 //SYSUT1 DD * 000000000100Anderson Adrian A 123.456.7890 000000000200Brown Billie B 234.567.8901 000000000300Carson Cameron C 345.678.9012 000000002600Zenith Zebulon Z 890.123.4567 000000000500Everest Evan E 567.890.1234 000000000600Franklin Francis F 678.901.2345 000000000700Garfunkel Gwen G 789.012.3456 000000000800Harrison Hilary H 890.123.4567 000000000900Isley Isabel I 901.234.5678 000000001000Johnson Jamie J 123.456.7890 000000001100Kemper Kelly K 234.567.8901 000000001200Lemond Lesley L 345.678.9012 000000001300Mitchell Marlow M 456.789.0123 000000001400Newman Noel N 567.890.1234 000000001500Osborn Owen O 678.901.2345 000000001600Powell Pierce P 789.012.3456 000000001700Quigley Quincy Q 890.123.4567 000000000400Davidson Dion D 456.789.0123 000000001800Ripley Ray R 901.234.5678 000000001900Smith Sammy S 123.456.7890 000000002000Tucker Taylor T 234.567.8901 000000002100Underwood Ulysses U 345.678.9012 000000002200Victoria Vaughn V 456.789.0123 000000002300Wilson Wiley W 567.890.1234 000000002400Xray Xavier X 678.901.2345 000000002500Young Yanni Y 789.012.3456 /* //SYSUT2 DD DSN=SIMOTIME.DATA.ALTQSMD1, // DISP=(NEW,CATLG,DELETE), // STORCLAS=MFI, // SPACE=(TRK,5), // DCB=(RECFM=FB,LRECL=80,BLKSIZE=800,DSORG=PS) //* //* ******************************************************************* //* Step 3 of 4, Sort by customer number (positions 1-12)... //* ******************************************************************* //* //SORTST03 EXEC PGM=SORT, // REGION=1024K, // PARM='CORE=500K,RELEASE=OFF' //SYSIN DD DSN=SIMOTIME.PDS.PARMLIB(CBLALTT1),DISP=SHR //SORTWK01 DD UNIT=SYSDA,SPACE=(CYL,55) //SORTWK02 DD UNIT=SYSDA,SPACE=(CYL,55) //SORTWK03 DD UNIT=SYSDA,SPACE=(CYL,55) //SORTIN DD DSN=SIMOTIME.DATA.ALTQSMD1,DISP=SHR //SORTOUT DD DSN=SIMOTIME.DATA.ALTQSMD2,DISP=(NEW,CATLG,DELETE), // STORCLAS=MFI, // SPACE=(TRK,5), // DCB=(RECFM=FB,LRECL=80,BLKSIZE=8000,DSORG=PS) //SYSOUT DD SYSOUT=* //* //* ******************************************************************* //* Step 4 of 4, Create and populate a new QSAM file... //* //QSAMCRT3 EXEC PGM=IEBGENER //SYSPRINT DD SYSOUT=* //SYSIN DD DUMMY //* NUMBER..NAME, LAST FIRST MIDDLE TELEPHONE //* :....1....:....2....:....3....:....4....:....5....:....6....:....7....:....8 //SYSUT1 DD * 000000987654SMITH JANE J 444.432.8765 000000123456DOE JOHN JAY 901.234.5678 /* //SYSUT2 DD DSN=SIMOTIME.DATA.ALTQSMD3, // DISP=(NEW,CATLG,DELETE), // STORCLAS=MFI, // SPACE=(TRK,5), // DCB=(RECFM=FB,LRECL=80,BLKSIZE=800,DSORG=PS) //*
The following (CBLALTJ9.jcl) is a sample of the mainframe JCL needed to run IDCAMS and create a VSAM Cluster for a Key Sequenced Data Set (KSDS) with a primary index and an alternate index. This example is a single job consisting of five steps.
The individual steps are explained in more detail and shown as individual jobs in the sections after this JCL listing. It is important to note the steps must be executed in the sequence shown.
//CBLALTJ9 JOB SIMOTIME,CLASS=1,MSGCLASS=0,NOTIFY=CSIP1 //* ******************************************************************* //* CBLALTJ9.JCL - a JCL Member for Batch Job Processing * //* This JCL Member is provided by SimoTime Technologies * //* (C) Copyright 1987-2019 All Rights Reserved * //* Web Site URL: http://www.simotime.com * //* e-mail: helpdesk@simotime.com * //* ******************************************************************* //* //* Text - Create a VSAM, KSDS with an alternate index. //* Author - SimoTime Technologies //* Date - January 24, 1991 //* //* This job will use IDCAMS to create a VSAM, KSDS data set with an //* alternate index. The primary key is twelve characters starting at //* the first position in the record. The Alternate key is twelve //* characters starting at position 69 of the record. //* The record length is 512 characters. //* //* The purpose of this procedure is to create and load a new VSAM //* Key-Sequenced-Data-Set (KSDS) with a primary key of a customer //* number and an alternate index of the telephone number. The //* procedure does an ordered load (i.e. sequential processing) for //* speed in populating the file. Therefore, the records to be added //* must be added in sequence. //* //* This set of programs will run on a mainframe under MVS or on a //* Personal Computer with Windows and Micro Focus Mainframe Express. //* //* ******************************************************************* //* Step 1 of 5, Create a VSAM Cluster for a Key-Sequenced-Data-Set. //* //KSDCRTS1 EXEC PGM=IDCAMS //SYSPRINT DD SYSOUT=* //SYSIN DD * DEFINE CLUSTER (NAME (SIMOTIME.DATA.ALTKSD) - TRACKS (45 15) - RECORDSIZE (512 512) - FREESPACE (10 15) - KEYS (12 0) - INDEXED) - DATA (NAME (SIMOTIME.DATA.ALTKSD.DAT) - CISZ (8192)) - INDEX (NAME (SIMOTIME.DATA.ALTKSD.IDX)) /* //* //* ******************************************************************* //* Step 2 of 5, Read Sequential File, populate (or Write records to) //* the VSAM Key-Sequenced-Data-Set (KSDS). //* //ADDNEWS1 EXEC PGM=CBLALTC9 //STEPLIB DD DSN=MFI01.SIMOPROD.LOADLIB1,DISP=SHR //ALTQSMD2 DD DSN=SIMOTIME.DATA.ALTQSMD2,DISP=SHR //ALTKSD DD DSN=SIMOTIME.DATA.ALTKSD,DISP=SHR //SYSOUT DD SYSOUT=* //* //* ******************************************************************* //* Step 3 of 5, Define an Alternate Index based on telephone number. //* //DEFALTIX EXEC PGM=IDCAMS //SYSPRINT DD SYSOUT=* //SYSIN DD * DEFINE AIX (NAME (SIMOTIME.DATA.ALTKSD1) - RELATE (SIMOTIME.DATA.ALTKSD) - RECORDSIZE (512 512) - TRACKS (10 5) - KEYS (12 68) - UPGRADE) /* //* //* ******************************************************************* //* Step 4 of 5, Define an path for the Alternate index. //* //DEFPATH EXEC PGM=IDCAMS //SYSPRINT DD SYSOUT=* //SYSIN DD * DEFINE PATH (NAME (SIMOTIME.DATA.ALTKSD.PATH) - PATHENTRY (SIMOTIME.DATA.ALTKSD1) - UPDATE - ) /* //* //* ******************************************************************* //* Step 5 of 5, Build the Alternate Index. //* //BLDINDEX EXEC PGM=IDCAMS //SYSPRINT DD SYSOUT=* //BASEDD DD DSN=SIMOTIME.DATA.ALTKSD,DISP=OLD //AIXDD DD DSN=SIMOTIME.DATA.ALTKSD1,DISP=OLD //IDCUT1 DD UNIT=SYSDA,SPACE=(CYL,55) //IDCUT2 DD UNIT=SYSDA,SPACE=(CYL,55) //SYSIN DD * BLDINDEX INFILE (BASEDD) - OUTFILE (AIXDD) /* //*
This is the first step of the five step process that is defined and executed as a single job.
This purpose of this job is to define the data and primary index for the Key Sequenced Data Set (KSDS). The following job (CBLALTS1.jcl) performs the same function as the first step in the single job CBLALTJ9.JCL described earlier in this document.
//CBLALTS1 JOB SIMOTIME,CLASS=1,MSGCLASS=0,NOTIFY=CSIP1 //* ******************************************************************* //* CBLALTS1.JCL - a JCL Member for Batch Job Processing * //* This JCL Member is provided by SimoTime Technologies * //* (C) Copyright 1987-2019 All Rights Reserved * //* Web Site URL: http://www.simotime.com * //* e-mail: helpdesk@simotime.com * //* ******************************************************************* //* //* Text - Define a VSAM, KSDS. //* Author - SimoTime Technologies //* Date - January 24, 1991 //* //* This job will use IDCAMS to define a VSAM, KSDS. The primary key //* is twelve characters starting at the first position in the record. //* The record length is 512 characters. //* //* This set of programs will run on a mainframe under MVS or on a //* Windows System and Micro Focus Mainframe Express. //* //* ******************************************************************* //* Step 1 of 1, Create a VSAM Cluster for a Key-Sequenced-Data-Set. //* //KSDCRTS1 EXEC PGM=IDCAMS //SYSPRINT DD SYSOUT=* //SYSIN DD * DEFINE CLUSTER (NAME (SIMOTIME.DATA.ALTKSD) - TRACKS (45 15) - RECORDSIZE (512 512) - FREESPACE (10 15) - KEYS (12 0) - INDEXED) - DATA (NAME (SIMOTIME.DATA.ALTKSD.DAT) - CISZ (8192)) - INDEX (NAME (SIMOTIME.DATA.ALTKSD.IDX)) /* //* ******************************************************************* //*
This is the second step of the five step process that is defined and executed as a single job.
The following is a sample of the mainframe JCL needed to run a COBOL program that will read a sequential file and write the records to a VSAM, KSDS. The program will add the records in sequence according to the customer number. The prime index will be maintained.
This step expects an empty VSAM, KSDS without an alternate index (the alternate index will be created in a later step). The following job (CBLALTS2.jcl) performs the same function as the second step in the single job CBLALTJ9.JCL described earlier in this document.
//CBLALTS2 JOB SIMOTIME,CLASS=1,MSGCLASS=0,NOTIFY=CSIP1 //* ******************************************************************* //* CBLALTS2.JCL - a JCL Member for Batch Job Processing * //* This JCL Member is provided by SimoTime Technologies * //* (C) Copyright 1987-2019 All Rights Reserved * //* Web Site URL: http://www.simotime.com * //* e-mail: helpdesk@simotime.com * //* ******************************************************************* //* //* Text - Load the Data into a VSAM, KSDS. //* Author - SimoTime Technologies //* Date - January 24, 1991 //* //* This job will use a COBOL program to read a sequential file and add //* records to the VSAM, KSDS. This is an ordered (or sequential) load. //* The records must be in sequence for this process. //* //* ******************************************************************* //* Step 1 of 1, This is a single step job. //* Read Sequential File, populate (or Write records to) //* the VSAM Key-Sequenced-Data-Set (KSDS). //* //ADDNEWS1 EXEC PGM=CBLALTC9 //STEPLIB DD DSN=MFI01.SIMOPROD.LOADLIB1,DISP=SHR //ALTQSMD2 DD DSN=SIMOTIME.DATA.ALTQSMD2,DISP=SHR //ALTKSD DD DSN=SIMOTIME.DATA.ALTKSD,DISP=SHR //SYSOUT DD SYSOUT=* //* //* ******************************************************************* //*
This is the third step of the five step process that is defined and executed as a single job.
The following is a sample of the mainframe JCL needed to run IDCAMS to define the alternate index.
The following job (CBLALTS3.jcl) performs the same function as the third step in the single job CBLALTJ9.JCL described earlier in this document.
//CBLALTS3 JOB SIMOTIME,CLASS=1,MSGCLASS=0,NOTIFY=CSIP1 //* ******************************************************************* //* CBLALTS3.JCL - a JCL Member for Batch Job Processing * //* This JCL Member is provided by SimoTime Technologies * //* (C) Copyright 1987-2019 All Rights Reserved * //* Web Site URL: http://www.simotime.com * //* e-mail: helpdesk@simotime.com * //* ******************************************************************* //* //* Text - Create a VSAM, KSDS with an alternate index. //* Author - SimoTime Technologies //* Date - January 24, 1991 //* //* This job will use IDCAMS to define an alternate index. //* The Alternate key is twelve bytes and starts at position 69 of //* the record. The record length is 512 characters. //* //* This job will run on a mainframe under MVS or on a Personal //* Computer with Windows and Micro Focus Mainframe Express. //* //* ******************************************************************* //* Step 1 of 1, Define an Alternate Index based on telephone number. //* //DEFALTIX EXEC PGM=IDCAMS //SYSPRINT DD SYSOUT=* //SYSIN DD * DEFINE AIX (NAME (SIMOTIME.DATA.ALTKSD1) - RELATE (SIMOTIME.DATA.ALTKSD) - RECORDSIZE (512 512) - TRACKS (10 5) - KEYS (12 68) - UPGRADE) /* //* ******************************************************************* //*
This is the fourth step of the five step process that is defined and executed as a single job.
The following is a sample of the mainframe JCL needed to run IDCAMS to create the path that relates the alternate index to the VSAM cluster.
The following job (CBLALTS4.jcl) performs the same function as the fourth step in the single job CBLALTJ9.JCL described earlier in this document.
//CBLALTS4 JOB SIMOTIME,CLASS=1,MSGCLASS=0,NOTIFY=CSIP1 //* ******************************************************************* //* CBLALTS4.JCL - a JCL Member for Batch Job Processing * //* This JCL Member is provided by SimoTime Technologies * //* (C) Copyright 1987-2019 All Rights Reserved * //* Web Site URL: http://www.simotime.com * //* e-mail: helpdesk@simotime.com * //* ******************************************************************* //* //* Text - Define the path for the alternate index. //* Author - SimoTime Technologies //* Date - January 24, 1991 //* //* This job will use IDCAMS to define a path for the alternate index. //* //* This set of programs will run on a mainframe under MVS or on a //* Windows System and Micro Focus Mainframe Express. //* //* ******************************************************************* //* Step 1 of 1, This is a single step job. //* //DEFPATH EXEC PGM=IDCAMS //SYSPRINT DD SYSOUT=* //SYSIN DD * DEFINE PATH (NAME (SIMOTIME.DATA.ALTKSD.PATH) - PATHENTRY (SIMOTIME.DATA.ALTKSD1) - UPDATE - ) /* //* ******************************************************************* //*
This is the fifth step of the five step process that is defined and executed as a single job.
The following is a sample of the mainframe JCL needed to run IDCAMS to build the alternate index.
The following job (CBLALTS5.jcl) performs the same function as the fifth step in the single job CBLALTJ9.JCL described earlier in this document.
//CBLALTS5 JOB SIMOTIME,CLASS=1,MSGCLASS=0,NOTIFY=CSIP1 //* ******************************************************************* //* CBLALTS5.JCL - a JCL Member for Batch Job Processing * //* This JCL Member is provided by SimoTime Technologies * //* (C) Copyright 1987-2019 All Rights Reserved * //* Web Site URL: http://www.simotime.com * //* e-mail: helpdesk@simotime.com * //* ******************************************************************* //* //* Text - Build an alternate index for a VSAM, KSDS. //* Author - SimoTime Technologies //* Date - January 24, 1991 //* //* This job will use IDCAMS to build the alternate index. The primary //* index is twelve characters starting at the first position in the //* record. The Alternate key is twelve characters starting at position //* 69 of the record. The record length is 512 characters. //* //* This set of programs will run on a mainframe under MVS or on a //* Personal Computer with Windows and Micro Focus Mainframe Express. //* //* ******************************************************************* //* Step 1 of 1, Build the Alternate Index. //* //BLDINDEX EXEC PGM=IDCAMS //SYSPRINT DD SYSOUT=* //BASEDD DD DSN=SIMOTIME.DATA.ALTKSD,DISP=OLD //AIXDD DD DSN=SIMOTIME.DATA.ALTKSD1,DISP=OLD //IDCUT1 DD UNIT=SYSDA,SPACE=(CYL,55) //IDCUT2 DD UNIT=SYSDA,SPACE=(CYL,55) //SYSIN DD * BLDINDEX INFILE (BASEDD) - OUTFILE (AIXDD) /* //* ******************************************************************* //*
The following (CBLALTJ7.jcl) is a sample of the mainframe JCL needed to run a COBOL program that will randomly update existing records or add new records to the existing VSAM. KSDS. This program will also update the alternate index.
//CBLALTJ7 JOB SIMOTIME,CLASS=1,MSGCLASS=0,NOTIFY=CSIP1 //* ******************************************************************* //* CBLALTJ7.JCL - a JCL Member for Batch Job Processing * //* This JCL Member is provided by SimoTime Technologies * //* (C) Copyright 1987-2019 All Rights Reserved * //* Web Site URL: http://www.simotime.com * //* e-mail: helpdesk@simotime.com * //* ******************************************************************* //* //* Text - Read a Sequential update a VSAM, KSDS. //* Author - SimoTime Technologies //* Date - January 24, 1996 //* //* This job demonstrates how to randomly add new records or update //* existing records in a KSDS with an alternate index. //* This job uses a COBOL program that reads a sequential file and //* randomly adds or updates the KSDS. //* //* This set of programs will run on a mainframe under MVS or on a //* Personal Computer with Windows and Micro Focus Mainframe Express. //* //* ************ //* * CBLALTJ7 * //* ********jcl* //* * //* * //* ************ ************ ************ //* * ALTQSM ******* CBLALTC7 ******* ALTKSD * //* *******qsam* ********cbl* *******ksds* //* * //* * //* ************ //* * EOJ * //* ************ //* //* ******************************************************************* //* Step 1 of 1, This is a single step job. //* //LOADALT4 EXEC PGM=CBLALTC7 //STEPLIB DD DSN=MFI01.SIMOPROD.LOADLIB1,DISP=SHR //ALTQSM DD DSN=SIMOTIME.DATA.ALTQSMD3,DISP=SHR //ALTKSD DD DSN=SIMOTIME.DATA.ALTKSD,DISP=SHR //ALTKSD1 DD DSN=SIMOTIME.DATA.ALTKSD.PATH,DISP=SHR //SYSOUT DD SYSOUT=* //*
The section describes various approaches to sequentially processing the VSAM data set using the primary or alternate index. The following JCL examples use COBOL programs to access the file sequentially by the primary or alternate keys and print reports.
The following (CBLALTJ1.jcl) is a sample of the mainframe JCL needed to run a COBOL program that will sequentially read records using the primary key from the VSAM, KSDS and print a report.
//CBLALTJ1 JOB SIMOTIME,CLASS=1,MSGCLASS=0,NOTIFY=CSIP1 //* ******************************************************************* //* CBLALTJ1.JCL - a JCL Member for Batch Job Processing * //* This JCL Member is provided by SimoTime Technologies * //* (C) Copyright 1987-2019 All Rights Reserved * //* Web Site URL: http://www.simotime.com * //* e-mail: helpdesk@simotime.com * //* ******************************************************************* //* //* Text - Process a VSAM, KSDS using the Primary Key. //* Author - SimoTime Technologies //* Date - January 24, 1996 //* //* This job will read a VSAM KSDS using the primary key and //* produce a report in sequence by customer number. //* //* This set of programs will run on a mainframe under MVS or on a //* Personal Computer with Windows and Micro Focus Mainframe Express. //* //* ******************************************************************* //* Step 1 of 2, Delete previously created report. //* //STEPBR14 EXEC PGM=IEFBR14 //REPORT01 DD DSN=SIMOTIME.DATA.ALTRPTD1,DISP=(MOD,DELETE,DELETE), // STORCLAS=MFI, // SPACE=(TRK,5), // DCB=(RECFM=FB,LRECL=133,DSORG=PS) //* //* ******************************************************************* //* Step 2 of 2, Create the Report sequenced by telephone number. //* ******************************************************************* //* //LISTIDX1 EXEC PGM=CBLALTC1 //STEPLIB DD DSN=MFI01.SIMOPROD.LOADLIB1,DISP=SHR //ALTKSD DD DSN=SIMOTIME.DATA.ALTKSD,DISP=SHR //ALTKSD1 DD DSN=SIMOTIME.DATA.ALTKSD,DISP=SHR //REPORT01 DD DSN=SIMOTIME.DATA.ALTRPTD1,DISP=(NEW,CATLG,DELETE), // STORCLAS=MFI, // SPACE=(TRK,5), // DCB=(RECFM=FB,LRECL=133,DSORG=PS) //SYSOUT DD SYSOUT=* //* //*
The following (CBLALTJ2.jcl) is a sample of the mainframe JCL needed to run a COBOL program that will sequentially read records using the alternate index from the VSAM, KSDS and print a report.
//CBLALTJ2 JOB SIMOTIME,CLASS=1,MSGCLASS=0,NOTIFY=CSIP1 //* ******************************************************************* //* CBLALTJ2.JCL - a JCL Member for Batch Job Processing * //* This JCL Member is provided by SimoTime Technologies * //* (C) Copyright 1987-2019 All Rights Reserved * //* Web Site URL: http://www.simotime.com * //* e-mail: helpdesk@simotime.com * //* ******************************************************************* //* //* Text - Process a VSAM, KSDS using the Alternate Index. //* Author - SimoTime Technologies //* Date - January 24, 1996 //* //* This job will read a VSAM KSDS using the alternate index and //* produce a report in sequence by telephone number. //* //* This set of programs will run on a mainframe under MVS or on a //* Personal Computer with Windows and Micro Focus Mainframe Express. //* //* ******************************************************************* //* Step 1 of 2, Delete previously created report. //* //STEPBR14 EXEC PGM=IEFBR14 //REPORT02 DD DSN=SIMOTIME.DATA.ALTRPTD2,DISP=(MOD,DELETE,DELETE), // STORCLAS=MFI, // SPACE=(TRK,5), // DCB=(RECFM=FB,LRECL=133,DSORG=PS) //* //* ******************************************************************* //* Step 2 of 2, Create the Report sequenced by telephone number. //* ******************************************************************* //* //LISTALT2 EXEC PGM=CBLALTC2 //STEPLIB DD DSN=MFI01.SIMOPROD.LOADLIB1,DISP=SHR //ALTKSD DD DSN=SIMOTIME.DATA.ALTKSD,DISP=SHR //ALTKSD1 DD DSN=SIMOTIME.DATA.ALTKSD.PATH,DISP=SHR //REPORT02 DD DSN=SIMOTIME.DATA.ALTRPTD2,DISP=(NEW,CATLG,DELETE), // STORCLAS=MFI, // SPACE=(TRK,5), // DCB=(RECFM=FB,LRECL=133,DSORG=PS) //SYSOUT DD SYSOUT=* //* //*
The following (CBLALTJ3.jcl) is a sample of the mainframe JCL needed to run a COBOL program that will sequentially read records using the primary key or alternate index from the VSAM, KSDS and print a report. The sequence is determined by the parameter passed from JCL to the COBOL program.
//CBLALTJ3 JOB SIMOTIME,CLASS=1,MSGCLASS=0,NOTIFY=CSIP1 //* ******************************************************************* //* CBLALTJ3.JCL - a JCL Member for Batch Job Processing * //* This JCL Member is provided by SimoTime Technologies * //* (C) Copyright 1987-2019 All Rights Reserved * //* Web Site URL: http://www.simotime.com * //* e-mail: helpdesk@simotime.com * //* ******************************************************************* //* //* Text - Process a VSAM, KSDS using the prime or alternate Index. //* Author - SimoTime Technologies //* Date - January 24, 1996 //* //* This job will read a VSAM KSDS using the alternate index and //* produce a report in sequence by telephone number. //* //* This set of programs will run on a mainframe under MVS or on a //* Personal Computer with Windows and Micro Focus Mainframe Express. //* //* ******************************************************************* //* Step 1 of 3, Delete previously created report. //* //STEPBR14 EXEC PGM=IEFBR14 //REPORTP1 DD DSN=SIMOTIME.DATA.ALTRPTP1,DISP=(MOD,DELETE,DELETE), // STORCLAS=MFI, // SPACE=(TRK,5), // DCB=(RECFM=FB,LRECL=133,DSORG=PS) //REPORTP2 DD DSN=SIMOTIME.DATA.ALTRPTP2,DISP=(MOD,DELETE,DELETE), // STORCLAS=MFI, // SPACE=(TRK,5), // DCB=(RECFM=FB,LRECL=133,DSORG=PS) //* //* ******************************************************************* //* Step 2 of 3, Create the report sequenced by customer number. //* ******************************************************************* //* //LISTKSD EXEC PGM=CBLALTC3,PARM=PIX0 //STEPLIB DD DSN=MFI01.SIMOPROD.LOADLIB1,DISP=SHR //ALTKSD DD DSN=SIMOTIME.DATA.ALTKSD,DISP=SHR //ALTKSD1 DD DSN=SIMOTIME.DATA.ALTKSD.PATH,DISP=SHR //REPORT03 DD DSN=SIMOTIME.DATA.ALTRPTP1,DISP=(NEW,CATLG,DELETE), // STORCLAS=MFI, // SPACE=(TRK,5), // DCB=(RECFM=FB,LRECL=133,DSORG=PS) //SYSOUT DD SYSOUT=* //* //* ******************************************************************* //* Step 3 of 3, Create the Report sequenced by telephone number. //* ******************************************************************* //* //LISTALT2 EXEC PGM=CBLALTC3,PARM=AIX1 //STEPLIB DD DSN=MFI01.SIMOPROD.LOADLIB1,DISP=SHR //ALTKSD DD DSN=SIMOTIME.DATA.ALTKSD,DISP=SHR //ALTKSD1 DD DSN=SIMOTIME.DATA.ALTKSD.PATH,DISP=SHR //REPORT03 DD DSN=SIMOTIME.DATA.ALTRPTP2,DISP=(NEW,CATLG,DELETE), // STORCLAS=MFI, // SPACE=(TRK,5), // DCB=(RECFM=FB,LRECL=133,DSORG=PS) //SYSOUT DD SYSOUT=* //*
The following (CBLALTJ0.jcl) is a sample of the mainframe JCL needed to run IDCAMS and delete the VSAM cluster. Subsequent job steps will delete the sequential files that are created by the suite of jobs for the ALTERNATE INDEX suite of example programs.
CAUTION!!! This will delete the Keyed-Indexed file. This includes the data, primary index and alternate index. Also, the work files and other output files created by this suite of programs will be deleted.
//CBLALTJ0 JOB SIMOTIME,CLASS=1,MSGCLASS=0,NOTIFY=CSIP1 //* ******************************************************************* //* CBLALTJ0.JCL - a JCL Member for Batch Job Processing * //* This JCL Member is provided by SimoTime Technologies * //* (C) Copyright 1987-2019 All Rights Reserved * //* Web Site URL: http://www.simotime.com * //* e-mail: helpdesk@simotime.com * //* ******************************************************************* //* Text - JCL using the IDCAMS Utility to delete a VSAM Cluster. //* Subsequent job steps will delete the sequential files //* that are created by the suite of jobs for the ALTERNATE //* INDEX suite of example programs. //* Author - SimoTime Technologies //* Date - January 1, 1998 //*------------------------------------------------------------------- //* The following example is more than what is usually required to //* delete a VSAM Data Set. However, the purpose is to illustrate the //* functions of the IDCAMS utility. //* PURGE: A VSAM Data Set may be date-protected. The DEFINE Cluster //* has the option of specifying a retention date. If this //* retention date has not expired then the PURGE option will //* be required in order to delete the data set. //* The default is NOPURGE. //* ERASE: The standard operation by the VSAM DELETE is to delete //* the catalog entry of the cluster and mark the space used //* by the cluster as reclaimable. The data contents of the //* cluster is no longer generally available but it is still //* present until the area is reused. This introduces a //* potential problem or security exposure for sensitive data. //* The information could be retrieved using some special //* class of DUMP/RESTORE utilities that are often used by //* data center staff. The ERASE function will write over the //* data area used by the cluster and the original data is //* destroyed. The default is NOERASE. //* SET: The MAXCC = 0 will reset a non-zero return code to ZERO. //* This ensures a ZERO return code if this job is executed //* and the data set does not exist. //* //********************************************************************* //* Step 1 of 4, Delete a previously created VSAM KSDS Cluster... //* //KDEL0512 EXEC PGM=IDCAMS //SYSPRINT DD SYSOUT=* //SYSIN DD * DELETE SIMOTIME.DATA.ALTKSD - FILE(ALTKSD) - PURGE - ERASE - CLUSTER SET MAXCC = 0 /* //* //* ******************************************************************* //* Step 2 of 4, Delete any previously created work files... //* //CLEANUP1 EXEC PGM=IEFBR14 //ALTQSMD1 DD DSN=SIMOTIME.DATA.ALTQSMD1,DISP=(MOD,DELETE,DELETE), // STORCLAS=MFI, // SPACE=(TRK,5), // DCB=(RECFM=FB,LRECL=80,BLKSIZE=800,DSORG=PS) //ALTQSMD2 DD DSN=SIMOTIME.DATA.ALTQSMD2,DISP=(MOD,DELETE,DELETE), // STORCLAS=MFI, // SPACE=(TRK,5), // DCB=(RECFM=FB,LRECL=80,BLKSIZE=8000,DSORG=PS) //ALTQSMD3 DD DSN=SIMOTIME.DATA.ALTQSMD3,DISP=(MOD,DELETE,DELETE), // STORCLAS=MFI, // SPACE=(TRK,5), // DCB=(RECFM=FB,LRECL=80,BLKSIZE=8000,DSORG=PS) //* //* ******************************************************************* //* Step 3 of 4, Delete previously created report files. //* //DELRPTDN EXEC PGM=IEFBR14 //REPORT01 DD DSN=SIMOTIME.DATA.ALTRPTD1,DISP=(MOD,DELETE,DELETE), // STORCLAS=MFI, // SPACE=(TRK,5), // DCB=(RECFM=FB,LRECL=133,DSORG=PS) //REPORT02 DD DSN=SIMOTIME.DATA.ALTRPTD2,DISP=(MOD,DELETE,DELETE), // STORCLAS=MFI, // SPACE=(TRK,5), // DCB=(RECFM=FB,LRECL=133,DSORG=PS) //* //* ******************************************************************* //* Step 4 of 4, Delete previously created report files. //* //DELRPTPN EXEC PGM=IEFBR14 //REPORTP1 DD DSN=SIMOTIME.DATA.ALTRPTP1,DISP=(MOD,DELETE,DELETE), // STORCLAS=MFI, // SPACE=(TRK,5), // DCB=(RECFM=FB,LRECL=133,DSORG=PS) //REPORTP2 DD DSN=SIMOTIME.DATA.ALTRPTP2,DISP=(MOD,DELETE,DELETE), // STORCLAS=MFI, // SPACE=(TRK,5), // DCB=(RECFM=FB,LRECL=133,DSORG=PS) //*
This section will describe the various steps required to create a keyed-indexed file, populate the file with data, create an alternate index and then access the file sequentially using the primary key or the alternate index. Micro Focus COBOL and Net Express is used to run the programs in a Windows environment.
The following (CBLALTE8.cmd) is a sample of a Windows CMD file needed to create a sequential file. The records to be placed in the sequential file are included in the job stream. The records are intentionally loaded into the sequential file in an out- of-sequence arrangement.
The first step in the job is housekeeping. This step will set environment variables and delete any files created by a previous run of this job.
The second step in the job will create a sequential file. The records are intentionally placed in the file in an out-of-sequence arrangement.
The third step in the job will sort the file and create a sequential file that is in sequence by the customer number. This file will be used to do the initial loading (or populating) of the keyed-indexed file. Since the initial load will be done as a sequential add (or ordered load) the records must be in sequence.
The fourth step will create a smaller sequential file that will be used to randomly add or update records in an existing keyed-indexed file.
The fifth step performs the End-of-Job tasks.
@echo OFF rem * ******************************************************************* rem * CBLALTE8.CMD - a Windows Command File * rem * This program is provided by SimoTime Technologies * rem * (C) Copyright 1987-2019 All Rights Reserved * rem * Web Site URL: http://www.simotime.com * rem * e-mail: helpdesk@simotime.com * rem * ******************************************************************* rem * rem * Text - Create a Sequential Data Set on disk using IEBGENER. rem * Author - SimoTime Technologies rem * Date - January 24, 1996 rem * rem * The first job step (DELALTS1) will delete any previously created rem * file. The second job step (CRTQNAME) will create a new file. The rem * third job step (SORTST03) will sort the file. rem * rem * This set of programs will run on a mainframe under MVS or on a rem * Personal Computer with Windows and Micro Focus Mainframe Express. rem * rem * ************ rem * * CBLALTE8 * rem * ********cmd* rem * * rem * * rem * ************ ************ rem * * if EXIST ******* ALTTXTD1 * rem * ********cmd* ***delete*** rem * * rem * * rem * ************ ************ ************ rem * * SYSIN ******* echo ******* ALTTXTD1 * rem * ********cmd* ********cmd* ********txt* rem * * rem * * rem * ************ ************ ************ rem * * ALTQSMD1 ******* SORT ******* ALTQSMD2 * rem * ********qsm* ********utl* ********qsm* rem * * rem * * rem * ************ ************ ************ rem * * SYSIN ******* echo ******* ALTTXTD3 * rem * ********cmd* ********cmd* ********TXT* rem * * rem * * rem * ************ rem * * EOJ * rem * ************ rem * rem * rem * ******************************************************************** rem * Step 1 of 7, Set the global environment variables... rem * call ..\Env1BASE %CmdName% if "%SYSLOG%" == "" set syslog=c:\SimoLIBR\LOGS\SimoTime.LOG set CmdName=CblAltE8 rem * call SimoNOTE "*******************************************************%CmdName%" call SimoNOTE "Starting CmdName %CmdName%" rem * ******************************************************************* rem * Step 2 of 7, Delete any previously created file... rem * :CblAltSetClean call SimoNOTE "Identify JobStep CblAltSetClean, Set environment, Cleanup old files..." set ALTTXTD1=%BaseLib1%\DATA\Txt1\ALTTXTD1.TXT set ALTTXTD3=%BaseLib1%\DATA\Txt1\ALTTXTD3.TXT set ALTQSMD1=%BaseLib1%\DATA\Wrk1\ALTQSMD1.DAT set ALTQSMD2=%BaseLib1%\DATA\Wrk1\ALTQSMD2.DAT set ALTQSMD3=%BaseLib1%\DATA\Wrk1\ALTQSMD3.DAT if exist %ALTTXTD1% erase %ALTTXTD1% if exist %ALTTXTD3% erase %ALTTXTD3% if exist %ALTQSMD1% erase %ALTQSMD1% if exist %ALTQSMD2% erase %ALTQSMD2% if exist %ALTQSMD3% erase %ALTQSMD3% rem * :CreateText1 rem * ******************************************************************* rem * Step 3 of 7, Create out-of-sequence QSAM file... rem * rem * Number..Name, Last First Middle Telephone rem * ...:....1....:....2....:....3....:....4....:....5....:....6....:....7....:....8 echo 000000000100Anderson Adrian A 123.456.7890> %ALTTXTD1% echo 000000000200Brown Billie B 234.567.8901>> %ALTTXTD1% echo 000000000300Carson Cameron C 345.678.9012>> %ALTTXTD1% echo 000000002600Zenith Zebulon Z 890.123.4567>> %ALTTXTD1% echo 000000000500Everest Evan E 567.890.1234>> %ALTTXTD1% echo 000000000600Franklin Francis F 678.901.2345>> %ALTTXTD1% echo 000000000700Garfunkel Gwen G 789.012.3456>> %ALTTXTD1% echo 000000000800Harrison Hilary H 890.123.4567>> %ALTTXTD1% echo 000000000900Isley Isabel I 901.234.5678>> %ALTTXTD1% echo 000000001000Johnson Jamie J 123.456.7890>> %ALTTXTD1% echo 000000001100Kemper Kelly K 234.567.8901>> %ALTTXTD1% echo 000000001200Lemond Lesley L 345.678.9012>> %ALTTXTD1% echo 000000001300Mitchell Marlow M 456.789.0123>> %ALTTXTD1% echo 000000001400Newman Noel N 567.890.1234>> %ALTTXTD1% echo 000000001500Osborn Owen O 678.901.2345>> %ALTTXTD1% echo 000000001600Powell Pierce P 789.012.3456>> %ALTTXTD1% echo 000000001700Quigley Quincy Q 890.123.4567>> %ALTTXTD1% echo 000000000400Davidson Dion D 456.789.0123>> %ALTTXTD1% echo 000000001800Ripley Ray R 901.234.5678>> %ALTTXTD1% echo 000000001900Smith Sammy S 123.456.7890>> %ALTTXTD1% echo 000000002000Tucker Taylor T 234.567.8901>> %ALTTXTD1% echo 000000002100Underwood Ulysses U 345.678.9012>> %ALTTXTD1% echo 000000002200Victoria Vaughn V 456.789.0123>> %ALTTXTD1% echo 000000002300Wilson Wiley W 567.890.1234>> %ALTTXTD1% echo 000000002400Xray Xavier X 678.901.2345>> %ALTTXTD1% echo 000000002500Young Yanni Y 789.012.3456>> %ALTTXTD1% rem * :SortFile1 rem * ******************************************************************* rem * Step 4 of 7, Sort the file, rem * Read Line Sequential write Record Sequential rem * call SimoNOTE "Identify JobStep SortFile1, Sort by Primary Key" set SYSIN=%BaseLib1%\ParmLib1\CBLALTT1.SRT set SORTIN=%ALTTXTD1% set SORTOUT=%ALTQSMD2% MFSORT SORT FIELDS=(1,12,CH,A) use %SORTIN% ORG LS give %SORTOUT% RECORD F,80 ORG SQ if not "%ERRORLEVEL%" == "0" set JobStatus=0030 if not "%JobStatus%" == "0000" goto :EojNOK if exist %ALTQSMD2% call SimoNOTE "Produced DataSet %ALTQSMD2%" if exist %ALTQSMD2% goto :CreateText2 call SimoNOTE "ABENDING JobStep SortFile1, Sort Failure..." goto :EojNOK rem * :CreateText2 rem * ******************************************************************* rem * Step 5 of 7, Create 2nd QSAM file... rem * rem * Number..Name, Last First Middle Telephone rem * ...:....1....:....2....:....3....:....4....:....5....:....6....:....7....:....8 echo 000000987654SMITH JANE J 410.777.7000> %ALTTXTD3% echo 000000123456DOE JOHN JAY 499.999.9000>> %ALTTXTD3% if exist %ALTTXTD3% call SimoNOTE "Produced DataSet %ALTTXTD3%" rem * :ConvertLseqToRseq rem * ******************************************************************* rem * Step 6 of 7, Convert Line Sequential to Record Sequential... rem * set GETLS080=%ALTTXTD3% set PUTRS080=%ALTQSMD3% run CV80ALAR if exist %ALTQSMD3% call SimoNOTE "Produced DataSet %ALTQSMD3%" if exist %ALTQSMD3% goto :EojAOK call SimoNOTE "ABENDING JobStep ConvertLseqToRseq, Conversion Failure..." goto :EojNOK rem * rem * ******************************************************************* rem * Step 7 of 7, End-of-Job rem * :EojAOK call SimoNOTE "Finished CmdName %CmdName%, Job Status is %JobStatus%" goto :End :EojNOK call SimoNOTE "ABENDING CmdName %CmdName%, Job Status is %JobStatus%" echo %DATE% - %TIME% Starting User ABEND Processing...>>%SYSLOG% set >>%SYSLOG% echo %DATE% - %TIME% Complete User ABEND Processing...>>%SYSLOG% goto :End :End call SimoNOTE "Conclude SysOut is %SYSOUT%" if not "%1" == "nopause" pause exit /B %JobStatus%
The following (CBLALTE9.cmd) is a sample of the Windows CMD file needed to create a Key-Indexed file with a primary index and an alternate index. This example is a single job consisting of four steps.
The first step will set the environment for the job to execute.
The second step will create the Keyed-Indexed file with a primary index. Data is loaded into the file by reading a sequential file and writing records to the Keyed-Index file.
The third step uses the "rebuild" program to create the alternate index.
The fourth step performs the End-of-Job tasks.
@echo OFF rem * ******************************************************************* rem * CBLALTE9.CMD - a Windows Command File * rem * This program is provided by SimoTime Technologies * rem * (C) Copyright 1987-2019 All Rights Reserved * rem * Web Site URL: http://www.simotime.com * rem * e-mail: helpdesk@simotime.com * rem * ******************************************************************* rem * rem * Text - Sequentially write new records to an indexed file. rem * Author - SimoTime Technologies rem * Date - November 11, 2003 rem * Version - 04.03.12 rem * rem * This set of programs illustrate the use a COBOL program to read rem * a sequential file and write new records to a VSAM, KSDS or rem * indexed file. rem * The customer-number is the primary key. rem * rem * When running with Net Express the IBMCOMP an NOTRUNC directives rem * will be required to maintain compatability with the mainframe rem * format and field sizes for binary fields. rem * rem * This technique provides for the use of a single COBOL source rem * program that will run on OS/390, Windows or Unix. rem * rem * This set of programs will run on a Personal Computer with Windows rem * and Micro Focus Net Express. rem * ******************************************************************** rem * Step 1 of 4, Set the global environment variables... rem * call ..\Env1BASE %CmdName% if "%SYSLOG%" == "" set syslog=c:\SimoLIBR\LOGS\SimoTime.LOG set CmdName=CblAltE9 rem * call SimoNOTE "*******************************************************%CmdName%" call SimoNOTE "Starting CmdName %CmdName%" set ALTQSMD2=%BaseLib1%\DATA\Wrk1\ALTQSMD2.DAT set ALTKSD=%BaseLib1%\DATA\Wrk1\ALTKSD.DAT if exist %ALTKSD% set JobStatus=0010 if not "%JobStatus%" == "0000" goto :EojNOK rem * ******************************************************************** rem * Step 2 of 4, Load the data into the indexed file... rem * run CBLALTC9 if errorlevel = 1 set JobStatus=0020 if not "%JobStatus%" == "0000" goto :EojNOK rem * ******************************************************************** rem * Step 3 of 4, Build the alternate index... rem * rem * /e Reports illegal duplicate keys and continues processing rem * /i Displays information about the files being processed rem * /x:n Specifies the order in which data is written when rem * reorganizing an indexed file rem * n=0 Primary Index rem * n=1 1st Alternate Index, etc... rem * rebuild %BaseLib1%\DATA\Wrk1\ALTKSD.DAT /ka:69+12d /e /x:0 /i if errorlevel = 1 set JobStatus=0030 if not "%JobStatus%" == "0000" goto :EojNOK rem * ******************************************************************** rem * Step 4 of 4, End-of-Job... rem * :EojAOK call SimoNOTE " ..." call SimoNOTE "Finished CmdName %CmdName%, Job Status is %JobStatus%" goto :End :EojNOK call SimoNOTE "ABENDING CmdName %CmdName%, Job Status is %JobStatus%" echo %DATE% - %TIME% Starting User ABEND Processing...>>%SYSLOG% set >>%SYSLOG% echo %DATE% - %TIME% Complete User ABEND Processing...>>%SYSLOG% goto :End :End call SimoNOTE "Conclude SysOut is %SYSOUT%" if not "%1" == "nopause" pause exit /B %JobStatus%
The following (CBLALTE7.cmd) is a sample of the Windows CMD file that will run a COBOL program that will randomly update existing records or add new records to the existing Keyed-Indexed file. This program will also update the alternate index.
@echo OFF rem * ******************************************************************* rem * CBLALTE7.CMD - a Windows Command File * rem * This program is provided by SimoTime Technologies * rem * (C) Copyright 1987-2019 All Rights Reserved * rem * Web Site URL: http://www.simotime.com * rem * e-mail: helpdesk@simotime.com * rem * ******************************************************************* rem * rem * Text - Randomly write new records to an indexed file. rem * Author - SimoTime Technologies rem * Date - November 11, 2003 rem * Version - 04.03.12 rem * rem * This set of programs illustrate the use a COBOL program to read rem * a sequential file and write new records to a VSAM, KSDS or rem * indexed file. rem * The customer-number is the primary key. rem * rem * When running with Net Express the IBMCOMP an NOTRUNC directives rem * will be required to maintain compatability with the mainframe rem * format and field sizes for binary fields. rem * rem * This technique provides for the use of a single COBOL source rem * program that will run on OS/390, Windows or Unix. rem * rem * This set of programs will run on a Personal Computer with Windows rem * and Micro Focus Net Express. rem * ******************************************************************** rem * Step 1 of 3, Set the global environment variables... rem * call ..\Env1BASE %CmdName% if "%SYSLOG%" == "" set syslog=c:\SimoLIBR\LOGS\SimoTime.LOG set CmdName=CblAltE7 rem * call SimoNOTE "*******************************************************%CmdName%" call SimoNOTE "Starting CmdName %CmdName%" set ALTQSM=%BaseLib1%\DATA\Wrk1\ALTQSMD3.DAT set ALTKSD=%BaseLib1%\DATA\Wrk1\ALTKSD.DAT rem * ******************************************************************** rem * Step 2 of 3, Add new or update existing records in the indexed file. rem * run CBLALTC7 if errorlevel = 1 set JobStatus=0010 if not "%JobStatus%" == "0000" goto :EojNOK rem * ******************************************************************** rem * Step 3 of 3, End-of-Job... rem * :EojAOK call SimoNOTE "Finished CmdName %CmdName%, Job Status is %JobStatus%" goto :End :EojNOK call SimoNOTE "ABENDING CmdName %CmdName%, Job Status is %JobStatus%" echo %DATE% - %TIME% Starting User ABEND Processing...>>%SYSLOG% set >>%SYSLOG% echo %DATE% - %TIME% Complete User ABEND Processing...>>%SYSLOG% goto :End :End call SimoNOTE "Conclude SysOut is %SYSOUT%" if not "%1" == "nopause" pause exit /B %JobStatus%
The section describes various approaches to sequentially processing the Keyed-Indexed File using the primary or alternate index. The following examples use COBOL programs to access the file sequentially by the primary or alternate keys and print reports.
The following (CBLALTE1.cmd) is a sample of the Windows CMD needed to run a COBOL program that will sequentially read records using the primary key from the Keyed-Indexed file and print a report.
@echo OFF rem * ******************************************************************* rem * CBLALTE1.CMD - a Windows Command File * rem * This program is provided by SimoTime Technologies * rem * (C) Copyright 1987-2019 All Rights Reserved * rem * Web Site URL: http://www.simotime.com * rem * e-mail: helpdesk@simotime.com * rem * ******************************************************************* rem * rem * Text - COBOL and Primary Index Access rem * Author - SimoTime Technologies rem * Date - November 11, 2003 rem * Version - 04.03.12 rem * rem * This set of programs illustrate the use a COBOL program to access rem * a VSAM, KSDS and produce a report in customer-number sequence. rem * The customer-number is the primary key. rem * rem * When running with Net Express the IBMCOMP an NOTRUNC directives rem * will be required to maintain compatability with the mainframe rem * format and field sizes for binary fields. rem * rem * This technique provides for the use of a single COBOL source rem * program that will run on OS/390, Windows or Unix. rem * rem * This set of programs will run on a Personal Computer with Windows rem * and Micro Focus Net Express. rem * ******************************************************************** rem * Step 1 of 3, Set the global environment variables... rem * call ..\Env1BASE %CmdName% if "%SYSLOG%" == "" set syslog=c:\SimoLIBR\LOGS\SimoTime.LOG set CmdName=CblAltE1 rem * call SimoNOTE "*******************************************************%CmdName%" call SimoNOTE "Starting CmdName %CmdName%" set ALTKSD=%BaseLib1%\DATA\Wrk1\ALTKSD.DAT set REPORT01=%BaseLib1%\DATA\Wrk1\ALTRPTD1.DAT if exist %REPORT01% erase %REPORT01% rem * ******************************************************************** rem * Step 2 of 3, Read sequentially by primary key and print report rem * run CBLALTC1 if errorlevel = 1 set JobStatus=0010 if not "%JobStatus%" == "0000" goto :EojNOK rem * ******************************************************************** rem * Step 3 of 3, End-of-Job rem * :EojAOK call SimoNOTE "Finished CmdName %CmdName%, Job Status is %JobStatus%" goto :End :EojNOK call SimoNOTE "ABENDING CmdName %CmdName%, Job Status is %JobStatus%" echo %DATE% - %TIME% Starting User ABEND Processing...>>%SYSLOG% set >>%SYSLOG% echo %DATE% - %TIME% Complete User ABEND Processing...>>%SYSLOG% goto :End :End call SimoNOTE "Conclude SysOut is %SYSOUT%" if not "%1" == "nopause" pause exit /B %JobStatus%
The following (CBLALTE2.cmd) is a sample of the Windows CMD needed to run a COBOL program that will sequentially read records using the alternate index from the Keyed-Indexed file and print a report.
@echo OFF rem * ******************************************************************* rem * CBLALTE2.CMD - a Windows Command File * rem * This program is provided by SimoTime Technologies * rem * (C) Copyright 1987-2019 All Rights Reserved * rem * Web Site URL: http://www.simotime.com * rem * e-mail: helpdesk@simotime.com * rem * ******************************************************************* rem * rem * Text - COBOL and Alternate Index Access rem * Author - SimoTime Technologies rem * Date - November 11, 2003 rem * Version - 04.03.12 rem * rem * This set of programs illustrate the use a COBOL program to access rem * a VSAM, KSDS and produce a report in customer-number sequence. rem * The customer-number is the primary key. rem * rem * When running with Net Express the IBMCOMP an NOTRUNC directives rem * will be required to maintain compatability with the mainframe rem * format and field sizes for binary fields. rem * rem * This technique provides for the use of a single COBOL source rem * program that will run on OS/390, Windows or Unix. rem * rem * This set of programs will run on a Personal Computer with Windows rem * and Micro Focus Net Express. rem * ******************************************************************** rem * Step 1 of 3, Set the global environment variables... rem * call ..\Env1BASE %CmdName% if "%SYSLOG%" == "" set syslog=c:\SimoLIBR\LOGS\SimoTime.LOG set CmdName=CblAltE2 rem * call SimoNOTE "*******************************************************%CmdName%" call SimoNOTE "Starting CmdName %CmdName%" set ALTKSD=%BaseLib1%\DATA\Wrk1\ALTKSD.DAT set ALTKSD1=%BaseLib1%\DATA\Wrk1\ALTKSD.PATH set REPORT02=%BaseLib1%\DATA\Wrk1\ALTRPTD2.DAT if exist %REPORT02% erase %REPORT02% rem * ******************************************************************** rem * Step 2 of 3, Read sequentially by alternate key and print report rem * run CBLALTC2 if errorlevel = 1 set JobStatus=0010 if not "%JobStatus%" == "0000" goto :EojNOK rem * ******************************************************************** rem * Step 3 of 3, End-of-Job rem * :EojAOK call SimoNOTE "Finished CmdName %CmdName%, Job Status is %JobStatus%" goto :End :EojNOK call SimoNOTE "ABENDING CmdName %CmdName%, Job Status is %JobStatus%" echo %DATE% - %TIME% Starting User ABEND Processing...>>%SYSLOG% set >>%SYSLOG% echo %DATE% - %TIME% Complete User ABEND Processing...>>%SYSLOG% goto :End :End call SimoNOTE "Conclude SysOut is %SYSOUT%" if not "%1" == "nopause" pause exit /B %JobStatus%
The following (CBLALTE3.cmd) is a sample of the Windows CMD needed to run a COBOL program that will sequentially read records using the primary key or alternate index from the Keyed-Indexed file and print a report. The sequence is determined by the parameter passed from CMD to the COBOL program.
@echo OFF rem * ******************************************************************* rem * CBLALTE3.CMD - a Windows Command File * rem * This program is provided by SimoTime Technologies * rem * (C) Copyright 1987-2019 All Rights Reserved * rem * Web Site URL: http://www.simotime.com * rem * e-mail: helpdesk@simotime.com * rem * ******************************************************************* rem * rem * Text - COBOL with Primary and Alternate Index Access rem * Author - SimoTime Technologies rem * Date - November 11, 2003 rem * Version - 05.07.06 rem * rem * This set of programs illustrate the use a COBOL program to access rem * a VSAM, KSDS and produce a report in customer-number sequence or rem * telephone-number sequence. rem * The customer-number is the primary key. The telephone-number is rem * the alternate index key. rem * rem * When running with Net Express the IBMCOMP an NOTRUNC directives rem * will be required to maintain compatability with the mainframe rem * format and field sizes for binary fields. rem * rem * This technique provides for the use of a single COBOL source rem * program that will run on z/OS, Windows or Unix. rem * rem * This set of programs will run on a Personal Computer with Windows rem * and Micro Focus Net Express. rem * ******************************************************************** rem * Step 1 of 4, Set the global environment variables... rem * call ..\Env1BASE %CmdName% if "%SYSLOG%" == "" set syslog=c:\SimoLIBR\LOGS\SimoTime.LOG set CmdName=CblAltE3 rem * call SimoNOTE "*******************************************************%CmdName%" call SimoNOTE "Starting CmdName %CmdName%" set ALTKSD=%BaseLib1%\DATA\Wrk1\ALTKSD.DAT rem * ******************************************************************** rem * Step 2 of 4, Report by Telephone number sequence rem * set REPORT03=%BaseLib1%\DATA\Wrk1\ALTRPTP1.DAT if exist %REPORT03% erase %REPORT03% rem * run SimoEXEC EXEC CBLALTC3 PIX0 if not "%errorlevel%" == "0" set JobStatus=0020 if not "%JobStatus%" == "0000" goto :EojNOK if exist %REPORT03% ( call SimoNOTE "* %CmdName% The Following was created in Sequence by Prime Index," call SimoNOTE "* %CmdName% %REPORT03%") rem * ******************************************************************** rem * Step 3 of 4, Report by Telephone number sequence rem * set REPORT03=%BaseLib1%\DATA\Wrk1\ALTRPTP2.DAT if exist %REPORT03% erase %REPORT03% rem * run SimoEXEC EXEC CBLALTC3 AIX1 if not "%errorlevel%" == "0" set JobStatus=0030 if not "%JobStatus%" == "0000" goto :EojNOK if exist %REPORT03% ( call SimoNOTE "* %CmdName% The Following was created in Sequence by Alternate Index," call SimoNOTE "* %CmdName% %REPORT03%") rem * ******************************************************************** rem * Step 4 of 4, End-of-Job processing rem * :EojAOK call SimoNOTE "Finished CmdName %CmdName%, Job Status is %JobStatus%" goto :End :EojNOK call SimoNOTE "ABENDING CmdName %CmdName%, Job Status is %JobStatus%" echo %DATE% - %TIME% Starting User ABEND Processing...>>%SYSLOG% set >>%SYSLOG% echo %DATE% - %TIME% Complete User ABEND Processing...>>%SYSLOG% goto :End :End call SimoNOTE "Conclude SysOut is %SYSOUT%" if not "%1" == "nopause" pause exit /B %JobStatus%
The following (CBLALTE0.cmd) is a sample of the Windows CMD file that will delete the Keyed-Indexed file. This procedure will also log information to a SYSLOG file.
CAUTION!!! This will delete the Keyed-Indexed file. This includes the data, primary index and alternate index. Also, the work files and other output files created by this suite of programs will be deleted
@echo OFF rem * ******************************************************************* rem * CBLALTE0.CMD - a Windows Command File * rem * This program is provided by SimoTime Technologies * rem * (C) Copyright 1987-2019 All Rights Reserved * rem * Web Site URL: http://www.simotime.com * rem * e-mail: helpdesk@simotime.com * rem * ******************************************************************* rem * rem * Text - Delete the Index file with an alternate index. rem * Author - SimoTime Technologies rem * Date - November 11, 2003 rem * Version - 04.03.12 rem * rem * ******************************************************************** rem * Step 1 of 2 Set the global environment variables, rem * Delete any previously created file... rem * call ..\Env1BASE %CmdName% if "%SYSLOG%" == "" set syslog=c:\SimoLIBR\LOGS\SimoTime.LOG set JobName=CBLALTE0 rem * call SimoNOTE "*******************************************************%JobName%" call SimoNOTE "Starting JobName %JobName%, User is %USERNAME%" rem * rem * ******************************************************************** rem * Step 2 of 3, Add new or update existing records in the indexed file. rem * call SimoNOTE "InfoNote JobName %JobName%, Delete the VSAM, KSDS Cluster" set ALTKSD=%BaseLib1%\DATA\Wrk1\ALTKSD.DAT if exist %ALTKSD% erase %ALTKSD% if exist %ALTKSD% set JobStatus=0020 if not "%JobStatus%" == "0000" goto :EojNok rem * rem * ******************************************************************** rem * Step 3 of 3, Add new or update existing records in the indexed file. rem * call SimoNOTE "InfoNote JobName %JobName%, Delete the Work Files" set ALTQSMD1=C:\SimoNXE4\AN01\DATA\Txt1\ALTQSMD1.TXT set ALTQSMD2=C:\SimoNXE4\AN01\DATA\Txt1\ALTQSMD2.TXT set ALTQSMD3=C:\SimoNXE4\AN01\DATA\Wrk1\ALTQSMD3.TXT if exist %ALTQSMD1% erase %ALTQSMD1% if exist %ALTQSMD1% set JobStatus=0031 if not "%JobStatus%" == "0000" goto :EojNok if exist %ALTQSMD2% erase %ALTQSMD2% if exist %ALTQSMD2% set JobStatus=0032 if not "%JobStatus%" == "0000" goto :EojNok if exist %ALTQSMD3% erase %ALTQSMD3% if exist %ALTQSMD3% set JobStatus=0033 if not "%JobStatus%" == "0000" goto :EojNok rem * ******************************************************************** rem * Step 4 of 3, End-of-Job... rem * :EojAok call SimoNOTE "Finished JobName %JobName%, Job Status is %JobStatus%" goto :End :EojNok type %SYSOUT% call SimoNOTE "ABENDING JobName %JobName%, Job Status is %JobStatus%" :End call SimoNOTE "Conclude SysLog is %SYSLOG%" if not "%1" == "nopause" pause
The example has a number of COBOL programs that perform the various steps to create, load and access a VSAM, Keyed Sequential Data Set with a primary key and an alternate index. The COBOL programs may execute on an IBM Mainframe with z/OS or a Wintel System with Micro Focus Mainframe Express. The following sections include the source listings and a brief description of the programs.
The following (CBLALTC9.cbl) is a sample of the COBOL program that will read the sorted sequential file and write the records to the VSAM, KSDS. This program does a sequential read of the QSAM file and a Sequential write to the VSAM, KSDS. This program expects the VSAM, KSDS to be empty. The sequential writing of records (i.e. ordered load) is usually faster than a random read and update or add records. Since this is a sequential process the records must be in sequence according to the primary key. This program does not expect the alternate index to be defined for the VSAM, KSDS.
IDENTIFICATION DIVISION. PROGRAM-ID. CBLALTC9. AUTHOR. SIMOTIME TECHNOLOGIES. ***************************************************************** * This program was generated by SimoZAPS * * A product of SimoTime Technologies * * Our e-mail address is: helpdesk@simotime.com * * Also, visit our Web Site at http://www.simotime.com * * * * Generation Date: 2005-06-29 Generation Time: 22:51:28:17 * * * * Record Record Key * * Function Name Organization Format Max-Min Pos-Len * * INPUT ALTQSMD2 SEQUENTIAL FIXED 00080 * * * * OUTPUT ALTKSD INDEXED VARIABLE 00512 00001 * * 00012 * * * ***************************************************************** ENVIRONMENT DIVISION. INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT ALTQSMD2-FILE ASSIGN TO ALTQSMD2 ORGANIZATION IS SEQUENTIAL ACCESS MODE IS SEQUENTIAL FILE STATUS IS ALTQSMD2-STATUS. SELECT ALTKSD-FILE ASSIGN TO ALTKSD ORGANIZATION IS INDEXED ACCESS MODE IS SEQUENTIAL RECORD KEY IS ALTKSD-KEY-01 FILE STATUS IS ALTKSD-STATUS. ***************************************************************** DATA DIVISION. FILE SECTION. FD ALTQSMD2-FILE DATA RECORD IS ALTQSMD2-REC . 01 ALTQSMD2-REC. 05 ALTQSMD2-DATA-01 PIC X(00080). FD ALTKSD-FILE DATA RECORD IS ALTKSD-REC . 01 ALTKSD-REC. 05 ALTKSD-KEY-01 PIC X(00012). 05 ALTKSD-DATA-01 PIC X(00500). ***************************************************************** * This program was created using the SYSMASK3.TXT file as the * * template for the File I/O. It is intended for use with the * * TransCALL facility that makes a call to a routine that does * * the actual conversion between EBCDIC and ASCII. For more * * information or questions contact SimoTime Technologies. * * * * Our e-mail address is: helpdesk@simotime.com * * Also, visit our Web Site at http://www.simotime.com * * * * The SYSMASK3 provides for the sequential reading of the input * * file and the sequential writing of the output file. * * If the output file is indexed then the input file must be in * * sequence by the field that will be used to provide the key * * for the output file. * * * * If the key field is not in sequence then refer to SYSMASK4 * * to provide for a random add or update of the indexed file. * ***************************************************************** WORKING-STORAGE SECTION. 01 SIM-TITLE. 05 T1 pic X(11) value '* CBLALTC9 '. 05 T2 pic X(34) value 'Data Migration and Conversion '. 05 T3 pic X(10) value 'v05.06.08 '. 05 T4 pic X(24) value ' http://www.simotime.com'. 01 SIM-COPYRIGHT. 05 C1 pic X(11) value '* CBLALTC9 '. 05 C2 pic X(20) value 'Created by SimoZAPS,'. 05 C3 pic X(20) value ' a utility package '. 05 C4 pic X(28) value 'of SimoTime Technologies '. 01 ALTQSMD2-STATUS. 05 ALTQSMD2-STATUS-L pic X. 05 ALTQSMD2-STATUS-R pic X. 01 ALTQSMD2-EOF pic X value 'N'. 01 ALTQSMD2-OPEN-FLAG pic X value 'C'. 01 ALTKSD-STATUS. 05 ALTKSD-STATUS-L pic X. 05 ALTKSD-STATUS-R pic X. 01 ALTKSD-EOF pic X value 'N'. 01 ALTKSD-OPEN-FLAG pic X value 'C'. ***************************************************************** * The following buffers are used to create a four-byte status * * code that may be displayed. * ***************************************************************** 01 IO-STATUS. 05 IO-STAT1 pic X. 05 IO-STAT2 pic X. 01 IO-STATUS-04. 05 IO-STATUS-0401 pic 9 value 0. 05 IO-STATUS-0403 pic 999 value 0. 01 TWO-BYTES-BINARY pic 9(4) BINARY. 01 TWO-BYTES-ALPHA redefines TWO-BYTES-BINARY. 05 TWO-BYTES-LEFT pic X. 05 TWO-BYTES-RIGHT pic X. ***************************************************************** * Message Buffer used by the Z-DISPLAY-MESSAGE-TEXT routine. * ***************************************************************** 01 MESSAGE-BUFFER. 05 MESSAGE-HEADER pic X(11) value '* CBLALTC9 '. 05 MESSAGE-TEXT. 10 MESSAGE-TEXT-1 pic X(68) value SPACES. 10 MESSAGE-TEXT-2 pic X(188) value SPACES. ***************************************************************** 01 PROGRAM-NAME pic X(8) value 'CBLALTC9'. 01 APPL-RESULT pic S9(9) comp. 88 APPL-AOK value 0. 88 APPL-EOF value 16. 01 ALTQSMD2-TOTAL. 05 ALTQSMD2-RDR pic 9(9) value 0. 05 filler pic X(3) value ' - '. 05 filler pic X(23) value 'Line count for ALTQSMD2'. 01 ALTKSD-TOTAL. 05 ALTKSD-ADD pic 9(9) value 0. 05 filler pic X(3) value ' - '. 05 filler pic X(23) value 'Line count for ALTKSD '. ***************************************************************** PROCEDURE DIVISION. perform Z-POST-COPYRIGHT perform ALTQSMD2-OPEN perform ALTKSD-OPEN perform until ALTQSMD2-STATUS not = '00' perform ALTQSMD2-READ if ALTQSMD2-STATUS = '00' add 1 to ALTQSMD2-RDR perform BUILD-OUTPUT-RECORD perform ALTKSD-WRITE if ALTKSD-STATUS = '00' add 1 to ALTKSD-ADD end-if end-if end-perform move ALTQSMD2-TOTAL to MESSAGE-TEXT perform Z-DISPLAY-MESSAGE-TEXT move ALTKSD-TOTAL to MESSAGE-TEXT perform Z-DISPLAY-MESSAGE-TEXT if APPL-EOF move 'is Complete...' to MESSAGE-TEXT else move 'is ABENDING...' to MESSAGE-TEXT end-if perform Z-DISPLAY-MESSAGE-TEXT perform ALTKSD-CLOSE perform ALTQSMD2-CLOSE GOBACK. ***************************************************************** BUILD-OUTPUT-RECORD. *> TransMODE is &&&... *> TransCOPY... move ALTQSMD2-REC(00001:00080) to ALTKSD-REC(00001:00080) exit. ***************************************************************** * I/O Routines for the INPUT File... * ***************************************************************** ALTQSMD2-CLOSE. add 8 to ZERO giving APPL-RESULT. close ALTQSMD2-FILE if ALTQSMD2-STATUS = '00' subtract APPL-RESULT from APPL-RESULT else add 12 to ZERO giving APPL-RESULT end-if if APPL-AOK CONTINUE else move 'CLOSE Failure with ALTQSMD2' to MESSAGE-TEXT perform Z-DISPLAY-MESSAGE-TEXT move ALTQSMD2-STATUS to IO-STATUS perform Z-DISPLAY-IO-STATUS perform Z-ABEND-PROGRAM end-if exit. *---------------------------------------------------------------* ALTQSMD2-READ. read ALTQSMD2-FILE if ALTQSMD2-STATUS = '00' subtract APPL-RESULT from APPL-RESULT else if ALTQSMD2-STATUS = '10' add 16 to ZERO giving APPL-RESULT else add 12 to ZERO giving APPL-RESULT end-if end-if if APPL-AOK CONTINUE else if APPL-EOF move 'Y' to ALTQSMD2-EOF else move 'READ Failure with ALTQSMD2' to MESSAGE-TEXT perform Z-DISPLAY-MESSAGE-TEXT move ALTQSMD2-STATUS to IO-STATUS perform Z-DISPLAY-IO-STATUS perform Z-ABEND-PROGRAM end-if end-if exit. *---------------------------------------------------------------* ALTQSMD2-OPEN. add 8 to ZERO giving APPL-RESULT. open input ALTQSMD2-FILE if ALTQSMD2-STATUS = '00' subtract APPL-RESULT from APPL-RESULT move 'O' to ALTQSMD2-OPEN-FLAG else add 12 to ZERO giving APPL-RESULT end-if if APPL-AOK CONTINUE else move 'OPEN Failure with ALTQSMD2' to MESSAGE-TEXT perform Z-DISPLAY-MESSAGE-TEXT move ALTQSMD2-STATUS to IO-STATUS perform Z-DISPLAY-IO-STATUS perform Z-ABEND-PROGRAM end-if exit. ***************************************************************** * I/O Routines for the OUTPUT File... * ***************************************************************** ALTKSD-WRITE. if ALTKSD-OPEN-FLAG = 'C' perform ALTKSD-OPEN end-if write ALTKSD-REC if ALTKSD-STATUS = '00' subtract APPL-RESULT from APPL-RESULT else if ALTKSD-STATUS = '10' add 16 to ZERO giving APPL-RESULT else add 12 to ZERO giving APPL-RESULT end-if end-if. if APPL-AOK CONTINUE else move 'WRITE Failure with ALTKSD ' to MESSAGE-TEXT perform Z-DISPLAY-MESSAGE-TEXT move ALTKSD-STATUS to IO-STATUS perform Z-DISPLAY-IO-STATUS perform Z-ABEND-PROGRAM end-if exit. *---------------------------------------------------------------* ALTKSD-OPEN. add 8 to ZERO giving APPL-RESULT. open OUTPUT ALTKSD-FILE if ALTKSD-STATUS = '00' subtract APPL-RESULT from APPL-RESULT move 'O' to ALTKSD-OPEN-FLAG else add 12 to ZERO giving APPL-RESULT end-if if APPL-AOK CONTINUE else move 'OPEN Failure with ALTKSD ' to MESSAGE-TEXT perform Z-DISPLAY-MESSAGE-TEXT move ALTKSD-STATUS to IO-STATUS perform Z-DISPLAY-IO-STATUS perform Z-ABEND-PROGRAM end-if exit. *---------------------------------------------------------------* ALTKSD-CLOSE. add 8 to ZERO giving APPL-RESULT. close ALTKSD-FILE if ALTKSD-STATUS = '00' subtract APPL-RESULT from APPL-RESULT move 'C' to ALTKSD-OPEN-FLAG else add 12 to ZERO giving APPL-RESULT end-if if APPL-AOK CONTINUE else move 'CLOSE Failure with ALTKSD ' to MESSAGE-TEXT perform Z-DISPLAY-MESSAGE-TEXT move ALTKSD-STATUS to IO-STATUS perform Z-DISPLAY-IO-STATUS perform Z-ABEND-PROGRAM end-if exit. ***************************************************************** * The following Z-ROUTINES provide administrative functions * * for this program. * ***************************************************************** * ABEND the program, post a message to the console and issue * * a STOP RUN. * ***************************************************************** Z-ABEND-PROGRAM. if MESSAGE-TEXT not = SPACES perform Z-DISPLAY-MESSAGE-TEXT end-if move 'PROGRAM-IS-ABENDING...' to MESSAGE-TEXT perform Z-DISPLAY-MESSAGE-TEXT add 12 to ZERO giving RETURN-CODE STOP RUN. * exit. ***************************************************************** * Display CONSOLE messages... * ***************************************************************** Z-DISPLAY-MESSAGE-TEXT. if MESSAGE-TEXT-2 = SPACES display MESSAGE-BUFFER(1:79) else display MESSAGE-BUFFER end-if move all SPACES to MESSAGE-TEXT exit. ***************************************************************** * Display the file status bytes. This routine will display as * * four digits. If the full two byte file status is numeric it * * will display as 00nn. If the 1st byte is a numeric nine (9) * * the second byte will be treated as a binary number and will * * display as 9nnn. * ***************************************************************** Z-DISPLAY-IO-STATUS. if IO-STATUS not NUMERIC or IO-STAT1 = '9' move IO-STAT1 to IO-STATUS-04(1:1) subtract TWO-BYTES-BINARY from TWO-BYTES-BINARY move IO-STAT2 to TWO-BYTES-RIGHT add TWO-BYTES-BINARY to ZERO giving IO-STATUS-0403 move 'File Status is: nnnn' to MESSAGE-TEXT move IO-STATUS-04 to MESSAGE-TEXT(17:4) perform Z-DISPLAY-MESSAGE-TEXT else move '0000' to IO-STATUS-04 move IO-STATUS to IO-STATUS-04(3:2) move 'File Status is: nnnn' to MESSAGE-TEXT move IO-STATUS-04 to MESSAGE-TEXT(17:4) perform Z-DISPLAY-MESSAGE-TEXT end-if exit. ***************************************************************** Z-POST-COPYRIGHT. display SIM-TITLE display SIM-COPYRIGHT exit. ***************************************************************** * This program was generated by SimoZAPS * * A product of SimoTime Technologies * * Our e-mail address is: helpdesk@simotime.com * * Also, visit our Web Site at http://www.simotime.com * * * * Generation Date: 2005-06-29 Generation Time: 22:51:28:18 * *****************************************************************
The following (CBLALTC7.cbl) is a sample of the COBOL program that will read a sequential file and write the records to the VSAM, KSDS. This program will update existing records with a matching key or add the record if a key match is not found. The program will also update the alternate index.
IDENTIFICATION DIVISION. PROGRAM-ID. CBLALTC7. AUTHOR. SIMOTIME TECHNOLOGIES. ***************************************************************** * This program was generated by SimoZAPS * * A product of SimoTime Technologies * * Our e-mail address is: helpdesk@simotime.com * * Also, visit our Web Site at http://www.simotime.com * * * * Generation Date: 2005-06-29 Generation Time: 22:50:04:84 * * * * Record Record Key * * Function Name Organization Format Max-Min Pos-Len * * INPUT ALTQSM SEQUENTIAL FIXED 00080 * * * * OUTPUT ALTKSD INDEXED VARIABLE 00512 00001 * * 00012 * * * ***************************************************************** ENVIRONMENT DIVISION. INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT ALTQSM-FILE ASSIGN TO ALTQSM ORGANIZATION IS SEQUENTIAL ACCESS MODE IS SEQUENTIAL FILE STATUS IS ALTQSM-STATUS. SELECT ALTKSD-FILE ASSIGN TO ALTKSD ORGANIZATION IS INDEXED ACCESS MODE IS RANDOM RECORD KEY IS ALTKSD-KEY-01 ALTERNATE RECORD KEY IS ALTKSD-KEY-02 WITH DUPLICATES FILE STATUS IS ALTKSD-STATUS. ***************************************************************** DATA DIVISION. FILE SECTION. FD ALTQSM-FILE DATA RECORD IS ALTQSM-REC . 01 ALTQSM-REC. 05 ALTQSM-DATA-01 PIC X(00080). FD ALTKSD-FILE DATA RECORD IS ALTKSD-REC . 01 ALTKSD-REC. 05 ALTKSD-KEY-01 PIC X(00012). 05 ALTKSD-DATA-01 PIC X(56). 05 ALTKSD-KEY-02 PIC X(12). 05 ALTKSD-DATA-02 PIC X(432). ***************************************************************** * This program was created using the SYSMASK4.TXT file as the * * template for the File I/O. It is intended for use with the * * TransCALL facility that makes a call to a routine that does * * the actual conversion between EBCDIC and ASCII. For more * * information or questions contact SimoTime Technologies. * * * * Our e-mail address is: helpdesk@simotime.com * * Also, visit our Web Site at http://www.simotime.com * * * * The SYSMASK4 provides for the sequential reading of the input * * file and the random writing of the output file. * * * * If the output file is indexed then the input file does not * * need to be in sequence by the field that will be used to * * provide the key for the output file. * * * * New records will be added and existing records will be * * updated. If duplicate keys are provided from the input file * * then only the information from the last duplicate key record * * of the input file will be reflected in the output file. * ***************************************************************** WORKING-STORAGE SECTION. 01 SIM-TITLE. 05 T1 pic X(11) value '* CBLALTC7 '. 05 T2 pic X(34) value 'Data Migration and Conversion '. 05 T3 pic X(10) value 'v05.06.30 '. 05 T4 pic X(24) value ' http://www.simotime.com'. 01 SIM-COPYRIGHT. 05 C1 pic X(11) value '* CBLALTC7 '. 05 C2 pic X(20) value 'Created by SimoZAPS,'. 05 C3 pic X(20) value ' a utility package '. 05 C4 pic X(28) value 'of SimoTime Technologies '. 01 ALTQSM-STATUS. 05 ALTQSM-STATUS-L pic X. 05 ALTQSM-STATUS-R pic X. 01 ALTQSM-EOF pic X value 'N'. 01 ALTQSM-OPEN-FLAG pic X value 'C'. 01 ALTQSM-RECORD-FOUND pic X value 'N'. 01 ALTKSD-STATUS. 05 ALTKSD-STATUS-L pic X. 05 ALTKSD-STATUS-R pic X. 01 ALTKSD-EOF pic X value 'N'. 01 ALTKSD-OPEN-FLAG pic X value 'C'. 01 ALTKSD-RECORD-FOUND pic X value 'N'. ***************************************************************** * The following buffers are used to create a four-byte status * * code that may be displayed. * ***************************************************************** 01 IO-STATUS. 05 IO-STAT1 pic X. 05 IO-STAT2 pic X. 01 IO-STATUS-04. 05 IO-STATUS-0401 pic 9 value 0. 05 IO-STATUS-0403 pic 999 value 0. 01 TWO-BYTES-BINARY pic 9(4) BINARY. 01 TWO-BYTES-ALPHA redefines TWO-BYTES-BINARY. 05 TWO-BYTES-LEFT pic X. 05 TWO-BYTES-RIGHT pic X. ***************************************************************** * Message Buffer used by the Z-DISPLAY-MESSAGE-TEXT routine. * ***************************************************************** 01 MESSAGE-BUFFER. 05 MESSAGE-HEADER pic X(11) value '* CBLALTC7 '. 05 MESSAGE-TEXT. 10 MESSAGE-TEXT-1 pic X(68) value SPACES. 10 MESSAGE-TEXT-2 pic X(188) value SPACES. ***************************************************************** 01 APPL-RESULT pic S9(9) comp. 88 APPL-AOK value 0. 88 APPL-EOF value 16. 01 ALTQSM-TOTAL. 05 ALTQSM-RDR pic 9(9) value 0. 05 filler pic X(3) value ' - '. 05 filler pic X(23) value 'Read count for ALTQSM'. 01 ALTKSD-TOTAL-ADDS. 05 ALTKSD-ADD pic 9(9) value 0. 05 filler pic X(3) value ' - '. 05 filler pic X(17) value 'Adds for ALTKSD'. 01 ALTKSD-TOTAL-UPDATES. 05 ALTKSD-UPD pic 9(9) value 0. 05 filler pic X(3) value ' - '. 05 filler pic X(20) value 'Updates for ALTKSD'. ***************************************************************** PROCEDURE DIVISION. perform Z-POST-COPYRIGHT perform ALTQSM-OPEN perform ALTKSD-OPEN move SPACES to ALTQSM-REC move SPACES to ALTKSD-REC perform UNTIL ALTQSM-EOF = 'Y' if ALTQSM-EOF = 'N' perform ALTQSM-READ if ALTQSM-EOF = 'N' add 1 to ALTQSM-RDR perform BUILD-OUTPUT-RECORD perform ALTKSD-READ perform BUILD-OUTPUT-RECORD if ALTKSD-RECORD-FOUND = 'Y' add 1 to ALTKSD-UPD perform ALTKSD-REWRITE else add 1 to ALTKSD-ADD perform ALTKSD-WRITE end-if end-if end-if end-perform. move ALTQSM-TOTAL to MESSAGE-TEXT perform Z-DISPLAY-MESSAGE-TEXT move ALTKSD-TOTAL-ADDS to MESSAGE-TEXT perform Z-DISPLAY-MESSAGE-TEXT move ALTKSD-TOTAL-UPDATES to MESSAGE-TEXT perform Z-DISPLAY-MESSAGE-TEXT if APPL-EOF move 'is Complete...' to MESSAGE-TEXT else move 'is ABENDING...' to MESSAGE-TEXT end-if perform Z-DISPLAY-MESSAGE-TEXT perform ALTKSD-CLOSE perform ALTQSM-CLOSE GOBACK. ***************************************************************** BUILD-OUTPUT-RECORD. move ALTQSM-REC(00001:00080) to ALTKSD-REC(00001:00080) exit. ***************************************************************** * I/O Routines for the INPUT File... * ***************************************************************** ALTQSM-CLOSE. add 8 to ZERO giving APPL-RESULT. close ALTQSM-FILE if ALTQSM-STATUS = '00' subtract APPL-RESULT from APPL-RESULT else add 12 to ZERO giving APPL-RESULT end-if if APPL-AOK CONTINUE else move 'CLOSE Failure with ALTQSM' to MESSAGE-TEXT perform Z-DISPLAY-MESSAGE-TEXT move ALTQSM-STATUS to IO-STATUS perform Z-DISPLAY-IO-STATUS perform Z-ABEND-PROGRAM end-if exit. *---------------------------------------------------------------* ALTQSM-READ. read ALTQSM-FILE if ALTQSM-STATUS = '00' subtract APPL-RESULT from APPL-RESULT else if ALTQSM-STATUS = '10' add 16 to ZERO giving APPL-RESULT else add 12 to ZERO giving APPL-RESULT end-if end-if if APPL-AOK CONTINUE else if APPL-EOF move 'Y' to ALTQSM-EOF else move 'READ Failure with ALTQSM' to MESSAGE-TEXT perform Z-DISPLAY-MESSAGE-TEXT move ALTQSM-STATUS to IO-STATUS perform Z-DISPLAY-IO-STATUS perform Z-ABEND-PROGRAM end-if end-if exit. *---------------------------------------------------------------* ALTQSM-OPEN. add 8 to ZERO giving APPL-RESULT. open input ALTQSM-FILE if ALTQSM-STATUS = '00' subtract APPL-RESULT from APPL-RESULT move 'O' to ALTQSM-OPEN-FLAG else add 12 to ZERO giving APPL-RESULT end-if if APPL-AOK CONTINUE else move 'OPEN Failure with ALTQSM' to MESSAGE-TEXT perform Z-DISPLAY-MESSAGE-TEXT move ALTQSM-STATUS to IO-STATUS perform Z-DISPLAY-IO-STATUS perform Z-ABEND-PROGRAM end-if exit. ***************************************************************** * I/O Routines for the OUTPUT File... * ***************************************************************** ALTKSD-WRITE. if ALTKSD-OPEN-FLAG = 'C' perform ALTKSD-OPEN end-if write ALTKSD-REC if ALTKSD-STATUS = '00' subtract APPL-RESULT from APPL-RESULT else if ALTKSD-STATUS = '10' add 16 to ZERO giving APPL-RESULT else add 12 to ZERO giving APPL-RESULT end-if end-if. if APPL-AOK CONTINUE else move 'WRITE Failure with ALTKSD' to MESSAGE-TEXT perform Z-DISPLAY-MESSAGE-TEXT move ALTKSD-STATUS to IO-STATUS perform Z-DISPLAY-IO-STATUS perform Z-ABEND-PROGRAM end-if exit. *---------------------------------------------------------------* ALTKSD-REWRITE. if ALTKSD-OPEN-FLAG = 'C' perform ALTKSD-OPEN end-if rewrite ALTKSD-REC if ALTKSD-STATUS = '00' subtract APPL-RESULT from APPL-RESULT else if ALTKSD-STATUS = '10' add 16 to ZERO giving APPL-RESULT else add 12 to ZERO giving APPL-RESULT end-if end-if. if APPL-AOK CONTINUE else move 'REWRITE Failure with ALTKSD' to MESSAGE-TEXT perform Z-DISPLAY-MESSAGE-TEXT move ALTKSD-STATUS to IO-STATUS perform Z-DISPLAY-IO-STATUS perform Z-ABEND-PROGRAM end-if exit. *---------------------------------------------------------------* ALTKSD-OPEN. add 8 to ZERO giving APPL-RESULT. open I-O ALTKSD-FILE if ALTKSD-STATUS = '00' subtract APPL-RESULT from APPL-RESULT move 'O' to ALTKSD-OPEN-FLAG else add 12 to ZERO giving APPL-RESULT end-if if APPL-AOK CONTINUE else move 'OPEN Failure with ALTKSD' to MESSAGE-TEXT perform Z-DISPLAY-MESSAGE-TEXT move ALTKSD-STATUS to IO-STATUS perform Z-DISPLAY-IO-STATUS perform Z-ABEND-PROGRAM end-if exit. *---------------------------------------------------------------* ALTKSD-READ. move 'N' to ALTKSD-RECORD-FOUND move 'N' to ALTKSD-EOF add 12 to ZERO giving APPL-RESULT read ALTKSD-FILE evaluate ALTKSD-STATUS when '00' move 'Y' to ALTKSD-RECORD-FOUND subtract APPL-RESULT from APPL-RESULT when '23' move 'N' to ALTKSD-RECORD-FOUND subtract APPL-RESULT from APPL-RESULT when '10' move 'N' to ALTKSD-RECORD-FOUND move 'Y' to ALTKSD-EOF subtract APPL-RESULT from APPL-RESULT end-evaluate. if APPL-AOK CONTINUE else move 'READ Failure with ALTKSD' to MESSAGE-TEXT perform Z-DISPLAY-MESSAGE-TEXT move ALTKSD-STATUS to IO-STATUS perform Z-DISPLAY-IO-STATUS perform Z-ABEND-PROGRAM end-if exit. *---------------------------------------------------------------* ALTKSD-CLOSE. add 8 to ZERO giving APPL-RESULT. close ALTKSD-FILE if ALTKSD-STATUS = '00' subtract APPL-RESULT from APPL-RESULT move 'C' to ALTKSD-OPEN-FLAG else add 12 to ZERO giving APPL-RESULT end-if if APPL-AOK CONTINUE else move 'CLOSE Failure with ALTKSD' to MESSAGE-TEXT perform Z-DISPLAY-MESSAGE-TEXT move ALTKSD-STATUS to IO-STATUS perform Z-DISPLAY-IO-STATUS perform Z-ABEND-PROGRAM end-if exit. ***************************************************************** * The following Z-ROUTINES provide administrative functions * * for this program. * ***************************************************************** * ABEND the program, post a message to the console and issue * * a STOP RUN. * ***************************************************************** Z-ABEND-PROGRAM. if MESSAGE-TEXT not = SPACES perform Z-DISPLAY-MESSAGE-TEXT end-if move 'PROGRAM-IS-ABENDING...' to MESSAGE-TEXT perform Z-DISPLAY-MESSAGE-TEXT add 12 to ZERO giving RETURN-CODE STOP RUN. * exit. ***************************************************************** * Display CONSOLE messages... * ***************************************************************** Z-DISPLAY-MESSAGE-TEXT. if MESSAGE-TEXT-2 = SPACES display MESSAGE-BUFFER(1:79) else display MESSAGE-BUFFER end-if move all SPACES to MESSAGE-TEXT exit. ***************************************************************** * Display the file status bytes. This routine will display as * * four digits. If the full two byte file status is numeric it * * will display as 00nn. If the 1st byte is a numeric nine (9) * * the second byte will be treated as a binary number and will * * display as 9nnn. * ***************************************************************** Z-DISPLAY-IO-STATUS. if IO-STATUS not NUMERIC or IO-STAT1 = '9' move IO-STAT1 to IO-STATUS-04(1:1) subtract TWO-BYTES-BINARY from TWO-BYTES-BINARY move IO-STAT2 to TWO-BYTES-RIGHT add TWO-BYTES-BINARY to ZERO giving IO-STATUS-0403 move 'File Status is: nnnn' to MESSAGE-TEXT move IO-STATUS-04 to MESSAGE-TEXT(17:4) perform Z-DISPLAY-MESSAGE-TEXT else move '0000' to IO-STATUS-04 move IO-STATUS to IO-STATUS-04(3:2) move 'File Status is: nnnn' to MESSAGE-TEXT move IO-STATUS-04 to MESSAGE-TEXT(17:4) perform Z-DISPLAY-MESSAGE-TEXT end-if exit. ***************************************************************** Z-POST-COPYRIGHT. display SIM-TITLE display SIM-COPYRIGHT exit. ***************************************************************** * This program was generated by SimoZAPS * * A product of SimoTime Technologies * * Our e-mail address is: helpdesk@simotime.com * * Also, visit our Web Site at http://www.simotime.com * * * * Generation Date: 2005-06-29 Generation Time: 22:50:04:85 * *****************************************************************
The section describes various approaches to sequentially processing the VSAM data set using the primary or alternate index. The following COBOL programs will access the file sequentially by the primary or alternate keys and print reports.
The following (CBLALTC1.cbl) is a sample of a COBOL program that will read a VSAM, KSDS sequentially by the primary key and write a report that is sequenced by customer number.
IDENTIFICATION DIVISION. PROGRAM-ID. CBLALTC1. AUTHOR. SIMOTIME TECHNOLOGIES. ***************************************************************** * This program was generated by SimoZAPS * * A product of SimoTime Technologies * * Our e-mail address is: helpdesk@simotime.com * * Also, visit our Web Site at http://www.simotime.com * * * * Generation Date: 2005-06-23 Generation Time: 19:40:56:69 * * * * Record Record Key * * Function Name Organization Format Max-Min Pos-Len * * INPUT ALTKSD INDEXED VARIABLE 00512 00001 * * 00012 * * * ***************************************************************** ENVIRONMENT DIVISION. INPUT-OUTPUT SECTION. FILE-CONTROL. * * When processing using the Primary Index the following two * DD statements are required. * * //ALTKSD DD DSN=SIMOTIME.DATA.ALTKSD,DISP=SHR * //ALTKSD1 DD DSN=SIMOTIME.DATA.ALTKSD,DISP=SHR * * The first DD statement points to the VSAM cluster and the * second DD statement causes the primary index within the * cluster to be used for processing. * SELECT ALTKSD-FILE ASSIGN TO ALTKSD ORGANIZATION IS INDEXED ACCESS MODE IS SEQUENTIAL RECORD KEY IS ALTKSD-KEY-01 ALTERNATE RECORD KEY IS ALTKSD-KEY-02 WITH DUPLICATES FILE STATUS IS ALTKSD-STATUS. SELECT PRINT-FILE ASSIGN TO REPORT01. ***************************************************************** DATA DIVISION. FILE SECTION. FD ALTKSD-FILE DATA RECORD IS ALTKSD-REC . 01 ALTKSD-REC. 05 ALTKSD-KEY-01 PIC X(12). 05 ALTKSD-DATA-01 PIC X(56). 05 ALTKSD-KEY-02 PIC X(12). 05 ALTKSD-DATA-02 PIC X(432). FD PRINT-FILE. 01 PRINT-LINE PIC X(132). ***************************************************************** * This program was created using the SYSMASK3.TXT file as the * * template for the File I/O. It is intended for use with the * * TransCALL facility that makes a call to a routine that does * * the actual conversion between EBCDIC and ASCII. For more * * information or questions contact SimoTime Technologies. * * * * Our e-mail address is: helpdesk@simotime.com * * Also, visit our Web Site at http://www.simotime.com * * * * The SYSMASK3 provides for the sequential reading of the input * * file and the sequential writing of the output file. * * If the output file is indexed then the input file must be in * * sequence by the field that will be used to provide the key * * for the output file. * * * * If the key field is not in sequence then refer to SYSMASK4 * * to provide for a random add or update of the indexed file. * ***************************************************************** WORKING-STORAGE SECTION. 01 SIM-TITLE. 05 T1 pic X(11) value '* CBLALTC1 '. 05 T2 pic X(34) value 'Read KSDS by Primary Key & Print '. 05 T3 pic X(10) value 'v05.06.08 '. 05 T4 pic X(24) value ' http://www.simotime.com'. 01 SIM-COPYRIGHT. 05 C1 pic X(11) value '* CBLALTC1 '. 05 C2 pic X(20) value 'Copyright 1987-2019 '. 05 C3 pic X(28) value ' SimoTime Technologies '. 05 C4 pic X(20) value ' All Rights Reserved'. 01 SIM-THANKS-01. 05 C1 pic X(11) value '* CBLALTC1 '. 05 C2 pic X(32) value 'Thank you for using this program'. 05 C3 pic X(32) value ' provided from SimoTime Technolo'. 05 C4 pic X(04) value 'gies'. 01 SIM-THANKS-02. 05 C1 pic X(11) value '* CBLALTC1 '. 05 C2 pic X(32) value 'Please send all inquires or sugg'. 05 C3 pic X(32) value 'estions to the helpdesk@simotime'. 05 C4 pic X(04) value '.com'. 01 ALTKSD-STATUS. 05 ALTKSD-STATUS-L pic X. 05 ALTKSD-STATUS-R pic X. 01 ALTKSD-EOF pic X value 'N'. 01 ALTKSD-OPEN-FLAG pic X value 'C'. ***************************************************************** * The following buffers are used to create a four-byte status * * code that may be displayed. * ***************************************************************** 01 IO-STATUS. 05 IO-STAT1 pic X. 05 IO-STAT2 pic X. 01 IO-STATUS-04. 05 IO-STATUS-0401 pic 9 value 0. 05 IO-STATUS-0403 pic 999 value 0. 01 TWO-BYTES-BINARY pic 9(4) BINARY. 01 TWO-BYTES-ALPHA redefines TWO-BYTES-BINARY. 05 TWO-BYTES-LEFT pic X. 05 TWO-BYTES-RIGHT pic X. ***************************************************************** * Message Buffer used by the Z-DISPLAY-MESSAGE-TEXT routine. * ***************************************************************** 01 MESSAGE-BUFFER. 05 MESSAGE-HEADER pic X(11) value '* CBLALTC1 '. 05 MESSAGE-TEXT. 10 MESSAGE-TEXT-1 pic X(68) value SPACES. 10 MESSAGE-TEXT-2 pic X(188) value SPACES. ***************************************************************** 01 PROGRAM-NAME pic X(8) value 'CBLALTC1'. 01 HEADER-LINE. 05 filler pic X(10) value '....:....1'. 05 filler pic X(10) value '....:....2'. 05 filler pic X(10) value '....:....3'. 05 filler pic X(10) value '....:....4'. 05 filler pic X(10) value '....:....5'. 05 filler pic X(10) value '....:....6'. 05 filler pic X(10) value '....:....7'. 05 filler pic X(10) value '....:....8'. 01 APPL-RESULT pic S9(9) comp. 88 APPL-AOK value 0. 88 APPL-EOF value 16. 01 ALTKSD-TOTAL. 05 ALTKSD-CTR pic 9(9) value 0. 05 filler pic X(3) value ' - '. 05 filler pic X(23) value 'Line count for ALTKSD'. ***************************************************************** PROCEDURE DIVISION. perform Z-POST-COPYRIGHT OPEN OUTPUT PRINT-FILE perform ALTKSD-OPEN perform PRINT-HEADER perform until ALTKSD-STATUS > '02' perform ALTKSD-READ if ALTKSD-STATUS = '00' or ALTKSD-STATUS = '02' add 1 to ALTKSD-CTR WRITE PRINT-LINE FROM ALTKSD-REC AFTER ADVANCING 1 LINE end-if end-perform move ALTKSD-TOTAL to MESSAGE-TEXT perform Z-DISPLAY-MESSAGE-TEXT if APPL-EOF move 'is Complete...' to MESSAGE-TEXT else move 'is ABENDING...' to MESSAGE-TEXT end-if perform Z-DISPLAY-MESSAGE-TEXT perform PRINT-FOOTER perform ALTKSD-CLOSE CLOSE PRINT-FILE perform Z-THANK-YOU GOBACK. ***************************************************************** PRINT-HEADER. move SPACES TO PRINT-LINE. write PRINT-LINE after advancing page move SIM-TITLE TO PRINT-LINE. write PRINT-LINE after advancing page move SIM-COPYRIGHT TO PRINT-LINE. write PRINT-LINE after advancing page move HEADER-LINE TO PRINT-LINE. write PRINT-LINE after advancing page exit. ***************************************************************** PRINT-FOOTER. move SPACES TO PRINT-LINE. write PRINT-LINE after advancing page move SIM-THANKS-01 TO PRINT-LINE. write PRINT-LINE after advancing page move SIM-THANKS-02 TO PRINT-LINE. write PRINT-LINE after advancing page exit. ***************************************************************** * I/O Routines for the INPUT File... * ***************************************************************** ALTKSD-READ. if ALTKSD-OPEN-FLAG = 'C' perform ALTKSD-OPEN end-if read ALTKSD-FILE if ALTKSD-STATUS = '00' or ALTKSD-STATUS = '02' subtract APPL-RESULT from APPL-RESULT else if ALTKSD-STATUS = '10' add 16 to ZERO giving APPL-RESULT else add 12 to ZERO giving APPL-RESULT end-if end-if. if APPL-AOK or APPL-EOF CONTINUE else move 'READ Failure with ALTKSD' to MESSAGE-TEXT perform Z-DISPLAY-MESSAGE-TEXT move ALTKSD-STATUS to IO-STATUS perform Z-DISPLAY-IO-STATUS perform Z-ABEND-PROGRAM end-if exit. *---------------------------------------------------------------* ALTKSD-OPEN. add 8 to ZERO giving APPL-RESULT. open INPUT ALTKSD-FILE if ALTKSD-STATUS = '00' subtract APPL-RESULT from APPL-RESULT move 'O' to ALTKSD-OPEN-FLAG else add 12 to ZERO giving APPL-RESULT end-if if APPL-AOK CONTINUE else move 'OPEN Failure with ALTKSD' to MESSAGE-TEXT perform Z-DISPLAY-MESSAGE-TEXT move ALTKSD-STATUS to IO-STATUS perform Z-DISPLAY-IO-STATUS perform Z-ABEND-PROGRAM end-if exit. *---------------------------------------------------------------* ALTKSD-CLOSE. add 8 to ZERO giving APPL-RESULT. close ALTKSD-FILE if ALTKSD-STATUS = '00' subtract APPL-RESULT from APPL-RESULT move 'C' to ALTKSD-OPEN-FLAG else add 12 to ZERO giving APPL-RESULT end-if if APPL-AOK CONTINUE else move 'CLOSE Failure with ALTKSD' to MESSAGE-TEXT perform Z-DISPLAY-MESSAGE-TEXT move ALTKSD-STATUS to IO-STATUS perform Z-DISPLAY-IO-STATUS perform Z-ABEND-PROGRAM end-if exit. ***************************************************************** * The following Z-ROUTINES provide administrative functions * * for this program. * ***************************************************************** * ABEND the program, post a message to the console and issue * * a STOP RUN. * ***************************************************************** Z-ABEND-PROGRAM. if MESSAGE-TEXT not = SPACES perform Z-DISPLAY-MESSAGE-TEXT end-if move 'PROGRAM-IS-ABENDING...' to MESSAGE-TEXT perform Z-DISPLAY-MESSAGE-TEXT add 12 to ZERO giving RETURN-CODE STOP RUN. * exit. ***************************************************************** * Display CONSOLE messages... * ***************************************************************** Z-DISPLAY-MESSAGE-TEXT. if MESSAGE-TEXT-2 = SPACES display MESSAGE-BUFFER(1:79) else display MESSAGE-BUFFER end-if move all SPACES to MESSAGE-TEXT exit. ***************************************************************** * Display the file status bytes. This routine will display as * * four digits. If the full two byte file status is numeric it * * will display as 00nn. If the 1st byte is a numeric nine (9) * * the second byte will be treated as a binary number and will * * display as 9nnn. * ***************************************************************** Z-DISPLAY-IO-STATUS. if IO-STATUS not NUMERIC or IO-STAT1 = '9' move IO-STAT1 to IO-STATUS-04(1:1) subtract TWO-BYTES-BINARY from TWO-BYTES-BINARY move IO-STAT2 to TWO-BYTES-RIGHT add TWO-BYTES-BINARY to ZERO giving IO-STATUS-0403 move 'File Status is: nnnn' to MESSAGE-TEXT move IO-STATUS-04 to MESSAGE-TEXT(17:4) perform Z-DISPLAY-MESSAGE-TEXT else move '0000' to IO-STATUS-04 move IO-STATUS to IO-STATUS-04(3:2) move 'File Status is: nnnn' to MESSAGE-TEXT move IO-STATUS-04 to MESSAGE-TEXT(17:4) perform Z-DISPLAY-MESSAGE-TEXT end-if exit. ***************************************************************** Z-POST-COPYRIGHT. display SIM-TITLE upon console display SIM-COPYRIGHT upon console exit. ***************************************************************** Z-THANK-YOU. display SIM-THANKS-01 upon console display SIM-THANKS-02 upon console exit. ***************************************************************** * This program was generated by SimoZAPS * * A product of SimoTime Technologies * * Our e-mail address is: helpdesk@simotime.com * * Also, visit our Web Site at http://www.simotime.com * * * * Generation Date: 2005-06-23 Generation Time: 19:40:56:70 * *****************************************************************
The following (CBLALTC2.cbl) is a sample of a COBOL program that will read a VSAM, KSDS sequentially by the alternate index and write a report that is sequenced by telephone number.
IDENTIFICATION DIVISION. PROGRAM-ID. CBLALTC2. AUTHOR. SIMOTIME TECHNOLOGIES. ***************************************************************** * This program was generated by SimoZAPS * * A product of SimoTime Technologies * * Our e-mail address is: helpdesk@simotime.com * * Also, visit our Web Site at http://www.simotime.com * * * * Generation Date: 2005-06-23 Generation Time: 19:40:56:69 * * * * Record Record Key * * Function Name Organization Format Max-Min Pos-Len * * INPUT ALTKSD INDEXED VARIABLE 00512 00001 * * 00012 * * INPUT ALTKSD1 Alternate-IDX VARIABLE 00512 00069 * * 00012 * * * ***************************************************************** ENVIRONMENT DIVISION. INPUT-OUTPUT SECTION. FILE-CONTROL. * * When processing using the Alternate Index the following two * DD statements are required. * * //ALTKSD DD DSN=SIMOTIME.DATA.ALTKSD,DISP=SHR * //ALTKSD1 DD DSN=SIMOTIME.DATA.ALTKSD.PATH,DISP=SHR * * The first DD statement points to the VSAM cluster and the * second DD statement points to the path that was created * using the BLDINDEX of IDCAMS. * SELECT ALTKSD-FILE ASSIGN TO ALTKSD ORGANIZATION IS INDEXED ACCESS MODE IS SEQUENTIAL RECORD KEY IS ALTKSD-KEY-01 ALTERNATE RECORD KEY IS ALTKSD-KEY-02 WITH DUPLICATES FILE STATUS IS ALTKSD-STATUS. SELECT PRINT-FILE ASSIGN TO REPORT02. ***************************************************************** DATA DIVISION. FILE SECTION. FD ALTKSD-FILE DATA RECORD IS ALTKSD-REC . 01 ALTKSD-REC. 05 ALTKSD-KEY-01 PIC X(12). 05 ALTKSD-DATA-01 PIC X(56). 05 ALTKSD-KEY-02 PIC X(12). 05 ALTKSD-DATA-02 PIC X(432). FD PRINT-FILE. 01 PRINT-LINE PIC X(132). ***************************************************************** * This program was created using the SYSMASK3.TXT file as the * * template for the File I/O. It is intended for use with the * * TransCALL facility that makes a call to a routine that does * * the actual conversion between EBCDIC and ASCII. For more * * information or questions contact SimoTime Technologies. * * * * Our e-mail address is: helpdesk@simotime.com * * Also, visit our Web Site at http://www.simotime.com * * * * The SYSMASK3 provides for the sequential reading of the input * * file and the sequential writing of the output file. * * If the output file is indexed then the input file must be in * * sequence by the field that will be used to provide the key * * for the output file. * * * * If the key field is not in sequence then refer to SYSMASK4 * * to provide for a random add or update of the indexed file. * ***************************************************************** WORKING-STORAGE SECTION. 01 SIM-TITLE. 05 T1 pic X(11) value '* CBLALTC2 '. 05 T2 pic X(34) value 'Read KSDS by Alternate Key & Print'. 05 T3 pic X(10) value ' v05.06.08'. 05 T4 pic X(24) value ' http://www.simotime.com'. 01 SIM-COPYRIGHT. 05 C1 pic X(11) value '* CBLALTC2 '. 05 C2 pic X(20) value 'Copyright 1987-2019 '. 05 C3 pic X(28) value ' SimoTime Technologies '. 05 C4 pic X(20) value ' All Rights Reserved'. 01 SIM-THANKS-01. 05 C1 pic X(11) value '* CBLALTC2 '. 05 C2 pic X(32) value 'Thank you for using this program'. 05 C3 pic X(32) value ' provided from SimoTime Technolo'. 05 C4 pic X(04) value 'gies'. 01 SIM-THANKS-02. 05 C1 pic X(11) value '* CBLALTC2 '. 05 C2 pic X(32) value 'Please send all inquires or sugg'. 05 C3 pic X(32) value 'estions to the helpdesk@simotime'. 05 C4 pic X(04) value '.com'. 01 ALTKSD-STATUS. 05 ALTKSD-STATUS-L pic X. 05 ALTKSD-STATUS-R pic X. 01 ALTKSD-EOF pic X value 'N'. 01 ALTKSD-OPEN-FLAG pic X value 'C'. ***************************************************************** * The following buffers are used to create a four-byte status * * code that may be displayed. * ***************************************************************** 01 IO-STATUS. 05 IO-STAT1 pic X. 05 IO-STAT2 pic X. 01 IO-STATUS-04. 05 IO-STATUS-0401 pic 9 value 0. 05 IO-STATUS-0403 pic 999 value 0. 01 TWO-BYTES-BINARY pic 9(4) BINARY. 01 TWO-BYTES-ALPHA redefines TWO-BYTES-BINARY. 05 TWO-BYTES-LEFT pic X. 05 TWO-BYTES-RIGHT pic X. ***************************************************************** * Message Buffer used by the Z-DISPLAY-MESSAGE-TEXT routine. * ***************************************************************** 01 MESSAGE-BUFFER. 05 MESSAGE-HEADER pic X(11) value '* CBLALTC2 '. 05 MESSAGE-TEXT. 10 MESSAGE-TEXT-1 pic X(68) value SPACES. 10 MESSAGE-TEXT-2 pic X(188) value SPACES. ***************************************************************** 01 PROGRAM-NAME pic X(8) value 'CBLALTC2'. 01 HEADER-LINE. 05 filler pic X(10) value '....:....1'. 05 filler pic X(10) value '....:....2'. 05 filler pic X(10) value '....:....3'. 05 filler pic X(10) value '....:....4'. 05 filler pic X(10) value '....:....5'. 05 filler pic X(10) value '....:....6'. 05 filler pic X(10) value '....:....7'. 05 filler pic X(10) value '....:....8'. 01 APPL-RESULT pic S9(9) comp. 88 APPL-AOK value 0. 88 APPL-EOF value 16. 01 ALTKSD-TOTAL. 05 ALTKSD-CTR pic 9(9) value 0. 05 filler pic X(3) value ' - '. 05 filler pic X(23) value 'Line count for ALTKSD'. ***************************************************************** PROCEDURE DIVISION. perform Z-POST-COPYRIGHT open OUTPUT PRINT-FILE perform ALTKSD-OPEN * * Prepare to use the Alternate Index. On a z/OS system or * with Micro Focus Mainframe Express (MFE) the following * code (START statement) is not required. The DD statements in * the JCL will relate the alternate path to the VSAM cluster * and this will cause the file to be read sequentially by * alternate key. For Micro Focus Net Express the following is * required. * move LOW-VALUES to ALTKSD-KEY-02 start ALTKSD-FILE key greater ALTKSD-KEY-02 if ALTKSD-STATUS not = '00' move 'Error starting alternate index' to MESSAGE-TEXT perform Z-ABEND-PROGRAM end-if * End of Preparation to use alternate index. perform PRINT-HEADER perform until ALTKSD-STATUS > '02' perform ALTKSD-READ if ALTKSD-STATUS = '00' or ALTKSD-STATUS = '02' add 1 to ALTKSD-CTR write PRINT-LINE from ALTKSD-REC after advancing 1 line end-if end-perform move ALTKSD-TOTAL to MESSAGE-TEXT perform Z-DISPLAY-MESSAGE-TEXT if APPL-EOF move 'is Complete...' to MESSAGE-TEXT else move 'is ABENDING...' to MESSAGE-TEXT end-if perform Z-DISPLAY-MESSAGE-TEXT perform PRINT-FOOTER perform ALTKSD-CLOSE close PRINT-FILE perform Z-THANK-YOU GOBACK. ***************************************************************** PRINT-HEADER. move SPACES TO PRINT-LINE. write PRINT-LINE after advancing page move SIM-TITLE TO PRINT-LINE. write PRINT-LINE after advancing page move SIM-COPYRIGHT TO PRINT-LINE. write PRINT-LINE after advancing page move HEADER-LINE TO PRINT-LINE. write PRINT-LINE after advancing page exit. ***************************************************************** PRINT-FOOTER. move SPACES TO PRINT-LINE. write PRINT-LINE after advancing page move SIM-THANKS-01 TO PRINT-LINE. write PRINT-LINE after advancing page move SIM-THANKS-02 TO PRINT-LINE. write PRINT-LINE after advancing page exit. ***************************************************************** * I/O Routines for the INPUT File... * ***************************************************************** ALTKSD-READ. if ALTKSD-OPEN-FLAG = 'C' perform ALTKSD-OPEN end-if read ALTKSD-FILE if ALTKSD-STATUS = '00' or ALTKSD-STATUS = '02' subtract APPL-RESULT from APPL-RESULT else if ALTKSD-STATUS = '10' add 16 to ZERO giving APPL-RESULT else add 12 to ZERO giving APPL-RESULT end-if end-if. if APPL-AOK or APPL-EOF CONTINUE else move 'READ Failure with ALTKSD' to MESSAGE-TEXT perform Z-DISPLAY-MESSAGE-TEXT move ALTKSD-STATUS to IO-STATUS perform Z-DISPLAY-IO-STATUS perform Z-ABEND-PROGRAM end-if exit. *---------------------------------------------------------------* ALTKSD-OPEN. add 8 to ZERO giving APPL-RESULT. open INPUT ALTKSD-FILE if ALTKSD-STATUS = '00' subtract APPL-RESULT from APPL-RESULT move 'O' to ALTKSD-OPEN-FLAG else add 12 to ZERO giving APPL-RESULT end-if if APPL-AOK CONTINUE else move 'OPEN Failure with ALTKSD' to MESSAGE-TEXT perform Z-DISPLAY-MESSAGE-TEXT move ALTKSD-STATUS to IO-STATUS perform Z-DISPLAY-IO-STATUS perform Z-ABEND-PROGRAM end-if exit. *---------------------------------------------------------------* ALTKSD-CLOSE. add 8 to ZERO giving APPL-RESULT. close ALTKSD-FILE if ALTKSD-STATUS = '00' subtract APPL-RESULT from APPL-RESULT move 'C' to ALTKSD-OPEN-FLAG else add 12 to ZERO giving APPL-RESULT end-if if APPL-AOK CONTINUE else move 'CLOSE Failure with ALTKSD' to MESSAGE-TEXT perform Z-DISPLAY-MESSAGE-TEXT move ALTKSD-STATUS to IO-STATUS perform Z-DISPLAY-IO-STATUS perform Z-ABEND-PROGRAM end-if exit. ***************************************************************** * The following Z-ROUTINES provide administrative functions * * for this program. * ***************************************************************** * ABEND the program, post a message to the console and issue * * a STOP RUN. * ***************************************************************** Z-ABEND-PROGRAM. if MESSAGE-TEXT not = SPACES perform Z-DISPLAY-MESSAGE-TEXT end-if move 'PROGRAM-IS-ABENDING...' to MESSAGE-TEXT perform Z-DISPLAY-MESSAGE-TEXT add 12 to ZERO giving RETURN-CODE STOP RUN. * exit. ***************************************************************** * Display CONSOLE messages... * ***************************************************************** Z-DISPLAY-MESSAGE-TEXT. if MESSAGE-TEXT-2 = SPACES display MESSAGE-BUFFER(1:79) upon console else display MESSAGE-BUFFER upon console end-if move all SPACES to MESSAGE-TEXT exit. ***************************************************************** * Display the file status bytes. This routine will display as * * four digits. If the full two byte file status is numeric it * * will display as 00nn. If the 1st byte is a numeric nine (9) * * the second byte will be treated as a binary number and will * * display as 9nnn. * ***************************************************************** Z-DISPLAY-IO-STATUS. if IO-STATUS not NUMERIC or IO-STAT1 = '9' move IO-STAT1 to IO-STATUS-04(1:1) subtract TWO-BYTES-BINARY from TWO-BYTES-BINARY move IO-STAT2 to TWO-BYTES-RIGHT add TWO-BYTES-BINARY to ZERO giving IO-STATUS-0403 move 'File Status is: nnnn' to MESSAGE-TEXT move IO-STATUS-04 to MESSAGE-TEXT(17:4) perform Z-DISPLAY-MESSAGE-TEXT else move '0000' to IO-STATUS-04 move IO-STATUS to IO-STATUS-04(3:2) move 'File Status is: nnnn' to MESSAGE-TEXT move IO-STATUS-04 to MESSAGE-TEXT(17:4) perform Z-DISPLAY-MESSAGE-TEXT end-if exit. ***************************************************************** Z-POST-COPYRIGHT. display SIM-TITLE upon console display SIM-COPYRIGHT upon console exit. ***************************************************************** Z-THANK-YOU. display SIM-THANKS-01 upon console display SIM-THANKS-02 upon console exit. ***************************************************************** * This program was generated by SimoZAPS * * A product of SimoTime Technologies * * Our e-mail address is: helpdesk@simotime.com * * Also, visit our Web Site at http://www.simotime.com * * * * Generation Date: 2005-06-23 Generation Time: 19:40:56:70 * *****************************************************************
The following (CBLALTC3.cbl) is a sample of a COBOL program that will read a VSAM, KSDS sequentially by the primary key or the alternate index and write a report that is sequenced by the customer number or the telephone number. The sequence is controlled by a parameter passed from the JCL member.
IDENTIFICATION DIVISION. PROGRAM-ID. CBLALTC3. AUTHOR. SIMOTIME TECHNOLOGIES. ***************************************************************** * This program was generated by SimoZAPS * * A product of SimoTime Technologies * * Our e-mail address is: helpdesk@simotime.com * * Also, visit our Web Site at http://www.simotime.com * * * * Generation Date: 2005-06-23 Generation Time: 19:40:56:69 * * * * Record Record Key * * Function Name Organization Format Max-Min Pos-Len * * INPUT ALTKSD INDEXED VARIABLE 00512 00001 * * 00012 * * * * Based upon a parameter received from JCL this program will * * read the VSAM, KSDS and produce a report in customer-number * * (i.e. primary key) or telephone-number (i.e. alternate index) * * sequence. * * * ***************************************************************** ENVIRONMENT DIVISION. INPUT-OUTPUT SECTION. FILE-CONTROL. * * When processing using the Primary Index the following two * DD statements are required in the JCL member. * * //ALTKSD DD DSN=SIMOTIME.DATA.ALTKSD,DISP=SHR * //ALTKSD1 DD DSN=SIMOTIME.DATA.ALTKSD.PATH,DISP=SHR * * The first DD statement points to the VSAM cluster and the * second DD statement causes the alternate index within the * cluster to be available when processing. * * This program uses the parameter passed from JCL to * determine the sequence of processing records within the * data set. If the parameter is "AIX1" then the START * statement is used to position the read to start at the * first entry in the alternate index. The following shows * the JCL statement for passing the parameter. * * //LISTKSD EXEC PGM=CBLALTC3,PARM=AIX1 * SELECT ALTKSD-FILE ASSIGN TO ALTKSD ORGANIZATION IS INDEXED ACCESS MODE IS SEQUENTIAL RECORD KEY IS ALTKSD-KEY-01 ALTERNATE RECORD KEY IS ALTKSD-KEY-02 WITH DUPLICATES FILE STATUS IS ALTKSD-STATUS. SELECT PRINT-FILE ASSIGN TO REPORT03. ***************************************************************** DATA DIVISION. FILE SECTION. FD ALTKSD-FILE DATA RECORD IS ALTKSD-REC . 01 ALTKSD-REC. 05 ALTKSD-KEY-01 PIC X(12). 05 ALTKSD-DATA-01 PIC X(56). 05 ALTKSD-KEY-02 PIC X(12). 05 ALTKSD-DATA-02 PIC X(432). FD PRINT-FILE. 01 PRINT-LINE PIC X(132). ***************************************************************** * This program was created using the SYSMASK3.TXT file as the * * template for the File I/O. It is intended for use with the * * TransCALL facility that makes a call to a routine that does * * the actual conversion between EBCDIC and ASCII. For more * * information or questions contact SimoTime Technologies. * * * * Our e-mail address is: helpdesk@simotime.com * * Also, visit our Web Site at http://www.simotime.com * * * * The SYSMASK3 provides for the sequential reading of the input * * file and the sequential writing of the output file. * * If the output file is indexed then the input file must be in * * sequence by the field that will be used to provide the key * * for the output file. * * * * If the key field is not in sequence then refer to SYSMASK4 * * to provide for a random add or update of the indexed file. * ***************************************************************** WORKING-STORAGE SECTION. 01 SIM-TITLE. 05 T1 pic X(11) value '* CBLALTC3 '. 05 T2 pic X(34) value 'Read KSDS by Primary or Alternate '. 05 T3 pic X(10) value 'v05.06.08 '. 05 T4 pic X(24) value ' http://www.simotime.com'. 01 SIM-COPYRIGHT. 05 C1 pic X(11) value '* CBLALTC3 '. 05 C2 pic X(20) value 'Copyright 1987-2019 '. 05 C3 pic X(28) value ' SimoTime Technologies '. 05 C4 pic X(20) value ' All Rights Reserved'. 01 SIM-THANKS-01. 05 C1 pic X(11) value '* CBLALTC3 '. 05 C2 pic X(32) value 'Thank you for using this program'. 05 C3 pic X(32) value ' provided from SimoTime Technolo'. 05 C4 pic X(04) value 'gies'. 01 SIM-THANKS-02. 05 C1 pic X(11) value '* CBLALTC3 '. 05 C2 pic X(32) value 'Please send all inquires or sugg'. 05 C3 pic X(32) value 'estions to the helpdesk@simotime'. 05 C4 pic X(04) value '.com'. 01 ALTKSD-STATUS. 05 ALTKSD-STATUS-L pic X. 05 ALTKSD-STATUS-R pic X. 01 ALTKSD-EOF pic X value 'N'. 01 ALTKSD-OPEN-FLAG pic X value 'C'. ***************************************************************** * The following buffers are used to create a four-byte status * * code that may be displayed. * ***************************************************************** 01 IO-STATUS. 05 IO-STAT1 pic X. 05 IO-STAT2 pic X. 01 IO-STATUS-04. 05 IO-STATUS-0401 pic 9 value 0. 05 IO-STATUS-0403 pic 999 value 0. 01 TWO-BYTES-BINARY pic 9(4) BINARY. 01 TWO-BYTES-ALPHA redefines TWO-BYTES-BINARY. 05 TWO-BYTES-LEFT pic X. 05 TWO-BYTES-RIGHT pic X. ***************************************************************** * Message Buffer used by the Z-DISPLAY-MESSAGE-TEXT routine. * ***************************************************************** 01 MESSAGE-BUFFER. 05 MESSAGE-HEADER pic X(11) value '* CBLALTC3 '. 05 MESSAGE-TEXT. 10 MESSAGE-TEXT-1 pic X(68) value SPACES. 10 MESSAGE-TEXT-2 pic X(188) value SPACES. ***************************************************************** 01 PROGRAM-NAME pic X(8) value 'CBLALTC3'. 01 HEADER-LINE. 05 filler pic X(10) value '....:....1'. 05 filler pic X(10) value '....:....2'. 05 filler pic X(10) value '....:....3'. 05 filler pic X(10) value '....:....4'. 05 filler pic X(10) value '....:....5'. 05 filler pic X(10) value '....:....6'. 05 filler pic X(10) value '....:....7'. 05 filler pic X(10) value '....:....8'. 01 APPL-RESULT pic S9(9) comp. 88 APPL-AOK value 0. 88 APPL-EOF value 16. 01 ALTKSD-TOTAL. 05 ALTKSD-CTR pic 9(9) value 0. 05 filler pic X(3) value ' - '. 05 filler pic X(23) value 'Line count for ALTKSD'. ***************************************************************** LINKAGE SECTION. 01 PARM-PASS-AREA. 05 PARM-LEN PIC 9(04) COMP. 05 PARM-DATA. 10 PARM-DATA-BYTE PIC X(01) OCCURS 0 TO 100 DEPENDING ON PARM-LEN. ***************************************************************** PROCEDURE DIVISION using PARM-PASS-AREA. perform Z-POST-COPYRIGHT OPEN OUTPUT PRINT-FILE perform ALTKSD-OPEN move all LOW-VALUES to ALTKSD-REC if PARM-LEN > 0 and < 5 evaluate PARM-DATA when 'AIX1' perform SETUP-AIX1-PROCESS when 'PIX0' perform SETUP-PIX0-PROCESS when other perform SETUP-INVALID-PROCESS end-evaluate else move 'Assume Primary Index Processing' to MESSAGE-TEXT perform Z-DISPLAY-MESSAGE-TEXT end-if perform PRINT-HEADER perform until ALTKSD-STATUS > '02' perform ALTKSD-READ if ALTKSD-STATUS = '00' or ALTKSD-STATUS = '02' add 1 to ALTKSD-CTR WRITE PRINT-LINE FROM ALTKSD-REC AFTER ADVANCING 1 LINE end-if end-perform move ALTKSD-TOTAL to MESSAGE-TEXT perform Z-DISPLAY-MESSAGE-TEXT if APPL-EOF move 'is Complete...' to MESSAGE-TEXT else move 'is ABENDING...' to MESSAGE-TEXT end-if perform Z-DISPLAY-MESSAGE-TEXT perform PRINT-FOOTER perform ALTKSD-CLOSE CLOSE PRINT-FILE perform Z-THANK-YOU GOBACK. ***************************************************************** PRINT-HEADER. move SPACES TO PRINT-LINE. write PRINT-LINE after advancing page move SIM-TITLE TO PRINT-LINE. write PRINT-LINE after advancing page move SIM-COPYRIGHT TO PRINT-LINE. write PRINT-LINE after advancing page move HEADER-LINE TO PRINT-LINE. write PRINT-LINE after advancing page exit. ***************************************************************** PRINT-FOOTER. move SPACES TO PRINT-LINE. write PRINT-LINE after advancing page move SIM-THANKS-01 TO PRINT-LINE. write PRINT-LINE after advancing page move SIM-THANKS-02 TO PRINT-LINE. write PRINT-LINE after advancing page exit. ***************************************************************** SETUP-AIX1-PROCESS. start ALTKSD-FILE key greater ALTKSD-KEY-02 if ALTKSD-STATUS = '00' move 'Process by alternate index' to MESSAGE-TEXT perform Z-DISPLAY-MESSAGE-TEXT else move 'Error starting alternate index' to MESSAGE-TEXT perform Z-ABEND-PROGRAM end-if exit. ***************************************************************** SETUP-PIX0-PROCESS. move 'Process by primary index' to MESSAGE-TEXT perform Z-DISPLAY-MESSAGE-TEXT exit. ***************************************************************** SETUP-INVALID-PROCESS. move 'Invalid Parameter for index usage' to MESSAGE-TEXT perform Z-ABEND-PROGRAM exit. ***************************************************************** * I/O Routines for the INPUT File... * ***************************************************************** ALTKSD-READ. if ALTKSD-OPEN-FLAG = 'C' perform ALTKSD-OPEN end-if read ALTKSD-FILE if ALTKSD-STATUS = '00' or ALTKSD-STATUS = '02' subtract APPL-RESULT from APPL-RESULT else if ALTKSD-STATUS = '10' add 16 to ZERO giving APPL-RESULT else add 12 to ZERO giving APPL-RESULT end-if end-if. if APPL-AOK or APPL-EOF CONTINUE else move 'READ Failure with ALTKSD' to MESSAGE-TEXT perform Z-DISPLAY-MESSAGE-TEXT move ALTKSD-STATUS to IO-STATUS perform Z-DISPLAY-IO-STATUS perform Z-ABEND-PROGRAM end-if exit. *---------------------------------------------------------------* ALTKSD-OPEN. add 8 to ZERO giving APPL-RESULT. open INPUT ALTKSD-FILE if ALTKSD-STATUS = '00' subtract APPL-RESULT from APPL-RESULT move 'O' to ALTKSD-OPEN-FLAG else add 12 to ZERO giving APPL-RESULT end-if if APPL-AOK CONTINUE else move 'OPEN Failure with ALTKSD' to MESSAGE-TEXT perform Z-DISPLAY-MESSAGE-TEXT move ALTKSD-STATUS to IO-STATUS perform Z-DISPLAY-IO-STATUS perform Z-ABEND-PROGRAM end-if exit. *---------------------------------------------------------------* ALTKSD-CLOSE. add 8 to ZERO giving APPL-RESULT. close ALTKSD-FILE if ALTKSD-STATUS = '00' subtract APPL-RESULT from APPL-RESULT move 'C' to ALTKSD-OPEN-FLAG else add 12 to ZERO giving APPL-RESULT end-if if APPL-AOK CONTINUE else move 'CLOSE Failure with ALTKSD' to MESSAGE-TEXT perform Z-DISPLAY-MESSAGE-TEXT move ALTKSD-STATUS to IO-STATUS perform Z-DISPLAY-IO-STATUS perform Z-ABEND-PROGRAM end-if exit. ***************************************************************** * The following Z-ROUTINES provide administrative functions * * for this program. * ***************************************************************** * ABEND the program, post a message to the console and issue * * a STOP RUN. * ***************************************************************** Z-ABEND-PROGRAM. if MESSAGE-TEXT not = SPACES perform Z-DISPLAY-MESSAGE-TEXT end-if move 'PROGRAM-IS-ABENDING...' to MESSAGE-TEXT perform Z-DISPLAY-MESSAGE-TEXT add 12 to ZERO giving RETURN-CODE STOP RUN. * exit. ***************************************************************** * Display CONSOLE messages... * ***************************************************************** Z-DISPLAY-MESSAGE-TEXT. if MESSAGE-TEXT-2 = SPACES display MESSAGE-BUFFER(1:79) else display MESSAGE-BUFFER end-if move all SPACES to MESSAGE-TEXT exit. ***************************************************************** * Display the file status bytes. This routine will display as * * four digits. If the full two byte file status is numeric it * * will display as 00nn. If the 1st byte is a numeric nine (9) * * the second byte will be treated as a binary number and will * * display as 9nnn. * ***************************************************************** Z-DISPLAY-IO-STATUS. if IO-STATUS not NUMERIC or IO-STAT1 = '9' move IO-STAT1 to IO-STATUS-04(1:1) subtract TWO-BYTES-BINARY from TWO-BYTES-BINARY move IO-STAT2 to TWO-BYTES-RIGHT add TWO-BYTES-BINARY to ZERO giving IO-STATUS-0403 move 'File Status is: nnnn' to MESSAGE-TEXT move IO-STATUS-04 to MESSAGE-TEXT(17:4) perform Z-DISPLAY-MESSAGE-TEXT else move '0000' to IO-STATUS-04 move IO-STATUS to IO-STATUS-04(3:2) move 'File Status is: nnnn' to MESSAGE-TEXT move IO-STATUS-04 to MESSAGE-TEXT(17:4) perform Z-DISPLAY-MESSAGE-TEXT end-if exit. ***************************************************************** Z-POST-COPYRIGHT. display SIM-TITLE upon console display SIM-COPYRIGHT upon console exit. ***************************************************************** Z-THANK-YOU. display SIM-THANKS-01 upon console display SIM-THANKS-02 upon console exit. ***************************************************************** * This program was generated by SimoZAPS * * A product of SimoTime Technologies * * Our e-mail address is: helpdesk@simotime.com * * Also, visit our Web Site at http://www.simotime.com * * * * Generation Date: 2005-06-23 Generation Time: 19:40:56:70 * *****************************************************************
The purpose of this suite of programs is to provide an example for creating and processing a VSAM, Keyed Sequential Data Sets (KSDS) with a primary key and an alternate index. This document may be used to assist as a tutorial for new programmers or as a quick reference for experienced programmers.
In the world of programming there are many ways to solve a problem. This documentation and software were developed and tested on systems that are configured for a SIMOTIME environment based on the hardware, operating systems, user requirements and security requirements. Therefore, adjustments may be needed to execute the jobs and programs when transferred to a system of a different architecture or configuration.
SIMOTIME Services has experience in moving or sharing data or application processing across a variety of systems. For additional information about SIMOTIME Services or Technologies please contact us using the information in the Contact or Feedback section of this document.
Software Agreement and Disclaimer
Permission to use, copy, modify and distribute this software, documentation or training material for any purpose requires a fee to be paid to SimoTime Technologies. Once the fee is received by SimoTime the latest version of the software, documentation or training material will be delivered and a license will be granted for use within an enterprise, provided the SimoTime copyright notice appear on all copies of the software. The SimoTime name or Logo may not be used in any advertising or publicity pertaining to the use of the software without the written permission of SimoTime Technologies.
SimoTime Technologies makes no warranty or representations about the suitability of the software, documentation or learning material for any purpose. It is provided "AS IS" without any expressed or implied warranty, including the implied warranties of merchantability, fitness for a particular purpose and non-infringement. SimoTime Technologies shall not be liable for any direct, indirect, special or consequential damages resulting from the loss of use, data or projects, whether in an action of contract or tort, arising out of or in connection with the use or performance of this software, documentation or training material.
This section includes links to documents with additional information that is beyond the scope and purpose of this document. The first sub-section requires an internet connection, the second sub-section references locally available documents.
Note: A SimoTime License is required for the items to be made available on a local server.
The following links may be to the current server or to the Internet.
Explore The ASCII and EBCDIC Translation Tables. These tables are provided for individuals that need to better understand the bit structures and differences of the encoding formats.
Explore The File Status Return Codes that are used to interpret the results of accessing VSAM data sets and/or QSAM files.
Explore the non-Relational Data Connection for more examples of accessing methodologies and coding techniques for Data Files and VSAM Data Sets.
Explore the COBOL Connection for more examples of COBOL programming techniques and sample code.
Explore the JCL Connection for more examples of JCL functionality with programming techniques and sample code.
The following links will require an internet connect.
This suite of programs and documentation is available for download. Link to an Evaluation zPAK Option that includes the program members, documentation and control files.
A good place to start is The SimoTime Home Page for access to white papers, program examples and product information. This link requires an Internet Connection
Explore The Micro Focus Web Site for more information about products (including Micro Focus COBOL) and services available from Micro Focus. This link requires an Internet Connection.
Explore the Glossary of Terms for a list of terms and definitions used in this suite of documents and white papers.
This document was created and is maintained by SimoTime Technologies. If you have any questions, suggestions, comments or feedback please use the following contact information.
1. | Send an e-mail to our helpdesk. |
1.1. | helpdesk@simotime.com. |
2. | Our telephone numbers are as follows. |
2.1. | 1 415 763-9430 office-helpdesk |
2.2. | 1 415 827-7045 mobile |
We appreciate hearing from you.
SimoTime Technologies was founded in 1987 and is a privately owned company. We specialize in the creation and deployment of business applications using new or existing technologies and services. We have a team of individuals that understand the broad range of technologies being used in today's environments. Our customers include small businesses using Internet technologies to corporations using very large mainframe systems.
Quite often, to reach larger markets or provide a higher level of service to existing customers it requires the newer Internet technologies to work in a complementary manner with existing corporate mainframe systems. We specialize in preparing applications and the associated data that are currently residing on a single platform to be distributed across a variety of platforms.
Preparing the application programs will require the transfer of source members that will be compiled and deployed on the target platform. The data will need to be transferred between the systems and may need to be converted and validated at various stages within the process. SimoTime has the technology, services and experience to assist in the application and data management tasks involved with doing business in a multi-system environment.
Whether you want to use the Internet to expand into new market segments or as a delivery vehicle for existing business functions simply give us a call or check the web site at http://www.simotime.com
Return-to-Top |
Alternate Index for a VSAM, Keyed Sequential Data Set or KSDS |
Copyright © 1987-2025 SimoTime Technologies and Services All Rights Reserved |
When technology complements business |
http://www.simotime.com |