COBOL and VSAM
Sequential Access to a VSAM, KSDS
  Table of Contents  v-24.01.01 - cblvsm01.htm 
  Introduction
  Program Objectives
  Program Requirements
  Program Overview
  Program Input and Output
  Job Scripts
  The JCL Member
  Windows Command File
  Bash Script File
  The COBOL Program
  Ancillary Functions
  Set the Environment
  Display and Log Messages
  Create Test Files
  CMD, Create Test Files
  Bash, Create Test Files
  Summary
  Software Agreement and Disclaimer
  Downloads and Links
  Current Server or Internet Access
  Internet Access Required
  Glossary of Terms
  Contact or Feedback
  Company Overview
The SimoTime Home Page 

Table of Contents Previous Section Next Section Introduction

This suite of programs provides an example of how a single mainline COBOL program accesses a VSAM data set. The COBOL program is written using COBOL/2 dialect but also works with COBOL for MVS, COBOL/370 and COBOL for 390. Job scripts are provided to run this suite of programs on a variety of system configurations.

JCL members are provided to run the jobs as MVS or ZOS batch jobs on an IBM Mainframe System or as a project with Micro Focus Mainframe Express (MFE) running on a Windows System.

Windows Command files are provided to run the jobs as batch jobs on a Windows System using Micro Focus COBOL technology.

Bash script files are provided to run the jobs as batch jobs on a Linux System using GnuCOBOL technology. SimoTime uses Ubuntu 16.04 LTS for a Linux development and Testing environment.

The programs to create the test data files are included in this suite of programs. This program may serve as a tutorial for programmers that are new to COBOL or VSAM and as a reference for experienced programmers.


We have made a significant effort to ensure the documents and software technologies are correct and accurate. We reserve the right to make changes without notice at any time. The function delivered in this version is based upon the enhancement requests from a specific group of users. The intent is to provide changes as the need arises and in a timeframe that is dependent upon the availability of resources.

Copyright © 1987-2025
SimoTime Technologies and Services
All Rights Reserved

Table of Contents Previous Section Next Section Program Objectives

This example illustrates the following functions.

1 Describe how to read a VSAM, Keyed-Sequential-Data-Set (KSDS) in a single, COBOL program.
2 Describe how to display records to the console.
3 Describe how to display the file return code when an abnormal condition occurs.
4 Provide an example of mainframe JCL to run the job on the mainframe.
5 Provide an example of mainframe JCL to run the job on Windows using Micro Focus Mainframe Express (MFE).
6 Provide an example of a Window's CMD file to run the job on Windows using Micro Focus Net Express.
7 Maintain a single set of COBOL source code that will run on a ZOS Mainframe, Linux, Unix or Windows System.
  Submit Job, Execute a COBOL Program, Access a VSAM, KSDS

Table of Contents Previous Section Next Section Program Requirements

This suite of samples programs will run on the following platforms.

1 Executes on an IBM Mainframe running MVS or OS/390. The COBOL program complies with ANSI/85 and runs with COBOL/2, COBOL for MVS and COBOL for OS/390.
2 Executes on Windows/XP, Windows/7 or Windows Server using Micro Focus Micro Focus Studio/Server.
3 Executes on Windows/XP, Windows/7 or Windows Server using Micro Focus COBOL.
4 Executes on a Linux or UNIX platform using GnuCOBOL or Micro Focus COBOL.
  Requirements, Operating System & Supporting Software

Table of Contents Previous Section Next Section Program Overview

The following is a flowchart of the job for executing the VSAM access program.

             
Entry Point
ZOS
Entry Point
Linux
Entry Point
Windows
   
   
   
CBLVSMJ1
jcl
cblvsms1
sh
CBLVSME1
cmd
Submit the Job
   
   
 
 
   
   
 
 
   
   
VKSD0080
KSDS
 
 
CBLVSMC1
cbl
 
 
SYSOUT
spool
Read VSAM, KSDS and Write to SYSOUT
   
EOJ
End-Of-Job
 
Accessing a VSAM, KSDS from a COBOL Program

