VSAM, COBOL I/O Routine
COBOL Program calls COBOL Routine
  Table of Contents  v-24.01.01 - cblcbl01.htm 
  Introduction
  Application Flowchart
  The Calling Convention
  The JCL Members
  Execute COBOL calling COBOL
  Create a new Sequential File
  Define a Cluster for a VSAM, KSDS
  Update KSDS, use the Sequential File
  Delete the Sequential File
  Delete the VSAM, KSDS
  The CMD Files
  Execute COBOL calling COBOL
  Create a new Sequential File
  Create/Load KSDS, use Sequential File
  Delete the Sequential File
  Delete the VSAM, KSDS
  The Mainline COBOL Program
  The COBOL I/O Routine
  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 mainline COBOL program calls a COBOL I/O routine to access a VSAM data set. Both COBOL programs are written using the VS COBOL II dialect and should work with COBOL for MVS and COBOL/370. A JCL member is provided to run the job as an MVS batch job on an IBM mainframe or as a project with Micro Focus Mainframe Express (MFE) running on a PC with Windows.

This program may serve as a tutorial for programmers that are new to COBOL, JCL 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-2024
SimoTime Technologies and Services
All Rights Reserved

Table of Contents Previous Section Next Section Application Flowchart

The following is a flowchart of the COBOL calling COBOL example.

             
Entry Point
ZOS
Entry Point
Windows
   
   
CBLCBLJ1
jcl
CBLCBLE1
cmd
Start the VSAM processing example
   
   
 
 
   
   
 
 
   
   
   
   
 
 
 
 
CBLCBLC1
cbl
 
 
DISPLAY
console
Call I/O Member to get a record then display to SYSOUT
   
   
   
End-of-File
   
   
Test for End-of-File
   
No
Yes
   
VKSD0080
ksds
 
 
CBLCBLC2
cbl
   
Get a record from the KSDS
   
   
   
   
   
 
 
 
 
Return
   
Return-To-Caller
   
   
   
   
EOJ
End-Of-Job
 
Overview of the a VSAM Access Technique using a callable COBOL I/O Module

Table of Contents Previous Section Next Section The Calling Convention

The following summarizes the items needed for a "caller program" (CBLCBLC1.cbl) to call a "called program" (CBLCBLC2.CBL).

The "caller program" needs the following data structure (PASS-AREA) to be defined in the WORKING-STORAGE section.

       WORKING-STORAGE SECTION.
      *****************************************************************
      *    Data Structure used for calling CBLCBLC2.
      *    The CALL statement is as follows…
      *    CALL 'CBLCBLC2' USING PASS-AREA
      *
       01  PASS-AREA.
           05  PASS-REQUEST            pic X(8).
           05  PASS-RESULT             pic S9(9)   comp.
               88  NORMAL-RESULT       value 0.
               88  COBOL-RESULT-SAME   value 8.
               88  EOF-RESULT          value 16.
           05  PASS-RECORD.
               10  PASS-KEY            pic X(6).
               10  PASS-INFO           pic X(74).

The "caller program" contains the following statement in the PROCEDURE DIVISION to make the call to the "called program".

            CALL 'CBLCBLC2' USING PASS-AREA

The "called-program" needs the following Linkage Section defined for the pass area.

       LINKAGE SECTION.
      *****************************************************************
      *    Data Structure used for passing a data string.
      *    The Procedure Division statement must also be as follows…
      *    The PROCEDURE DIVISION using PASS-AREA.
      *
       01  PASS-AREA.
           05  PASS-REQUEST            pic X(8).
           05  PASS-RESULT             pic S9(9)   comp.
               88  NORMAL-RESULT       value 0.
               88  COBOL-RESULT-SAME   value 8.
               88  EOF-RESULT          value 16.
           05  PASS-RECORD.
               10  PASS-KEY            pic X(6).
               10  PASS-INFO           pic X(74).

In addition to defining the pass area in the Linkage Section the "called program" needs the Procedure Division statement to be coded as follows.

       PROCEDURE DIVISION using PASS-AREA.

The source code listings for both the "caller program" and the "called program" are included within this document.

Table of Contents Previous Section Next Section The JCL Members

This suite of six (6) JCL members will provide the capability of creating a sequential file, defining a cluster for a KSDS, updating the KSDS with the data in the sequential file and then execute the COBOL calling COBOL to access and display the records in the KSDS. The two other JCL members are provided to delete the files.

JCL Member Description
CBLCBLJ1 Execute COBOL calling COBOL, Read and display records from a VSAM Key-Sequenced-Data-Set (KSDS)
QSMCRTJ1 Delete previously created file then Create and Populate a new Sequential File
KSDCRTJ1 Define a Cluster for a VSAM, KSDS
KSDUPDJ1 Update the VSAM, KSDS with records in the Sequential File
QSMDELJ1 Delete the Sequential File
KSDDELJ1 Delete the VSAM, KSDS
  A List of JCL Members provided in this Suite of Sample Programs for VSAM Processing

The following sub-sections will describe the preceding JCL Members in more detail.

Table of Contents Previous Section Next Section Execute COBOL calling COBOL

The following is the mainframe JCL (CBLCBLJ1.jcl) required to run the mainline program. The coding technique is used with the expectation the JCL would be used as a stand alone procedure. The job and DD statements will need to be modified for different mainframe environments.

