VSAM and QSAM
JCL Examples, 80 Byte Records
  Table of Contents  v-16.01.01 - utldat01.htm 
  Introduction
  Create and Populate a QSAM File
  Define a VSAM Cluster
  Populate a VSAM, KSDS Data Set
  JCL Member
  The COBOL Program
  COBOL Copy File for QSAM
  COBOL Copy File for VSAM
  Delete a QSAM File
  Delete a VSAM, KSDS Data Set
  Summary
  Software Agreement and Disclaimer
  Downloads and Links
  Current Server or Internet Access
  Internet Access Required
  Glossary of Terms
  Comments or Feedback
  Company Overview
The SimoTime Home Page 

Table of Contents Previous Section Next Section Introduction

This suite of programs will create and populate the QSAM files and VSAM data sets used by many of the sample programs provided by SimoTime.

This example illustrates the following functions.

                 
 
 
 
 
 
 
Step 1
 
 
 
 
 
 
 
 
 
 
 
Create a Sequential File
 
instream
 
 
QSMCRTJ1
 
 
   
   
Provide the instream data . . .
IEBGENER
 
 
QSAM0080
and write to the QSAM File.
 
 
 
 
 
 
 
Step 2
 
 
 
 
 
 
 
 
 
 
 
Define a VSAM Cluster
 
instream
 
 
KSDCRTJ1
 
 
   
   
Provide the instream specifications . . .
IDCAMS
 
 
VKSD0080
and define the VSAM Cluster.
 
 
 
 
 
 
 
Step 3
 
 
 
 
 
 
 
 
 
 
 
Populate the VSAM, KSDS
 
KSDUPDJ1
 
 
   
   
Execute a COBOL Program . . .
   
   
   
   
   
   
QSAM0080
 
 
KSDUPDC1
 
 
VKSD0080
Read QSAM, Populate VSAM KSDS.
   
   
   
   
   
EOJ
This is End-of-Job
 
Logic Flow to Create and Populate a VSAM Data Set from a Sequential File

On the Linux, UNIX or Windows platforms the data file names and source member names typically have file extensions. When uploaded to the mainframe from the PC the file extension is dropped.

This suite of programs, data sets and documentation are available in a single zipped file referred to as a zPack. For additional information refer to the Downloads and Links to Similar Pages section of this document.


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-2024
SimoTime Technologies and Services
All Rights Reserved

Table of Contents Previous Section Next Section Create and Populate a QSAM File

Many of the sample programs access a QSAM or sequential file. This file is created by running an MVS batch job using a single mainframe JCL member.

             
QSMCRTJ1
jcl
Start the Job
   
IEFBR14
utility
 
 
QSAM0080
Use the DISP=MOD,DELETE,DELETE
   
SYSUT1
instream
 
 
IEBGENER
utility
 
 
QSAM0080
rseq
Create the QSAM File, see Note-1
   
EOJ
This is End-of-Job
 
Note-1: rseq = a Record Sequential File, this example uses 80-byte, fixed length records.
Job Flow to Create a Sequential File

The first step in the job executes IEFBR14 with a DD statement that has a DISP=(MOD,DELETE,DELETE). This step will delete a previously created file with the same name.

The second step in the job executes IEBGENER. The data for populating the QSAM file is contained within the JCL member. The inline data will add 26 records to the file in alphabetic sequence by customer number.

The following is the JCL member QSMCRTJ1.jcl used to create and populate the Sequential file.