Color Associations: The  light-green  boxes are unique to SIMOTIME Technologies using an IBM Mainframe System or Micro Focus Enterprise Developer. The  light-red  boxes are unique to the SIMOTIME Technologies using a Linux, UNIX or Windows System and COBOL Technologies such as Micro Focus. The  light-yellow  boxes are SIMOTIME Technologies, Third-party Technologies, decision points or program transitions in the processing logic or program generations. The  light-blue  boxes identify the input/output data structures such as Documents, Spreadsheets, Data Files, VSAM Data Sets, Partitioned Data Set Members (PDSM's) or Relational Tables. The  light-gray  boxes identify a system function or an informational item.

Table of Contents Previous Section Next Section Program Input and Output

The input for this job is a Customer Master File. The Customer Master File is a VSAM/KSDS or Indexed File. The record length is eighty (80) bytes. The key length is six (6) bytes starting at position one (1) of each record. As each record is read the record content is displayed on the System Console or piped to a SYSOUT file.

* CBLVSMC1 Sample, COBOL for VSAM I/O         v08.01.04 http://www.simotime.com
* CBLVSMC1 Copyright 1987-2017    SimoTime Technologies     All Rights Reserved
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
* CBLVSMC1 NORMAL-END-OF-JOB...
* CBLVSMC1 Thank you for using this program provided from SimoTime Technologies
* CBLVSMC1 Please send all inquires or suggestions to the helpdesk@simotime.com

Table of Contents Previous Section Next Section Job Scripts

A job script may be defined as a text file containing job setup information followed by job steps that identify programs to be executed along with parameters unique to the job step. A job script may be created using a text editor. The naming of a job script is determined by the Operating System. A simple job script may contain a single job step that performs a single function. A typical job script will contain multiple job steps executed in a predefined sequence. The status of each job step may be tested at the end of each job step.

Table of Contents Previous Section Next Section The JCL Member

The following is the mainframe JCL (CBLVSMJ1.jcl) required to run as an MVS batch job on the mainframe. This will also run on the PC with Micro Focus Mainframe Express. The coding technique is used with the expectation the JCL would be used as a stand alone procedure.

//CBLVSMJ1 JOB SIMOTIME,ACCOUNT,CLASS=1,MSGCLASS=0,NOTIFY=CSIP1,
//             COND=(0,LT)
//* *******************************************************************
//*       CBLVSMJ1.JCL - a JCL Member for Batch Job Processing        *
//*       This JCL Member is provided by SimoTime Technologies        *
//*           (C) Copyright 1987-2019 All Rights Reserved             *
//*             Web Site URL:   http://www.simotime.com               *
//*                   e-mail:   helpdesk@simotime.com                 *
//* *******************************************************************
//*
//* Text   - COBOL for VSAM I/O
//* Author - SimoTime Technologies
//* Date   - January 01, 1997
//*
//* This set of programs illustrates the use of a COBOL program
//* to do VSAM sequential I/O. The purpose is to show the processing
//* of a VSAM Keyed Sequential Data Set (KSDS).
//*
//* This set of programs will run on a mainframe under MVS or on a
//* Personal Computer with Windows and Micro Focus Mainframe Express.
//*
//*                     ************
//*                     * CBLVSMJ1 *
//*                     ********JCL*
//*                          *
//*                          *
//*    ************     ************     ************
//*    * CUSKS080 *-----* CBLVSMC1 *-----* CONSOLE  *
//*    ********DAT*     ********CBL*     ********DAT*
//*                          *
//*                          *
//*                     ************
//*                     *   EOJ    *
//*                     ************
//*
//* *******************************************************************
//* Step 1 of 1, This is a single step job.
//*
//CBLVSMX1 EXEC PGM=CBLVSMC1
//STEPLIB  DD  DSN=SIMOTIME.DEMO.LOADLIB1,DISP=SHR
//CUSKS080 DD  DSN=SIMOTIME.DATA.VKSD0080,DISP=SHR
//SYSOUT   DD  SYSOUT=*
//*

Table of Contents Previous Section Next Section Windows Command File

The following is the Windows Command file (CBLVSME1.cmd) required to run as a batch job on a Windows System. This process was tested on a Windows System with Micro Focus Net Express.

@echo OFF
rem  * ************************************************************************
rem  *                 CBLVSME1.cmd - a Windows Command File                  *
rem  *           This program is provided by SimoTime Technologies            *
rem  *              (C) Copyright 1987-2019 All Rights Reserved               *
rem  *                Web Site URL:   http://www.simotime.com                 *
rem  *                      e-mail:   helpdesk@simotime.com                   *
rem  * ************************************************************************
rem  *
rem  * Text   - COBOL for VSAM, KSDS processing
rem  * Author - SimoTime Technologies
rem  * Date   - January 01, 1997
rem  *
rem  * This set of programs illustrates the use of COBOL programs
rem  * to do VSAM, Keyed-Sequential-Data-Set I/O.
rem  *
rem  * The COBOL programs are compiled with the ASSIGN(EXTERNAL) and
rem  * the CHARSET(EBCDIC) directives. This provides for external
rem  * file mapping of the file names. The CHARSET(EBCDIC) allows for the
rem  * processing of the EBCDIC data from the VSAM, KSDS
rem  * This technique provides for the use of a single COBOL source
rem  * program that will run on OS/390, Windows or Unix.
rem  *
rem  * This set of programs will run on a Personal Computer with Windows
rem  * and Micro Focus Net Express.
rem  *
rem  *                     ************
rem  *                     * CblVsmJ1 *
rem  *                     ********jcl*
rem  *                          *
rem  *                          *
rem  *    ************     ************     ************
rem  *    * VKSD0080 ******* CblVsmC1 ******* Console  *
rem  *    ********dat*     ********cbl*     ********crt*
rem  *                          *
rem  *                          *
rem  *                     ************
rem  *                     *   EOJ    *
rem  *                     ************
rem  *
rem  * *******************************************************************
rem  * Step   1 of 2  Set the global environment variables...
rem  *
     call ..\ENV1BASE
     set CmdName=CBLVSME1
rem  *
     call SimoNOTE "*******************************************************%CmdName%.cmd"
     call SimoNOTE "Starting JobName %CmdName%.cmd"
rem  *
     set CUSKS080=%BaseLib1%\DATA\Asc1\SIMOTIME.DATA.CUST0080.DAT
     run CBLVSMC1
     if not "%ERRORLEVEL%" == "0" set JobStatus=0010
     if not "%JobStatus%" == "0000" goto :EojNOK
     goto EojAok
:EojAOK
     call SimoNOTE "Finished CmdName %CmdName%, Job Status is %JobStatus%"
     goto :End
:EojNOK
     call SimoNOTE "ABENDING CmdName %CmdName%, Job Status is %JobStatus%"
     echo %DATE% - %TIME% Starting User ABEND Processing...>>%SYSLOG%
     set >>%SYSLOG%
     echo %DATE% - %TIME% Complete User ABEND Processing...>>%SYSLOG%
     goto :End
:End
     call SimoNOTE "Conclude SysOut is %SYSOUT%"
     if not "%1" == "nopause" pause
     exit /B %JobStatus%

Table of Contents Previous Section Next Section Bash Script File

The following is the Linux Bash Script file (cblvsms1.sh) required to run as a batch job on a Linux System. This process was tested on an Ubuntu System with GnuCOBOL.

#!/bin/bash
   JOBNAME=cblvsms1
#  *********************************************************************
#  *       Bash Script File - provided by SimoTime Technologies        *
#  *           (C) Copyright 1987-2018 All Rights Reserved             *
#  *             Web Site URL:   http://www.simotime.com               *
#  *                   e-mail:   helpdesk@simotime.com                 *
#  *********************************************************************
#  *
#  * Text   - Access a Customer Master File
#  * Author - SimoTime Technologies
#  * Date   = January 24, 1996
#  *
#  * The Customer Master File is a VSAM/KSDS or Indexed File. The
#  * record length is eighty (80) bytes. The key length is six (6)
#  * bytes starting at position one (1) of each record.
#  *
#  * Job Step   Description
#  * --------   -------------------------------------------------------*
#  * 1ST step - Execute COBOL Program, Read a previously created VSAM,
#  *            KSDS and display to console.
#  * 2ND step - Execute COBOL Program, Read a previously created VSAM,
#  *            KSDS and pipe to SYSOUT.
#  * 3RD step - End of Job Processing.
#  *
#  * This set of programs will run on a Linux System with GnuCOBOL.
#  *
#  * *******************************************************************
#  * Prepare the System Environment.
#  *
   JOBSTATUS=0
   for textstring in $(cat ENV4SYS1.txt);
   do
#      # * The following statement will replace all occurences of
#      # * DL_BASESYS1 with the $BASESYS1 environment variable.
       textstring=${textstring//DL_BASESYS1/$BASESYS1}
#      # * The following statement will replace all occurences of
#      # * DL_JOBNAME with the $JOBNAME environment variable.
       textstring=${textstring/DL_JOBNAME/$JOBNAME}
       export $textstring
       rc=$?
       if [ $rc != 0 ]
       then
          simonote.sh "#  $textstring - Return Code is $rc"
          JOBSTATUS=$rc
       fi
   done
#  *
   simonote.sh "****************************************************************$JOBNAME"
   echo "# BASESYS1........... $BASESYS1"
   echo "# SIMONOTE........... $SIMONOTE"
   echo "# COB_LIBS........... $COB_LIBS"
   echo "# COB_LIBRARY_PATH... $COB_LIBRARY_PATH"
   simonote.sh "# Starting Job Name is $JOBNAME, User is $USER, Time is $(date +'%Y/%m/%d') - $(date +'%r')"
#  *
#  * *******************************************************************
#  * Step 1 of 3, Execute COBOL Program, Read a previously created VSAM,
#  * KSDS and display to console.
#  *
#  * Note: The cobcrun command is the COBOL Run Time support for GnuCOBOL.
#  * Note: CBLVSMC1 is a COBOL program provided by SimoTime Technologies.
#  *
   simonote.sh "# StepInfo Read VSAM, KSDS and display to screen"
   export CUSKS080=$BASESYS1/SIMOSAM1/DEVL/DATA/APPL/SIMOCUST.KSDS.CUST0080.dat
   cobcrun CBLVSMC1
   rc=$?
   if [ $rc != 0 ]
   then
      simonote.sh "+ $name - Return Code is $rc"
      JOBSTATUS=$rc
      simonote.sh "# ABENDING Job Name is  $JOBNAME, Job Status is $JOBSTATUS"
      exit $JOBSTATUS
   else
      simonote.sh "# DataRead $CUSKS080"
   fi
#  *
#  * *******************************************************************
#  * Step 2 of 3, Execute COBOL Program, Read a previously created VSAM,
#  * KSDS and pipe to SYSOUT.
#  *
#  * Note: The cobcrun command is the COBOL Run Time support for GnuCOBOL.
#  * Note: CBLVSMC1 is a COBOL program provided by SimoTime Technologies.
#  *       The output produced by the DISPLAY statements will be piped to
#  *       the SYSOUT device/file.
#  *
   simonote.sh "# StepInfo Read VSAM, KSDS and pipe to SYSOUT"
   export CUSKS080=$BASESYS1/SIMOSAM1/DEVL/DATA/APPL/SIMOCUST.KSDS.CUST0080.dat
   export SYSOUT=$BASESYS1/SIMOSAM1/DEVL/LOGS/SYSOUT_BASHUSER_$JOBNAME.txt
   cobcrun CBLVSMC1>$SYSOUT
   rc=$?
   if [ $rc != 0 ]
   then
      simonote.sh "# $name - Return Code is $rc"
      JOBSTATUS=$rc
      simonote.sh "# ABENDING Job Name is  $JOBNAME, Job Status is $JOBSTATUS"
      exit $JOBSTATUS
   else
      simonote.sh "# DataRead $CUSKS080"
      simonote.sh "# DataPipe $SYSOUT"
   fi
#  *
#  * *******************************************************************
#  * Step 3 of 3, End of Job Processing...
#  *
   if [ "$JOBSTATUS" = "0" ]
   then
      simonote.sh "# Finished Job Name $JOBNAME, Time is $(date +'%Y/%m/%d') - $(date +'%r')"
   else
      simonote.sh "# ABENDING Job Name $JOBNAME, Time is $(date +'%Y/%m/%d') - $(date +'%r')"
   fi


Table of Contents Previous Section Next Section The COBOL Program

This program (CBLVSMC1.cbl) was written to be used as a teaching and learning aid. It is a simple program that reads a VSAM, Keyed-Sequential-Data-Set (KSDS) and displays the records. Notice the "Z-DISPLAY-IO-STATUS" routine to display the file status code.

       IDENTIFICATION DIVISION.
       PROGRAM-ID.    CBLVSMC1.
       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: CBLVSMC1.CBL
      *****************************************************************
      *
      * CBLVSMC1 -This is an example of a single COBOL program that
      * accesses a VSAM Keyed Sequential Data Set (KSDS).
      *
      * EXECUTION OR CALLING PROTOCOL
      * -----------------------------
      * Use standard mainframe JCL to EXECUTE or ANIMATE.
      *
      * DESCRIPTION
      * -----------
      * This program uses standard COBOL syntax to access a VSAM
      * Keyed Sequential Data Set (KSDS).
      *
      *                      ************
      *                      * CBLVSMJ1 *
      *                      ********jcl*
      *                           *
      *                           *
      *     ************     ************     ************
      *     * CUSKS080 *-----* CBLVSMC1 *-----* CONSOLE  *
      *     *******vsam*     ********cbl*     ******dsply*
      *
      *
      * REQUIREMENTS
      * ------------
      * This program was originally written to conform to the IBM,
      * COBOL II dialect but will work with COBOL for MVS or COBOL/390.
      * This program may also be executed on the PC using Mainframe
      * Express (MFE) from Micro Focus.
      *
      *****************************************************************
      *
      * MAINTENANCE
      * -----------
      * 1997/02/27 Simmons, Created program.
      * 1997/02/27 Simmons, No changes to date.
      * 1998/11/10 Simmons, Modified to conform to COBOL II.
      * 1998/11/21 Simmons, Added code to display file status when an
      *                     I/O error occurs.
      *
      *****************************************************************
      *
       ENVIRONMENT DIVISION.
       INPUT-OUTPUT SECTION.
       FILE-CONTROL.
           SELECT CUSKS080-FILE ASSIGN to CUSKS080
                  ORGANIZATION is INDEXED
                  ACCESS MODE  is SEQUENTIAL
                  RECORD KEY   is CUSKS080-KEY
                  FILE STATUS  is CUSKS080-STATUS.
      *
       DATA DIVISION.
       FILE SECTION.
       FD  CUSKS080-FILE.
       01  CUSKS080-RECORD.
           05  CUSKS080-KEY       pic X(6).
           05  CUSKS080-DATA      pic X(74).

       WORKING-STORAGE SECTION.
      *****************************************************************
      *    Data-structure for Title and Copyright...
      *    ------------------------------------------------------------
       01  SIM-TITLE.
           05  T1 pic X(11) value '* CBLVSMC1 '.
           05  T2 pic X(34) value 'Sample, COBOL for VSAM I/O        '.
           05  T3 pic X(10) value ' v08.01.04'.
           05  T4 pic X(24) value ' http://www.simotime.com'.
       01  SIM-COPYRIGHT.
           05  C1 pic X(11) value '* CBLVSMC1 '.
           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 '* CBLVSMC1 '.
           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 '* CBLVSMC1 '.
           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  CUSKS080-STATUS.
           05  CUSKS080-STAT1      pic X.
           05  CUSKS080-STAT2      pic X.

      *****************************************************************
      * The following buffers are used to create a four-byte numeric  *
      * file status code that may be displayed.                       *
      *****************************************************************
       01  IO-STATUS.
           05  IO-STAT1            pic X.
           05  IO-STAT2            pic X.
       01  TWO-BYTES-BINARY        pic 9(4) BINARY.
       01  TWO-BYTES-ALPHA         redefines TWO-BYTES-BINARY.
           05  TWO-BYTES-LEFT      pic X.
           05  TWO-BYTES-RIGHT     pic X.
       01  IO-STATUS-04.
           05  IO-STATUS-0401      pic 9   value 0.
           05  IO-STATUS-0403      pic 999 value 0.

      *****************************************************************
      *    Buffer used for posting messages to the console.
      *****************************************************************
       01  MESSAGE-BUFFER.
           05  MESSAGE-HEADER      pic X(11)   value '* CBLVSMC1 '.
           05  MESSAGE-TEXT.
               10  MESSAGE-TEXT-1  pic X(68)   value SPACES.
               10  MESSAGE-TEXT-2  pic X(188)  value SPACES.

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

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

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

           perform Z-POST-COPYRIGHT.

           perform CUSKS080-OPEN.

           perform until END-OF-FILE = 'YES'
               if  END-OF-FILE = 'NO '
                   perform CUSKS080-GET-NEXT
                   if  END-OF-FILE = 'NO '
                       display CUSKS080-RECORD upon console
                   end-if
               end-if
           end-perform.

           perform CUSKS080-CLOSE.

           move 'NORMAL-END-OF-JOB...'  to MESSAGE-TEXT
           perform Z-DISPLAY-MESSAGE-TEXT

           perform Z-THANK-YOU.

           GOBACK.

      *****************************************************************
      * I/O routines to access a KSDS, VSAM Data Set...               *
      *****************************************************************
       CUSKS080-GET-NEXT.
           read CUSKS080-FILE.
           if  CUSKS080-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
           else
               if  CUSKS080-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 'CUSKS080-FAILURE-GET-!!!' to MESSAGE-TEXT
                   perform Z-DISPLAY-MESSAGE-TEXT
                   move CUSKS080-STATUS to IO-STATUS
                   perform Z-DISPLAY-IO-STATUS
                   perform Z-ABEND-PROGRAM
               end-if
           end-if
           exit.
      *---------------------------------------------------------------*
       CUSKS080-OPEN.
           add 8 to ZERO giving APPL-RESULT.
           open input CUSKS080-FILE
           if  CUSKS080-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
           else
               add 12 to ZERO giving APPL-RESULT
           end-if
           if  APPL-AOK
               CONTINUE
           else
               move 'CUSKS080-FAILURE-OPEN-!!!' to MESSAGE-TEXT
               perform Z-DISPLAY-MESSAGE-TEXT
               move CUSKS080-STATUS to IO-STATUS
               perform Z-DISPLAY-IO-STATUS
               perform Z-ABEND-PROGRAM
           end-if
           exit.
      *---------------------------------------------------------------*
       CUSKS080-CLOSE.
           add 8 to ZERO giving APPL-RESULT.
           close CUSKS080-FILE
           if  CUSKS080-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
           else
               add 12 to ZERO giving APPL-RESULT
           end-if
           if  APPL-AOK
               CONTINUE
           else
               move 'CUSKS080-FAILURE-CLOSE-!!!' to MESSAGE-TEXT
               perform Z-DISPLAY-MESSAGE-TEXT
               move CUSKS080-STATUS to IO-STATUS
               perform Z-DISPLAY-IO-STATUS
               perform Z-ABEND-PROGRAM
           end-if
           exit.

      *****************************************************************
      * The following Z-Routines perform administrative functions
      * for this program.
      *****************************************************************
       Z-ABEND-PROGRAM.
           if  MESSAGE-TEXT not = SPACES
               perform Z-DISPLAY-MESSAGE-TEXT
           end-if
           move 'PROGRAM IS ABENDING !!!' to MESSAGE-TEXT
           perform Z-DISPLAY-MESSAGE-TEXT
           add 12 to ZERO giving RETURN-CODE
           STOP RUN.
      *    exit.

      *****************************************************************
      * Display the file status bytes. This routine will display as   *
      * four digits. If the full two byte file status is numeric it   *
      * will display as 00nn. If the 1st byte is a numeric nine (9)   *
      * the second byte will be treated as a binary number and will   *
      * display as 9nnn.                                              *
      *****************************************************************
       Z-DISPLAY-IO-STATUS.
           if  IO-STATUS not NUMERIC
           or  IO-STAT1 = '9'
               move IO-STAT1 to IO-STATUS-04(1:1)
               subtract TWO-BYTES-BINARY from TWO-BYTES-BINARY
               move IO-STAT2 to TWO-BYTES-RIGHT
               add TWO-BYTES-BINARY to ZERO giving IO-STATUS-0403
               move 'File Status is: nnnn' to MESSAGE-TEXT
               move IO-STATUS-04 to MESSAGE-TEXT(17:4)
               perform Z-DISPLAY-MESSAGE-TEXT
           else
               move '0000' to IO-STATUS-04
               move IO-STATUS to IO-STATUS-04(3:2)
               move 'File Status is: nnnn' to MESSAGE-TEXT
               move IO-STATUS-04 to MESSAGE-TEXT(17:4)
               perform Z-DISPLAY-MESSAGE-TEXT
           end-if
           exit.

      *****************************************************************
      * Display CONSOLE messages...                                   *
      *****************************************************************
       Z-DISPLAY-MESSAGE-TEXT.
           if  MESSAGE-TEXT-2 = SPACES
               display MESSAGE-BUFFER(1:79) upon console
           else
               display MESSAGE-BUFFER upon console
           end-if
           move all SPACES to MESSAGE-TEXT
           exit.

      *****************************************************************
       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 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 Ancillary Functions

This section provides additional detail about the CMD files and programs that are used to support this set of sample programs.

Table of Contents Previous Section Next Section Set the Environment

A Windows command file (ENV1BASE.cmd) is called from other command files to set commonly used environment variables. This provides a single point of definition. The following is a listing of the contents of the command file.

@echo OFF
rem  * *******************************************************************
rem  *               ENV1BASE.cmd - a Windows Command File               *
rem  *        This program is provided by SimoTime Technologies          *
rem  *           (C) Copyright 1987-2021 All Rights Reserved             *
rem  *             Web Site URL:   http://www.simotime.com               *
rem  *                   e-mail:   helpdesk@simotime.com                 *
rem  * *******************************************************************
rem  *
rem  * Text   - Provide a single point to set common environment variables.
rem  * Author - SimoTime Technologies
rem  * Date   - January 24, 1996
rem  *
rem  * Set the commonly used environment variables. This is used to provide
rem  * a single point for managing the commonly used environment variables.
rem  *
     set SimoLIBR=c:\SimoLIBR
     set BASELIB1=c:\SIMOSAM1\DEVL
     set BASELIB8=c:\SimoSAM8
     set BaseWIP1=c:\SimoSAM1\WIP1
     set DATAZERO=c:\SIMODATA\DEVL\DATA\ZERO
     set BASEAPP=%BaseLib1%
     set BASESYS=%BaseLib1%\SYS1
     set BASECAT=%BaseLib1%\DATA
     set UMAPALIB=%BASECAT%\ASC1
     set UMAPELIB=%BASECAT%\EBC1
     set SYSLOG=%BASESYS%\LOGS\SYSLOG_USER.DAT
     set SYSOUT=%BASEAPP%\LOGS\SYSOUT_SIMSAM01.txt
     set SLZMSG=%BASEAPP%\LOGS\SLZMSG_USER.TXT
     set PostNOTE=%BASEAPP%\LOGS\JOBLOG_SIMONOTE.TXT
     set SIMONOTE=%BASEAPP%\LOGS\JOBLOG_SIMONOTE.txt
     set USERPOST=%BASEAPP%\LOGS\ASSIGNED_USER_POST_FILE.txt
     if [%1]==[] goto NO_POST
     set SYSOUT=%BaseLib1%\LOGS\SYSOUT_%1.txt
     call SIMONOTE "+ ENV1BASE *"
     call SIMONOTE "+ ENV1BASE ********************************************************************%1"
     call SIMONOTE "+ ENV1BASE is preparing the System Environment..."
     call SIMONOTE "+ SIMOLIBR is %SIMOLIBR%"
     call SIMONOTE "+ MIFOSYS1 is %MIFOSYS1%"
     call SIMONOTE "+ BASELIB1 is %BASELIB1%"
:NO_POST
     call SIMONOTE "+ SIMONOTE Job Log File is %SIMONOTE% "
rem  *
     set MQBASE=C:\Program Files\IBM\WebSphere MQ
rem  *
rem  * Set the location for the Apache-Tomcat Server...
     set CATALINA_HOME=C:\APACHETC\apache-tomcat-7.0.52
rem     set CATALINA_HOME=C:\Program Files (x86)\Java\jdk1.8.0_112
rem  *
rem  * Set the Environment for the Java Environment...
rem     set JAVABASE=C:\APACHETC\apache-tomcat-7.0.52
     set JAVABASE=C:\Program Files (x86)\Java\jdk1.8.0_112
     set JAVASDK="%JAVABASE%\bin"
     set JAVA_HOME=%JAVABASE%
     set JRE_HOME=%JAVABASE%
     set SIMOTCAT=%CATALINA_HOME%\webapps\simotcat
     set SIMPACKS=%CATALINA_HOME%\webapps\simotcat\WEB-INF\classes\simpacks
rem  *
rem  * Set the environment for the Micro Focus technology...
     set MIFOEDEV=C:\Program Files (x86)\Micro Focus\Enterprise Developer
     set MIFOVCBL=C:\Program Files (x86)\Micro Focus\Visual COBOL Build Tools
     set MIFOESTU=C:\Program Files (x86)\Micro Focus\Studio Enterprise Edition 6.0
     set MIFOEMFE="C:\Program Files (x86)\Micro Focus\Mainframe Express"
rem  *
rem  * Large file support, performance tuning and record locking of the File Handler
     set EXTFH=%BASESYS%\CONFIG\EXTFHBIG.CFG
rem  *
rem  * For IMS Support
     set ES_IMSLIB=%BASEAPP%\IMSLIB
     set ES_ACBLIB=%BASEAPP%\IMSLIB
rem  *
rem  * EZASOKETS Check EZASOKETS Enabled box or set ES_EZASOKET_SUPPORT=YES
     set EZACONFG=BASESYS1\CONFIG\EZACONFG.dat
rem  *
rem  * Resource Allocation and Performance for SORT and non-Relational Data
rem  set MFJSENGINE=SYNCSORT
     set SORTSCHEME=1
     set SORTSPACE=750000000
     set TMP=C:\SORTWORK
rem  *
     set ES_ALLOC_OVERRIDE=%BASESYS%\CONFIG\CATMAPA1.cfg
rem  * For CORE_ON_ERROR function, ABEND Dump
rem  *     set COBCONFIG_=%BASESYS%\CONFIG\diagnose.cfg
rem  *
rem  * Consolidated Trace Facility (CTF)
rem  *     set MFTRACE_CONFIG=%BASESYS%\CONFIG\ctf.cfg
rem  *     set MFTRACE_LOGS=c:\ctflogs
rem  *
rem  * For Job Restart, ABEND Recovery
     set MF_UCC11=Y
     set ES_JES_RESTART=Y
rem  *
rem  * Set environment for MFBSI (Micro Focus Batch Scheduling Interface)
     set ES_EMP_EXIT_1=mfbsiemx
     set MFBSI_DIR=%BASESYS%\LOGS\%JESSERVERNAME%
     set MFBSIEOP_CMD=ENABLE
     set MFBSIEOP_CSV=ENABLE
     set MFBSIEOP_HTM=ENABLE
     set MFBSIEOP_XML=ENABLE
rem  *
rem  * Set Behavior and Trace Flags for GETJOBDD
rem  *   Position=12345678/12345678
     set JDDFLAGS=nnnWnnnn/YYnnnnnn
rem  *
rem  * If not already set then set the PATH for Micro Focus Directories
     if "%SIMOPATH%" == "Y" goto JUMPPATH
     if "%MIFOSYS1%" == "EDEV" goto JUMPEDEV
     if "%MIFOSYS1%" == "VCBL" goto JUMPVCBL
     if "%MIFOSYS1%" == "ESTU" goto JUMPESTU
     if "%MIFOSYS1%" == "EMFE" goto JUMPEMFE
:JUMPEDEV
     set path=%BASESYS%\LOADLIB;%MIFOEDEV%\bin;%JAVASDK%;%BASEAPP%\JAVA;%PATH%;
     set CobCpy=%BASEAPP%\CobCpy1;%BASEAPP%\CobCpy2;%BASEAPP%\CobCpy6;%SimoLIBR%;%MIFOEDEV%\CPYLIB
     set MIFOBASE=%MIFOEDEV%
     goto JUMPPATH
:JUMPVCBL
     set path=%MIFOVCBL%\bin;%MIFOVCBL%;%JAVASDK%;%BASEAPP%\JAVA;%PATH%;
     set MIFOBASE=%MIFOVCBL%
     goto JUMPPATH
:JUMPESTU
     set MIFOBASE=%MIFOESTU%\Base
     set MIFOBIN=%MIFOBASE%\bin
     set path=%BASESYS%\LOADLIB;%MIFOBASE%;%MIFOBIN%;%JAVASDK%;%BASEAPP%\JAVA;%PATH%;
     set CobCpy=%BASEAPP%\CobCpy1;%BASEAPP%\CobCpy2;%BASEAPP%\CobCpy6;%SimoLIBR%;%MIFOBASE%\SOURCE
     goto JUMPPATH
:JUMPEMFE
     set MIFOBASE=%MIFOEMFE%\Base
     set MIFOBIN=%MIFOBASE%\bin
     set path=%BASESYS%\LOADLIB;%MIFOBASE%;%MIFOBIN%;%JAVASDK%;%BASEAPP%\JAVA;%PATH%;
     set CobCpy=%BASEAPP%\CobCpy1;%BASEAPP%\CobCpy2;%BASEAPP%\CobCpy6;%SimoLIBR%;%MIFOBASE%\SOURCE
     goto JUMPPATH
rem  *
:JUMPPATH
     set SIMOPATH=Y
rem  *
     set MAINFRAME_FLOATING_POINT=true
     set COBIDY=%BASEAPP%\COBIDY
     set COBPATH=.;%BASEAPP%\LOADLIB;%BASEAPP%\LOADLIB\GNTS;%BASESYS%\LOADLIB;%SimoLIBR%
     set LIBPATH=.;%BASEAPP%\LOADLIB;%BASEAPP%\LOADLIB\GNTS;%BASESYS%\LOADLIB;%SimoLIBR%
     set TXDIR=%BASESYS%\LOADLIB;%MIFOBASE%
     set CobCpy=%BASEAPP%\CobCpy1;%BASEAPP%\CobCpy2;%BASEAPP%\CobCpy6;%SimoLIBR%
rem  *
     set USERCLASS=%BASELIB1%\LOADLIB
     set CLASSPATH=.
     set CLASSPATH=%CLASSPATH%;%JAVABASE%
     set CLASSPATH=%CLASSPATH%;%JAVABASE%\lib
     set CLASSPATH=%CLASSPATH%;\%USERCLASS%\simpacks
     set CLASSPATH=%CLASSPATH%;C:\APACHETC\apache-tomcat-7.0.52\webapps\simotcat\WEB-INF\classes
     set CLASSPATH=%CLASSPATH%;C:\APACHETC\apache-tomcat-7.0.52\webapps\simotcat\WEB-INF\classes\simpacks
rem  *
     if "%MIFOSYS1%" == "ESTU" set CLASSPATH=%CLASSPATH%;%MIFOBIN%
     if "%MIFOSYS1%" == "EDEV" set CLASSPATH=%CLASSPATH%;%MIFOEDEV%
     if "%MIFOSYS1%" == "VCBL" set CLASSPATH=%CLASSPATH%;%MIFOVCBL%
     if "%MIFOSYS1%" == "VCBL" set CLASSPATH=%CLASSPATH%;%MIFOVCBL%\bin\mfcobol.jar
rem  *
     set JobStatus=0000
     call SIMONOTE "+ ENV1BASE is returning to caller"


Table of Contents Previous Section Next Section Display and Log Messages

The following (SIMONOTE.cmd) is a listing of the contents of the SimoNOTE.CMD command file.

@echo OFF
rem  * *******************************************************************
rem  *               SIMONOTE.cmd - a Windows Command File               *
rem  *         This program is provided by SimoTime Technologies         *
rem  *            (C) Copyright 1987-2019 All Rights Reserved            *
rem  *              Web Site URL:   http://www.simotime.com              *
rem  *                    e-mail:   helpdesk@simotime.com                *
rem  * *******************************************************************
rem  *
rem  * Text    - Display message on screen and write to a log file.
rem  * Author  - SimoTime Technologies
rem  *
rem  * This script may be called from other scripts and expects a single
rem  * parameter enclosed in double quotes. The double quotes will be
rem  * removed. Before writing to the log file a date and time stamp
rem  * will be inserted in front of the message text.
rem  *
rem  * Note: The tilde (~) removes leading/trailing double-quotes.
rem  *
if "%SimoNOTE%" == "" set SimoNOTE=c:\SimoLIBR\LOGS\SimoTime.LOG
echo %date% %time% %~1>> %SimoNOTE%
echo %~1

Table of Contents Previous Section Next Section Create Test Files

This suite of programs will create various files containing customer data. The customer data is arranged in 80 byte records and the customer number (or key) is 6 bytes starting in the first position of each record.

Table of Contents Previous Section Next Section CMD, Create Test Files

This Windows CMD file (CBLVSME8.cmd) will use the Windows ECHO Command to create an ASCII/Text (or Line Sequential) file. The ASCII/Text file will then be used to create an ASCII-encoded sequential file and an EBCDIC-encoded sequential file. The ASCII-encoded sequential file will be used to create an ASCII-encoded VSAM Key-Sequenced-Data-Set (KSDS).

@echo OFF
rem  * ************************************************************************
rem  *                 CBLVSME8.cmd - a Windows Command File                  *
rem  *           This program is provided by SimoTime Technologies            *
rem  *              (C) Copyright 1987-2019 All Rights Reserved               *
rem  *                Web Site URL:   http://www.simotime.com                 *
rem  *                      e-mail:   helpdesk@simotime.com                   *
rem  * ************************************************************************
rem  *
rem  * Text   - Create various sequential files with 80-byte records.
rem  * Author - SimoTime Technologies
rem  * Date   - January 24, 1996
rem  *
rem  * This procedure uses the Microsoft "ECHO" command to pipe instream
rem  * data to an ASCII/Text file. The following terms are used.
rem  *
rem  * LSEQ - a Line Sequential File or ASCII/Text File
rem  * RSEQ - a Record Sequential File. This example uses a file of
rem  *        80-byte records that may be ASCII or EBCDIC encoded.
rem  * KSDS - a VSAM Key-Sequenced-Data-Set.
rem  *
rem  * 1. Use the Windows "ECHO" Create an LSEQ file to be used as input to
rem  *    create additional files.
rem  * 2. Read the LSEQ file and write an RSEQ, ASCII File.
rem  * 3. Read the LSEQ file and write an RSEQ, EBCDIC File.
rem  * 4. Read the RSEQ, ASCII file and write a KSDS, ASCII File.
rem  *
rem  * *******************************************************************
rem  * Step 1, Delete any previously created file...
rem  *
     call ..\ENV1BASE
     set CmdName=CBLVSME8
rem  *
     call SimoNOTE "*******************************************************%CmdName%.cmd"
     call SimoNOTE "Starting JobName %CmdName%"
:DeleteLSEQ
     call SimoNOTE "Identify JobStep DeleteLSEQ"
     set LSEQ0080=%BaseLib1%\DATA\Txt1\LSEQ0080.TXT
     if exist %LSEQ0080% del %LSEQ0080%
rem  *
rem  * *******************************************************************
rem  * Step 2, Create a new output file. Use the "echo" command provided
rem  *         with Microsoft Windows to pipe instream data to a new
rem  *         ASCII/Text file.
rem  *
:ExecuteCreateLSEQ
     call SimoNOTE "Identify JobStep ExecuteCreateLSEQ"
rem  ....:....1....:....2....:....3....:....4....:....5....:....6....:....7....:....8
echo 000100 Anderson       Adrian    111 Peachtree Plaza     Atlanta        GA 26101 >%LSEQ0080%
echo 000200 Brown          Billie    222 Baker Boulevard     Baltimore      MD 35702 >>%LSEQ0080%
echo 000300 Carson         Cameron   333 Crenshaw Blvd.      Cupertino      CA 96154 >>%LSEQ0080%
echo 000400 Davidson       Dion      444 Main Street         Wilmington     DE 27323 >>%LSEQ0080%
echo 000500 Everest        Evan      555 5TH Avenue          New York       NY 10341 >>%LSEQ0080%
echo 000600 Franklin       Francis   666 66TH Avenue         Bedrock        NY 11903 >>%LSEQ0080%
echo 000700 Garfunkel      Gwen      777 77TH Street         New York       NY 16539 >>%LSEQ0080%
echo 000800 Harrison       Hilary    888 88TH Street         Pocatello      ID 79684 >>%LSEQ0080%
echo 000900 Isley          Isabel    999 99TH Avenue         Indianapolis   IN 38762 >>%LSEQ0080%
echo 001000 Johnson        Jamie     1010 Paradise Drive     Larkspur       CA 90504 >>%LSEQ0080%
echo 001100 Kemper         Kelly     1111 Oak Circle         Kansas City    KS 55651 >>%LSEQ0080%
echo 001200 Lemond         Lesley    1212 Lockwood Road      Mohave Desert  AZ 80303 >>%LSEQ0080%
echo 001300 Mitchell       Marlow    1313 Miller Creek Road  Anywhere       TX 77123 >>%LSEQ0080%
echo 001400 Newman         Noel      1414 Park Avenue        Santa Monica   CA 90210 >>%LSEQ0080%
echo 001500 Osborn         Owen      1515 Center Stage       Rolling Rock   PA 36613 >>%LSEQ0080%
echo 001600 Powell         Pierce    PO Box 1616             Ventura        CA 97712 >>%LSEQ0080%
echo 001700 Quigley        Quincy    1717 Farm Hill Road     Oshkosh        WI 43389 >>%LSEQ0080%
echo 001800 Ripley         Ray       1818 Alien Lane         Wayout         KS 55405 >>%LSEQ0080%
echo 001900 Smith          Sammy     1919 Carnoustie Drive   Novato         CA 94919 >>%LSEQ0080%
echo 002000 Tucker         Taylor    2020 Sanger Lane        St. Paul       MN 43998 >>%LSEQ0080%
echo 002100 Underwood      Ulysses   2121 Wall Street        New York       NY 17623 >>%LSEQ0080%
echo 002200 Van Etten      Valerie   2222 Vine Street        Hollywood      CA 98775 >>%LSEQ0080%
echo 002300 Wilson         Wiley     2323 Main Street        Boston         MA 01472 >>%LSEQ0080%
echo 002400 Xray           Xavier    2424 24TH Street        Nashville      TN 44190 >>%LSEQ0080%
echo 002500 Young          Yanni     2525 Yonge Street       Toronto        ON 6B74A6>>%LSEQ0080%
echo 002600 Zenith         Zebulon   2626 26TH Street        Dallas         TX 71922 >>%LSEQ0080%
echo 123456 Doe            John      123 Main Street         Anywhere       OR 88156 >>%LSEQ0080%
rem  *
     if not exist %LSEQ0080% set JobStatus=0002
     if not "%JobStatus%" == "0000" goto EojNok
     call SimoNOTE "Produced DataSet %LSEQ0080%"
rem  *
:ConvertLSEQtoRSEQasc
rem  *
rem  * *******************************************************************
rem  * Step 3, Read the previously created Line Sequential File (LSEQ)
rem  *         and write a Record Sequential File (RSEQ) with 80-byte,
rem  *         ASCII-encoded records.
rem  *         Note: The convert program (CV80ALAR) was generated using
rem  *               SimoTime Technology.
rem  *
     call SimoNOTE "Identify JobStep ConvertLSEQtoRSEQasc"
     set GETLS080=%LSEQ0080%
     set PUTRS080=%BaseLib1%\DATA\Asc1\SIMOTIME.DATA.QSAM0080.DAT
     if exist %PUTRS080% del %PUTRS080%
     run CV80ALAR
     if not exist %PUTRS080% set JobStatus=0003
     if not "%JobStatus%" == "0000" goto EojNok
     call SimoNOTE "Produced DataSet %PUTRS080%"
rem  *
:ConvertLSEQtoRSEQebc
rem  *
rem  * *******************************************************************
rem  * Step 4, Read the previously created Line Sequential File (LSEQ)
rem  *         and write a Record Sequential File (RSEQ) with 80-byte,
rem  *         EBCDIC-encoded records.
rem  *         Note: The convert program (CV80ALER) was generated using
rem  *               SimoTime Technology.
rem  *
     call SimoNOTE "Identify JobStep ConvertLSEQtoRSEQebc"
     set GETLS080=%LSEQ0080%
     set PUTRS080=%BaseLib1%\DATA\Ebc1\SIMOTIME.DATA.QSAM0080.DAT
     if exist %PUTRS080% del %PUTRS080%
     run CV80ALER
     if not exist %PUTRS080% set JobStatus=0004
     if not "%JobStatus%" == "0000" goto EojNok
     call SimoNOTE "Produced DataSet %PUTRS080%"
rem  *
:ConvertLSEQtoRSEQebc
rem  *
rem  * *******************************************************************
rem  * Step 5, Read a previously created Record Sequential File (RSEQ),
rem  *         write a VSAM, KSDS  with 80-byte, ASCII-encoded records.
rem  *         Note: The convert program (KSLOADC1) was generated using
rem  *               SimoTime Technology.
rem  *
     call SimoNOTE "Identify JobStep ConvertRSEQtoKSDS"
     set QSAM0080=%BaseLib1%\DATA\Asc1\SIMOTIME.DATA.QSAM0080.DAT
     set KSDS0080=%BaseLib1%\DATA\Asc1\SIMOTIME.DATA.CUST0080.DAT
     if exist %KSDS0080% del %KSDS0080%
     run KSLOADC1
     if not exist %KSDS0080% set JobStatus=0004
     if not "%JobStatus%" == "0000" goto EojNok
     call SimoNOTE "Produced DataSet %KSDS0080%"
rem  *
rem  * *******************************************************************
rem  *
:EojAok
     call SimoNOTE "Finished JobName %CmdName%, Job Status is %JobStatus%"
     goto :End
:EojNok
     call SimoNOTE "ABENDING JobName %CmdName%, Job Status is %JobStatus%"
:End
     call SimoNOTE "Conclude SysLog is %SYSLOG%"
     if not "%1" == "nopause" pause

Table of Contents Previous Section Next Section Bash, Create Test Files

This Bash Script file (cblvsms8.sh) will use the Linux ECHO Command to create an ASCII/Text (or Line Sequential) file. The ASCII/Text file will then be used to create an ASCII-encoded record sequential file and an EBCDIC-encoded record sequential file. The ASCII-encoded record sequential file will be used to create an ASCII-encoded VSAM Key-Sequenced-Data-Set (KSDS).

#!/bin/bash
   JOBNAME=cblvsms8
#  *********************************************************************
#  *       Bash Script File - provided by SimoTime Technologies        *
#  *           (C) Copyright 1987-2018 All Rights Reserved             *
#  *             Web Site URL:   http://www.simotime.com               *
#  *                   e-mail:   helpdesk@simotime.com                 *
#  *********************************************************************
#  *
#  * Text   - Create a Customer Master File
#  * Author - SimoTime Technologies
#  * Date   = January 24, 1996
#  *
#  * The Customer Master File is a VSAM/KSDS or Indexed File. The
#  * record length is eighty (80) bytes. The key length is six (6)
#  * bytes starting at position one (1) of each record.
#  *
#  * Job Step   Description
#  * --------   -------------------------------------------------------*
#  * 1ST step - Linux echo command, Create and populate a new ASCII/TEXT file.
#  * 2ND step - COBOL Program, Convert ASCII/TEXT file to ASCII RSEQ File.
#  * 3RD step - COBOL Program, Convert ASCII/TEXT file to EBCDIC RSEQ File.
#  * 4TH step - COBOL Program, Read the previously created ASCII-encoded
#  *            Record Sequential File (RSEQ) and Load or Populate an
#  *            ASCII-encoded VSAM/KSDS or Indexed File.
#  * 5TH step - End of Job Processing.
#  *
#  * This batch job will run on a Linux System with GnuCOBOL.
#  *
#  * *******************************************************************
#  * Prepare the System Environment.
#  *
   JOBSTATUS=0
   for textstring in $(cat ENV4SYS1.txt);
   do
#      # * The following statement will replace all occurences of
#      # * DL_BASESYS1 with the $BASESYS1 environment variable.
       textstring=${textstring//DL_BASESYS1/$BASESYS1}
#      # * The following statement will replace all occurences of
#      # * DL_JOBNAME with the $JOBNAME environment variable.
       textstring=${textstring/DL_JOBNAME/$JOBNAME}
       export $textstring
       rc=$?
       if [ $rc != 0 ]
       then
          simonote.sh "#  $textstring - Return Code is $rc"
          JOBSTATUS=$rc
       fi
   done
#  *
   simonote.sh "****************************************************************$JOBNAME"
   echo "# BASESYS1........... $BASESYS1"
   echo "# SIMONOTE........... $SIMONOTE"
   echo "# COB_LIBS........... $COB_LIBS"
   echo "# COB_LIBRARY_PATH... $COB_LIBRARY_PATH"
   simonote.sh "# Starting Job Name is $JOBNAME, User is $USER, Time is $(date +'%Y/%m/%d') - $(date +'%r')"
   simonote.sh "# StepInfo Delete previously created files"
#  *
#  * *******************************************************************
#  * Step 1 of 5, Linux echo command, Create and populate a new ASCII/TEXT file
#  *
   simonote.sh "# StepInfo Create an ASCII/Text File"
   export GETLS080=$BASESYS1/SIMOSAM1/DEVL/DATA/TXT1/SIMOCUST.LSEQ.CUST0080.txt
   if [ -f "$GETLS080" ]
   then
      rm $GETLS080
   fi
#  * ..1....:....2....:....3....:....4....:....5....:....6....:....7.
echo "000100 Anderson       Adrian    111 Peachtree Plaza     Atlanta        GA 26101 ">$GETLS080
echo "000200 Brown          Billie    222 Baker Boulevard     Baltimore      MD 35702 ">>$GETLS080
echo "000300 Carson         Cameron   333 Crenshaw Blvd.      Cupertino      CA 96154 ">>$GETLS080
echo "000400 Davidson       Dion      444 Main Street         Wilmington     DE 27323 ">>$GETLS080
echo "000500 Everest        Evan      555 5TH Avenue          New York       NY 10341 ">>$GETLS080
echo "000600 Franklin       Francis   666 66TH Avenue         Bedrock        NY 11903 ">>$GETLS080
echo "000700 Garfunkel      Gwen      777 77TH Street         New York       NY 16539 ">>$GETLS080
echo "000800 Harrison       Hilary    888 88TH Street         Pocatello      ID 79684 ">>$GETLS080
echo "000900 Isley          Isabel    999 99TH Avenue         Indianapolis   IN 38762 ">>$GETLS080
echo "001000 Johnson        Jamie     1010 Paradise Drive     Larkspur       CA 90504 ">>$GETLS080
echo "001100 Kemper         Kelly     1111 Oak Circle         Kansas City    KS 55651 ">>$GETLS080
echo "001200 Lemond         Lesley    1212 Lockwood Road      Mohave Desert  AZ 80303 ">>$GETLS080
echo "001300 Mitchell       Marlow    1313 Miller Creek Road  Anywhere       TX 77123 ">>$GETLS080
echo "001400 Newman         Noel      1414 Park Avenue        Santa Monica   CA 90210 ">>$GETLS080
echo "001500 Osborn         Owen      1515 Center Stage       Rolling Rock   PA 36613 ">>$GETLS080
echo "001600 Powell         Pierce    PO Box 1616             Ventura        CA 97712 ">>$GETLS080
echo "001700 Quigley        Quincy    1717 Farm Hill Road     Oshkosh        WI 43389 ">>$GETLS080
echo "001800 Ripley         Ray       1818 Alien Lane         Wayout         KS 55405 ">>$GETLS080
echo "001900 Smith          Sammy     1919 Carnoustie Drive   Novato         CA 94919 ">>$GETLS080
echo "002000 Tucker         Taylor    2020 Sanger Lane        St. Paul       MN 43998 ">>$GETLS080
echo "002100 Underwood      Ulysses   2121 Wall Street        New York       NY 17623 ">>$GETLS080
echo "002200 Van Etten      Valerie   2222 Vine Street        Hollywood      CA 98775 ">>$GETLS080
echo "002300 Wilson         Wiley     2323 Main Street        Boston         MA 01472 ">>$GETLS080
echo "002400 Xray           Xavier    2424 24TH Street        Nashville      TN 44190 ">>$GETLS080
echo "002500 Young          Yanni     2525 Yonge Street       Toronto        ON 6B74A6">>$GETLS080
echo "002600 Zenith         Zebulon   2626 26TH Street        Dallas         TX 71922 ">>$GETLS080
echo "123456 Doe            John      123 Main Street         Anywhere       OR 88156 ">>$GETLS080
#  *
   if [ -f "$GETLS080" ]
   then
     simonote.sh "# CUST0080 is $GETLS080"
   else
     simonote.sh "# ABENDING File not created, $GETLS080"
     exit 9001
   fi
#  *
#  * *******************************************************************
#  * Step 2 of 5, COBOL Program, Convert ASCII/TEXT file to ASCII RSEQ File
#  *
#  * Note: The cobcrun command is the COBOL Run Time support for GnuCOBOL.
#  * Note: CV80ALAR is a convert program provided by SimoTime Technologies.
#  *
   simonote.sh "# StepInfo Convert Line Sequential to ASC Record Sequential"
   export PUTRS080=$BASESYS1/SIMOSAM1/DEVL/DATA/APPL/SIMOCUST.RSEQ.CUST0080.dat
   if [ -f "$PUTRS080" ]
   then
      rm $PUTRS080
   fi
   cobcrun CV80ALAR
   rc=$?
   if [ $rc != 0 ]
   then
      simonote.sh "# $name - Return Code is $rc"
      JOBSTATUS=$rc
      simonote.sh "# ABENDING Job Name is  $JOBNAME, Job Status is $JOBSTATUS"
      exit $JOBSTATUS
   else
      simonote.sh "# DataTake $GETLS080"
      simonote.sh "# DataMake $PUTRS080"
   fi
#  *
#  * *******************************************************************
#  * Step 3 of 5, COBOL Program, Convert ASCII/TEXT file to EBCDIC RSEQ File...
#  *
#  * Note: The cobcrun command is the COBOL Run Time support for GnuCOBOL.
#  * Note: CV80ALER is a convert program provided by SimoTime Technologies.
#  *
   simonote.sh "# StepInfo Convert Line Sequential to EBC Record Sequential"
   export PUTRS080=$BASESYS1/SIMOSAM1/DEVL/DATA/EBC1/SIMOCUST.RSEQ.CUST0080.dat
   if [ -f "$PUTRS080" ]
   then
      rm $PUTRS080
   fi
   cobcrun CV80ALER
   rc=$?
   if [ $rc != 0 ]
   then
      simonote.sh "# $name - Return Code is $rc"
      JOBSTATUS=$rc
      simonote.sh "# ABENDING Job Name is  $JOBNAME, Job Status is $JOBSTATUS"
      exit $JOBSTATUS
   else
      simonote.sh "# DataTake $GETLS080"
      simonote.sh "# DataMake $PUTRS080"
   fi
#  *
#  * *******************************************************************
#  * Step 4 of 5, COBOL Program, Read the previously created ASCII-encoded
#  * Record Sequential File (RSEQ) and Load the ASCII-encoded KSDS.
#  *
#  * Note: The cobcrun command is the COBOL Run Time support for GnuCOBOL.
#  * Note: KS80MKC1 is a convert program provided by SimoTime Technologies.
#  *
   simonote.sh "# StepInfo Convert RSEQ to KSDS"
   export SYSUT1=$BASESYS1/SIMOSAM1/DEVL/DATA/APPL/SIMOCUST.RSEQ.CUST0080.dat
   export SYSUT2=$BASESYS1/SIMOSAM1/DEVL/DATA/APPL/SIMOCUST.KSDS.CUST0080.dat
   if [ -f "$SYSUT2" ]
   then
      rm $SYSUT2
   fi
   cobcrun KS80MKC1
   rc=$?
   if [ $rc != 0 ]
   then
      simonote.sh "# $name - Return Code is $rc"
      JOBSTATUS=$rc
      simonote.sh "# ABENDING Job Name is  $JOBNAME, Job Status is $JOBSTATUS"
      exit $JOBSTATUS
   else
      simonote.sh "# DataTake $SYSUT1"
      simonote.sh "# DataMake $SYSUT2"
   fi
#  *
#  * *******************************************************************
#  * Step 5 of 5, End of Job Processing...
#  *
   if [ "$JOBSTATUS" = "0" ]
   then
      simonote.sh "# Finished Job Name $JOBNAME, Time is $(date +'%Y/%m/%d') - $(date +'%r')"
   else
      simonote.sh "# ABENDING Job Name $JOBNAME, Time is $(date +'%Y/%m/%d') - $(date +'%r')"
   fi


Table of Contents Previous Section Next Section Summary

The purpose for this document is to show how a singe COBOL program can process a VSAM Key Sequenced Data Set or KSDS. This document may be used to assist as a tutorial for new programmers or as a quick reference for experienced programmers.

In the world of programming there are many ways to solve a problem. This documentation and software were developed and tested on systems that are configured for a SIMOTIME environment based on the hardware, operating systems, user requirements and security requirements. Therefore, adjustments may be needed to execute the jobs and programs when transferred to a system of a different architecture or configuration.

SIMOTIME Services has experience in moving or sharing data or application processing across a variety of systems. For additional information about SIMOTIME Services or Technologies please contact us using the information in the  Contact or Feedback  section of this document.

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 COBOL calls Assembler for VSAM, KSDS Access for an example of a COBOL program calling an Assembler I/O routine. The COBOL program is written using the COBOL/2 dialect but also work with COBOL for MVS and COBOL/370. The Assembler program was written using Assembler/H on the mainframe.

Link to Internet   Link to Server   Explore COBOL calls COBOL for VSAM, KSDS Access for an example of a COBOL program calling a COBOL I/O routine. The COBOL programs are written using the COBOL/2 dialect but also work with COBOL for MVS and COBOL/370.

Link to Internet   Link to Server   Explore How to Define a VSAM Data Set using IDCAMS. This example will describe how to create and populate a VSAM, KSDS (or Key-Sequenced-Data-Set).

Link to Internet   Link to Server   Explore the JCL Connection for more examples of JCL functionality with programming techniques and sample code.

Link to Internet   Link to Server   Explore the COBOL Connection for more examples of COBOL programming techniques and sample code.

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 connection.

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.

Explore the GnuCOBOL Technologies available from SourceForge. SourceForge is an Open Source community resource dedicated to helping open source projects be as successful as possible. GnuCOBOL (formerly OpenCOBOL) is a COBOL compiler with run time support. The compiler (cobc) translates COBOL source to executable using intermediate C, designated C compiler and linker. This link will require 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 Contact 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
COBOL and VSAM, access a VSAM Key Sequenced Data Set (KSDS)
Copyright © 1987-2025
SimoTime Technologies and Services
All Rights Reserved
When technology complements business
http://www.simotime.com