Customer Master File
When technology complements business   Create and Update in Batch Mode
Copyright © 1987-2008  SimoTime Enterprises, LLC  All Rights Reserved http://www.simotime.com

 
Introduction Version 07.02.15
 
  Programming Objectives
  Programming Requirements
  Programming Overview
  JCL to Manage a Customer Master File
 
  JCL to Define the Cluster for the Customer Master File
  JCL to Populate Customer Master by Individual Fields
 
  JCL to Create a Sequential File with Customer Data (Field Level)
  JCL to Update the Customer Master File (Field Level)
  JCL to Populate Customer Master by Individual Records
 
  JCL to Create a Sequential File with Customer Data (Record Reformatting)
  JCL to Update the Customer Master File (Record Reformatting)
  JCL to Extract Data from Customer Master File for use by Microsoft Excel
  COBOL Program Listings
 
  COBOL, Update the Customer Master File by Individual Fields
  COBOL, Update the Customer Master File (Record Reformatting)
  COBOL, Extract Data from Customer Master File for use by Microsoft Excel
  COBOL, Convert a Customer Master File (from EBCDIC to ASCII)
  COBOL, Convert File Format, Record-Sequential to Line-Sequential
  COBOL, Convert File Format & Content, Record-Sequential to Line-Sequential, EBCDIC to ASCII
  Summary
 
  Software Agreement and Disclaimer
  Downloads and Links to Similar Pages
  Glossary of Terms
  Comments or Suggestions
  About SimoTime

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

Many of the sample programs provided by SimoTIme Enterprises use a "Customer Master File" to get data that is used to demonstrate various processing or data accessing techniques. This suite of sample programs describes how to create this "Customer Master File". On the IBM Mainframe the Customer Master File is an EBCDIC-encoded VSAM Keyed Sequential Data Set (referred to as KSDS). On a Windows or UNIX System using Micro Focus the Customer Master File is an Indexed File or Key Sequenced File. In the Micro Focus world on Windows or UNIX the file content may be EBCDIC or ASCII encoded.

The Customer Master file contains variable length records with the minimum and avrage record length being the same length of 512 bytes. The key startis in the first position of the record and is 12 bytes in length. The record layout is defined in a COBOL copy file and contains text strings and various numeric formats including zoned-decimal, packed and binary.

Programming Objectives
(Next) (Previous) (Table-of-Contents)

This suite of programs will illustratesthe following functions.

1. Demonstrate how to create (or define) a cluster for a VSAM, Key-Sequenced-Data-Set (or KSDS) using JCL and IDCAMS.
2. Demonstrate how to create a sequential file using the IEBGENER Utility program and JCL with instream data.
3. Demonstrate how to read a record sequential file (or a Line Sequential file) and update existing records or add new records to a mainframe VSAM, KSDS or Micro Focus Indexed File.
4. Demonstrate how to use a COBOL copy file to define the record layout..
5. Demonstrate how to convert an EBCDIC-encoded Customer Master file to an ASCII-encoded Customer Master file.
6. Demonstate how to extract data from the Customer Master file and create a Comma-Separated-Values (CSV) file for exporting data to be used in an Microsoft excel spread sheet. This will expand (or convert) packed and binary numeric fields.

Programming Requirements
(Next) (Previous) (Table-of-Contents)

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

1. Executes on Windows/XP using Micro Focus Mainframe Express or Enterprise Server in both EBCDIC or ASCII encoded configurations.
2. May be ported to run on the UNIX platforms supported by Micro Focus Enterprise Server with ES/MTO and the Batch Facility.

Programming Overview
(Next) (Previous) (Table-of-Contents)

The following describes the process flow for the jobs to be submitted to create the Customer Master File with 26 records

1. Run the job that creates the Customer Master File without data.
2. Run the job that creates a Sequential file with customer information.
3. Run the job that loads records into the Customer Master File based on the information in the sequential file.

JCL to Manage a Customer Master File
(Next) (Previous) (Table-of-Contents)

The JCL provided with this suite of programs will run in a Mainframe-Oriented Environment. The term "Mainframe-Oriented Environment" is used to refer to the following.

1. An actual ZOS Mainframe System
2. A Micro Focus Mainframe Express sub-system running on a Windows System.
3. A Micro Focus Enterprise Server running on a Windows or UNIX System.

JCL to Define the Cluster for the Customer Master File
(Next) (Previous) (Table-of-Contents)

The following (CUCRTJ01.JCL) is a listing of the JCL member that may be used to create the Customer Master File.

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

JCL to Populate Customer Master by Individual Fields
(Next) (Previous) (Table-of-Contents)

The following two JCL members will create a sequential file with each record containing a field identifier, a customer number and a string of data. The sequential file will then be read and the information will be used to update fields within records of the Customer Master File.

JCL to Create a Sequential File with Customer Data (Field Level)
(Next) (Previous) (Table-of-Contents)

The following (CUCSQJ01.JCL) is a listing of the JCL member that may be used to create a sequential file using instream data. The sequential file may be used to update the Customer Master File.