//QSMCRTJ1 JOB SIMOTIME,CLASS=1,MSGCLASS=0,NOTIFY=CSIP1
//* *******************************************************************
//*        This program 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 first job step (QSAMDELT) will delete any previously created
//* file. The second job step (QSAMCRT1) will create a new file.
//*
//* This set of programs will run on a mainframe under MVS or on a
//* Personal Computer with Windows and Micro Focus Mainframe Express.
//*
//*                      ************
//*                      * QSMCRTJ1 *
//*                      ********jcl*
//*                           *
//*                           *
//*                      ************     ************
//*                      * IEFBR14  ******* QSAM0080 *
//*                      ********utl*     ***delete***
//*                           *
//*                           *
//*     ************     ************     ************
//*     *  SYSIN   ******* IEBGENER ******* QSAM0080 *
//*     ********jcl*     ********utl*     *******qsam*
//*                           *
//*                           *
//*                      ************
//*                      *   EOJ    *
//*                      ************
//*
//* *******************************************************************
//* Step   1 of 2  Delete any previously created file...
//*
//QSAMDELT EXEC PGM=IEFBR14
//QSAM0080 DD  DSN=SIMOTIME.DATA.QSAM0080,DISP=(MOD,DELETE,DELETE),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=FB,LRECL=80,BLKSIZE=800,DSORG=PS)
//*
//* *******************************************************************
//* Step   2 of 2  Create and populate a new QSAM file...
//*
//QSAMCRT1 EXEC PGM=IEBGENER
//SYSPRINT DD  SYSOUT=*
//SYSIN    DD  DUMMY
//* :....1....:....2....:....3....:....4....:....5....:....6....:....7....:....8
//SYSUT1   DD  *
000100 Anderson       Adrian    111 Peachtree Plaza     Atlanta        GA 26101
000200 Brown          Billie    222 Baker Boulevard     Baltimore      MD 35702
000300 Carson         Cameron   333 Crenshaw Blvd.      Cupertino      CA 96154
000400 Davidson       Dion      444 Main Street         Wilmington     DE 27323
000500 Everest        Evan      555 5TH Avenue          New York       NY 10341
000600 Franklin       Francis   666 66TH Avenue         Bedrock        NY 11903
000700 Garfunkel      Gwen      777 77TH Street         New York       NY 16539
000800 Harrison       Hilary    888 88TH Street         Pocatello      ID 79684
000900 Isley          Isabel    999 99TH Avenue         Indianapolis   IN 38762
001000 Johnson        Jamie     1010 Paradise Drive     Larkspur       CA 90504
001100 Kemper         Kelly     1111 Oak Circle         Kansas City    KS 55651
001200 Lemond         Lesley    1212 Lockwood Road      Mohave Desert  AZ 80303
001300 Mitchell       Marlow    1313 Miller Creek Road  Anywhere       TX 77123
001400 Newman         Noel      1414 Park Avenue        Santa Monica   CA 90210
001500 Osborn         Owen      1515 Center Stage       Rolling Rock   PA 36613
001600 Powell         Pierce    PO Box 1616             Ventura        CA 97712
001700 Quigley        Quincy    1717 Farm Hill Road     Oshkosh        WI 43389
001800 Ripley         Ray       1818 Alien Lane         Wayout         KS 55405
001900 Smith          Sammy     1919 Carnoustie Drive   Novato         CA 94919
002000 Tucker         Taylor    2020 Sanger Lane        St. Paul       MN 43998
002100 Underwood      Ulysses   2121 Wall Street        New York       NY 17623
002200 Van Etten      Valerie   2222 Vine Street        Hollywood      CA 98775
002300 Wilson         Wiley     2323 Main Street        Boston         MA 01472
002400 Xray           Xavier    2424 24TH Street        Nashville      TN 44190
002500 Young          Yanni     2525 Yonge Street       Toronto        ON 6B74A6
002600 Zenith         Zebulon   2626 26TH Street        Dallas         TX 71922
123456 Doe            John      123 Main Street         Anywhere       OR 88156
/*
//SYSUT2   DD  DSN=SIMOTIME.DATA.QSAM0080,
//             DISP=(NEW,CATLG,DELETE),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=FB,LRECL=80,BLKSIZE=800,DSORG=PS)
//

The following table contains detailed information about the file.

Item Description
PC file name QSAM0080.DAT
Fully Qualified MVS name SIMOTIME.DATA.QSAM0080
DD Name QSAM0080
Record Format Fixed, Blocked
Record Length 80 character
Position Description
01-06 Customer Number
07-07 FILLER
08-22 Last Name
23-32 First Name
33-56 Street Address
57-71 City
72-74 State Code
75-80 Postal Code
  File Specifications and Record layout

The preceding job may be executed on the mainframe as an MVS batch job. It may also be executed on the PC running Micro Focus Mainframe Express product. The JOB and DD statements will require modification prior to execution on a mainframe.

Table of Contents Previous Section Next Section Define a VSAM Cluster

Creating and populating the VSAM, KSDS data set is a two step process. The first step runs the KSDCRTJ1.JCL member that executes IDCAMS. This will create an empty VSAM data set.

             
KSDCRTJ1
jcl
Start the Job
   
SYSIN
instream
 
 
IDCAMS
utility
 
 
VKSD0080
ksds
Define the VSAM Cluster, see Note-1
   
EOJ
This is End-of-Job
 
Note-1: ksds = a VSAM, Key-Sequenced-Data-Set, 80 byte records with a key position of 1 and a length of 6.
Job Flow to Define a VSAM Cluster

The following is the JCL member (KSDCRTJ1.jcl) used to define the VSAM Cluster.

//KSDCRTJ1 JOB SIMOTIME,CLASS=1,MSGCLASS=0,NOTIFY=CSIP1
//* *******************************************************************
//*        This program 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 an empty VSAM, KSDS data set using IDCAMS.
//* Author - SimoTime Technologies
//* Date   - January 24, 1996
//*
//* This job will create a VSAM, KSDS data set. The key is 6 bytes
//* characters starting at the first position in the record.
//* The record length is 80 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   This is a single step job.
//*
//VKSDCRT1 EXEC PGM=IDCAMS
//SYSPRINT DD   SYSOUT=*
//SYSIN    DD   *
 DEFINE    CLUSTER  (NAME(SIMOTIME.DATA.VKSD0080)             -
                    TRACKS(45 15)                             -
                    RECORDSIZE(80 80)                         -
                    FREESPACE(10 15)                          -
                    KEYS(6 0)                                 -
                    INDEXED)                                  -
           DATA     (NAME(SIMOTIME.DATA.VKSD0080.DAT)         -
                    CISZ(8192))                               -
           INDEX    (NAME(SIMOTIME.DATA.VKSD0080.IDX))
/*
//*

The preceding mainframe job will just create a catalog entry. There are no records in the file. The following section provides an example of one method that may be used to populate the VSAM, KSDS data set.

Table of Contents Previous Section Next Section Populate a VSAM, KSDS Data Set

To populate the VSAM data set requires mainframe JCL and a COBOL program. The approach used in this example will read a QSAM file and update or add records in the VSAM data set.

             
KSDUPDJ1
jcl
Start the Job
   
QSAM0080
rseq
 
 
KSDUPDC1
utility
 
 
VKSD0080
ksds
Populate the VSAM Cluster,
see Notes-1 and 2
   
EOJ
This is End-of-Job
 
Note-1: rseq = a Record Sequential File, this example uses 80-byte, fixed length records.
Note-2: ksds = a VSAM, Key-Sequenced-Data-Set, 80 byte records with key poition is 1 and a length of 6.
Job Flow to Define a VSAM Cluster

Table of Contents Previous Section Next Section JCL Member

The following is a sample of the mainframe JCL (KSDUPDJ1.jcl) needed to run on an IBM mainframe as an MVS batch job. This job will also run on the Linux, UNIX or Windows using Micro Focus Server.

//KSDUPDJ1 JOB SIMOTIME,ACCOUNT,CLASS=1,MSGCLASS=0,NOTIFY=CSIP1
//* *******************************************************************
//*        This program 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   -   Execute a COBOL program to read QSAM and write VSAM.
//* Author -   SimoTime Technologies
//* Date   -   January 01, 1997
//*
//* This COBOL program will read a QSAM, EBCDIC, 80-byte,
//* fixed-record-length file and update a KSDS, VSAM data set.
//*
//*                     ************
//*                     * KSDUPDJ1 *
//*                     ********jcl*
//*                          *
//*                          *
//*    ************     ************     ************
//*    * QSAM0080 *-----* KSD080C1 *-----* VKSD0080 *
//*    *******qsam*     ********cbl*     *******vsam*
//*                          *
//*                          *
//*                     ************
//*                     *   EOJ    *
//*                     ************
//*
//* *******************************************************************
//* Step   1   This is a single step job.
//*
//VSAMKSDU EXEC PGM=KSDUPDC1
//STEPLIB  DD  DISP=SHR,DSN=SIMOTIME.DEMO.LOADLIB1
//QSAM0080 DD  DISP=SHR,DSN=SIMOTIME.DATA.QSAM0080
//VKSD0080 DD  DISP=SHR,DSN=SIMOTIME.DATA.VKSD0080
//SYSOUT   DD  SYSOUT=*
//*

The preceding job may be executed on the mainframe as an MVS batch job. It may also be executed on the PC running Micro Focus Mainframe Express. The JOB and DD statements will require modification prior to execution on a mainframe.

Table of Contents Previous Section Next Section The COBOL Program

The following (KSDUPDC1.cbl) is a sample of the mainframe COBOL program for populating a VSAM, KSDS Data Set.

       IDENTIFICATION DIVISION.
       PROGRAM-ID.    KSDUPDC1.
       AUTHOR.        SIMOTIME TECHNOLOGIES.
      *****************************************************************
      * Copyright (C) 1987-2019 SimoTime Technologies.                *
      *                                                               *
      * All rights reserved.  Unpublished, all rights reserved under  *
      * copyright law and international treaty.  Use of a copyright   *
      * notice is precautionary only and does not imply publication   *
      * or disclosure.                                                *
      *                                                               *
      * Permission to use, copy, modify and distribute this software  *
      * for any non-commercial purpose and without fee is hereby      *
      * granted, 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.                                                 *
      *                                                               *
      * Permission to use, copy, modify and distribute this software  *
      * for any commercial purpose requires a fee to be paid to       *
      * SimoTime Technologies. Once the fee is received by SimoTime   *
      * the latest version of the software 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 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                                  *
      *                                                               *
      * SimoTime Technologies                                         *
      * 15 Carnoustie Drive                                           *
      * Novato, CA 94949-5849                                         *
      * 415.883.6565                                                  *
      *                                                               *
      * RESTRICTED RIGHTS LEGEND                                      *
      * Use, duplication, or disclosure by the Government is subject  *
      * to restrictions as set forth in subparagraph (c)(1)(ii) of    *
      * the Rights in Technical Data and Computer Software clause at  *
      * DFARS 52.227-7013 or subparagraphs (c)(1) and (2) of          *
      * Commercial  Computer Software - Restricted Rights  at 48      *
      * CFR 52.227-19, as applicable.  Contact SimoTime Technologies, *
      * 15 Carnoustie Drive, Novato, CA 94949-5849.                   *
      *                                                               *
      *****************************************************************
      *      This program is provided by SimoTime Technologies        *
      *        Our e-mail address is: helpdesk@simotime.com           *
      *     Also, visit our Web Site at http://www.simotime.com       *
      *                                                               *
      *****************************************************************
      *
      *****************************************************************
      * Source Member: KSDUPDC1.CBL
      * Copy Files:    QQSMREC1.CPY
      *****************************************************************
      *
      * KSDUPDC1 - Execute KSDUPDC1 to read a QSAM file and  update
      * a VSAM Keyed Sequential Data Set (KSDS).
      *
      * EXECUTION or CALLING PROTOCOL
      * -----------------------------
      * Use standard JCL to EXECUTE or ANIMATE.
      *
      * DESCRIPTION
      * -----------
      * This single COBOL program will read an 80-byte, EBCDIC, QSAM
      * file an populate or update an empty or existing KSDS, VSAM
      * data set.
      *
      *                      ************
      *                      * KSDUPD *
      *                      ********jcl*
      *                           *
      *                           *
      *     ************     ************     ************
      *     * QSAM0080 *-----* KSDUPDC1 *-----* VKSD0080 *
      *     *******qsam*     ********cbl*     *******vsam*
      *                           *
      *                           *
      *                      ************
      *                      *   EOJ    *
      *                      ************
      *
      *
      *****************************************************************
      *
      * MAINTENANCE
      * -----------
      * 1997/02/27 Simmons, Created program.
      * 1997/02/27 Simmons, No changes to date.
      *
      *****************************************************************
      *
       ENVIRONMENT DIVISION.
       INPUT-OUTPUT   SECTION.
       FILE-CONTROL.

      *****************************************************************
           SELECT QSAM0080-FILE
               ASSIGN       to QSAM0080
               ORGANIZATION is SEQUENTIAL
               ACCESS MODE  is SEQUENTIAL
               FILE STATUS  is QSAM0080-STATUS.
           SELECT VKSD0080-FILE
               ASSIGN       to VKSD0080
               ORGANIZATION is indexed
               ACCESS MODE  is RANDOM
               RECORD KEY   is VKSD-KEY
               FILE STATUS  is VKSD0080-STATUS.

      *****************************************************************
       DATA DIVISION.
       FILE SECTION.

      *****************************************************************
       FD   QSAM0080-FILE
            RECORD CONTAINS 80 CHARACTERS.

       COPY SQ0080B1.

       FD  VKSD0080-FILE.
       COPY VKSDREC1.

       WORKING-STORAGE SECTION.
      *****************************************************************
      *    Data-structure for Title and Copyright...
      *****************************************************************
       01  SIM-TITLE.
           05  T1 pic X(11) value '* KSDUPDC1 '.
           05  T2 pic X(34) value ' Sample, Read QSAM, Update VSAM   '.
           05  T3 pic X(10) value ' v04.04.14'.
           05  T4 pic X(24) value ' http://www.simotime.com'.
       01  SIM-COPYRIGHT.
           05  C1 pic X(11) value '* KSDUPDC1 '.
           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 '* KSDUPDC1 '.
           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 '* KSDUPDC1 '.
           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  VKSD0080-STATUS.
           05  VKSD0080-STAT1      pic X.
           05  VKSD0080-STAT2      pic X.

       01  QSAM0080-STATUS.
           05  QSAM0080-STAT1      pic X.
           05  QSAM0080-STAT2      pic X.

       01  IO-STATUS.
           05  IO-STAT1            pic X.
           05  IO-STAT2            pic X.
       01  TWO-BYTES.
           05  TWO-BYTES-LEFT      pic X.
           05  TWO-BYTES-RIGHT     pic X.
       01  TWO-BYTES-BINARY        redefines TWO-BYTES pic 9(4) comp.

       01  END-OF-FILE             pic X(3)    value 'NO '.

       01  CONSOLE-MESSAGE         pic X(48).

       01  VSAM-WRITE-ONLY         pic X       value 'N'.

       01  APPL-RESULT             pic S9(9)   comp.
           88  APPL-AOK            value 0.
           88  APPL-EOF            value 16.

      *****************************************************************
       PROCEDURE DIVISION.

           perform Z-POST-COPYRIGHT.

           perform QSAM0080-OPEN.
           perform VKSD0080-OPEN.

           perform until END-OF-FILE = 'YES'
               if  END-OF-FILE = 'NO '
                   perform QSAM0080-GET
                   if  END-OF-FILE = 'NO '
                       display QSAM-RECORD upon console
                       if  VSAM-WRITE-ONLY = 'Y'
                           move QSAM-RECORD to VKSD-RECORD
                           perform VKSD0080-WRITE
                       else
                           move QSAM-KEY to VKSD-KEY
                           perform VKSD0080-GET
                           move QSAM-RECORD to VKSD-RECORD
                           if  APPL-AOK
                               perform VKSD0080-REWRITE
                           else
                               perform VKSD0080-WRITE
                           end-if
                       end-if
                   end-if
               end-if
           end-perform.

           perform VKSD0080-CLOSE.
           perform QSAM0080-CLOSE.

           display 'KSDUPDC1 VKSD0080-HAS-BEEN-UPDATED' upon console
           display 'KSDUPDC1 NORMAL-END-OF-JOB...'      upon console

           perform Z-THANK-YOU.

           GOBACK.

      *****************************************************************
      * The following routines are in alphabetic sequence.            *
      *****************************************************************

      *****************************************************************
      * Routines to do a sequential read of the QSAM file.            *
      *****************************************************************
       QSAM0080-GET.
           read QSAM0080-FILE
           if  QSAM0080-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
           else
               if  QSAM0080-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 'YES' to END-OF-FILE
               else
                   move 'KSDUPDC1 QSAM0080-FAILURE-GET...'
                     to   CONSOLE-MESSAGE
                   move QSAM0080-STATUS to IO-STATUS
                   perform Z-DISPLAY-CONSOLE-MESSAGE
                   perform Z-DISPLAY-IO-STATUS
                   perform Z-ABEND-PROGRAM
               end-if
           end-if
           exit.
      *---------------------------------------------------------------*
       QSAM0080-OPEN.
           add 8 to ZERO giving APPL-RESULT.
           open input QSAM0080-FILE
           if  QSAM0080-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
           else
               add 12 to ZERO giving APPL-RESULT
           end-if
           if  APPL-AOK
               CONTINUE
           else
               move 'KSDUPDC1 QSAM0080-FAILURE-OPEN...'
                 to CONSOLE-MESSAGE
               move QSAM0080-STATUS to IO-STATUS
               perform Z-DISPLAY-CONSOLE-MESSAGE
               perform Z-DISPLAY-IO-STATUS
               perform Z-ABEND-PROGRAM
           end-if
           exit.
      *---------------------------------------------------------------*
       QSAM0080-CLOSE.
           add 8 to ZERO giving APPL-RESULT.
           close QSAM0080-FILE
           if  QSAM0080-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
           else
               add 12 to ZERO giving APPL-RESULT
           end-if

           if  APPL-AOK
               CONTINUE
           else
               move 'KSDUPDC1, QSAM0080, FAILURE, CLOSE...'
                 to CONSOLE-MESSAGE
               move QSAM0080-STATUS to IO-STATUS
               perform Z-DISPLAY-CONSOLE-MESSAGE
               perform Z-DISPLAY-IO-STATUS
               perform Z-ABEND-PROGRAM
           end-if
           exit.

      *****************************************************************
      * Routines to do a read by KEY of the KSDS, VSAM Data Set. If   *
      * the read is successful then the record may be updated else a  *
      * new record may be added.                                      *
      *****************************************************************
       VKSD0080-GET.
           read VKSD0080-FILE
           if  VKSD0080-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
           else
               if  VKSD0080-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 'YES' to END-OF-FILE
               else
                   move 'KSDUPDC1 VKSD0080-Record-NOT-Found.'
                     to   CONSOLE-MESSAGE
                   perform Z-DISPLAY-CONSOLE-MESSAGE
               end-if
           end-if
           exit.
      *---------------------------------------------------------------*
       VKSD0080-WRITE.
           write VKSD-RECORD
           if  VKSD0080-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
           else
               if  VKSD0080-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 'YES' to END-OF-FILE
               else
                   move 'KSDUPDC1 VKSD0080-FAILURE-WRITE...'
                     to   CONSOLE-MESSAGE
                   move VKSD0080-STATUS to IO-STATUS
                   perform Z-DISPLAY-CONSOLE-MESSAGE
                   perform Z-DISPLAY-IO-STATUS
                   perform Z-ABEND-PROGRAM
               end-if
           end-if
           exit.
      *---------------------------------------------------------------*
       VKSD0080-REWRITE.
           REWRITE VKSD-RECORD
           if  VKSD0080-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
           else
               if  VKSD0080-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 'YES' to END-OF-FILE
               else
                   move 'KSDUPDC1 VKSD0080-FAILURE-REWRITE...'
                     to   CONSOLE-MESSAGE
                   move VKSD0080-STATUS to IO-STATUS
                   perform Z-DISPLAY-CONSOLE-MESSAGE
                   perform Z-DISPLAY-IO-STATUS
                   perform Z-ABEND-PROGRAM
               end-if
           end-if
           exit.
      *---------------------------------------------------------------*
       VKSD0080-OPEN.
           add 8 to ZERO giving APPL-RESULT.
           open I-O VKSD0080-FILE
           if  VKSD0080-STATUS = '35'
               move 'Y' to VSAM-WRITE-ONLY
               move 'KSDUPDC1 VKSD0080-FAILURE-OPEN-IO...'
                 to CONSOLE-MESSAGE
               perform Z-DISPLAY-CONSOLE-MESSAGE
               move VKSD0080-STATUS to IO-STATUS
               perform Z-DISPLAY-IO-STATUS
               move 'KSDUPDC1 VKSD0080-ATTEMPT-OPEN-OUTPUT...'
                 to CONSOLE-MESSAGE
               perform Z-DISPLAY-CONSOLE-MESSAGE
               open output VKSD0080-FILE
           end-if
           if  VKSD0080-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
           else
               add 12 to ZERO giving APPL-RESULT
           end-if
           if  APPL-AOK
               CONTINUE
           else
               move 'KSDUPDC1 VKSD0080-FAILURE-OPEN...'
                 to CONSOLE-MESSAGE
               move VKSD0080-STATUS to IO-STATUS
               perform Z-DISPLAY-CONSOLE-MESSAGE
               perform Z-DISPLAY-IO-STATUS
               perform Z-ABEND-PROGRAM
           end-if
           exit.
      *---------------------------------------------------------------*
       VKSD0080-CLOSE.
           add 8 to ZERO giving APPL-RESULT.
           close VKSD0080-FILE
           if  VKSD0080-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
           else
               add 12 to ZERO giving APPL-RESULT
           end-if
           if  APPL-AOK
               CONTINUE
           else
               move 'KSDUPDC1 VKSD0080-FAILURE-CLOSE...'
                 to   CONSOLE-MESSAGE
               move VKSD0080-STATUS to IO-STATUS
               perform Z-DISPLAY-CONSOLE-MESSAGE
               perform Z-DISPLAY-IO-STATUS
               perform Z-ABEND-PROGRAM
           end-if
           exit.

      *****************************************************************
      * The following Z-Routines perform administrative tasks         *
      * for this program.                                             *
      *****************************************************************
      *
      *****************************************************************
      * ABEND the program, post a message to the console and issue    *
      * a STOP RUN.                                                   *
      *****************************************************************
       Z-ABEND-PROGRAM.
           if  CONSOLE-MESSAGE not = SPACES
               perform Z-DISPLAY-CONSOLE-MESSAGE
           end-if
           move 'KSDUPDC1 PROGRAM-IS-ABENDING...'  to CONSOLE-MESSAGE
           perform Z-DISPLAY-CONSOLE-MESSAGE
           add 12 to ZERO giving RETURN-CODE
           STOP RUN.

      *****************************************************************
      * Display the file status bytes. This routine will display as   *
      * two digits if the full two byte file status is numeric. If    *
      * second byte is non-numeric then it will be treated as a       *
      * binary number.                                                *
      *****************************************************************
       Z-DISPLAY-IO-STATUS.
           if  IO-STATUS not NUMERIC
           or  IO-STAT1 = '9'
               subtract TWO-BYTES-BINARY from TWO-BYTES-BINARY
               move IO-STAT2 to TWO-BYTES-RIGHT
               display '* KSDUPDC1 FILE-STATUS-' IO-STAT1 '/'
                       TWO-BYTES-BINARY upon console
               display '* KSDUPDC1 FILE-STATUS-' IO-STAT1 '/'
                       TWO-BYTES-BINARY
           else
               display '* KSDUPDC1 FILE-STATUS-' IO-STATUS upon console
               display '* KSDUPDC1 FILE-STATUS-' IO-STATUS
           end-if
           exit.

      *****************************************************************
       Z-DISPLAY-CONSOLE-MESSAGE.
           display CONSOLE-MESSAGE
           move all SPACES to CONSOLE-MESSAGE
           exit.

      *****************************************************************
       Z-POST-COPYRIGHT.
           display SIM-TITLE
           display SIM-COPYRIGHT
           exit.

      *****************************************************************
       Z-THANK-YOU.
           display SIM-THANKS-01
           display SIM-THANKS-02
           exit.
      *****************************************************************
      *      This example is provided by SimoTime Technologies        *
      *        Our e-mail address is: helpdesk@simotime.com           *
      *     Also, visit our Web Site at http://www.simotime.com       *
      *****************************************************************

Table of Contents Previous Section Next Section COBOL Copy File for QSAM

The following (SQ0080B1.cpy) is a sample of the mainframe COBOL copy file that contains the record format for the QSAM file that is read as a sequential input file.

      *****************************************************************
      *               SQ0080B1.CPY - a COBOL Copy File                *
      *    Copy File for the QSAM File used for the Demo programs.    *
      *         Copyright (C) 1987-2019 SimoTime Technologies         *
      *                     All Rights Reserved                       *
      *              Provided by SimoTime Technologies                *
      *        Our e-mail address is: helpdesk@simotime.com           *
      *     Also, visit our Web Site at http://www.simotime.com       *
      *****************************************************************
      *    QSAM-RECORD size is 80 Bytes.
      *
       01  QSAM-RECORD.
           05  QSAM-KEY            PIC X(6).
           05  filler              PIC X.
           05  QSAM-LAST-NAME      PIC X(15).
           05  QSAM-FIRST-NAME     PIC X(10).
           05  QSAM-STREET-ADDRESS PIC X(24).
           05  QSAM-CITY           PIC X(15).
           05  QSAM-STATE          PIC X(3).
           05  QSAM-POSTAL-CODE    PIC X(6).
      *
      ***  SQ0080B1 - End-of-Copy File - - - - - - - - - - - SQ0080B1 *
      *****************************************************************
      *

Table of Contents Previous Section Next Section COBOL Copy File for VSAM

The following (VKSDREC1.cpy) is a sample of the mainframe COBOL copy file that contains the record format for the VSAM, Keyed Sequential Data Set.

      *****************************************************************
      *               VKSDREC1.CPY - a COBOL Copy File                *
      *  Copy File for the VSAM Data Set used for the Demo programs.  *
      *         Copyright (C) 1987-2019 SimoTime Technologies         *
      *                     All Rights Reserved                       *
      *              Provided by SimoTime Technologies                *
      *        Our e-mail address is: helpdesk@simotime.com           *
      *     Also, visit our Web Site at http://www.simotime.com       *
      *****************************************************************
      *    VKSD-RECORD maximum record size is 80 Bytes.
      *
       01  VKSD-RECORD.
           05  VKSD-KEY            PIC X(6).
           05  FILLER              PIC X.
           05  VSAM-LAST-NAME      PIC X(15).
           05  VSAM-FIRST-NAME     PIC X(10).
           05  VSAM-STREET-ADDRESS PIC X(24).
           05  VSAM-CITY           PIC X(15).
           05  VSAM-STATE          PIC X(3).
           05  VSAM-POSTAL-CODE    PIC X(6).
      *
      ***  VKSDREC1 - End-of-Copy File - - - - - - - - - - - VKSDREC1 *
      *****************************************************************
      *

Table of Contents Previous Section Next Section Delete a QSAM File

The following JCL (QSMDELJ1.jcl) uses IEFBR14 and a DD statement to delete a QSAM file.

//QSMDELJ1 JOB SIMOTIME,CLASS=1,MSGCLASS=0,NOTIFY=CSIP1
//* *******************************************************************
//*        This program 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   - Delete a Sequential File on disk using IEFBR14.
//* Author - SimoTime Technologies
//* Date   - January 24, 1996
//*
//* *******************************************************************
//*
//QSAMDELT EXEC PGM=IEFBR14
//QSAM0080 DD  DSN=SIMOTIME.DATA.QSAM0080,DISP=(MOD,DELETE,DELETE),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=FB,LRECL=80,BLKSIZE=800,DSORG=PS)
//*

The preceding job may be executed on the mainframe as an MVS batch job. The JOB and DD statements will require modification prior to execution in different mainframe environments. The job may also be executed on the PC running the Micro Focus Mainframe Express product.

Table of Contents Previous Section Next Section Delete a VSAM, KSDS Data Set

This section describes how to delete a VSAM Keyed-Sequential-Data-Set (KSDS). A VSAM, KSDS 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.

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 the data 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.

The following JCL (KSDDELJ1.jcl) uses IDCAMS to delete a VSAM Data Set.

//KSDDELJ1 JOB SIMOTIME,CLASS=1,MSGCLASS=0,NOTIFY=CSIP1
//* *******************************************************************
//*        This program is provided by SimoTime Technologies          *
//*           (C) Copyright 1987-2019 All Rights Reserved             *
//*             Web Site URL:   http://www.simotime.com               *
//*                   e-mail:   helpdesk@simotime.com                 *
//* *******************************************************************
//* Subject: JCL to delete a VSAM Data Set using the IDCAMS Utility   *
//* 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.                        *
//*********************************************************************
//*
//         EXEC PGM=IDCAMS
//SYSPRINT DD  SYSOUT=*
//SYSIN    DD  *
 DELETE    SIMOTIME.DATA.VKSD0080   -
           FILE (VKSD0080)          -
           PURGE                    -
           ERASE                    -
           CLUSTER
 SET       MAXCC = 0
/*
//

The preceding job may be executed on the mainframe as an MVS batch job. The JOB and DD statements will require modification prior to execution in different mainframe environments. The job may also be executed on the PC running the Micro Focus Mainframe Express product.

Table of Contents Previous Section Next Section Summary

The purpose of this suite of programs is to provide examples for creating, populating, maintaining and deleting mainframe files and data sets. This document may be used 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.

Table of Contents Previous Section Next Section 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.

Table of Contents Previous Section Next Section Downloads and Links

This section includes links to documents with additional information that are beyond the scope and purpose of this document. The first group of documents may be available from a local system or via an internet connection, the second group of documents will require an internet connection.

Note: A SimoTime License is required for the items to be made available on a local system or server.

Table of Contents Previous Section Next Section Current Server or Internet Access

The following links may be to the current server or to the Internet.

Note: The latest versions of the SimoTime Documents and Program Suites are available on the Internet and may be accessed using the Link to Internet icon. If a user has a SimoTime Enterprise License the Documents and Program Suites may be available on a local server and accessed using the Link to Server icon.

Link to Internet   Link to Server   Explore the non-Relational Data Connection for more examples of accessing methodologies and coding techniques for Data Files and VSAM Data Sets.

Link to Internet   Link to Server   Explore An Enterprise System Model that describes and demonstrates how Applications that were running on a Mainframe System and non-relational data that was located on the Mainframe System were copied and deployed in a Microsoft Windows environment with Micro Focus Enterprise Server.

Link to Internet   Link to Server   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.

Link to Internet   Link to Server   Explore The File Status Return Codes that are used to interpret the results of accessing VSAM data sets and/or QSAM files.

Table of Contents Previous Section Next Section Internet Access Required

The following links will require an internet connect.

This suite of programs and documentation is available to download for review and evaluation purposes. Other uses will require a SimoTime Software License. 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.

Table of Contents Previous Section Next Section Glossary of Terms

Link to Internet   Link to Server   Explore the Glossary of Terms for a list of terms and definitions used in this suite of documents and white papers.

Table of Contents Previous Section Next Section Comments or Feedback

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.

Table of Contents Previous Section Next Section Company Overview

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
VSAM and QSAM Examples
Copyright © 1987-2024
SimoTime Technologies and Services
All Rights Reserved
When technology complements business
http://www.simotime.com