VSAM and QSAM
When technology complements business   JCL Examples, 80 Byte Records
Copyright © 1987-2008  SimoTime Enterprises, LLC  All Rights Reserved  http://www.simotime.com

 
Introduction Version 03.01.24
  Create and Populate a QSAM File
  Create a VSAM, KSDS Data Set
  Populate a VSAM, KSDS Data Set
 
  Populate a VSAM Data Set - JCL
  Populate a VSAM Data Set - COBOL Program
  Populate a VSAM Data Set - COBOL Copy File for QSAM
  Populate a VSAM Data Set - COBOL Copy File for VSAM
  Delete a QSAM File
  Delete a VSAM, KSDS Data Set
  Summary
 
  Software Agreement and Disclaimer
  Downloads and Links to Similar Pages
  Comments or Suggestions
  About SimoTime

Introduction
(Next) (Previous) (Table-of-Contents)

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.

1. How to create and populate a QSAM file using mainframe JCL.
2. How to create a VSAM, KSDS (Keyed Sequential Data Set) data set using mainframe JCL and IDCAMS.
3. How to populate a VSAM, KSDS data set using mainframe JCL and a COBOL program.
4. How to delete a VSAM, KSDS data set using mainframe JCL and IDCAMS.

The source code, data sets and documentation are provided in a single zipped file called UTLDAT01.ZIP. This zipped file may be downloaded from the SimoTime Web site. The file names have file extensions. When uploaded to the mainframe from the PC the file extension is dropped.

Create and Populate a QSAM File
(Next) (Previous) (Table-of-Contents)

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

   
QSMCRTJ1
jcl
       
   
 
       
   
IEFBR14
utiliy
       
   
 
       
   
IEBGENER
utility
     
     
     
QSAM0080
qsam
   
   
 
       
   
EOJ
       
             

The member name is QSMCRTJ1.JCL. 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.