//CBLCBLJ1 JOB SIMOTIME,ACCOUNT,CLASS=1,MSGCLASS=0,NOTIFY=CSIP1,
//             COND=(0,LT)
//* *******************************************************************
//*       CBLCBLJ1.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 calls COBOL for VSAM I/O
//* Author - SimoTime Technologies
//* Date   - January 01, 1997
//*
//* This set of programs illustrates the use of COBOL calling a COBOL
//* program to do KSDS, VSAM sequential I/O. The purpose is to show
//* sequential processing of a KSDS, VSAM Data Set.
//*
//* This set of programs may be compiled and executed on a Mainframe
//* System with ZOS or a Linux, UNIX or Windows System with Micro Focus
//* Enterprise Server.
//*
//*   ************                   ************
//*   * CBLCBLJ1 *                   * CBLCBLE1 *
//*   ********jcl*                   ********cmd*
//*        *                              *
//*        *------------------------------*
//*        *
//*   ************                   ************
//*   * CBLCBLC1 *-------------------* Display  *
//*   ********cbl*                   ************
//*        *
//*        *-------call-------------------*
//*        *                              *
//*        *                              *
//*        *        ************     ************
//*        *        * VKSD0080 *-----* CBLCBLC2 *
//*        *        ********get*     ********cbl*
//*        *
//*   ************
//*   *   EOJ    *
//*   ************
//*
//* *******************************************************************
//* Step 1 of 1, This is a single step job.
//*
//CBLCBLX1 EXEC PGM=CBLCBLC1
//STEPLIB  DD  DSN=SIMOTIME.DEMO.LOADLIB1,DISP=SHR
//VKSD0080 DD  DSN=SIMOTIME.DATA.VKSD0080,DISP=SHR
//

Table of Contents Previous Section Next Section Create a new Sequential File

The following is the mainframe JCL (QSMCRTJ1.jcl) to create a new sequential file. Also, this member will delete any previously created file.

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

Table of Contents Previous Section Next Section Define a Cluster for a VSAM, KSDS

The following is the mainframe JCL (KSDCRTJ1.jcl) to define a cluster for a VSAM Key Sequenced Data Set (or KSDS).

//KSDCRTJ1 JOB SIMOTIME,CLASS=1,MSGCLASS=0,NOTIFY=CSIP1
//* *******************************************************************
//*        This program is provided by SimoTime Technologies          *
//*           (C) Copyright 1987-2019 All Rights Reserved             *
//*             Web Site URL:   http://www.simotime.com               *
//*                   e-mail:   helpdesk@simotime.com                 *
//* *******************************************************************
//*
//* Text   - Create an empty VSAM, KSDS data set using IDCAMS.
//* Author - SimoTime Technologies
//* Date   - January 24, 1996
//*
//* This job will create a VSAM, KSDS data set. The key is 6 bytes
//* characters starting at the first position in the record.
//* The record length is 80 characters.
//*
//* This set of programs will run on a mainframe under MVS or on a
//* Personal Computer with Windows and Micro Focus Mainframe Express.
//*
//* *******************************************************************
//* Step   1   This is a single step job.
//*
//VKSDCRT1 EXEC PGM=IDCAMS
//SYSPRINT DD   SYSOUT=*
//SYSIN    DD   *
 DEFINE    CLUSTER  (NAME(SIMOTIME.DATA.VKSD0080)             -
                    TRACKS(45 15)                             -
                    RECORDSIZE(80 80)                         -
                    FREESPACE(10 15)                          -
                    KEYS(6 0)                                 -
                    INDEXED)                                  -
           DATA     (NAME(SIMOTIME.DATA.VKSD0080.DAT)         -
                    CISZ(8192))                               -
           INDEX    (NAME(SIMOTIME.DATA.VKSD0080.IDX))