//CUCSQJ01 JOB SIMOTIME,CLASS=1,MSGCLASS=0,NOTIFY=CSIP1
//* *******************************************************************
//*                   This program is provided by:                    *
//*                    SimoTime Enterprises, LLC                      *
//*           (C) Copyright 1987-2005 All Rights Reserved             *
//*             Web Site URL:   http://www.simotime.com               *
//*                   e-mail:   helpdesk@simotime.com                 *
//* *******************************************************************
//*
//* Text   - Create a Sequential Data Set on disk using IEBGENER.
//* Author - SimoTime Enterprises
//* Date   - January 24, 1996
//*
//* The first job step (SQ01DELT) will delete any previously created
//* file. The second job step (CUCSQS01) 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.
//*
//*                      ************
//*                      * CUCSQJ01 *
//*                      ********jcl*
//*                           *
//*                           *
//*                      ************     ************
//*                      * IEFBR14  ******* CUSTSQ01 *
//*                      ********utl*     ***delete***
//*                           *
//*                           *
//*     ************     ************     ************
//*     *  SYSUT2  ******* IEBGENER ******* CUSTSQ01 *
//*     ********jcl*     ********utl*     *******qsam*
//*                           *
//*                           *
//*                      ************
//*                      *   EOJ    *
//*                      ************
//*
//* *******************************************************************
//* Step   1 of 2  Delete any previously created file...
//*
//SQ01DELT EXEC PGM=IEFBR14
//CUSTSQ01 DD  DSN=SIMOTIME.DATA.CUSTSQ01,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...
//*
//CUCSQS01 EXEC PGM=IEBGENER
//SYSPRINT DD  SYSOUT=*
//SYSIN    DD  DUMMY
//* :....1....:....2....:....3....:....4....:....5....:....6....:....7....:....8
//SYSUT1   DD  *
/NL000000000001Anderson
/NF000000000001Adrian
/A1000000000001111 Peachtree Plaza
/CT000000000001Atlanta
/ST000000000001GA
/PC00000000000111033
/NL000000000002Brown
/NF000000000002Billie
/A1000000000002222 Baker Boulevard
/A2000000000002Apartment 22B
/CT000000000002Baltimore
/ST000000000002MD
/PC00000000000221033
/CL0000000000022500
/NL000000000003Carson
/NF000000000003Cameron
/A1000000000003333 Crenshaw Blvd.
/CT000000000003Cupertino
/ST000000000003CA
/PC00000000000394116
/NL000000000004Davidson
/NF000000000004Dion
/A1000000000004444 Main Street
/CT000000000004Wilmington
/ST000000000004DE
/PC00000000000410421-6767
/NL000000000005Everest
/NF000000000005Evan
/A1000000000005555 5TH Avenue
/CT000000000005New York
/ST000000000005NY
/PC00000000000512135
/NL000000000006Franklin
/NF000000000006Francis
/A1000000000006666 66TH Avenue
/CT000000000006Bedrock
/ST000000000006NY
/PC00000000000613897
/NL000000000007Garfunkel
/NF000000000007Gwen
/A1000000000007777 77TH Street
/CT000000000007New York
/ST000000000007NY
/PC00000000000711397
/NL000000000008Harrison
/NF000000000008Hilary
/A1000000000008888 88TH Street
/CT000000000008Pocatello
/ST000000000008ID
/PC00000000000878662
/NL000000000009Isley
/NF000000000009Isabel
/A1000000000009999 99TH Avenue
/CT000000000009Indianapolis
/ST000000000009IN
/PC00000000000937912
/NL000000000010Johnson
/NF000000000010Jamie
/A10000000000101010 Paradise Drive
/CT000000000010Larkspur
/ST000000000010CA
/PC00000000001097661
/NL000000000011Kemper
/NF000000000011Kelly
/A10000000000111111 Oak Circle
/CT000000000011Kansas City
/ST000000000011KS
/PC00000000001143077
/NL000000000012Lemond
/NF000000000012Lesley
/A10000000000121212 Lockwood Road
/A2000000000012Suite 12A
/CT000000000012Mohave Desert
/ST000000000012AZ
/PC00000000001287033
/NL000000000013Mitchell
/NF000000000013Marlow
/A10000000000131313 Miller Creek Road
/CT000000000013Anywhere
/ST000000000013TX
/PC00000000001361773
/NL000000000014Newman
/NF000000000014Noel
/A10000000000141414 Park Avenue
/CT000000000014Santa Monica
/ST000000000014CA
/PC00000000001490503
/NL000000000015Osborn
/NF000000000015Owen
/A10000000000151515 Center Stage
/CT000000000015Rolling Rock
/ST000000000015PA
/PC00000000001527113
/NL000000000016Powell
/NF000000000016Pierce
/A1000000000016PO Box 1616
/CT000000000016Ventura
/ST000000000016CA
/PC00000000001690507
/NL000000000017Quigley
/NF000000000017Quincy
/A10000000000171717 Farm Hill Road
/CT000000000017Oshkosh
/ST000000000017WI
/PC00000000001706112
/NL000000000018Ripley
/NF000000000018Ray
/A10000000000181818 Alien Lane
/CT000000000018Wayout
/ST000000000018KS
/PC00000000001804713
/NL000000000019Smith
/NF000000000019Sammy
/A10000000000191919 Carnoustie Drive
/CT000000000019Novato
/ST000000000019CA
/PC00000000001994949
/TO000000000019415 883-6565
/CL00000000001910000
/NL000000000020Tucker
/NF000000000020Taylor
/A10000000000202020 Sanger Lane
/CT000000000020St. Paul
/ST000000000020MN
/PC00000000002006147
/CL0000000000201234567
/NL000000000021Underwood
/NF000000000021Ulysses
/A10000000000212121 Wall Street
/CT000000000021New York
/ST000000000021NY
/PC00000000002104001
/NL000000000022Van Etten
/NF000000000022Valerie
/A10000000000222222 Vine Street
/A200000000002216TH Floor
/CT000000000022Hollywood
/ST000000000022CA
/PC00000000002297163
/NL000000000023Wilson
/NF000000000023Wiley
/A10000000000232323 Main Street
/CT000000000023Boston
/ST000000000023MA
/PC00000000002327135
/NL000000000024Xray
/NF000000000024Xavier
/A10000000000242424 24TH Street
/CT000000000024Nashville
/ST000000000024TN
/PC00000000002450513
/NL000000000025Young
/NF000000000025Yanni
/A10000000000252525 Yonge Street
/CT000000000025Toronto
/ST000000000025ON
/PC0000000000251K3 B4R
/NL000000000026Zenith
/NF000000000026Zebulon
/A10000000000262626 26TH Street
/CT000000000026Dallas
/ST000000000026TX
/PC00000000002661735
/*
//SYSUT2   DD  DSN=SIMOTIME.DATA.CUSTSQ01,
//             DISP=(NEW,CATLG,DELETE),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=FB,LRECL=80,BLKSIZE=800,DSORG=PS)
//

JCL to Update the Customer Master File (Field Level)
(Next) (Previous) (Table-of-Contents)

The following (CUUPDJ01.JCL) is a listing of the JCL member that may be used to update the Customer Master File.

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

JCL to Populate Customer Master by Individual Records
(Next) (Previous) (Table-of-Contents)

The following two JCL members will create a sequential file of eighty (80) byte records with each record containing a six (6) byte customer number and customer data. The sequential file will then be read and the information will be reformatted to a twelve (12) byte customer number with larger data fields. The reformatted data will then be used to update records in the Customer Master File.

JCL to Create a Sequential File with Customer Data (Record Reformat)
(Next) (Previous) (Table-of-Contents)

The following (CUSC80J1.JCL) is a listing of the JCL member that may be used to create a sequential file using instream data. The sequential file may be used to update the Customer Master File.

//CUSC80J1 JOB SIMOTIME,CLASS=1,MSGCLASS=0,NOTIFY=CSIP1
//* *******************************************************************
//*                   This program is provided by:                    *
//*                    SimoTime Enterprises, LLC                      *
//*           (C) Copyright 1987-2008 All Rights Reserved             *
//*             Web Site URL:   http://www.simotime.com               *
//*                   e-mail:   helpdesk@simotime.com                 *
//* *******************************************************************
//*
//* Text   - Create a Sequential Data Set on disk using IEBGENER.
//* Author - SimoTime Enterprises
//* Date   - January 24, 1996
//*
//* The first job step (QSAMDELT) will delete any previously created
//* file. The second job step (QSAMCRT1) will create a new file.
//*
//* This set of programs will run on a mainframe under MVS or on a
//* Personal Computer with Windows and Micro Focus Mainframe Express.
//*
//*                      ************
//*                      * QUSC80J1 *
//*                      ********jcl*
//*                           *
//*                           *
//*                      ************     ************
//*                      * IEFBR14  ******* CUST0080 *
//*                      ********utl*     ***delete***
//*                           *
//*                           *
//*     ************     ************     ************
//*     *  SYSIN   ******* IEBGENER ******* CUST0080 *
//*     ********jcl*     ********utl*     *******qsam*
//*                           *
//*                           *
//*                      ************
//*                      *   EOJ    *
//*                      ************
//*
//* *******************************************************************
//* Step   1 of 2  Delete any previously created file...
//*
//QSAMDELT EXEC PGM=IEFBR14
//CUST0080 DD  DSN=SIMOTIME.DATA.CUST0080,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    1113 Peachtree Plaza    Atlanta        GA 26101
000200 Brown          Billie    224 Baker Boulevard     Baltimore      MD 35702
000300 Carson         Cameron   336 Crenshaw Blvd.      Cupertino      CA 96154
000400 Davidson       Dion      448 Main Street         Wilmington     DE 27323
000500 Everest        Evan      55 5TH Avenue           New York       NY 10341
000600 Franklin       Francis   6612 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.CUST0080,
//             DISP=(NEW,CATLG,DELETE),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=FB,LRECL=80,BLKSIZE=800,DSORG=PS)
//

JCL to Update the Customer Master File (Record Reformat)
(Next) (Previous) (Table-of-Contents)

The following (CUSI80J1.JCL) is a listing of the JCL member that may be used to update the Customer Master File.

//CUSI80J1 JOB SIMOTIME,ACCOUNT,CLASS=1,MSGCLASS=0,NOTIFY=CSIP1
//* *******************************************************************
//*                   This program is provided by:                    *
//*                    SimoTime Enterprises, LLC                      *
//*           (C) Copyright 1987-2008 All Rights Reserved             *
//*             Web Site URL:   http://www.simotime.com               *
//*                   e-mail:   helpdesk@simotime.com                 *
//* *******************************************************************
//*
//* Text    - Read 80-Byte input and populate a VSAM, KSDS.
//* Author  - SimoTime Enterprises
//* Date    - November 24, 2004
//* Version - 07.01.22
//*
//* This job uses a COBOL program to read a sequential file.
//* The sequential file is then used as input to update the KSDS.
//*
//* *******************************************************************
//* Step   1 of 1  Delete previous files.
//*
//*
//STEP010  EXEC PGM=CUSI80C1
//STEPLIB  DD  DSN=SIMOTIME.DEMO.LOADLIB1,DISP=SHR
//CUST0080 DD  DSN=SIMOTIME.DATA.CUST0080,
//             DISP=SHR
//CUSTMAST DD  DSN=SIMOTIME.DATA.CUSTMAST,
//             DISP=SHR
//SYSOUT   DD  SYSOUT=*
//*

JCL to Extract Data from Customer Master File for use by Microsoft Excel
(Next) (Previous) (Table-of-Contents)

The following (CUEXTJ01.JCL) is a listing of the JCL member that may be used to extract information from the Customer Master File and create a sequential file with the records formatted with the fields delimited by a comma.

//CUEXTJ01 JOB SIMOTIME,ACCOUNT,CLASS=1,MSGCLASS=0,NOTIFY=CSIP1
//* *******************************************************************
//*                   This program is provided by:                    *
//*                    SimoTime Enterprises, LLC                      *
//*           (C) Copyright 1987-2005 All Rights Reserved             *
//*             Web Site URL:   http://www.simotime.com               *
//*                   e-mail:   helpdesk@simotime.com                 *
//* *******************************************************************
//*
//* Text   - Read Customer Master File, write to a sequential file
//* Author - SimoTime Enterprises
//* Date   - January 01, 1989
//*
//* This set of programs will run on a mainframe under MVS or on
//* a Personal Computer running Windows and Mainframe Express by
//* Micro Focus.
//*
//*   ************                    ************
//*   *  Entry   *                    *  Entry   *
//*   *   MVS    *                    * Windows  *
//*   ************                    ************
//*        *                               *
//*   ************                    ************
//*   * CUEXTJ01 *                    * CUEXTJ01 *
//*   ********jcl*                    ********cmd*
//*        *                               *
//*   ************                         *
//*   * IEFBR14  *                         *
//*   ********utl*                         *
//*        *                               *
//*        *********************************
//*                        *
//*                        *
//*   ************    ************    ************
//*   * CUSTMAST *----* CUSEXTC1 *----* CUSEXTSV *
//*   ************    ********cbl*    ********dat*
//*                        *   *
//*                        *   *
//*                        *   *---CALL----*
//*                        *               *
//*                        *               *
//*                        *          ************
//*                        *          * CUSEXTR1 *
//*                        *          ********cbl*
//*                        *
//*                   ************
//*                   *   EOJ    *
//*                   ************
//*
//* *******************************************************************
//* Step   1 of 2  This job step will delete a previously created file.
//*
//DELTSEQ1 EXEC PGM=IEFBR14
//CUSEXTSV DD  DSN=SIMOTIME.DATA.CUSEXTSV,DISP=(MOD,DELETE,DELETE),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=FB,LRECL=256,DSORG=PS)
//* *******************************************************************
//* Step   2 of 2  Execute the Sample programs....
//*
//CBLEXTS1 EXEC PGM=CUSEXTC1
//STEPLIB  DD  DSN=MFI01.SIMOPROD.LOADLIB1,DISP=SHR
//CUSTMAST DD  DSN=SIMOTIME.DATA.CUSTMAST,DISP=SHR
//CUSEXTSV DD  DSN=SIMOTIME.DATA.CUSEXTSV,DISP=(NEW,CATLG,DELETE),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=FB,LRECL=256,DSORG=PS)
//*

The COBOL Program Listings
(Next) (Previous) (Table-of-Contents)

This section includes a listing of the source code for the COBOL programs used to create, maintain and access the Customer Master File.

COBOL, Update the Customer Master File by Individual Fields
(Next) (Previous) (Table-of-Contents)

The following (CUUPDC01.CBL) is a sample COBOL demonstration program. This program will "read from" a sequential file and "update records or add records" to the Customer Master File. The program will compile and run in a Mainframe-oriented environment using an EBCDIC or ASCII encoded format.

       IDENTIFICATION DIVISION.
       PROGRAM-ID.    CUUPDC01.
       AUTHOR.        SIMOTIME ENTERPRISES.
      *****************************************************************
      * Copyright (C) 1987-2007 SimoTime Enterprises, LLC.            *
      *                                                               *
      * 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 commercial purpose requires a fee to be paid to       *
      * SimoTime Enterprises. 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           *
      * Enterprises.                                                  *
      *                                                               *
      * Permission to use, copy and modify 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           *
      * Enterprises.                                                  *
      *                                                               *
      * SimoTime Enterprises makes no warranty or representations     *
      * about the suitability of the software for any purpose. It is  *
      * provided "AS IS" without any express or implied warranty,     *
      * including the implied warranties of merchantability, fitness  *
      * for a particular purpose and non-infringement. SimoTime       *
      * Enterprises shall not be liable for any direct, indirect,     *
      * special or consequential damages resulting from the loss of   *
      * use, data or projects, whether in an action of contract or    *
      * tort, arising out of or in connection with the use or         *
      * performance of this software                                  *
      *                                                               *
      * SimoTime Enterprises                                          *
      * 15 Carnoustie Drive                                           *
      * Novato, CA 94949-5849                                         *
      * 415.883.6565                                                  *
      *                                                               *
      * RESTRICTED RIGHTS LEGEND                                      *
      * Use, duplication, or disclosure by the Government is subject  *
      * to restrictions as set forth in subparagraph (c)(1)(ii) of    *
      * the Rights in Technical Data and Computer Software clause at  *
      * DFARS 52.227-7013 or subparagraphs (c)(1) and (2) of          *
      * Commercial  Computer Software - Restricted Rights  at 48      *
      * CFR 52.227-19, as applicable.  Contact SimoTime Enterprises,  *
      * 15 Carnoustie Drive, Novato, CA 94949-5849.                   *
      *                                                               *
      *****************************************************************
      *      This program is provided by SimoTime Enterprises         *
      *        Our e-mail address is: helpdesk@simotime.com           *
      *     Also, visit our Web Site at http://www.simotime.com       *
      *                                                               *
      *****************************************************************
      *
      *****************************************************************
      * Source Member: CUUPDC01.CBL
      * Copy Files:    QQSMREC1.CPY
      *****************************************************************
      *
      * CUUPDC01 - Execute CUUPDC01 to read a QSAM file and  update
      * a VSAM Keyed Sequential Data Set (KSDS).
      *
      * EXECUTION or CALLING PROTOCOL
      * -----------------------------
      * Use standard JCL to EXECUTE or ANIMATE.
      *
      * DESCRIPTION
      * -----------
      * This single COBOL program will read an 80-byte, EBCDIC, QSAM
      * file an populate or update an empty or existing KSDS, VSAM
      * data set.
      *
      *                      ************
      *                      * KSDUPD *
      *                      ********jcl*
      *                           *
      *                           *
      *     ************     ************     ************
      *     * CUSTSQ01 *-----* CUUPDC01 *-----* CUSTMAST *
      *     *******qsam*     ********cbl*     *******vsam*
      *                           *
      *                           *
      *                      ************
      *                      *   EOJ    *
      *                      ************
      *
      *****************************************************************
      * This program will read the input file and update the master
      * file (SYSMLR2). The format of the input file (SYSMLR1) is
      * as follows.
      *
      * Position Length Description...
      *  ------   ----  -----------------------------------------------
      *    01      03   Record Idendifier
      *                 /N1 Name change or correction
      *                 /A1 Address change or correction (street)
      *                 /CT City
      *                 /ST State
      *                 /PC Postal Code
      *    04      12   The Key Field
      *    16      nn   Length based on Record Identifier
      *
      *****************************************************************
      *
      * MAINTENANCE
      * -----------
      * 1997/02/27 Simmons, Created program.
      * 1997/02/27 Simmons, No changes to date.
      *
      *****************************************************************
      *
       ENVIRONMENT DIVISION.
       INPUT-OUTPUT   SECTION.
       FILE-CONTROL.

      *****************************************************************
           SELECT CUSTSQ01-FILE
               ASSIGN       to CUSTSQ01
               ORGANIZATION is SEQUENTIAL
               ACCESS MODE  is SEQUENTIAL
               FILE STATUS  is CUSTSQ01-STATUS.
           SELECT CUSTMAST-FILE
               ASSIGN       to CUSTMAST
               ORGANIZATION is indexed
               ACCESS MODE  is RANDOM
               RECORD KEY   is CUST-NUMBER
               FILE STATUS  is CUSTMAST-STATUS.

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

      *****************************************************************
       FD   CUSTSQ01-FILE
            RECORD CONTAINS 80 CHARACTERS.
       COPY QSMCPYB2.

       FD  CUSTMAST-FILE.
       COPY CUSTCB01.

       WORKING-STORAGE SECTION.
      *****************************************************************
      *    Data-structure for Title and Copyright...
      *****************************************************************
       01  SIM-TITLE.
           05  T1 pic X(11) value '* CUUPDC01 '.
           05  T2 pic X(34) value ' Read CUSTSQ01, Update CUSTMAST '.
           05  T3 pic X(10) value ' v07.07.15'.
           05  T4 pic X(24) value ' http://www.simotime.com'.
       01  SIM-COPYRIGHT.
           05  C1 pic X(11) value '* CUUPDC01 '.
           05  C2 pic X(20) value 'Copyright 1987-2007 '.
           05  C3 pic X(28) value '  SimoTime Enterprises, LLC '.
           05  C4 pic X(20) value ' All Rights Reserved'.

       01  SIM-THANKS-01.
           05  C1 pic X(11) value '* CUUPDC01 '.
           05  C2 pic X(32) value 'Thank you for using this sample '.
           05  C3 pic X(32) value 'by SimoTime Enterprises, LLC    '.
           05  C4 pic X(04) value '    '.

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

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

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

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

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

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

       01  CONSOLE-MESSAGE         pic X(48).

       01  CUSTSQ01-FLAG           pic X       value 'N'.

       01  WORK-07.
           05  WORK-07-NUMB        pic 9(7)    value 0.
       01  WX-7                    pic 9(2)    value 0.

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

      *****************************************************************
       PROCEDURE DIVISION.
           perform Z-POST-COPYRIGHT.

           perform CUSTSQ01-OPEN.
           perform CUSTMAST-OPEN.

           perform until END-OF-FILE = 'YES'
               if  END-OF-FILE = 'NO '
                   perform CUSTSQ01-GET
                   if  END-OF-FILE = 'NO '
                       move QSAM-B2-RECORD to MESSAGE-TEXT
                       perform Z-DISPLAY-MESSAGE-TEXT
                       move QSAM-B2-KEY to CUST-NUMBER
                       perform CUSTMAST-GET
                       perform EVALUATE-FIELD-TYPE
                       if  CUSTSQ01-FLAG = 'Y'
                           if  APPL-AOK
                               perform MOVE-QSAM-FIELD-TO-KSDS-RECORD
                               perform CUSTMAST-REWRITE
                           else
                               perform INITIALIZE-CUSTOMER-RECORD
                               move QSAM-B2-KEY to CUST-NUMBER
                               perform MOVE-QSAM-FIELD-TO-KSDS-RECORD
                               perform CUSTMAST-WRITE
                           end-if
                       end-if
                   end-if
               end-if
           end-perform.

           perform CUSTMAST-CLOSE.
           perform CUSTSQ01-CLOSE.

           display 'CUUPDC01 CUSTMAST-HAS-BEEN-UPDATED' upon console
           display 'CUUPDC01 NORMAL-END-OF-JOB...'      upon console

           perform Z-THANK-YOU.

           GOBACK.

      *****************************************************************
      * The following routines are in alphabetic sequence.            *
      *****************************************************************
       INITIALIZE-CUSTOMER-RECORD.
           move all SPACES to CUST-RECORD
           initialize CUST-RECORD
           exit.

      *****************************************************************
       EVALUATE-FIELD-TYPE.
           if  QSAM-B2-ID = '/NM'
           or  QSAM-B2-ID = '/NL'
           or  QSAM-B2-ID = '/NF'
           or  QSAM-B2-ID = '/A2'
           or  QSAM-B2-ID = '/CT'
           or  QSAM-B2-ID = '/ST'
           or  QSAM-B2-ID = '/PC'
           or  QSAM-B2-ID = '/CL'
           or  QSAM-B2-ID = '/TH'
           or  QSAM-B2-ID = '/TO'
           or  QSAM-B2-ID = '/TM'
               move 'Y' to CUSTSQ01-FLAG
           else
               move 'N' to CUSTSQ01-FLAG
           end-if
           exit.
      *****************************************************************
       MOVE-QSAM-FIELD-TO-KSDS-RECORD.
           move 'Y' to CUSTSQ01-FLAG
           evaluate QSAM-B2-ID
               when '/NL' move QSAM-B2-DATA to CUST-LAST-NAME
               when '/NF' move QSAM-B2-DATA to CUST-FIRST-NAME
               when '/NM' move QSAM-B2-DATA to CUST-MID-NAME
               when '/A1' move QSAM-B2-DATA to CUST-ADDRESS-1
               when '/A2' move QSAM-B2-DATA to CUST-ADDRESS-2
               when '/CT' move QSAM-B2-DATA to CUST-CITY
               when '/ST' move QSAM-B2-DATA to CUST-STATE
               when '/PC' move QSAM-B2-DATA to CUST-POSTAL-CODE
               when '/CL' perform MOVE-CUST-CREDIT-LIMIT
               when '/TH' move QSAM-B2-DATA to CUST-PHONE-HOME
               when '/TO' move QSAM-B2-DATA to CUST-PHONE-WORK
               when '/TM' move QSAM-B2-DATA to CUST-PHONE-CELL
               when other move 'N' to CUSTSQ01-FLAG
           end-evaluate

           exit.

      *****************************************************************
       MOVE-CUST-CREDIT-LIMIT.
           move QSAM-B2-DATA to WORK-07
           perform until WORK-07(7:1) not = SPACE
             perform varying WX-7 from 6 by -1 until WX-7 = 0
               move WORK-07(WX-7:1) to WORK-07(WX-7 + 1:1)
             end-perform
      *      move WORK-07(6:1) to WORK-07(7:1)
      *      move WORK-07(5:1) to WORK-07(6:1)
      *      move WORK-07(4:1) to WORK-07(5:1)
      *      move WORK-07(3:1) to WORK-07(4:1)
      *      move WORK-07(2:1) to WORK-07(3:1)
      *      move WORK-07(1:1) to WORK-07(2:1)
             move ZERO         to WORK-07(1:1)
           end-perform
           if  WORK-07-NUMB is NUMERIC
               add WORK-07-NUMB to ZERO giving CUST-CREDIT-LIMIT
           else
               move 'Credit Limit Update Error...' to MESSAGE-TEXT
               perform Z-DISPLAY-MESSAGE-TEXT
           end-if
           exit.

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

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

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

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

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

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

      *****************************************************************
       Z-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 Enterprises         *
      *        Our e-mail address is: helpdesk@simotime.com           *
      *     Also, visit our Web Site at http://www.simotime.com       *
      *****************************************************************

COBOL, Update the Customer Master File (Record Reformatting)
(Next) (Previous) (Table-of-Contents)

The following (CUSI80C1.CBL) is a sample COBOL demonstration program. This program will "read from" a sequential file and "update records or add records" to the Customer Master File. The sequential input file is eighty (80) byte fixed length records with a six (6) byte customer number in positions 1-6. The Customer number will be expanded to twelve (12) bytes and the individual fields will be increased in size. The program will compile and run in a Mainframe-oriented environment using an EBCDIC or ASCII encoded format.

       IDENTIFICATION DIVISION.
       PROGRAM-ID.     CUSI80C1.
       AUTHOR.        SIMOTIME ENTERPRISES.
      *****************************************************************
      *           This program was generated by SimoZAPS              *
      *             A product of SimoTime Enterprises                 *
      *        Our e-mail address is: helpdesk@simotime.com           *
      *     Also, visit our Web Site at http://www.simotime.com       *
      *                                                               *
      *  Generation Date: 2007-11-05  Generation Time: 23:39:52:81    *
      *                                                               *
      *                                   Record    Record     Key    *
      *  Function  Name     Organization  Format    Max-Min  Pos-Len  *
      *  INPUT     CUST0080 SEQUENTIAL    FIXED      00080            *
      *                                                               *
      *  OUTPUT    CUSTMAST INDEXED       VARIABLE   00512    00001   *
      *                                              00012    00012   *
      *                                                               *
      *            Translation Mode is ASCII to ASCII                 *
      *                                                               *
      *****************************************************************
       ENVIRONMENT DIVISION.
       INPUT-OUTPUT SECTION.
       FILE-CONTROL.
           SELECT CUST0080-FILE  ASSIGN TO       CUST0080
                  ORGANIZATION  IS SEQUENTIAL
                  ACCESS MODE   IS SEQUENTIAL
                  FILE STATUS   IS CUST0080-STATUS.
           SELECT CUSTMAST-FILE  ASSIGN TO       CUSTMAST
                  ORGANIZATION  IS INDEXED
                  ACCESS MODE   IS RANDOM
                  RECORD KEY    IS CUSTMAST-PKEY-00001-00012
                  FILE STATUS   IS CUSTMAST-STATUS.

      *****************************************************************
       DATA DIVISION.
       FILE SECTION.
       FD  CUST0080-FILE
           DATA RECORD    IS CUST0080-REC
           .
       01  CUST0080-REC.
           05  CUST0080-DATA-01 PIC X(00080).

       FD  CUSTMAST-FILE
           DATA RECORD    IS CUSTMAST-REC
           .
       01  CUSTMAST-REC.
           05  CUSTMAST-PKEY-00001-00012        PIC X(00012).
           05  CUSTMAST-DATA-00013-00500        PIC X(00500).

      *****************************************************************
      * This program was created using the SYSMASK2.TXT file as input.*
      *                                                               *
      * The SYSMASK2 provides for the sequential reading of the input *
      * file and the random writing of the output file.               *
      *                                                               *
      * If the output file is indexed then the input file does not    *
      * need to be in sequence by the field that will be used to      *
      * provide the key for the output file.                          *
      *                                                               *
      * New records will be added and existing records will be        *
      * updated. If duplicate keys are provided from the input file   *
      * then only the information from the last duplicate key record  *
      * of the input file will be reflected in the output file.       *
      *                                                               *
      * This program mask will have the ASCII/EBCDIC table inserted   *
      * for use by the /TRANSLATE function of SimoZAPS.               *
      *                                                               *
      * For additional information contact SimoTime Enterprises.      *
      *                                                               *
      *        Our e-mail address is: helpdesk@simotime.com           *
      *     Also, visit our Web Site at http://www.simotime.com       *
      *****************************************************************
       WORKING-STORAGE SECTION.
       01  SIM-TITLE.
           05  T1 pic X(11) value '* CUSI80C1 '.
           05  T2 pic X(34) value 'File Copy and Reformatting, 80/512'.
           05  T3 pic X(10) value ' v07.11.04'.
           05  T4 pic X(24) value ' http://www.simotime.com'.
       01  SIM-COPYRIGHT.
           05  C1 pic X(11) value '* CUSI80C1 '.
           05  C2 pic X(20) value 'Created by SimoZAPS,'.
           05  C3 pic X(20) value '  a utility package '.
           05  C4 pic X(28) value 'of SimoTime Enterprises, LLC'.

       01  CUST0080-STATUS.
           05  CUST0080-STATUS-L     pic X.
           05  CUST0080-STATUS-R     pic X.
       01  CUST0080-EOF              pic X       value 'N'.
       01  CUST0080-OPEN-FLAG        pic X       value 'C'.
       01  CUST0080-RECORD-FOUND     pic X       value 'N'.

       01  CUSTMAST-STATUS.
           05  CUSTMAST-STATUS-L     pic X.
           05  CUSTMAST-STATUS-R     pic X.
       01  CUSTMAST-EOF              pic X       value 'N'.
       01  CUSTMAST-OPEN-FLAG        pic X       value 'C'.
       01  CUSTMAST-RECORD-FOUND     pic X       value 'N'.

       01  CUST0080-LRECL    pic 9(5)    value 00080.
       01  CUSTMAST-LRECL    pic 9(5)    value 00512.

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

      *****************************************************************
      * Message Buffer used by the Z-DISPLAY-MESSAGE-TEXT routine.    *
      *****************************************************************
       01  MESSAGE-BUFFER.
           05  MESSAGE-HEADER      pic X(11)   value '* CBL512C1 '.
           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  CUST0080-TOTAL.
           05  CUST0080-RDR  pic 9(9)    value 0.
           05  filler      pic X(3)    value ' - '.
           05  filler      pic X(23)   value 'Read count for CUST0080'.

       01  CUSTMAST-TOTAL-ADDS.
           05  CUSTMAST-ADD  pic 9(9)    value 0.
           05  filler      pic X(3)    value ' - '.
           05  filler      pic X(17)   value 'Adds for CUSTMAST'.
       01  CUSTMAST-TOTAL-UPDATES.
           05  CUSTMAST-UPD  pic 9(9)    value 0.
           05  filler      pic X(3)    value ' - '.
           05  filler      pic X(20)   value 'Updates for CUSTMAST'.


      *****************************************************************
       PROCEDURE DIVISION.
           perform Z-POST-COPYRIGHT
           perform CUST0080-OPEN
           perform CUSTMAST-OPEN

           perform UNTIL CUST0080-EOF = 'Y'
               if  CUST0080-EOF = 'N'
                   perform CUST0080-READ
                   if  CUST0080-EOF = 'N'
                       add 1 to CUST0080-RDR
                       perform BUILD-OUTPUT-RECORD
                       perform CUSTMAST-READ
                       perform BUILD-OUTPUT-RECORD
                       if  CUSTMAST-RECORD-FOUND = 'Y'
                           add 1 to CUSTMAST-UPD
                           perform CUSTMAST-REWRITE
                       else
                           add 1 to CUSTMAST-ADD
                           perform CUSTMAST-WRITE
                       end-if
                   end-if
               end-if
           end-perform.

           move CUST0080-TOTAL to MESSAGE-TEXT
           perform Z-DISPLAY-MESSAGE-TEXT

           move CUSTMAST-TOTAL-ADDS to MESSAGE-TEXT
           perform Z-DISPLAY-MESSAGE-TEXT

           move CUSTMAST-TOTAL-UPDATES to MESSAGE-TEXT
           perform Z-DISPLAY-MESSAGE-TEXT

           if  APPL-EOF
               move 'is Complete...' to MESSAGE-TEXT
           else
               move 'is ABENDING...' to MESSAGE-TEXT
           end-if
           perform Z-DISPLAY-MESSAGE-TEXT

           perform CUSTMAST-CLOSE
           perform CUST0080-CLOSE
           GOBACK.

      *****************************************************************
       BUILD-OUTPUT-RECORD.
      *>   TransMODE is A2A...
      *>   TransINIT process...
           move ALL SPACES to CUSTMAST-REC
      *>   TransCOPY...
           move CUST0080-REC(00001:00006) to CUSTMAST-REC(00007:00006)
      *>   TransCOPY...
           move CUST0080-REC(00008:00015) to CUSTMAST-REC(00014:00015)
      *>   TransCOPY...
           move CUST0080-REC(00023:00010) to CUSTMAST-REC(00042:00010)
      *>   TransCOPY...
           move CUST0080-REC(00033:00024) to CUSTMAST-REC(00082:00024)
      *>   TransCOPY...
           move CUST0080-REC(00057:00015) to CUSTMAST-REC(00178:00015)
      *>   TransCOPY...
           move CUST0080-REC(00072:00003) to CUSTMAST-REC(00206:00003)
      *>   TransCOPY...
           move CUST0080-REC(00075:00006) to CUSTMAST-REC(00234:00006)
      *>   TransFILL...
           move
           '000000'
           to CUSTMAST-REC(00001:00006)
      *>   TransFILL...
           move
           X'0000250F'
           to CUSTMAST-REC(00300:00004)
           exit.

      *****************************************************************
      * I/O Routines for the INPUT File...                            *
      *****************************************************************
       CUST0080-CLOSE.
           add 8 to ZERO giving APPL-RESULT.
           close CUST0080-FILE
           if  CUST0080-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
           else
               add 12 to ZERO giving APPL-RESULT
           end-if
           if  APPL-AOK
               CONTINUE
           else
               move 'CLOSE Failure with CUST0080' to MESSAGE-TEXT
               perform Z-DISPLAY-MESSAGE-TEXT
               move CUST0080-STATUS to IO-STATUS
               perform Z-DISPLAY-IO-STATUS
               perform Z-ABEND-PROGRAM
           end-if
           exit.
      *---------------------------------------------------------------*
       CUST0080-READ.
           read CUST0080-FILE
           if  CUST0080-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
           else
               if  CUST0080-STATUS = '10'
                   add 16 to ZERO giving APPL-RESULT
               else
                   add 12 to ZERO giving APPL-RESULT
               end-if
           end-if
           if  APPL-AOK
               CONTINUE
           else
               if  APPL-EOF
                   move 'Y' to CUST0080-EOF
               else
                   move 'READ Failure with CUST0080' to MESSAGE-TEXT
                   perform Z-DISPLAY-MESSAGE-TEXT
                   move CUST0080-STATUS to IO-STATUS
                   perform Z-DISPLAY-IO-STATUS
                   perform Z-ABEND-PROGRAM
               end-if
           end-if
           exit.
      *---------------------------------------------------------------*
       CUST0080-OPEN.
           add 8 to ZERO giving APPL-RESULT.
           open input CUST0080-FILE
           if  CUST0080-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
               move 'O' to CUST0080-OPEN-FLAG
           else
               add 12 to ZERO giving APPL-RESULT
           end-if
           if  APPL-AOK
               CONTINUE
           else
               move 'OPEN Failure with CUST0080' to MESSAGE-TEXT
               perform Z-DISPLAY-MESSAGE-TEXT
               move CUST0080-STATUS to IO-STATUS
               perform Z-DISPLAY-IO-STATUS
               perform Z-ABEND-PROGRAM
           end-if
           exit.

      *****************************************************************
      * I/O Routines for the OUTPUT File...                           *
      *****************************************************************
       CUSTMAST-WRITE.
           if  CUSTMAST-OPEN-FLAG = 'C'
               perform CUSTMAST-OPEN
           end-if
           write CUSTMAST-REC
           if  CUSTMAST-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
           else
               if  CUSTMAST-STATUS = '10'
                   add 16 to ZERO giving APPL-RESULT
               else
                   add 12 to ZERO giving APPL-RESULT
               end-if
           end-if.
           if  APPL-AOK
               CONTINUE
           else
               move 'WRITE Failure with CUSTMAST' to MESSAGE-TEXT
               perform Z-DISPLAY-MESSAGE-TEXT
               move CUSTMAST-STATUS to IO-STATUS
               perform Z-DISPLAY-IO-STATUS
               perform Z-ABEND-PROGRAM
           end-if
           exit.
      *---------------------------------------------------------------*
       CUSTMAST-REWRITE.
           if  CUSTMAST-OPEN-FLAG = 'C'
               perform CUSTMAST-OPEN
           end-if
           rewrite CUSTMAST-REC
           if  CUSTMAST-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
           else
               if  CUSTMAST-STATUS = '10'
                   add 16 to ZERO giving APPL-RESULT
               else
                   add 12 to ZERO giving APPL-RESULT
               end-if
           end-if.
           if  APPL-AOK
               CONTINUE
           else
               move 'REWRITE Failure with CUSTMAST' to MESSAGE-TEXT
               perform Z-DISPLAY-MESSAGE-TEXT
               move CUSTMAST-STATUS to IO-STATUS
               perform Z-DISPLAY-IO-STATUS
               perform Z-ABEND-PROGRAM
           end-if
           exit.
      *---------------------------------------------------------------*
       CUSTMAST-OPEN.
           add 8 to ZERO giving APPL-RESULT.
           open I-O CUSTMAST-FILE
           if  CUSTMAST-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
               move 'O' to CUSTMAST-OPEN-FLAG
           else
               add 12 to ZERO giving APPL-RESULT
           end-if
           if  APPL-AOK
               CONTINUE
           else
               move 'OPEN Failure with CUSTMAST' to MESSAGE-TEXT
               perform Z-DISPLAY-MESSAGE-TEXT
               move CUSTMAST-STATUS to IO-STATUS
               perform Z-DISPLAY-IO-STATUS
               perform Z-ABEND-PROGRAM
           end-if
           exit.
      *---------------------------------------------------------------*
       CUSTMAST-READ.
           move 'N' to CUSTMAST-RECORD-FOUND
           move 'N' to CUSTMAST-EOF
           add  12  to ZERO giving APPL-RESULT
           read CUSTMAST-FILE
           evaluate CUSTMAST-STATUS
               when '00'   move 'Y' to CUSTMAST-RECORD-FOUND
                           subtract APPL-RESULT from APPL-RESULT
               when '23'   move 'N' to CUSTMAST-RECORD-FOUND
                           subtract APPL-RESULT from APPL-RESULT
               when '10'   move 'N' to CUSTMAST-RECORD-FOUND
                           move 'Y' to CUSTMAST-EOF
                           subtract APPL-RESULT from APPL-RESULT
           end-evaluate.
           if  APPL-AOK
               CONTINUE
           else
               move 'READ Failure with CUSTMAST' to MESSAGE-TEXT
               perform Z-DISPLAY-MESSAGE-TEXT
               move CUSTMAST-STATUS to IO-STATUS
               perform Z-DISPLAY-IO-STATUS
               perform Z-ABEND-PROGRAM
           end-if
           exit.
      *---------------------------------------------------------------*
       CUSTMAST-CLOSE.
           add 8 to ZERO giving APPL-RESULT.
           close CUSTMAST-FILE
           if  CUSTMAST-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
               move 'C' to CUSTMAST-OPEN-FLAG
           else
               add 12 to ZERO giving APPL-RESULT
           end-if
           if  APPL-AOK
               CONTINUE
           else
               move 'CLOSE Failure with CUSTMAST' to MESSAGE-TEXT
               perform Z-DISPLAY-MESSAGE-TEXT
               move CUSTMAST-STATUS to IO-STATUS
               perform Z-DISPLAY-IO-STATUS
               perform Z-ABEND-PROGRAM
           end-if
           exit.

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

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

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

      *****************************************************************
       Z-POST-COPYRIGHT.
           display SIM-TITLE
           display SIM-COPYRIGHT
           exit.
      *****************************************************************
      *           This program was generated by SimoZAPS              *
      *             A product of SimoTime Enterprises                 *
      *        Our e-mail address is: helpdesk@simotime.com           *
      *     Also, visit our Web Site at http://www.simotime.com       *
      *                                                               *
      *  Generation Date: 2007-11-05  Generation Time: 23:39:52:82    *
      *****************************************************************

COBOL, Extract Data from Customer Master File for use by Microsoft Excel
(Next) (Previous) (Table-of-Contents)

This is actually two COBOL programs. The first program does the File I/O of reading the Customer Master File and writing reformatted records to a sequential file. The File I/O program calls the second program to do the record formatting that expands the numeric fields and does blank trunctaion on the text fields and then places a comma between the fields as the field delimiter. This link is provided to  view the file extract programs  that are provided in a separate document.

COBOL, Convert a Customer Master File (from EBCDIC to ASCII)
(Next) (Previous) (Table-of-Contents)

This is actually two COBOL programs. The first program does the File I/O of reading the Customer Master File and writing reformatted records to a sequential file. The File I/O program calls the second program to do the record formatting that expands the numeric fields and does blank trunctaion on the text fields and then places a comma between the fields as the field delimiter. This link is provided to  view the file content conversion programs  that are provided in a separate document.

COBOL, Convert File Format,
Record-Sequential to Line-Sequential
(Next) (Previous) (Table-of-Contents)

This is a single COBOL program. The program does the File I/O of reading a record sequential file and writing to a line sequential file (Micro Focus terminology for an ASCII/Text file). This link is provided to  view the file format conversion program  that are provided in a separate document.

COBOL, Convert File Format & Content,
Record-Sequential to Line-Sequential, EBCDIC to ASCII
(Next) (Previous) (Table-of-Contents)

This is actually two COBOL programs. The first program does the File I/O of reading a record sequential file and writing to a line sequential file (Micro Focus terminology for an ASCII/Text file). The File I/O program calls the second program to do the EBCDIC to ASCII conversion of the 256 byte record. This link is provided to  view the file format and file content conversion programs  that are provided in a separate document.

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

The purpose of this program is to provide examples for accessing records in a Sequential file and using the information to update records in a VSAM, KSDS (i.e. the Customer Master File).

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

Permission to use, copy, modify and distribute this software for any commercial purpose requires a fee to be paid to Simotime Enterprises. 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 Enterprises.

Permission to use, copy, modify and distribute this software for a 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 Enterprises.

SimoTime Enterprises makes no warranty or representations about the suitability of the software for any purpose. It is provided "AS IS" without any express or implied warranty, including the implied warranties of merchantability, fitness for a particular purpose and non-infringement. SimoTime Enterprises shall not be liable for any direct, indirect, special or consequential damages resulting from the loss of use, data or projects, whether in an action of contract or tort, arising out of or in connection with the use or performance of this software.

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

You may download this example at http://www.simotime.com/sim4dzip.htm#cumast01 or view the complete list of SimoTime Examples at http://www.simotime.com/sim4dzip.htm .

Note: You must be attached to the Internet to download a Z-Pack or view the list.

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

This item will provide a link to  an ASCII or EBCDIC translation table. A column for decimal, hexadecimal and binary is also included.

Check out  The VSAM - QSAM Connection  for more examples of mainframe VSAM and QSAM accessing techniques and sample code.

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

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

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

Glossary of Terms
(Next) (Previous) (Table-of-Contents)

Check out  The SimoTime Glossary  for a list of terms and definitions used in the documents provided by SimoTime.

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

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

We appreciate your comments and feedback.

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

Founded in 1987, SimoTime Enterprises is a privately owned, Limited Liability Corporation located in Novato, California. We specialize in the creation and deployment of business applications using new or existing technologies and services. We have a team of individuals that understand the broad range of technologies being used in today's environments. This includes the smallest thin client using the Internet and the very large mainframe systems. There is more to making the Internet work for your company's business than just having a nice looking WEB site. It is about combining the latest technologies and existing technologies with practical business experience. It's about the business of doing business and looking good in the process. Quite often, to reach larger markets or provide a higher level of service to existing customers it requires the newer Internet technologies to work in a complimentary manner with existing corporate mainframe systems. Whether you want to use the Internet to expand into new market segments or as a delivery vehicle for existing business functions simply give us a call or check the web site at http://www.simotime.com


Return-to-Top
Copyright © 1987-2008 SimoTime Enterprises, LLC  All Rights Reserved
When technology complements business
http://www.simotime.com
Version 06.11.01