//QSMCRTJ1 JOB SIMOTIME,CLASS=1,MSGCLASS=0,NOTIFY=CSIP1
//* *******************************************************************
//*                   This program is provided by:                    *
//*                    SimoTime Enterprises, LLC                      *
//*           (C) Copyright 1987-2003 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 Enterprises
//* 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   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   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
000200 Brown               Billie    222 Baker Boulevard      Baltimore       MD
000300 Carson              Cameron   333 Crenshaw Blvd.       Cupertino       CA
000400 Davidson            Dion      444 Main Street          Wilmington      DE
000500 Everest             Evan      555 5TH Avenue           New york        NY
000600 Franklin            Francis   666 66TH Avenue          Bedrock         NY
000700 Garfunkel           Gwen      777 77TH Street          New york        NY
000800 Harrison            Hilary    888 88TH Street          Pocatello       ID
000900 Isley               Isabel    999 99TH Avenue          Indianapolis    IN
001000 Johnson             Jamie     1010 Paradise Drive      Larkspur        CA
001100 Kemper              Kelly     1111 Oak Circle          Kansas City     KS
001200 Lemond              Lesley    1212 Lockwood Road       Mohave Desert   AZ
001300 Mitchell            Marlow    1313 Miller Creek Road   Anywhere        TX
001400 Newman              Noel      1414 Park Avenue         Santa Monica    CA
001500 Osborn              Owen      1515 Center Stage        Rolling Rock    PA
001600 Powell              Pierce    PO Box 1616              Ventura         CA
001700 Quigley             Quincy    1717 Farm Hill Road      Oshkosh         WI
001800 Ripley              Ray       1818 Alien Lane          Wayout          KS
001900 Smith               Sammy     1919 Carnoustie Drive    Novato          CA
002000 Tucker              Taylor    2020 Sanger Lane         St. Paul        MN
002100 Underwood           Ulysses   2121 Wall Street         New York        NY
002200 Victoria            Vaughn    2222 Vine Street         Hollywood       CA
002300 Wilson              Wiley     2323 Main Street         Boston          MA
002400 Xray                Xavier    2424 24TH Street         Nashville       TN
002500 Young               Yanni     2525 Yonge Street        Toronto         ON
002600 Zenith              Zebulon   2626 26TH Street         Dallas          TX
123456 Doe                 John      123 Main Street          Anywhere        OR
/*
//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 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 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 with 800 character block length
Position Description
01-06 Customer Number
07-07 filler
08-27 Last Name
28-37 First Name
38-62 Street Address
63-78 City
79-80 State Code

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.

Create a VSAM, KSDS Data Set
[9Next) (Previous) (Table-of-Contents)

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
IDCAMS
utility
     
     
     
VKSD0080
vsam, ksds
 
   
 
     
   
EOJ
           
//KSDCRTJ1 JOB SIMOTIME,CLASS=1,MSGCLASS=0,NOTIFY=CSIP1
//* *******************************************************************
//*                   This program is provided by:                    *
//*                    SimoTime Enterprises, LLC                      *
//*           (C) Copyright 1987-2003 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 Enterprises
//* Date   - January 24, 1996
//*
//* This job will create a VSAM, KSDS data set. The key is six
//* characters starting at the first position in the record.
//* The record length is eighty 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 is an example of the mainframe JCL (KSDCRTJ1.JCL) needed to create a catalog entry for a VSAM data set.

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.

Populate a VSAM, KSDS Data Set
(Next) (Previous) (Table-of-Contents)

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
       
   
 
       
QSAM0080
qsam
     
     
     
KSDUPDC1
cobol
     
     
     
VKSD0080
vsam, ksd
   
   
 
       
   
EOJ
       
             

Populate a VSAM Data Set - JCL
(Next) (Previous) (Table-of-Contents)

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 PC using Micro Focus Mainframe Express.

//KSDUPDJ1 JOB SIMOTIME,ACCOUNT,CLASS=1,MSGCLASS=0,NOTIFY=CSIP1
//* *******************************************************************
//*                   This program is provided by:                    *
//*                    SimoTime Enterprises, LLC                      *
//*           (C) Copyright 1987-2003 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 Enterprises
//* 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
//*

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.

Populate VSAM Data Set - COBOL Program
(Next) (Previous) (Table-of-Contents)

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 ENTERPRISES.
      *****************************************************************
      * Copyright (C) 1987-2003 SimoTime Enterprises, LLC.            *
      *                                                               *
      * All rights reserved.  Unpublished, all rights reserved under  *
      * copyright law and international treaty.  Use of a copyright   *
      * notice is precautionary only does not imply publication or    *
      * disclosure.  This software contains confidential information  *
      * and trade secrets of SimoTime Enterprises, LLC. No part of    *
      * this program or publication may be reproduced, transmitted,   *
      * transcribed, stored in a retrieval system, or translated into *
      * any language or computer language, in any form or by any      *
      * means, electronic, mechanical, magnetic, optical, chemical,   *
      * manual or otherwise, without the prior written permission of: *
      *                                                               *
      * SimoTime Enterprises                                          *
      * 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 Enterprises,  *
      * 15 Carnoustie Drive, Novato, CA 94949-5849.                   *
      *                                                               *
      *****************************************************************
      *      This program is provided by SimoTime Enterprises         *
      *        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 VSAM-KEY
               FILE STATUS  is VKSD0080-STATUS.

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

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

       COPY QQSMREC1.

       FD  VKSD0080-FILE.
       COPY QVSMREC1.

       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 ' v1.1.00  '.
           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-2003 '.
           05  C3 pic X(28) value '  SimoTime Enterprises, LLC '.
           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 sample '.
           05  C3 pic X(32) value 'by SimoTime Enterprises, LLC    '.
           05  C4 pic X(04) value '    '.

       01  SIM-THANKS-02.
           05  C1 pic X(11) value '* KSDUPDC1 '.
           05  C2 pic X(32) value 'Please send comments or suggesti'.
           05  C3 pic X(32) value 'ons to helpdesk@simotime.com    '.
           05  C4 pic X(04) value '    '.

       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 VSAM-RECORD
                           perform VKSD0080-WRITE
                       else
                           move QSAM-KEY to VSAM-KEY
                           perform VKSD0080-GET
                           move QSAM-RECORD to VSAM-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 VSAM-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 VSAM-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
           else
               display '* KSDUPDC1 FILE-STATUS-' IO-STATUS upon console
           end-if
           exit.

      *****************************************************************
       Z-DISPLAY-CONSOLE-MESSAGE.
           display CONSOLE-MESSAGE upon console
           move all SPACES to CONSOLE-MESSAGE
           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 example is provided by SimoTime Enterprises         *
      *        Our e-mail address is: helpdesk@simotime.com           *
      *     Also, visit our Web Site at http://www.simotime.com       *
      *****************************************************************

Populate VSAM Data Set - COBOL Copy File for QSAM
(Next) (Previous) (Table-of-Contents)

The following (QQSMREC1. 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.

      *****************************************************************
      *    Copy File for the QSAM File used for the Demo programs.    *
      *****************************************************************
      *         Copyright (C) 1987-2003 SimoTime Enterprises          *
      *                     All Rights Reserved                       *
      *****************************************************************
      *              Provided by SimoTime Enterprises                 *
      *        Our e-mail address is: helpdesk@simotime.com           *
      *     Also, visit our Web Site at http://www.simotime.com       *
      *****************************************************************
       01  QSAM-RECORD.
           05  QSAM-KEY            PIC X(6).
           05  FILLER              PIC X.
           05  QSAM-LAST-NAME      PIC X(20).
           05  QSAM-FIRST-NAME     PIC X(10).
           05  QSAM-STREET-ADDRESS PIC X(25).
           05  QSAM-CITY           PIC X(16).
           05  QSAM-STATE          PIC X(2).

Populate VSAM Data Set - COBOL Copy File for VSAM
(Next) (Previous) (Table-of-Contents)

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

      *****************************************************************
      *  Copy File for the VSAM Data Set used for the Demo programs.  *
      *****************************************************************
      *         Copyright (C) 1987-2003 SimoTime Enterprises          *
      *                     All Rights Reserved                       *
      *****************************************************************
      *              Provided by SimoTime Enterprises                 *
      *        Our e-mail address is: helpdesk@simotime.com           *
      *     Also, visit our Web Site at http://www.simotime.com       *
      *****************************************************************
       01  VSAM-RECORD.
           05  VSAM-KEY            PIC X(6).
           05  FILLER              PIC X.
           05  VSAM-LAST-NAME      PIC X(20).
           05  VSAM-FIRST-NAME     PIC X(10).
           05  VSAM-STREET-ADDRESS PIC X(25).
           05  VSAM-CITY           PIC X(16).
           05  VSAM-STATE          PIC X(2).

Delete a QSAM File
(Next) (Previous) (Table-of-Contents)

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

//QSMDELJ1 JOB SIMOTIME,ACCOUNT,CLASS=1,MSGCLASS=0,NOTIFY=CSIP1,
//             COND=(0,LT)
//* *******************************************************************
//*                   This program is provided by:                    *
//*                    SimoTime Enterprises, LLC                      *
//*           (C) Copyright 1987-2003 All Rights Reserved             *
//*                                                                   *
//*             Web Site URL:   http://www.simotime.com               *
//*                   e-mail:   helpdesk@simotime.com                 *
//* *******************************************************************
//*
//* Text   - Delete a QSAM File.
//* Author - SimoTime Enterprises
//* Date   - January 01, 1989
//*
//*                      ************
//*                      * QSMDELJ1 *
//*                      ********jcl*
//*                           *
//*                           *
//*                      ************     ************
//*                      * IEFBR14  ******* QSAM0080 *
//*                      ********utl*     ***delete***
//*                           *
//*                           *
//*                      ************
//*                      *   EOJ    *
//*                      ************
//*
//* The following step will delete the QSAM file using IEFBR14.
//* Technically speaking, IEFBR14 is not a utility program because it
//* does nothing. The name is derived from the fact that it contains
//* two assembler language instruction. The first instruction clears
//* register 15 (which sets the return code to zero) and the second
//* instruction is a BR 14 which performs an immediate return to the
//* operating system.
//*
//* IEFBR14's only purpose is to help meet the requirements that a
//* job must have at least one EXEC statement. The real purpose is to
//* allow the disposition of the DD statement to occur.
//*
//* *******************************************************************
//QSMDEL01 EXEC PGM=IEFBR14
//SYSUT2   DD  DSN=SIMOTIME.DATA.QSAM0080,DISP=(MOD,DELETE,DELETE),
//             STORCLAS=MFI,
//             SPACE=(TRK,10),
//             DCB=(RECFM=FB,LRECL=80,BLKSIZE=80,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.

Delete a VSAM, KSDS Data Set
(Next) (Previous) (Table-of-Contents)

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 Enterprises, LLC                      *
//*           (C) Copyright 1987-2003 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 Enterprises                                     *
//* 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
/*
//

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.

Summary
(Next) (Previous) (Table-of-Contents)

The purpose of this suite of programs is to provide examples for creating, populating, maintaining and deleting mainframe files and data sets.

Software Agreement and Disclaimer
(Next) (Previous) (Table-of-Contents)

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.

SimoTime Enterprises makes no warranty or representations about the suitability of the software for any purpose. It is provided "AS IS" without any express or implied warranty, including the implied warranties of merchantability, fitness for a particular purpose and non-infringement. SimoTime Enterprises 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.

Downloads and Links to Similar Pages
(Next) (Previous) (Table-of-Contents)

This document provides a quick summary of the File Status Key for VSAM data sets and QSAM files.

The SimoZAPS Utility Program has the capability of generating a COBOL program that will do the conversion of sequential and VSAM (KSDS) files between EBCDIC and ASCII. SimoZAPS can also read a sequential file in EBCDIC format and create an ASCII/CRLF file or VSAM KSDS file in ASCII format. The conversion tables may be viewed or modified to meet unique requirements.

The following is a list of sample conversion programs created by the GENERATE function of SimoZAPS.

Program Description
cble2a01 Convert from an EBCDIC-Sequential file to an ASCII-Sequential file. This example includes a mainframe JCL member.
zap00101 Convert from an EBCDIC-Sequential file to an ASCII-Text file.
zap00201 Convert from an EBCDIC-Sequential file to an ASCII-Indexed file (Sequential-Add).
zap00301 Convert from an EBCDIC-Sequential file to an ASCII-Sequential file.
zap00401 Convert from an ASCII-Text file to an EBCDIC-Indexed file (Sequential-Add).
zap00501 Convert from an ASCII-Text file to an EBCDIC-Indexed file (Random-Add).

Check out  The VSAM-QSAM Connection in the SimoTime Library for more examples of mainframe COBOL techniques and sample code.

Check out   The COBOL Connection  for more examples of mainframe COBOL coding techniques and sample code.

Check out   The JCL Connection  for more mainframe JCL examples.

Check out   The SimoTime Library  for a wide range of topics for Programmers, Project Managers and Software Developers.

To review all the information available on this site start at   The SimoTime Home Page .

Comments or Suggestions
(Next) (Previous) (Table-of-Contents)

If you have any questions, suggestions or comments please call or send an e-mail to: helpdesk@simotime.com

About SimoTime Enterprises, LLC
(Next) (Previous) (Table-of-Contents)

Founded in 1987, SimoTime Enterprises is a privately owned, Limited Liability Corporation located in Novato, California. 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. This includes the smallest thin client using the Internet and the very large mainframe systems. There is more to making the Internet work for your company's business than just having a nice looking WEB site. It is about combining the latest technologies and existing technologies with practical business experience. It's about the business of doing business and looking good in the process. 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. 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
Copyright © 1987-2008  SimoTime Enterprises, LLC  All Rights Reserved
When technology complements business