/*
//*

Table of Contents Previous Section Next Section Update KSDS, use the Sequential File

The following is the mainframe JCL (KSDUPDJ1.jcl) to update the VSAM, KSDS with records from the sequential.

//KSDUPDJ1 JOB SIMOTIME,ACCOUNT,CLASS=1,MSGCLASS=0,NOTIFY=CSIP1
//* *******************************************************************
//*        This program is provided by SimoTime Technologies          *
//*           (C) Copyright 1987-2019 All Rights Reserved             *
//*             Web Site URL:   http://www.simotime.com               *
//*                   e-mail:   helpdesk@simotime.com                 *
//* *******************************************************************
//*
//* Text   -   Execute a COBOL program to read QSAM and write VSAM.
//* Author -   SimoTime Technologies
//* Date   -   January 01, 1997
//*
//* This COBOL program will read a QSAM, EBCDIC, 80-byte,
//* fixed-record-length file and update a KSDS, VSAM data set.
//*
//*                     ************
//*                     * KSDUPDJ1 *
//*                     ********jcl*
//*                          *
//*                          *
//*    ************     ************     ************
//*    * QSAM0080 *-----* KSD080C1 *-----* VKSD0080 *
//*    *******qsam*     ********cbl*     *******vsam*
//*                          *
//*                          *
//*                     ************
//*                     *   EOJ    *
//*                     ************
//*
//* *******************************************************************
//* Step   1   This is a single step job.
//*
//VSAMKSDU EXEC PGM=KSDUPDC1
//STEPLIB  DD  DISP=SHR,DSN=SIMOTIME.DEMO.LOADLIB1
//QSAM0080 DD  DISP=SHR,DSN=SIMOTIME.DATA.QSAM0080
//VKSD0080 DD  DISP=SHR,DSN=SIMOTIME.DATA.VKSD0080
//SYSOUT   DD  SYSOUT=*
//*

Table of Contents Previous Section Next Section Delete the Sequential File

The following is the mainframe JCL (QSMDELJ1.jcl) to delete the sequential file.

//QSMDELJ1 JOB SIMOTIME,CLASS=1,MSGCLASS=0,NOTIFY=CSIP1
//* *******************************************************************
//*        This program is provided by SimoTime Technologies          *
//*           (C) Copyright 1987-2019 All Rights Reserved             *
//*             Web Site URL:   http://www.simotime.com               *
//*                   e-mail:   helpdesk@simotime.com                 *
//* *******************************************************************
//*
//* Text   - Delete a Sequential File on disk using IEFBR14.
//* Author - SimoTime Technologies
//* Date   - January 24, 1996
//*
//* *******************************************************************
//*
//QSAMDELT EXEC PGM=IEFBR14
//QSAM0080 DD  DSN=SIMOTIME.DATA.QSAM0080,DISP=(MOD,DELETE,DELETE),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=FB,LRECL=80,BLKSIZE=800,DSORG=PS)
//*

Table of Contents Previous Section Next Section Delete the VSAM, KSDS

The following is the mainframe JCL (KSDDELJ1.jcl) to delete the VSAM, KSDS.

//KSDDELJ1 JOB SIMOTIME,CLASS=1,MSGCLASS=0,NOTIFY=CSIP1
//* *******************************************************************
//*        This program is provided by SimoTime Technologies          *
//*           (C) Copyright 1987-2019 All Rights Reserved             *
//*             Web Site URL:   http://www.simotime.com               *
//*                   e-mail:   helpdesk@simotime.com                 *
//* *******************************************************************
//* Subject: JCL to delete a VSAM Data Set using the IDCAMS Utility   *
//* Author:  SimoTime Technologies                                    *
//* Date:    January 1, 1998                                          *
//*-------------------------------------------------------------------*
//* The following example is more than what is usually required to    *
//* delete a VSAM Data Set. However, the purpose is to illustrate the *
//* functions of the IDCAMS utility.                                  *
//*  PURGE: A VSAM Data Set may be date-protected. The DEFINE Cluster *
//*         has the option of specifying a retention date. If this    *
//*         retention date has not expired then the PURGE option will *
//*         be required in order to delete the data set.              *
//*         The default is NOPURGE.                                   *
//*  ERASE: The standard operation by the VSAM DELETE is to delete    *
//*         the catalog entry of the cluster and mark the space used  *
//*         by the cluster as reclaimable. The data contents of the   *
//*         cluster is no longer generally available but it is still  *
//*         present until the area is reused. This introduces a       *
//*         potential problem or security exposure for sensitive data.*
//*         The information could be retrieved using some special     *
//*         class of DUMP/RESTORE utilities that are often used by    *
//*         data center staff. The ERASE function will write over the *
//*         data area used by the cluster and the original data is    *
//*         destroyed. The default is NOERASE.                        *
//*********************************************************************
//*
//         EXEC PGM=IDCAMS
//SYSPRINT DD  SYSOUT=*
//SYSIN    DD  *
 DELETE    SIMOTIME.DATA.VKSD0080   -
           FILE (VKSD0080)          -
           PURGE                    -
           ERASE                    -
           CLUSTER
 SET       MAXCC = 0
/*
//

Table of Contents Previous Section Next Section The CMD Files

This suite of five (5) Windows CMD Files will provide the capability of creating a sequential file, creating and updating the KSDS with the data in the sequential file and then execute the COBOL calling COBOL to access and display the records in the KSDS. The two other Windows CMD Files are provided to delete the files.

Table of Contents Previous Section Next Section Execute COBOL calling COBOL

The following is the Windows CMD File (CBLCBLE1.cmd) required to run the mainline program. The coding technique is used with the expectation the CMD would be used as a stand alone procedure.

@echo OFF
     set JobName=CBLCBLE1
rem  * *******************************************************************
rem  *                Job Script - a Windows Command File                *
rem  *                 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 calls COBOL for VSAM I/O
rem  * Author - SimoTime Technologies
rem  * Date   - January 01, 1997
rem  *
rem  * This set of programs illustrates the use of COBOL calling a COBOL
rem  * program to do KSDS, VSAM sequential I/O. The purpose is to show
rem  * sequential processing of a KSDS, VSAM Data Set.
rem  *
rem  * This set of programs will run on a mainframe under MVS or on a
rem  * Personal Computer with Windows and Micro Focus Mainframe Express.
rem  *
rem  *   ************                   ************
rem  *   * CBLCBLJ1 *                   * CBLCBLE1 *
rem  *   ********jcl*                   ********cmd*
rem  *        *                              *
rem  *        *------------------------------*
rem  *        *
rem  *   ************                   ************
rem  *   * CBLCBLC1 *-------------------* Display  *
rem  *   ********cbl*                   ************
rem  *        *
rem  *        *-------call-------------------*
rem  *        *                              *
rem  *        *                              *
rem  *        *        ************     ************
rem  *        *        * VKSD0080 *-----* CBLCBLC2 *
rem  *        *        ********get*     ********cbl*
rem  *        *
rem  *   ************
rem  *   *   EOJ    *
rem  *   ************
rem  *
rem  * *******************************************************************
rem  * Step 1 of 2, Set the environment.
rem  *
     call ..\Env1BASE
     if "%SYSLOG%" == "" set syslog=c:\SimoLIBR\LOGS\SimoTime.LOG
rem  *
     call SimoNOTE "*******************************************************%JobName%"
     call SimoNOTE "Starting JobName %JobName%, User is %USERNAME%"
     call SimoNOTE "Identify JobStep DeleteQSAM"
     set SYSOUT=%BaseLib1%\LOGS\SYSOUT_%JobName%.TXT
     set VKSD0080=%BaseLib1%\DATA\Asc1\SIMOTIME.DATA.CUST0080.DAT
     echo %VKSD0080%
     echo %SYSOUT%
rem  *
rem  * *******************************************************************
rem  * Step 2 of 2, COBOL calls COBOL I/O Module to read a file...
rem  *
:StepCblCblC1
     call SimoNOTE "Identify JobStep StepCblCblC1"
     run CBLCBLC1
     if ERRORLEVEL 1 echo Error level is equal-to or Greater-then 1 . . .
     if ERRORLEVEL 1 set JobStatus=0001
     if not "%JobStatus%" == "0000" goto :EojNOK
rem  *
:EojAok
     call SimoNOTE "Finished JobName %JobName%, Job Status is %JobStatus%"
     goto :End
:EojNok
     type %SYSOUT%
     call SimoNOTE "ABENDING JobName %JobName%, Job Status is %JobStatus%"
:End
     call SimoNOTE "Conclude SysLog is %SYSLOG%"
     if not "%1" == "nopause" pause

Table of Contents Previous Section Next Section Create a new Sequential File

The following is the Windows CMD File (QSMCRTE1.cmd) to create a new sequential file. Also, this member will delete any previously created file.

@echo OFF
rem  * *******************************************************************
rem  *               QSMCRTE1.CMD - a Windows Command File               *
rem  *         This program is provided by SimoTime Technologies         *
rem  *           (C) Copyright 1987-2019 All Rights Reserved             *
rem  *             Web Site URL:   http://www.simotime.com               *
rem  *                   e-mail:   helpdesk@simotime.com                 *
rem  * *******************************************************************
rem  *
rem  * Text   - Create a Sequential Data Set on disk using IEBGENER.
rem  * Author - SimoTime Technologies
rem  * Date   = January 24, 1996
rem  *
rem  * The first job step (DeleteTEXT) will delete any previously created
rem  * files.
rem  * The second job step (CreateTEXT) will create a new ASCII/Text file.
rem  * The third step will convert the Line Sequential file to a Record
rem  * Sequential file.
rem  *
rem  * This set of programs will run on a Personal Computer with Windows
rem  * and Micro Focus Net Express.
rem  *
rem  *
rem  *                      ************
rem  *                      * QSMCRTE1 *
rem  *                      ********cmd*
rem  *                           *
rem  *                           *
rem  *                      ************
rem  *                      * Env1BASE *
rem  *                      ********cmd*
rem  *                           *
rem  *                           *
rem  *                      ************     ************
rem  *                      * if exist ******* TEXT0080 *
rem  *                      ************     ***delete***
rem  *                           *
rem  *                           *
rem  *     ************     ************     ************
rem  *     *  SYSIN   *******   echo   ******* TEXT0080 *
rem  *     ********cmd*     ********utl*     *******qsam*
rem  *                           *
rem  *                           *
rem  *                      ************
rem  *                      *   EOJ    *
rem  *                      ************
rem  *
rem  * *******************************************************************
     call ..\Env1BASE
     if "%SYSLOG%" == "" set syslog=c:\SimoLIBR\LOGS\SimoTime.LOG
     set JobName=QsmCrtE1
rem  *
     call SimoNOTE "*******************************************************%JobName%"
     call SimoNOTE "Starting JobName %JobName%, v13.03.04, User is %USERNAME%"
     call SimoNOTE "Identify JobStep DeleteQSAM"
     set TEXT0080=%BaseLib1%\Data\Txt1\TEXT0080.txt
rem  *
rem  * *******************************************************************
rem  * Step   1 of 2  Create and populate a new ASCII/TEXT file...
rem  *
     call SimoNOTE "Identify JobStep Create an ASCII/Text File"
     if exist %TEXT0080% del %TEXT0080%
rem  * ..1....:....2....:....3....:....4....:....5....:....6....:....7.
     echo 000100 Anderson       Adrian    111 Peachtree Plaza     Atlanta        GA 26101 >%TEXT0080%
     echo 000200 Brown          Billie    222 Baker Boulevard     Baltimore      MD 35702 >>%TEXT0080%
     echo 000300 Carson         Cameron   333 Crenshaw Blvd.      Cupertino      CA 96154 >>%TEXT0080%
     echo 000400 Davidson       Dion      444 Main Street         Wilmington     DE 27323 >>%TEXT0080%
     echo 000500 Everest        Evan      555 5TH Avenue          New York       NY 10341 >>%TEXT0080%
     echo 000600 Franklin       Francis   666 66TH Avenue         Bedrock        NY 11903 >>%TEXT0080%
     echo 000700 Garfunkel      Gwen      777 77TH Street         New York       NY 16539 >>%TEXT0080%
     echo 000800 Harrison       Hilary    888 88TH Street         Pocatello      ID 79684 >>%TEXT0080%
     echo 000900 Isley          Isabel    999 99TH Avenue         Indianapolis   IN 38762 >>%TEXT0080%
     echo 001000 Johnson        Jamie     1010 Paradise Drive     Larkspur       CA 90504 >>%TEXT0080%
     echo 001100 Kemper         Kelly     1111 Oak Circle         Kansas City    KS 55651 >>%TEXT0080%
     echo 001200 Lemond         Lesley    1212 Lockwood Road      Mohave Desert  AZ 80303 >>%TEXT0080%
     echo 001300 Mitchell       Marlow    1313 Miller Creek Road  Anywhere       TX 77123 >>%TEXT0080%
     echo 001400 Newman         Noel      1414 Park Avenue        Santa Monica   CA 90210 >>%TEXT0080%
     echo 001500 Osborn         Owen      1515 Center Stage       Rolling Rock   PA 36613 >>%TEXT0080%
     echo 001600 Powell         Pierce    PO Box 1616             Ventura        CA 97712 >>%TEXT0080%
     echo 001700 Quigley        Quincy    1717 Farm Hill Road     Oshkosh        WI 43389 >>%TEXT0080%
     echo 001800 Ripley         Ray       1818 Alien Lane         Wayout         KS 55405 >>%TEXT0080%
     echo 001900 Smith          Sammy     1919 Carnoustie Drive   Novato         CA 94919 >>%TEXT0080%
     echo 002000 Tucker         Taylor    2020 Sanger Lane        St. Paul       MN 43998 >>%TEXT0080%
     echo 002100 Underwood      Ulysses   2121 Wall Street        New York       NY 17623 >>%TEXT0080%
     echo 002200 Van Etten      Valerie   2222 Vine Street        Hollywood      CA 98775 >>%TEXT0080%
     echo 002300 Wilson         Wiley     2323 Main Street        Boston         MA 01472 >>%TEXT0080%
     echo 002400 Xray           Xavier    2424 24TH Street        Nashville      TN 44190 >>%TEXT0080%
     echo 002500 Young          Yanni     2525 Yonge Street       Toronto        ON 6B74A6>>%TEXT0080%
     echo 002600 Zenith         Zebulon   2626 26TH Street        Dallas         TX 71922 >>%TEXT0080%
     echo 123456 Doe            John      123 Main Street         Anywhere       OR 88156 >>%TEXT0080%
     if exist %TEXT0080% call SimoNOTE "Produced DataSet %TEXT0080%"
     if not exist %TEXT0080% set JobStatus=9001
     if not %JobStatus% == 0000 goto :EojNok
rem  *
rem  * *******************************************************************
rem  * Step   2 of 2  Convert ASCII/TEXT file to Record Sequential File...
rem  *
     call SimoNOTE "Identify JobStep Convert Line Sequential to Record Sequential"
     set GETLS080=%TEXT0080%
     set PUTRS080=%BaseLib1%\Data\Asc1\SIMOTIME.DATA.QSAM0080.DAT
     if exist %PUTRS080% del %PUTRS080%
     run CV80ALAR
     if exist %PUTRS080% call SimoNOTE "Produced DataSet %PUTRS080%"
     if not exist %PUTRS080% set JobStatus=9002
     if not %JobStatus% == 0000 goto :EojNok
rem  *
:EojAok
     call SimoNOTE "Finished JobName %JobName%, Job Status is %JobStatus%"
     goto :End
:EojNok
     call SimoNOTE "NOTE ABENDING JobName %JobName%, Job Status is %JobStatus%"
:End
     call SimoNOTE "Conclude SysLog is %SYSLOG%"
     if not "%1" == "nopause" pause

Table of Contents Previous Section Next Section Create/Load KSDS, use Sequential File

The following is the Windows CMD File (KSDUPDE1.cmd) to create a new Key-Sequenced-Data-Set. This procedure will read the Record Sequential file and add the records to the Micro Focus Key-Sequenced-Data-Set.

@echo OFF
echo * KsdUpdE2 is Starting...
rem  * ************************************************************************
rem  *                 KSDUPD1.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    - Read QSAM and Update KSDS...
rem  * Author  - SimoTime Technologies
rem  * Date    - December 12, 2003
rem  * Version - 03.12.15
rem  *
rem  * This set of programs illustrates the use a COBOL program
rem  * to read a sequential file and update a VSAM, KSDS.
rem  *
rem  * The COBOL program is compiled with the ASSIGN(EXTERNAL) directive.
rem  * This provides for external file mapping of the file names.
rem  *
rem  * This set of programs will run on a Personal Computer with Windows
rem  * and Micro Focus Net Express.
rem  *
rem  *                     ************
rem  *                     * KsdUpdE2 *
rem  *                     ********cmd*
rem  *                          *
rem  *                          *
rem  *    ************     ************     ************
rem  *    * QSAM0080 ******* KsdUpdC2 ******* VKSD0080 *
rem  *    ********dat*     ********cbl*     ********ksd*
rem  *                          *
rem  *                          *
rem  *                     ************
rem  *                     *   EOJ    *
rem  *                     ************
rem  *
rem  * ********************************************************************
rem  * Step   1 of 2  Set the global environment variables...
rem  *
     call ..\Env1BASE
     if "%SYSLOG%" == "" set syslog=c:\SimoLIBR\LOGS\SimoTime.LOG
rem  *
     call SimoNOTE  "*******************************************************%CmdName%"
     call SimoNOTE  "Starting JobName %CmdName%, User is %USERNAME%
rem  * *******************************************************************"
rem  * Step   2 of 2  This is a single step job.
rem  *
     set QSAM0080=%BaseLib1%\Data\Asc1\SIMOTIME.DATA.QSAM0080.DAT
     set VKSD0080=%BaseLib1%\Data\Wrk1\VKSD0080.DAT
     run KsdUpdC1
     call SimoNOTE  "Finished JobName %CmdName%"
:End
     call SimoNOTE  "Conclude SysLog is %SYSLOG%"
     if not "%1" == "nopause" pause

Table of Contents Previous Section Next Section Delete the Sequential File

The following is the Windows CMD File (QSMDELE1.cmd) that will delete the record sequential file.

@echo OFF
rem  * *******************************************************************
rem  *               QSMDELE1.CMD - a Windows Command File               *
rem  *         This program is provided by SimoTime Technologies         *
rem  *           (C) Copyright 1987-2019 All Rights Reserved             *
rem  *             Web Site URL:   http://www.simotime.com               *
rem  *                   e-mail:   helpdesk@simotime.com                 *
rem  * *******************************************************************
rem  *
rem  * Text   - Delete the Sequential Data Sets for QSAM0080.
rem  * Author - SimoTime Technologies
rem  * Date   = January 24, 1996
rem  *
rem  * The 1st job step (DeleteTEXT) will delete TEXT0080.TXT
rem  * The 2nd job step (DeleteQSAM) will delete QSAM0080.DAT
rem  *
rem  * This set of programs will run on a Personal Computer with Windows
rem  * and Micro Focus Net Express.
rem  *
rem  * *******************************************************************
     call ..\Env1BASE
     if "%SYSLOG%" == "" set syslog=c:\SimoLIBR\LOGS\SimoTime.LOG
     set JobName=QsmDelE1
rem  *
     call SimoNOTE "*******************************************************%JobName%"
     call SimoNOTE "Starting JobName %JobName%, v13.03.04, User is %USERNAME%"
rem  *
:DeleteTEXT
     set TEXT0080=%BaseLib1%\Data\Txt1\TEXT0080.TXT
     call SimoNOTE "Identify JobStep Delete %TEXT0080%"
     if exist %TEXT0080% del %TEXT0080%
:DeleteQSAM
     set QSAM0080=%BaseLib1%\Data\Asc1\SIMOTIME.DATA.QSAM0080.DAT
     call SimoNOTE "Identify JobStep Delete %QSAM0080%"
     if exist %QSAM0080% del %QSAM0080%
rem  *
:EojAok
     call SimoNOTE "Finished JobName %JobName%, Job Status is %JobStatus%"
     goto :End
:End
     call SimoNOTE "Conclude SysLog is %SYSLOG%"
     if not "%1" == "nopause" pause

Table of Contents Previous Section Next Section Delete the VSAM, KSDS

The following is the Windows CMD File (KSDDELE1.cmd) that will delete the Micro Focus Key-Sequenced-Data-Set.

@echo OFF
echo * KsdUpdE2 is Starting...
rem  * ************************************************************************
rem  *                 KSDDELE1.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    - Read QSAM and Update KSDS...
rem  * Author  - SimoTime Technologies
rem  * Date    - December 12, 2003
rem  * Version - 03.12.15
rem  *
rem  * This set of programs illustrates the use a COBOL program
rem  * to read a sequential file and update a VSAM, KSDS.
rem  *
rem  * The COBOL program is compiled with the ASSIGN(EXTERNAL) directive.
rem  * This provides for external file mapping of the file names.
rem  *
rem  * This set of programs will run on a Personal Computer with Windows
rem  * and Micro Focus Net Express.
rem  *
rem  * ********************************************************************
rem  * Step   1 of 2  Set the global environment variables...
rem  *
     if "%SYSLOG%" == "" set syslog=c:\SimoLIBR\LOGS\SimoTime.LOG
     CmdName=KsdDelE1
     call ezSetEnv
rem  *
     call SimoNOTE  "*******************************************************%CmdName%"
     call SimoNOTE  "Starting JobName %CmdName%, User is %USERNAME%
rem  * *******************************************************************"
rem  * Step   2 of 2  This is a single step job.
rem  *
     set VKSD0080=%BaseLib1%\DataLibA\Wrk1\VKSD0080.DAT
     if exist %VKSD0080% erase %VKSD0080%
     call SimoNOTE  "Finished JobName %CmdName%"
:End
     call SimoNOTE  "Conclude SysLog is %SYSLOG%"
     if not "%1" == "nopause" pause

Table of Contents Previous Section Next Section The Mainline COBOL Program

This program (CBLCBLC1.cbl) was written to be used as a teaching and learning aid. The displays are not required and the parameters use full words. The displays would probably be removed and the request codes would probably be a single character in a production environment.

       IDENTIFICATION DIVISION.
       PROGRAM-ID.    CBLCBLC1.
       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: CBLCBLC1.CBL
      *****************************************************************
      *
      * CBLCBLC1 - Call CBLCBLC2 to access a KSDS, VSAM file.
      *
      * CALLING PROTOCOL
      * ----------------
      * Use standard procedure to RUN or ANIMATE.
      *
      * DESCRIPTION
      * -----------
      * This program will call a COBOL routine to access a
      * KSDS, VSAM file for sequential processing.
      *
      *
      *   ************
      *   * CBLCBLJ1 *
      *   ********jcl*
      *        *
      *   ************
      *   * IEFBR14  *
      *   ********utl*
      *        *
      *   ************                   ************
      *   * CBLCBLC1 *-------------------* Display  *
      *   ********cbl*                   ************
      *        *
      *        *-------call-------------------*
      *        *                              *
      *        *                              *
      *        *        ************     ************
      *        *        * QKSD001F *-----* CBLCBLC2 *
      *        *        ********get*     ********cbl*
      *        *
      *   ************
      *   *   EOJ    *
      *   ************
      *
      *
      *
      *****************************************************************
      *
      * MAINTENANCE
      * -----------
      * 1997/02/27 Simmons, Created program.
      * 1997/02/27 Simmons, No changes to date.
      *
      *****************************************************************
      *
       ENVIRONMENT DIVISION.
       DATA DIVISION.

       WORKING-STORAGE SECTION.
      *****************************************************************
      *    Data-structure for Title and Copyright...
      *    ------------------------------------------------------------
       01  SIM-TITLE.
           05  T1 pic X(11) value '* CBLCBLC1 '.
           05  T2 pic X(34) value 'Sample, COBOL calls COBOL for I/O '.
           05  T3 pic X(10) value ' v08.02.25'.
           05  T4 pic X(24) value ' http://www.simotime.com'.
       01  SIM-COPYRIGHT.
           05  C1 pic X(11) value '* CBLCBLC1 '.
           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 '* CBLCBLC1 '.
           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 '* CBLCBLC1 '.
           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  REQUEST-OPEN            pic X(8)    value 'OPEN    '.
       01  REQUEST-GET             pic X(8)    value 'GET     '.
       01  REQUEST-CLOSE           pic X(8)    value 'CLOSE   '.
       01  REQUEST-KEY             pic X(6).

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

       01  OPERATOR-MESSAGE        pic X(48).

      *****************************************************************
      *    Data Structure used for calling CBLCBLC2.
      *    The calling statement is as follows...
      *    CALL 'CBLCBLC2' USING PASS-AREA
      *
       01  PASS-AREA.
           05  PASS-REQUEST            pic X(8).
           05  PASS-RESULT             pic S9(9)   comp.
               88  NORMAL-RESULT       value 0.
               88  COBOL-RESULT-SAME   value 8.
               88  EOF-RESULT          value 16.
           05  PASS-RECORD.
               10  PASS-KEY            pic X(6).
               10  PASS-INFO           pic X(74).

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

           perform Z-POST-COPYRIGHT

           display '* CBLCBLC1 OPEN Request...'  upon console.
           perform OPEN-THE-FILE.
           display '* CBLCBLC1 OPEN Complete...' upon console.

           perform until END-OF-FILE = 'YES'
               if  END-OF-FILE = 'NO '
                   move REQUEST-GET to PASS-REQUEST
                   move REQUEST-KEY to PASS-KEY
                   perform GET-NEXT-RECORD
                   if  END-OF-FILE = 'NO '
                       display PASS-INFO upon console
                   end-if
               end-if
           end-perform.

           perform CLOSE-THE-FILE.
           display '* CBLCBLC1 has COMPLETED...' upon console

           perform Z-THANK-YOU.

           GOBACK.

      *****************************************************************
       GET-NEXT-RECORD.
           call 'CBLCBLC2' using PASS-AREA.
           if  NORMAL-RESULT
               CONTINUE
           else
               if  EOF-RESULT
                   move 'YES' to END-OF-FILE
               else
                   move '* CBLCBLC1 QKSD001F, Failure, GET...'
                     to OPERATOR-MESSAGE
                   perform Z-ABEND-MESSAGE
                   add 12 to ZERO giving RETURN-CODE
                   STOP RUN
               end-if
           end-if
           exit.
      *---------------------------------------------------------------*
       OPEN-THE-FILE.
           add 8 to ZERO giving PASS-RESULT.
           move REQUEST-OPEN to PASS-REQUEST.
           call 'CBLCBLC2' using PASS-AREA.
           if  NORMAL-RESULT
               CONTINUE
           else
               move '* CBLCBLC1 QKSD001F, Failure, OPEN...'
                 to OPERATOR-MESSAGE
               perform Z-ABEND-MESSAGE
               add 12 to ZERO giving RETURN-CODE
               STOP RUN
           end-if
           exit.
      *---------------------------------------------------------------*
       CLOSE-THE-FILE.
           add 8 to ZERO giving PASS-RESULT.
           move REQUEST-CLOSE to PASS-REQUEST.
           call 'CBLCBLC2' using PASS-AREA.
           if  NORMAL-RESULT
               CONTINUE
           else
               move '* CBLCBLC2 QKSD001F, Failure, CLOSE...'
                 to OPERATOR-MESSAGE
               perform Z-ABEND-MESSAGE
               add 12 to ZERO giving RETURN-CODE
               add 12 to RETURN-CODE
               STOP RUN
           end-if
           exit.

      *****************************************************************
      * The following Z-Routines perform administrative functions     *
      * for this program.                                             *
      *****************************************************************

      *****************************************************************
       Z-ABEND-MESSAGE.
           if  OPERATOR-MESSAGE not = SPACES
               perform Z-DISPLAY-CONSOLE-MESSAGE
           else
               move '* CBLCBLC1 is ABENDING...'  to OPERATOR-MESSAGE
               perform Z-DISPLAY-CONSOLE-MESSAGE
           end-if
           exit.

      *****************************************************************
       Z-DISPLAY-CONSOLE-MESSAGE.
           display OPERATOR-MESSAGE upon console
           move SPACES to OPERATOR-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 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 The COBOL I/O Routine

The following is the source listing for the I/O routine (CBLCBLC2.cbl). When an I/O failure occurs the file status code will be displayed. Displaying the file status code takes a little extra effort. Many times the file status code is a two character field and each character is a printable numeric value. However, in some cases the second character may be a COMP value. The error handling in the following program will display the file status code correctly for either format.

       IDENTIFICATION DIVISION.
       PROGRAM-ID.    CBLCBLC2.
       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: CBLCBLC2.CBL
      *****************************************************************
      *
      * CBLCBLC2 - This is a called routine for KSDS,VSAM file I/O.
      *
      * CALLING PROTOCOL
      * ----------------
      * USE STANDARD PROCEDURE TO RUN OR ANIMATE.
      *
      * DESCRIPTION
      * -----------
      * This program will do KSDS, VSAM file I/O.
      *
      ****************************************************************
      *
      * MAINTENANCE
      * -----------
      * 1997/02/27 Simmons, Created program.
      * 1997/04/04 Simmons, Added code to display file status.
      *
      *****************************************************************
      *
       ENVIRONMENT DIVISION.
       INPUT-OUTPUT   SECTION.
      *
       FILE-CONTROL.
      *
           SELECT VKSD0080-FILE
                  ASSIGN       to VKSD0080
                  FILE STATUS  is VKSD0080-STATUS
                  ORGANIZATION is indexed
                  ACCESS MODE  is SEQUENTIAL
                  RECORD KEY   is VKSD0080-KEY.
      *
       DATA DIVISION.
       FILE SECTION.
      *
       FD  VKSD0080-FILE.
       01  VKSD0080-RECORD.
           02  VKSD0080-KEY    pic X(6).
           02  VKSD0080-DATA   pic X(74).

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

      *****************************************************************
      * The following buffers are used to create a four-byte status   *
      * code that may be displayed.                                   *
      *****************************************************************
       01  IO-STATUS.
           05  IO-STAT1            pic X.
           05  IO-STAT2            pic X.
       01  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 '* CBLCBLC2 '.
           05  MESSAGE-TEXT.
               10  MESSAGE-TEXT-1  pic X(68)   value SPACES.
               10  MESSAGE-TEXT-2  pic X(188)  value SPACES.

       01  REQUEST-OPEN            pic X(8)    value 'OPEN    '.
       01  REQUEST-GET             pic X(8)    value 'GET     '.
       01  REQUEST-CLOSE           pic X(8)    value 'CLOSE   '.
       01  REQUEST-KEY             pic X(6).

       01  FIRST-TIME              pic X       value 'Y'.

      *****************************************************************
       LINKAGE SECTION.
      *    Data Structure used for passing the address or an address
      *    list of a data string or strings..
      *    The Procedure Division statement must also be as follows...
      *    The PROCEDURE DIVISION using PASS-AREA.
      *
       01  PASS-AREA.
           05  PASS-REQUEST            pic X(8).
           05  PASS-RESULT             pic S9(9)   comp.
               88  NORMAL-RESULT       value 0.
               88  COBOL-RESULT-SAME   value 8.
               88  EOF-RESULT          value 16.
           05  PASS-RECORD.
               10  PASS-KEY            pic X(6).
               10  PASS-INFO           pic X(74).

      *****************************************************************
       PROCEDURE DIVISION using PASS-AREA.

       MAIN-ROUTINE.

           if  FIRST-TIME not = 'N'
               perform Z-POST-COPYRIGHT
               move 'N' to FIRST-TIME
           end-if

           evaluate PASS-REQUEST
               when REQUEST-GET    perform VKSD0080-GET
               when REQUEST-OPEN   perform VKSD0080-OPEN
               when REQUEST-CLOSE  perform VKSD0080-CLOSE
               when OTHER          perform INVALID-REQUEST
           end-evaluate

           GOBACK.

      *****************************************************************
       INVALID-REQUEST.
           display '* CBLCBLC2, Invalid Request, ' PASS-REQUEST
           add 24 to ZERO giving PASS-RESULT
           exit.

      *****************************************************************
       VKSD0080-GET.
           read VKSD0080-FILE INTO PASS-RECORD
           if  VKSD0080-STATUS = '00'
               subtract PASS-RESULT from PASS-RESULT
           else
               if  VKSD0080-STATUS = '10'
                   add 16 to ZERO giving PASS-RESULT
               else
                   add 12 to ZERO giving PASS-RESULT
                   display '* CBLCBLC2 VKSD0080-Failed-READ-attempt...'
                      upon console
                   move VKSD0080-STATUS to IO-STATUS
                   perform Z-DISPLAY-IO-STATUS
               end-if
           end-if
           exit.
      *---------------------------------------------------------------*
       VKSD0080-OPEN.
           open input VKSD0080-FILE
           if  VKSD0080-STATUS = '00'
               subtract PASS-RESULT from PASS-RESULT
           else
               add 12 to ZERO giving PASS-RESULT
               display '* CBLCBLC2 VKSD0080-Failed-OPEN-attempt...'
                  upon console
               move VKSD0080-STATUS to IO-STATUS
               perform Z-DISPLAY-IO-STATUS
           end-if
           exit.
      *---------------------------------------------------------------*
       VKSD0080-CLOSE.
           close VKSD0080-FILE
           if  VKSD0080-STATUS = '00'
               subtract PASS-RESULT from PASS-RESULT
           else
               add 12 to ZERO giving PASS-RESULT
               display '* CBLCBLC2 VKSD0080-Failed-CLOSE-attempt...'
                  upon console
               move VKSD0080-STATUS to IO-STATUS
               perform Z-DISPLAY-IO-STATUS
           end-if
           exit.

      *****************************************************************
      * The following Z-Routines perform administrative functions     *
      * for this program.                                             *
      *****************************************************************

      *****************************************************************
      * 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.
      *****************************************************************
      *      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 Summary

This suite of programs provides an example of how a mainline COBOL program calls a COBOL I/O routine to access a VSAM data set. 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.

Link to Internet   Link to Server   Explore The ASCII and EBCDIC Translation Tables. These tables are provided for individuals that need to better understand the bit structures and differences of the encoding formats.

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

Table of Contents Previous Section Next Section Internet Access Required

The following links will require an internet connect.

This suite of programs and documentation is available to download for review and evaluation purposes. Other uses will require a SimoTime Software License. Link to an Evaluation zPAK Option that includes the program members, documentation and control files.

A good place to start is The SimoTime Home Page for access to white papers, program examples and product information. This link requires an Internet Connection

Explore The Micro Focus Web Site for more information about products (including Micro Focus COBOL) and services available from Micro Focus. This link requires an Internet Connection.

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 I/O Routine for VSAM, COBOL calls COBOL
Copyright © 1987-2024
SimoTime Technologies and Services
All Rights Reserved
When technology complements business
http://www.simotime.com