Multiple Record Types in a File
 Accumulate Totals and Convert from EBDCIC to ASCII
When technology complements business    Copyright © 1987-2013  SimoTime Enterprises  All Rights Reserved
  Table of Contents Version 12.11.21 
  Introduction
  The CMD Files
  CMD Member, Create a Baseline File
  CMD Member, Create a File with Multiple Record Types
  CMD Member, Read a File & Accumulate Totals by Record Type
  The JCL Members
  JCL Member, Create a Baseline File
  JCL Member, Create a File with Multiple Record Types
  JCL Member, Read a File & Accumulate Totals by Record Type
  JCL Member, EBCDIC to ASCII Conversion
  The COBOL Programs
  COBOL Program, Create a File
  COBOL Program, Accumulate Sub-totals by Record Group
  The COBOL Program for File Format and Record Content Conversion
  Callable COBOL Conversion Routine for Record Type 01
  Callable COBOL Conversion Routine for Record Type 02
  Callable COBOL Conversion Routine for Record Type 03
  The COBOL Copy Files
  Copy File for Record Type 01
  Copy File for Record Type 02
  Copy File for Record Type 03
  Summary
  Software Agreement and Disclaimer
  Downloads and Links to Similar Pages
  Downloads and Links, Internet Access Required
  Glossary of Terms
  Comments, Suggestions or Feedback
  Company Overview
The SimoTime Home Page

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

This is an example of how COBOL can create and process a file containing multiple record types. The records contain a combination of text strings and numeric values stored in various formats such as signed-zoned-decimal, packed and binary.

Item Description
1 Create a file with multiple record types
2 Read a file with multiple record types and accumulate numeric totals by record groups.
3 Convert an EBCDIC encoded file with multiple record types to an ASCII encoded file with multiple record types.
  Objectives

The following shows the structure of the records in the sample file. The first three (3) bytes of every record are used for the same purpose.

Position Description
1 Record Status, A=Active, D=Delete, S=Suspend
2-3 Record Type, the following will show the structure of the remaining positions (or columns) in the record.
4-80 The format (or use) of columns 4-80 will vary based on the record type as define in columns 2-3.
Record Type Position Description
01 4-51 A 48 byte text string
  52-60 A nine (9) byte numeric field using a zoned-decimal format
  60-80 Filler
02 4-35 A 32 byte text string
  36-40 A five (5) byte numeric field using a packed (or COMP-3) format.
  41-80 Filler
03 4-19 A 16 byte text string
  19-22 A four (4) byte numeric field using a binary (or COMP) format.
  23-80 Filler

The COBOL programs were written and tested using the VS COBOL II dialect. Also, the COBOL programs will work with COBOL for MVS and COBOL/370. JCL members are provided to run the jobs as MVS batch jobs on an IBM Mainframe System or on a Linux, UNIX or Windows System using Micro Focus technologies.

Note:  A suite of command files are provided to run the programs in a non-mainframe oriented environment on a Windows System using Micro Focus technologies.

The CMD Files
(Next) (Previous) (Table-of-Contents)

There are three (3) Windows Command files provided with this suite of sample programs. The following describes each of the command files in more detail.

CMD Member, Create a Baseline File
(Next) (Previous) (Table-of-Contents)

This job (DATMRTE1.cmd) will use the Windows "ECHO" command to create an ASCII/Text file of data to be used to create a single file with multiple record types. Once an ASCII/Text file is created it will be used to create a record sequential file of fixed length records in a Micro Focus file format.

@echo OFF
rem  * *******************************************************************
rem  *               DATMRTE1.CMD - a Windows Command File               *
rem  *         This program is provided by SimoTime Enterprises          *
rem  *           (C) Copyright 1987-2013 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.
rem  * Author - SimoTime Enterprises
rem  * Date   = January 24, 1996
rem  *
rem  * The 1st step will set the global or comman environment variables.
rem  *
rem  * The 2nd job step (CreateTEXT) will create a new ASCII/Text file.
rem  *
rem  * The 3rd step will convert the Line Sequential file to a Record
rem  * Sequential file.
rem  *
rem  * The 4th step will perform the End-of-Job tasks.
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 4, Set the global or comman environment variables
rem  *
     set CmdName=DATMRTE1
     call ..\Env1BASE %CmdName%
     if "%SYSLOG%" == "" set syslog=c:\SimoLIBR\LOGS\SimoTime.LOG
rem  *
     call SimoNOTE "*******************************************************%CmdName%"
     call SimoNOTE "Starting CmdName %CmdName%, User is %USERNAME%"
     call SimoNOTE "StepInfo Delete previously created files"
     set DATMRTT1=%BaseLib1%\DataLibA\Txt1\DATMRTT1.TXT
rem  *
rem  * *******************************************************************
rem  * Step 2 of 4, Create and populate a new ASCII/TEXT file...
rem  *
     call SimoNOTE "StepInfo Create an ASCII/Text File"
     if exist %DATMRTT1% del %DATMRTT1%
rem  * ..1....:....2....:....3....:....4....:....5....:....6....:....7.
echo A01Text-48 with signed zoned decimal numeric data  000000101>>%DATMRTT1%
echo A02Text-32 with packed data                        000000204>>%DATMRTT1%
echo A03T16 binary data                                 000000307>>%DATMRTT1%
echo A01Text-48 with signed zoned decimal numeric data  000000102>>%DATMRTT1%
echo A02Text-32 with packed data                        000000205>>%DATMRTT1%
echo A01Text-48 with signed zoned decimal numeric data  000000103>>%DATMRTT1%
echo A03T16 binary data                                 000000308>>%DATMRTT1%
echo A01Text-48 with signed zoned decimal numeric data  000000114>>%DATMRTT1%
echo A01Text-48 with signed zoned decimal numeric data  000000115>>%DATMRTT1%
echo A03T16 binary data                                 000000309>>%DATMRTT1%
echo A02Text-32 with packed data                        000000206>>%DATMRTT1%
     if exist %DATMRTT1% call SimoNOTE "DataMake %DATMRTT1%"
     if not exist %DATMRTT1% set JobStatus=9001
     if not %JobStatus% == 0000 goto :EojNok
rem  *
rem  * *******************************************************************
rem  * Step 3 of 4, ConvertASCII/TEXT file to Record Sequential File...
rem  *
     call SimoNOTE "StepInfo Convert Line Sequential to Record Sequential"
     set GETLS080=%DATMRTT1%
     set PUTRS080=%BaseLib1%\DataLibA\Asc1\DATMRTW1.DAT
     if exist %PUTRS080% del %PUTRS080%
     run CV80ALAR
     if not ERRORLEVEL = 0 set JobStatus=0030
     if not %JobStatus% == 0000 goto :EojNok
     call SimoNOTE "DataTake %GETLS080%"
     call SimoNOTE "DataMake %PUTRS080%"
rem  *
rem  * *******************************************************************
rem  * Step 4 of 4, End of job routines...
rem  *
:EojAok
     call SimoNOTE "Finished CmdName %CmdName%, Job Status is %JobStatus% "
     goto :End
:EojNok
     call SimoNOTE "NOTE ABENDING CmdName %CmdName%, Job Status is %JobStatus% "
:End
     if not "%1" == "nopause" pause

CMD Member, Create a File with Multiple Record Types
(Next) (Previous) (Table-of-Contents)

This job (DATMRTE2.cmd) will use a COBOL program to read a record sequential file and write to a record sequential file containing multiple record types with different mainframe numeric formats.

@echo OFF
rem  * *******************************************************************
rem  *               DATMRTE2.CMD - a Windows Command File               *
rem  *         This program is provided by SimoTime Enterprises          *
rem  *           (C) Copyright 1987-2013 All Rights Reserved             *
rem  *             Web Site URL:   http://www.simotime.com               *
rem  *                   e-mail:   helpdesk@simotime.com                 *
rem  * *******************************************************************
rem  *
rem  * Text   - Create a file with multiple record types and multiple
rem  *          field types within the records.
rem  * Author - SimoTime Enterprises
rem  * Date   - January 24, 1996
rem  *
rem  * The job will read an 80-byte file that contains JUSTIFY
rem  * information. The job will also write a file containing the results
rem  * of the justify functions..
rem  *
rem  * This set of programs will run on a mainframe under MVS or on a
rem  * Personal Computer with Windows and Micro Focus Net Express.
rem  *
rem  *                     ************
rem  *                     * DATMRTE2 *
rem  *                     ********cmd*
rem  *                          *
rem  *                          *
rem  *                     ************     ************
rem  *                     * ezSetEnv *******  SetEnv  *
rem  *                     ********cmd*  *  *******task*
rem  *                          *
rem  *                          *
rem  *    ************     ************     ************
rem  *    * DATMRTW1 ******* DATMRTC1 ******* DATMRTW2 *
rem  *    *******rseq*     ********cbl*     *******rseq*
rem  *                          *
rem  *                          *
rem  *                     ************
rem  *                     *   EOJ    *
rem  *                     ************
rem  *
rem  * *******************************************************************
rem  * Step 1 of 4, Set global or Common Environment Variables
rem  *
     set CmdName=DATMRTE2
     call ..\Env1BASE %CmdName%
     if "%SYSLOG%" == "" set syslog=c:\SimoLIBR\LOGS\SimoTime.LOG
rem  *
     call SimoNOTE "*******************************************************%CmdName%"
     call SimoNOTE "Starting CmdName %CmdName%"
rem  *
rem  * Step 2 of 4, Do specific file mapping and delete any previously
rem  *              created file...
rem  *
     call SimoNOTE "StepInfo Delete previously created file"
     set DATMRTW1=%BaseLib1%\DataLibA\Asc1\DATMRTW1.DAT
     set DATMRTW2=%BaseLib1%\DataLibA\Wrk1\DATMRTW2.DAT
     if exist %DATMRTW2% del %DATMRTW2%
rem  *
rem  * *******************************************************************
rem  * Step 3 of 4, Create a file with multiple record types
rem  *
     call SimoNOTE "StepInfo Execute Multiple Record Types in a File"
     run DATMRTC1
     if not ERRORLEVEL = 0 set JobStatus=0010
     if not %JobStatus% == 0000 goto :EojNok
     call SimoNOTE "DataTake %DATMRTW1%"
     call SimoNOTE "DataMake %DATMRTW2%"
rem  *
     if exist %DATMRTW2% goto :EojAok
     set JobStatus=0020
     goto :EojNok
rem  *
rem  * *******************************************************************
rem  * Step 4 of 4, End of Job Routines
rem  *
:EojAok
     call SimoNOTE "Finished JobName %CmdName%, Job Status is %JobStatus%"
     goto :End
:EojNok
     call SimoNOTE "ABENDING JobName %CmdName%, Job Status is %JobStatus%"
:End
     if not "%1" == "nopause" pause

CMD Member, Read a File & Accumulate Totals by Record Type
(Next) (Previous) (Table-of-Contents)

This job (DATMRTE3.cmd) will use a COBOL program to read a file with multiple record types and accumulate sub-totals by record types.

@echo OFF
rem  * *******************************************************************
rem  *               DATMRTE3.CMD - a Windows Command File               *
rem  *         This program is provided by SimoTime Enterprises          *
rem  *           (C) Copyright 1987-2013 All Rights Reserved             *
rem  *             Web Site URL:   http://www.simotime.com               *
rem  *                   e-mail:   helpdesk@simotime.com                 *
rem  * *******************************************************************
rem  *
rem  * Text   - Accumulate subtotals by record type
rem  * Author - SimoTime Enterprises
rem  * Date   - January 24, 1996
rem  *
rem  * The job will read an 80-byte file that contains multiple record
rem  * types and accumulate sub-totals by record type.
rem  *
rem  * This set of programs will run on a mainframe under MVS or on a
rem  * Personal Computer with Windows and Micro Focus Net Express.
rem  *
rem  *                     ************
rem  *                     * DATMRTE3 *
rem  *                     ********cmd*
rem  *                          *
rem  *                          *
rem  *                     ************     ************
rem  *                     * ezSetEnv *******  SetEnv  *
rem  *                     ********cmd*  *  *******task*
rem  *                          *
rem  *                          *
rem  *    ************     ************     ************
rem  *    * DATMRTW2 ******* DATMRTC2 ******* DATMRTW3 *
rem  *    *******rseq*     ********cbl*     *******rseq*
rem  *                          *
rem  *                          *
rem  *                     ************
rem  *                     *   EOJ    *
rem  *                     ************
rem  *
rem  * *******************************************************************
rem  * Step 1 of 4, Set global or Common Environment Variables
rem  *
     set CmdName=DATMRTE3
     call ..\Env1BASE %CmdName%
     if "%SYSLOG%" == "" set syslog=c:\SimoLIBR\LOGS\SimoTime.LOG
rem  *
     call SimoNOTE "*******************************************************%CmdName%"
     call SimoNOTE "Starting CmdName %CmdName%"
rem  *
rem  * Step 2 of 4, Do specific file mapping and delete any previously
rem  *              created file...
rem  *
     call SimoNOTE "StepInfo Delete previously created file"
     set DATMRTW2=%BaseLib1%\DataLibA\Wrk1\DATMRTW2.DAT
     set DATMRTW3=%BaseLib1%\DataLibA\Wrk1\DATMRTW3.DAT
     if exist %DATMRTW3% del %DATMRTW3%
rem  *
rem  * *******************************************************************
rem  * Step 3 of 4, Create a file with multiple record types
rem  *
     call SimoNOTE "StepInfo Execute Multiple Record Types in a File"
     run DATMRTC2
     if not ERRORLEVEL = 0 set JobStatus=0010
     if not %JobStatus% == 0000 goto :EojNok
     call SimoNOTE "DataTake %DATMRTW2%"
     call SimoNOTE "DataMake %DATMRTW3%"
rem  *
     if exist %DATMRTW2% goto :EojAok
     set JobStatus=0020
     goto :EojNok
rem  *
rem  * *******************************************************************
rem  * Step 4 of 4, End of Job Routines
rem  *
:EojAok
     call SimoNOTE "Finished JobName %CmdName%, Job Status is %JobStatus%"
     goto :End
:EojNok
     call SimoNOTE "ABENDING JobName %CmdName%, Job Status is %JobStatus%"
:End
     if not "%1" == "nopause" pause

The JCL Members
(Next) (Previous) (Table-of-Contents)

There are four (4) JCL members provided with this suite of sample programs. The jobs are described in more detail in the following sections.

JCL Member, Create a Baseline File
(Next) (Previous) (Table-of-Contents)

This following job (DATMRTJ1.jcl) will use IEBGENER to create a file that contains the base data in a text format.

//DATMRTJ1 JOB SIMOTIME,CLASS=1,MSGCLASS=0,NOTIFY=CSIP1
//* *******************************************************************
//*       DATMRTJ1.JCL - a JCL Member for Batch Job Processing        *
//*       This JCL Member is provided by: SimoTime Enterprises        *
//*           (C) Copyright 1987-2013 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 1st job step will delete any previously created files.
//*
//* The 2nd job step uses IEBGENER to 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.
//*
//* *******************************************************************
//* Step 1 of 2, Delete any previously created files...
//*
//RSEQDELT EXEC PGM=IEFBR14
//DATMRTW1 DD  DSN=SIMOTIME.DATA.DATMRTW1,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 RSEQ file...
//*
//CRTDATW1 EXEC PGM=IEBGENER
//SYSPRINT DD  SYSOUT=*
//SYSIN    DD  DUMMY
//* :....1....:....2....:....3....:....4....:....5....:....6....:....7.
//SYSUT1   DD  *
A01Text-48 with signed zoned decimal numeric data  000000101
A02Text-32 with packed data                        000000204
A03T16 binary data                                 000000307
A01Text-48 with signed zoned decimal numeric data  000000102
A02Text-32 with packed data                        000000205
A01Text-48 with signed zoned decimal numeric data  000000103
A03T16 binary data                                 000000309
A01Text-48 with signed zoned decimal numeric data  000000114
A01Text-48 with signed zoned decimal numeric data  000000115
A03T16 binary data                                 000000308
A02Text-32 with packed data                        000000206
/*
//SYSUT2   DD  DSN=SIMOTIME.DATA.DATMRTW1,
//             DISP=(NEW,CATLG,DELETE),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=FB,LRECL=80,BLKSIZE=800,DSORG=PS)
//*

JCL Member, Create a File with Multiple Record Types
(Next) (Previous) (Table-of-Contents)

The following is the JCL Member (DATMRTJ2.jcl) that is required to run as a job on a Mainframe System or on a Windows System with Micro Focus Mainframe Express or Server for Mainframe. The first job step will delete any files created by a previous execution. The second job step will read the file created by IEBGENER and write a file containing multiple record types and different numeric formats.

//DATMRTJ2 JOB SIMOTIME,CLASS=1,MSGCLASS=0,NOTIFY=CSIP1
//* *******************************************************************
//*       DATMRTJ2.JCL - a JCL Member for Batch Job Processing        *
//*       This JCL Member is provided by: SimoTime Enterprises        *
//*           (C) Copyright 1987-2013 All Rights Reserved             *
//*             Web Site URL:   http://www.simotime.com               *
//*                   e-mail:   helpdesk@simotime.com                 *
//* *******************************************************************
//*
//* Text   - Create a Sequential File with Multiple Record Types.
//* Author - SimoTime Enterprises
//* Date   - January 24, 1996
//*
//* The 1st job step will delete any previously created files.
//*
//* The 2nd job step executes a COBOL program that creates a new file
//* that contains multiple record types.
//*
//* 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 of 2, Delete any previously created files...
//*
//RSEQDELT EXEC PGM=IEFBR14
//DATMRTW2 DD  DSN=SIMOTIME.DATA.DATMRTW2,DISP=(MOD,DELETE,DELETE),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=FB,LRECL=80,BLKSIZE=800,DSORG=PS)
//*
//* *******************************************************************
//* Step 2 of 2, Create A file with multiple record types that contain
//*              packed and binary values...
//*
//CRTDATW2 EXEC PGM=DATMRTC1
//DATMRTW1 DD  DSN=SIMOTIME.DATA.DATMRTW1,DISP=SHR
//DATMRTW2 DD  DSN=SIMOTIME.DATA.DATMRTW2,DISP=(NEW,CATLG,DELETE),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=FB,LRECL=80,BLKSIZE=800,DSORG=PS)
//SYSOUT   DD  SYSOUT=*
//*

JCL Member, Read a File & Accumulate Totals by Record Type
(Next) (Previous) (Table-of-Contents)

The following is the mainframe JCL member (DATMRTJ3.jcl) that will read the file with multiple record types and accumulate sub-totals by record groups. The sub-totals are posted to an output file.

//DATMRTJ3 JOB SIMOTIME,CLASS=1,MSGCLASS=0,NOTIFY=CSIP1
//* *******************************************************************
//*       DATMRTJ3.JCL - a JCL Member for Batch Job Processing        *
//*       This JCL Member is provided by: SimoTime Enterprises        *
//*           (C) Copyright 1987-2013 All Rights Reserved             *
//*             Web Site URL:   http://www.simotime.com               *
//*                   e-mail:   helpdesk@simotime.com                 *
//* *******************************************************************
//*
//* Text   - Read a sequential file and accumulate subtotals by
//*          record groups.
//* Author - SimoTime Enterprises
//* Date   - January 24, 1996
//*
//* The 1st job step will delete any previously created
//* file.
//*
//* The 2nd job step will read the file with multiple record types
//* and accumulate sub-totals by record groups.
//*
//* 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 of 2, Delete any previously created file...
//*
//RSEQDELT EXEC PGM=IEFBR14
//DATMRTW3 DD  DSN=SIMOTIME.DATA.DATMRTW3,DISP=(MOD,DELETE,DELETE),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=FB,LRECL=80,BLKSIZE=800,DSORG=PS)
//*
//* *******************************************************************
//* Step 2 of 2, Create file with multiple record types that contain
//*              packed and binary values...
//*
//CRTDATW2 EXEC PGM=DATMRTC2
//DATMRTW2 DD  DSN=SIMOTIME.DATA.DATMRTW2,DISP=SHR
//DATMRTW3 DD  DSN=SIMOTIME.DATA.DATMRTW3,DISP=(NEW,CATLG,DELETE),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=FB,LRECL=80,BLKSIZE=800,DSORG=PS)
//SYSOUT   DD  SYSOUT=*
//*

JCL Member, EBCDIC to ASCII Conversion
(Next) (Previous) (Table-of-Contents)

The following is the mainframe JCL member (DATMRTJ4.jcl) that will read the EBCDIC-encoded file with multiple record types and write to an ASCII-encoded output file.

//DATMRTJ4 JOB SIMOTIME,CLASS=1,MSGCLASS=0,NOTIFY=CSIP1
//* *******************************************************************
//*       DATMRTJ4.JCL - a JCL Member for Batch Job Processing        *
//*       This JCL Member is provided by: SimoTime Enterprises        *
//*           (C) Copyright 1987-2013 All Rights Reserved             *
//*             Web Site URL:   http://www.simotime.com               *
//*                   e-mail:   helpdesk@simotime.com                 *
//* *******************************************************************
//*
//* Text   - Read EBCDIC RSEQ-80 and write ASCII RSEQ-80
//* Author - SimoTime Enterprises
//* Date   - January 24, 1996
//*
//* The 1st job step will delete any previously created
//* file.
//*
//* The 2nd job step will read the file with multiple record types
//* and accumulate sub-totals by record groups.
//*
//* 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 of 2, Delete any previously created file...
//*
//RSEQDELT EXEC PGM=IEFBR14
//DATMRTW4 DD  DSN=SIMOTIME.DATA.DATMRTW4,DISP=(MOD,DELETE,DELETE),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=FB,LRECL=80,BLKSIZE=800,DSORG=PS)
//*
//* *******************************************************************
//* Step 2 of 2, Convert file with multiple record types that contain
//*              packed and binary values...
//*
//CVTDATW2 EXEC PGM=DATMRTIO
//DATMRTGE DD  DSN=SIMOTIME.DATA.DATMRTW2,DISP=SHR
//DATMRTPA DD  DSN=SIMOTIME.DATA.DATMRTW4,DISP=(NEW,CATLG,DELETE),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=FB,LRECL=80,BLKSIZE=800,DSORG=PS)
//SYSOUT   DD  SYSOUT=*
//*

The COBOL Programs
(Next) (Previous) (Table-of-Contents)

This section describes each of the COBOL programs provide in this suite of sample programs.

COBOL Program, Create a File
(Next) (Previous) (Table-of-Contents)

This program (DATMRTC1.cbl) will add records to a file. The records to be added will contain different record formats with a user-defined identifier for each record format.

       IDENTIFICATION DIVISION.
       PROGRAM-ID.    DATMRTC1.
       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: 2008-10-21  Generation Time: 21:20:25:28    *
      *                                                               *
      *                                   Record    Record     Key    *
      *  Function  Name     Organization  Format    Max-Min  Pos-Len  *
      *  INPUT     DATMRTW1 SEQUENTIAL    FIXED      00080            *
      *                                                               *
      *  OUTPUT    DATMRTW2 SEQUENTIAL    FIXED      00080            *
      *                                                               *
      *****************************************************************
       ENVIRONMENT DIVISION.
       INPUT-OUTPUT SECTION.
       FILE-CONTROL.
           SELECT DATMRTW1-FILE  ASSIGN TO       DATMRTW1
                  ORGANIZATION  IS SEQUENTIAL
                  ACCESS MODE   IS SEQUENTIAL
                  FILE STATUS   IS DATMRTW1-STATUS.
           SELECT DATMRTW2-FILE  ASSIGN TO       DATMRTW2
                  ORGANIZATION  IS SEQUENTIAL
                  ACCESS MODE   IS SEQUENTIAL
                  FILE STATUS   IS DATMRTW2-STATUS.

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

       FD  DATMRTW2-FILE
           DATA RECORD    IS DATMRTW2-REC
           .
       01  DATMRTW2-REC.
           05  DATMRTW2-DATA-01 PIC X(00080).

      *****************************************************************
       WORKING-STORAGE SECTION.
       01  SIM-TITLE.
           05  T1 pic X(11) value '* DATMRTC1 '.
           05  T2 pic X(34) value 'Create File, Multiple Record Types'.
           05  T3 pic X(10) value ' v08.02.15'.
           05  T4 pic X(24) value ' http://www.simotime.com'.
       01  SIM-COPYRIGHT.
           05  C1 pic X(11) value '* DATMRTC1 '.
           05  C2 pic X(20) value 'Copyright 1987-2013 '.
           05  C3 pic X(28) value '    SimoTime Enterprises    '.
           05  C4 pic X(20) value ' All Rights Reserved'.

       01  SIM-THANKS-01.
           05  C1 pic X(11) value '* DATMRTC1 '.
           05  C2 pic X(32) value 'Thank you, this technology was p'.
           05  C3 pic X(32) value 'roduced at SimoTime Enterprises,'.
           05  C4 pic X(04) value ' LLC'.

       01  SIM-THANKS-02.
           05  C1 pic X(11) value '* DATMRTC1 '.
           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  DATMRTW1-STATUS.
           05  DATMRTW1-STATUS-L     pic X.
           05  DATMRTW1-STATUS-R     pic X.
       01  DATMRTW1-EOF              pic X       value 'N'.
       01  DATMRTW1-OPEN-FLAG        pic X       value 'C'.

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

       01  DATMRTW1-LRECL    pic 9(5)    value 00080.
       01  DATMRTW2-LRECL    pic 9(5)    value 00080.

      *****************************************************************
      * 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 '* DATMRTC1 '.
           05  MESSAGE-TEXT.
               10  MESSAGE-TEXT-1  pic X(68)   value SPACES.
               10  MESSAGE-TEXT-2  pic X(188)  value SPACES.

      *****************************************************************
       01  PROGRAM-NAME            pic X(8)     value 'DATMRTC1'.

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

       01  DATMRTW1-TOTAL.
           05  DATMRTW1-RDR  pic 9(9)  value 0.
           05  filler        pic X(3)  value ' - '.
           05  filler        pic X(23) value 'Line count for DATMRTW1'.
       01  DATMRTW2-TOTAL.
           05  DATMRTW2-ADD  pic 9(9)  value 0.
           05  filler        pic X(3)  value ' - '.
           05  filler        pic X(23) value 'Line count for DATMRTW2'.

       01  WORK-03           pic X(3)  value SPACES.
       01  WRITE-FLAG        pic X     value 'N'.

       01  DATMRTWS-RECORD.
           05  DATMRTWS-STATUS         PIC X.
           05  DATMRTWS-TYPE           PIC XX.
           05  DATMRTWS-TEXT           PIC X(48).
           05  DATMRTWS-NUMBER         PIC S9(9).
           05  FILLER                  PIC X(20).

       COPY DATMRTB1.
       COPY DATMRTB2.
       COPY DATMRTB3.

      *****************************************************************
       PROCEDURE DIVISION.
           perform Z-POST-COPYRIGHT
           perform DATMRTW1-OPEN
           perform DATMRTW2-OPEN

           perform until DATMRTW1-STATUS not = '00'
               move ALL SPACES to DATMRTW2-REC
               move 'N' to WRITE-FLAG
               perform DATMRTW1-READ
               if  DATMRTW1-STATUS = '00'
                   add 1 to DATMRTW1-RDR
                   move DATMRTW1-DATA-01(1:3) to WORK-03
                   evaluate WORK-03
                     when 'A01' perform BUILD-OUTPUT-RECORD-01
                                move 'Y' to WRITE-FLAG
                     when 'A02' perform BUILD-OUTPUT-RECORD-02
                                move 'Y' to WRITE-FLAG
                     when 'A03' perform BUILD-OUTPUT-RECORD-03
                                move 'Y' to WRITE-FLAG
                   end-evaluate
                   if  WRITE-FLAG = 'Y'
                       perform DATMRTW2-WRITE
                       if  DATMRTW2-STATUS = '00'
                           add 1 to DATMRTW2-ADD
                       end-if
                   end-if
               end-if
           end-perform

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

           move DATMRTW2-TOTAL 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 DATMRTW2-CLOSE
           perform DATMRTW1-CLOSE

           perform Z-THANK-YOU.
           GOBACK.

      *****************************************************************
       BUILD-OUTPUT-RECORD-01.
           move DATMRTW1-REC to DATMRTW2-REC
           exit.

      *****************************************************************
       BUILD-OUTPUT-RECORD-02.
           move ALL SPACES to DATMRT02-RECORD
           move DATMRTW1-REC to DATMRTWS-RECORD
           move DATMRTWS-STATUS to DATMRT02-STATUS
           move DATMRTWS-TYPE   to DATMRT02-TYPE
           move DATMRTWS-TEXT   to DATMRT02-TEXT
           add  DATMRTWS-NUMBER to ZERO giving DATMRT02-NUMBER
           move DATMRT02-RECORD to DATMRTW2-REC
           exit.

      *****************************************************************
       BUILD-OUTPUT-RECORD-03.
           move ALL SPACES to DATMRT03-RECORD
           move DATMRTW1-REC to DATMRTWS-RECORD
           move DATMRTWS-STATUS to DATMRT03-STATUS
           move DATMRTWS-TYPE   to DATMRT03-TYPE
           move DATMRTWS-TEXT   to DATMRT03-TEXT
           add  DATMRTWS-NUMBER to ZERO giving DATMRT03-NUMBER
           move DATMRT03-RECORD to DATMRTW2-REC
           exit.

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

      *****************************************************************
      * I/O Routines for the OUTPUT File...                           *
      *****************************************************************
       DATMRTW2-WRITE.
           if  DATMRTW2-OPEN-FLAG = 'C'
               perform DATMRTW2-OPEN
           end-if
           write DATMRTW2-REC
           if  DATMRTW2-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
           else
               if  DATMRTW2-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 DATMRTW2' to MESSAGE-TEXT
               perform Z-DISPLAY-MESSAGE-TEXT
               move DATMRTW2-STATUS to IO-STATUS
               perform Z-DISPLAY-IO-STATUS
               perform Z-ABEND-PROGRAM
           end-if
           exit.
      *---------------------------------------------------------------*
       DATMRTW2-OPEN.
           add 8 to ZERO giving APPL-RESULT.
           open OUTPUT DATMRTW2-FILE
           if  DATMRTW2-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
               move 'O' to DATMRTW2-OPEN-FLAG
           else
               add 12 to ZERO giving APPL-RESULT
           end-if
           if  APPL-AOK
               CONTINUE
           else
               move 'OPEN Failure with DATMRTW2' to MESSAGE-TEXT
               perform Z-DISPLAY-MESSAGE-TEXT
               move DATMRTW2-STATUS to IO-STATUS
               perform Z-DISPLAY-IO-STATUS
               perform Z-ABEND-PROGRAM
           end-if
           exit.
      *---------------------------------------------------------------*
       DATMRTW2-CLOSE.
           add 8 to ZERO giving APPL-RESULT.
           close DATMRTW2-FILE
           if  DATMRTW2-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
               move 'C' to DATMRTW2-OPEN-FLAG
           else
               add 12 to ZERO giving APPL-RESULT
           end-if
           if  APPL-AOK
               CONTINUE
           else
               move 'CLOSE Failure with DATMRTW2' to MESSAGE-TEXT
               perform Z-DISPLAY-MESSAGE-TEXT
               move DATMRTW2-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.

      *****************************************************************
       Z-THANK-YOU.
           move SIM-THANKS-01 to MESSAGE-BUFFER
           perform Z-DISPLAY-MESSAGE-TEXT
           move SIM-THANKS-02 to MESSAGE-BUFFER
           perform Z-DISPLAY-MESSAGE-TEXT
           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 Program, Accumulate Sub-totals by Record Group
(Next) (Previous) (Table-of-Contents)

This program (DATMRTC2.cbl) will read the file with multiple record types and accumulate a record count for each record type along with a subtotal for the various numeric formats used in each record type.

       IDENTIFICATION DIVISION.
       PROGRAM-ID.    DATMRTC2.
       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: 2008-10-21  Generation Time: 21:20:25:28    *
      *                                                               *
      *                                   Record    Record     Key    *
      *  Function  Name     Organization  Format    Max-Min  Pos-Len  *
      *  INPUT     DATMRTW2 SEQUENTIAL    FIXED      00080            *
      *                                                               *
      *  OUTPUT    DATMRTW3 SEQUENTIAL    FIXED      00080            *
      *                                                               *
      *                                                               *
      *                Translation Mode is UNKNOWN                    *
      *                                                               *
      *****************************************************************
       ENVIRONMENT DIVISION.
       INPUT-OUTPUT SECTION.
       FILE-CONTROL.
           SELECT DATMRTW2-FILE  ASSIGN TO       DATMRTW2
                  ORGANIZATION  IS SEQUENTIAL
                  ACCESS MODE   IS SEQUENTIAL
                  FILE STATUS   IS DATMRTW2-STATUS.
           SELECT DATMRTW3-FILE  ASSIGN TO       DATMRTW3
                  ORGANIZATION  IS SEQUENTIAL
                  ACCESS MODE   IS SEQUENTIAL
                  FILE STATUS   IS DATMRTW3-STATUS.

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

       FD  DATMRTW3-FILE
           DATA RECORD    IS DATMRTW3-REC
           .
       01  DATMRTW3-REC.
           05  DATMRTW3-DATA-01 PIC X(00080).

      *****************************************************************
      * This program was created using the SYSMASK1.TXT file as input.*
      * The SYSMASK1 provides for the sequential reading of the input *
      * file and the sequential writing of the output file.           *
      *                                                               *
      * If the output file is indexed then the input file must be in  *
      * sequence by the field that will be used to provide the key    *
      * for the output file.                                          *
      *                                                               *
      * If the key field is not in sequence then refer to SYSMASK2    *
      * to provide for a random add or update of the indexed 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 '* DATMRTC2 '.
           05  T2 pic X(34) value 'Audit Count, Multiple Record Types'.
           05  T3 pic X(10) value ' v08.02.15'.
           05  T4 pic X(24) value ' http://www.simotime.com'.
       01  SIM-COPYRIGHT.
           05  C1 pic X(11) value '* DATMRTC2 '.
           05  C2 pic X(20) value 'Copyright 1987-2013 '.
           05  C3 pic X(28) value '    SimoTime Enterprises    '.
           05  C4 pic X(20) value ' All Rights Reserved'.

       01  SIM-THANKS-01.
           05  C1 pic X(11) value '* DATMRTC2 '.
           05  C2 pic X(32) value 'Thank you, this technology was p'.
           05  C3 pic X(32) value 'roduced at SimoTime Enterprises,'.
           05  C4 pic X(04) value ' LLC'.

       01  SIM-THANKS-02.
           05  C1 pic X(11) value '* DATMRTC2 '.
           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  DATMRTW2-STATUS.
           05  DATMRTW2-STATUS-L     pic X.
           05  DATMRTW2-STATUS-R     pic X.
       01  DATMRTW2-EOF              pic X       value 'N'.
       01  DATMRTW2-OPEN-FLAG        pic X       value 'C'.

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

       01  DATMRTW2-LRECL    pic 9(5)    value 00080.
       01  DATMRTW3-LRECL    pic 9(5)    value 00080.

      *****************************************************************
      * 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 '* DATMRTC2 '.
           05  MESSAGE-TEXT.
               10  MESSAGE-TEXT-1  pic X(68)   value SPACES.
               10  MESSAGE-TEXT-2  pic X(188)  value SPACES.

      *****************************************************************
       01  PROGRAM-NAME            pic X(8)     value 'DATMRTC2'.

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

       01  DATMRTW2-TOTAL.
           05  DATMRTW2-RDR  pic 9(9)  value 0.
           05  filler        pic X(3)  value ' - '.
           05  filler        pic X(23) value 'Line count for DATMRTW2'.
       01  DATMRTW3-TOTAL.
           05  DATMRTW3-ADD  pic 9(9)  value 0.
           05  filler        pic X(3)  value ' - '.
           05  filler        pic X(23) value 'Line count for DATMRTW3'.

       01  WORK-03           pic X(3)  value SPACES.
       01  WRITE-FLAG        pic X     value 'N'.

       01  DATMRTWS-RECORD.
           05  DATMRTWS-STATUS         PIC X.
           05  DATMRTWS-TYPE           PIC XX.
           05  DATMRTWS-TEXT           PIC X(48).
           05  DATMRTWS-NUMBER         PIC S9(9).
           05  FILLER                  PIC X(20).

       01  SUB-TOTAL-01   PIC 9(7)     value 0.
       01  SUB-TOTAL-02   PIC 9(7)     value 0.
       01  SUB-TOTAL-03   PIC 9(7)     value 0.
       01  SUB-TOTAL-99   PIC 9(7)     value 0.
       01  REC-COUNT-01   PIC 9(7)     value 0.
       01  REC-COUNT-02   PIC 9(7)     value 0.
       01  REC-COUNT-03   PIC 9(7)     value 0.
       01  REC-COUNT-99   PIC 9(7)     value 0.

       01  SUMMARY-LINE-01.
           05  FILLER     PIC X(12)    value '  Group-01  '.
           05  RECORDS-01 PIC Z,ZZZ,ZZ9+.
           05  FILLER     PIC X(18)    value '  record count    '.
           05  SUMMARY-01 PIC Z,ZZZ,ZZ9+.
           05  FILLER     PIC X(18)    value '  sub-total       '.
       01  SUMMARY-LINE-02.
           05  FILLER     PIC X(12)    value '  Group-02  '.
           05  RECORDS-02 PIC Z,ZZZ,ZZ9+.
           05  FILLER     PIC X(18)    value '  record count    '.
           05  SUMMARY-02 PIC Z,ZZZ,ZZ9+.
           05  FILLER     PIC X(18)    value '  sub-total       '.
       01  SUMMARY-LINE-03.
           05  FILLER     PIC X(12)    value '  Group-03  '.
           05  RECORDS-03 PIC Z,ZZZ,ZZ9+.
           05  FILLER     PIC X(18)    value '  record count    '.
           05  SUMMARY-03 PIC Z,ZZZ,ZZ9+.
           05  FILLER     PIC X(18)    value '  sub-total       '.
       01  SUMMARY-LINE-99.
           05  FILLER     PIC X(12)    value '  Group-All '.
           05  RECORDS-99 PIC Z,ZZZ,ZZ9+.
           05  FILLER     PIC X(18)    value '  record count    '.
           05  SUMMARY-99 PIC Z,ZZZ,ZZ9+.
           05  FILLER     PIC X(18)    value '  Final TOTAL     '.

       COPY DATMRTB1.
       COPY DATMRTB2.
       COPY DATMRTB3.

      *****************************************************************
       PROCEDURE DIVISION.
           perform Z-POST-COPYRIGHT
           perform DATMRTW2-OPEN
           perform DATMRTW3-OPEN

           move ZERO to SUB-TOTAL-01
           move ZERO to SUB-TOTAL-02
           move ZERO to SUB-TOTAL-03
           move ZERO to REC-COUNT-01
           move ZERO to REC-COUNT-02
           move ZERO to REC-COUNT-03

           perform until DATMRTW2-STATUS not = '00'
               move ALL SPACES to DATMRTW3-REC
               move 'N' to WRITE-FLAG
               perform DATMRTW2-READ
               if  DATMRTW2-STATUS = '00'
                   add 1 to DATMRTW2-RDR
                   move DATMRTW2-DATA-01(1:3) to WORK-03
                   evaluate WORK-03
                     when 'A01' perform POST-RECORD-01
                     when 'A02' perform POST-RECORD-02
                     when 'A03' perform POST-RECORD-03
                   end-evaluate
                   if  WRITE-FLAG = 'Y'
                       perform DATMRTW3-WRITE
                       if  DATMRTW3-STATUS = '00'
                           add 1 to DATMRTW3-ADD
                       end-if
                   end-if
               end-if
           end-perform

           move SIM-TITLE to DATMRTW3-REC
           perform DATMRTW3-WRITE
           move SIM-COPYRIGHT to DATMRTW3-REC
           perform DATMRTW3-WRITE
           move ALL SPACES to DATMRTW3-REC
           perform DATMRTW3-WRITE

           add SUB-TOTAL-01 to ZERO giving SUMMARY-01
           add REC-COUNT-01 to ZERO giving RECORDS-01
           move SUMMARY-LINE-01 to DATMRTW3-REC
           perform DATMRTW3-WRITE
           if  DATMRTW3-STATUS = '00'
               add 1 to DATMRTW3-ADD
           end-if

           add SUB-TOTAL-02 to ZERO giving SUMMARY-02
           add REC-COUNT-02 to ZERO giving RECORDS-02
           move SUMMARY-LINE-02 to DATMRTW3-REC
           perform DATMRTW3-WRITE
           if  DATMRTW3-STATUS = '00'
               add 1 to DATMRTW3-ADD
           end-if

           add SUB-TOTAL-03 to ZERO giving SUMMARY-03
           add REC-COUNT-03 to ZERO giving RECORDS-03
           move SUMMARY-LINE-03 to DATMRTW3-REC
           perform DATMRTW3-WRITE
           if  DATMRTW3-STATUS = '00'
               add 1 to DATMRTW3-ADD
           end-if

           compute SUB-TOTAL-99 = SUB-TOTAL-01
                                + SUB-TOTAL-02
                                + SUB-TOTAL-03
           add SUB-TOTAL-99 to ZERO giving SUMMARY-99
           compute REC-COUNT-99 = REC-COUNT-01
                                + REC-COUNT-02
                                + REC-COUNT-03
           add REC-COUNT-99 to ZERO giving RECORDS-99
           move SUMMARY-LINE-99 to DATMRTW3-REC
           perform DATMRTW3-WRITE
           if  DATMRTW3-STATUS = '00'
               add 1 to DATMRTW3-ADD
           end-if

           move ALL SPACES to DATMRTW3-REC
           perform DATMRTW3-WRITE
           move SIM-THANKS-01 to DATMRTW3-REC
           perform DATMRTW3-WRITE
           move SIM-THANKS-02 to DATMRTW3-REC
           perform DATMRTW3-WRITE
           move ALL SPACES to DATMRTW3-REC
           perform DATMRTW3-WRITE

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

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

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

           perform DATMRTW3-CLOSE
           perform DATMRTW2-CLOSE

           perform Z-THANK-YOU.

           GOBACK.

      *****************************************************************
       POST-RECORD-01.
           move DATMRTW2-REC to DATMRT01-RECORD
           add DATMRT01-NUMBER to SUB-TOTAL-01
           add 1 to REC-COUNT-01
           exit.

      *****************************************************************
       POST-RECORD-02.
           move DATMRTW2-REC to DATMRT02-RECORD
           add DATMRT02-NUMBER to SUB-TOTAL-02
           add 1 to REC-COUNT-02
           exit.

      *****************************************************************
       POST-RECORD-03.
           move DATMRTW2-REC to DATMRT03-RECORD
           add DATMRT03-NUMBER to SUB-TOTAL-03
           add 1 to REC-COUNT-03
           exit.

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

      *****************************************************************
      * I/O Routines for the OUTPUT File...                           *
      *****************************************************************
       DATMRTW3-WRITE.
           if  DATMRTW3-OPEN-FLAG = 'C'
               perform DATMRTW3-OPEN
           end-if
           write DATMRTW3-REC
           if  DATMRTW3-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
           else
               if  DATMRTW3-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 DATMRTW3' to MESSAGE-TEXT
               perform Z-DISPLAY-MESSAGE-TEXT
               move DATMRTW3-STATUS to IO-STATUS
               perform Z-DISPLAY-IO-STATUS
               perform Z-ABEND-PROGRAM
           end-if
           exit.
      *---------------------------------------------------------------*
       DATMRTW3-OPEN.
           add 8 to ZERO giving APPL-RESULT.
           open OUTPUT DATMRTW3-FILE
           if  DATMRTW3-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
               move 'O' to DATMRTW3-OPEN-FLAG
           else
               add 12 to ZERO giving APPL-RESULT
           end-if
           if  APPL-AOK
               CONTINUE
           else
               move 'OPEN Failure with DATMRTW3' to MESSAGE-TEXT
               perform Z-DISPLAY-MESSAGE-TEXT
               move DATMRTW3-STATUS to IO-STATUS
               perform Z-DISPLAY-IO-STATUS
               perform Z-ABEND-PROGRAM
           end-if
           exit.
      *---------------------------------------------------------------*
       DATMRTW3-CLOSE.
           add 8 to ZERO giving APPL-RESULT.
           close DATMRTW3-FILE
           if  DATMRTW3-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
               move 'C' to DATMRTW3-OPEN-FLAG
           else
               add 12 to ZERO giving APPL-RESULT
           end-if
           if  APPL-AOK
               CONTINUE
           else
               move 'CLOSE Failure with DATMRTW3' to MESSAGE-TEXT
               perform Z-DISPLAY-MESSAGE-TEXT
               move DATMRTW3-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.

      *****************************************************************
       Z-THANK-YOU.
           move SIM-THANKS-01 to MESSAGE-BUFFER
           perform Z-DISPLAY-MESSAGE-TEXT
           move SIM-THANKS-02 to MESSAGE-BUFFER
           perform Z-DISPLAY-MESSAGE-TEXT
           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       *
      *****************************************************************

The COBOL Program for File Format and Record Content Conversion
(Next) (Previous) (Table-of-Contents)

The following COBOL program (DATMRTIO.cbl) is the mainline program for doing the file I/O and calling the conversion routines based on the record type being processed.

       IDENTIFICATION DIVISION.
       PROGRAM-ID.    DATMRTIO.
       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: 2008-10-23  Generation Time: 21:44:04:46    *
      *                                                               *
      *                                   Record    Record     Key    *
      *  Function  Name     Organization  Format    Max-Min  Pos-Len  *
      *  INPUT     DATMRTGE SEQUENTIAL    FIXED      00080            *
      *                                                               *
      *  OUTPUT    DATMRTPA SEQUENTIAL    FIXED      00080            *
      *                                                               *
      *                                                               *
      *                Translation Mode is UNKNOWN                    *
      *                                                               *
      *****************************************************************
       ENVIRONMENT DIVISION.
       INPUT-OUTPUT SECTION.
       FILE-CONTROL.
           SELECT DATMRTGE-FILE  ASSIGN TO       DATMRTGE
                  ORGANIZATION  IS SEQUENTIAL
                  ACCESS MODE   IS SEQUENTIAL
                  FILE STATUS   IS DATMRTGE-STATUS.
           SELECT DATMRTPA-FILE  ASSIGN TO       DATMRTPA
                  ORGANIZATION  IS SEQUENTIAL
                  ACCESS MODE   IS SEQUENTIAL
                  FILE STATUS   IS DATMRTPA-STATUS.

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

       FD  DATMRTPA-FILE
           DATA RECORD    IS DATMRTPA-REC
           .
       01  DATMRTPA-REC.
           05  DATMRTPA-DATA-01 PIC X(00080).

      *****************************************************************
      * This program was created using the SYSMASK3.TXT file as the   *
      * template for the File I/O. It is intended for use with the    *
      * TransCALL facility that makes a call to a routine that does   *
      * the actual conversion between EBCDIC and ASCII. For more      *
      * information or questions contact SimoTime Enterprises.        *
      *                                                               *
      *        Our e-mail address is: helpdesk@simotime.com           *
      *     Also, visit our Web Site at http://www.simotime.com       *
      *                                                               *
      * The SYSMASK3 provides for the sequential reading of the input *
      * file and the sequential writing of the output file.           *
      * If the output file is indexed then the input file must be in  *
      * sequence by the field that will be used to provide the key    *
      * for the output file.                                          *
      *                                                               *
      * If the key field is not in sequence then refer to SYSMASK4    *
      * to provide for a random add or update of the indexed file.    *
      *****************************************************************
       WORKING-STORAGE SECTION.
       01  SIM-TITLE.
           05  T1 pic X(11) value '* DATMRTIO '.
           05  T2 pic X(34) value 'Convert Multiple Record types, E2A'.
           05  T3 pic X(10) value ' v08.02.15'.
           05  T4 pic X(24) value ' http://www.simotime.com'.
       01  SIM-COPYRIGHT.
           05  C1 pic X(11) value '* DATMRTIO '.
           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   '.

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

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

       01  DATMRTGE-LRECL    pic 9(5)    value 00080.
       01  DATMRTPA-LRECL    pic 9(5)    value 00080.

      *****************************************************************
      * 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 '* DATMRTIO '.
           05  MESSAGE-TEXT.
               10  MESSAGE-TEXT-1  pic X(68)   value SPACES.
               10  MESSAGE-TEXT-2  pic X(188)  value SPACES.

      *****************************************************************
       01  PROGRAM-NAME            pic X(8)     value 'DATMRTIO'.

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

       01  DATMRTGE-TOTAL.
           05  DATMRTGE-RDR  pic 9(9)    value 0.
           05  filler      pic X(3)    value ' - '.
           05  filler      pic X(23)   value 'Line count for DATMRTGE'.
       01  DATMRTPA-TOTAL.
           05  DATMRTPA-ADD  pic 9(9)    value 0.
           05  filler      pic X(3)    value ' - '.
           05  filler      pic X(23)   value 'Line count for DATMRTPA'.

      *****************************************************************
       PROCEDURE DIVISION.
           perform Z-POST-COPYRIGHT
           perform DATMRTGE-OPEN
           perform DATMRTPA-OPEN

           perform until DATMRTGE-STATUS not = '00'
               perform DATMRTGE-READ
               if  DATMRTGE-STATUS = '00'
                   add 1 to DATMRTGE-RDR
                   perform BUILD-OUTPUT-RECORD
                   perform DATMRTPA-WRITE
                   if  DATMRTPA-STATUS = '00'
                       add 1 to DATMRTPA-ADD
                   end-if
               end-if
           end-perform

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

           move DATMRTPA-TOTAL 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 DATMRTPA-CLOSE
           perform DATMRTGE-CLOSE
           GOBACK.

      *****************************************************************
       BUILD-OUTPUT-RECORD.
      *>   TransCALL process...
           move DATMRTGE-REC to DATMRTPA-REC
           evaluate DATMRTGE-REC(2:2)
             when x'F0F1' call 'DATMRTR1' using DATMRTPA-REC
             when x'F0F2' call 'DATMRTR2' using DATMRTPA-REC
             when x'F0F3' call 'DATMRTR3' using DATMRTPA-REC
           end-evaluate
           add 00080 to ZERO giving DATMRTPA-LRECL
           exit.

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

      *****************************************************************
      * I/O Routines for the OUTPUT File...                           *
      *****************************************************************
       DATMRTPA-WRITE.
           if  DATMRTPA-OPEN-FLAG = 'C'
               perform DATMRTPA-OPEN
           end-if
           write DATMRTPA-REC
           if  DATMRTPA-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
           else
               if  DATMRTPA-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 DATMRTPA' to MESSAGE-TEXT
               perform Z-DISPLAY-MESSAGE-TEXT
               move DATMRTPA-STATUS to IO-STATUS
               perform Z-DISPLAY-IO-STATUS
               perform Z-ABEND-PROGRAM
           end-if
           exit.
      *---------------------------------------------------------------*
       DATMRTPA-OPEN.
           add 8 to ZERO giving APPL-RESULT.
           open OUTPUT DATMRTPA-FILE
           if  DATMRTPA-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
               move 'O' to DATMRTPA-OPEN-FLAG
           else
               add 12 to ZERO giving APPL-RESULT
           end-if
           if  APPL-AOK
               CONTINUE
           else
               move 'OPEN Failure with DATMRTPA' to MESSAGE-TEXT
               perform Z-DISPLAY-MESSAGE-TEXT
               move DATMRTPA-STATUS to IO-STATUS
               perform Z-DISPLAY-IO-STATUS
               perform Z-ABEND-PROGRAM
           end-if
           exit.
      *---------------------------------------------------------------*
       DATMRTPA-CLOSE.
           add 8 to ZERO giving APPL-RESULT.
           close DATMRTPA-FILE
           if  DATMRTPA-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
               move 'C' to DATMRTPA-OPEN-FLAG
           else
               add 12 to ZERO giving APPL-RESULT
           end-if
           if  APPL-AOK
               CONTINUE
           else
               move 'CLOSE Failure with DATMRTPA' to MESSAGE-TEXT
               perform Z-DISPLAY-MESSAGE-TEXT
               move DATMRTPA-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: 2008-10-23  Generation Time: 21:44:04:48    *
      *****************************************************************

Callable COBOL Conversion Routine for Record Type 01
(Next) (Previous) (Table-of-Contents)

The following routine (DATMRTR1.cbl) is called to convert a record type 01 from EBCDIC to ASCII.

       IDENTIFICATION DIVISION.
       PROGRAM-ID.    DATMRTR1.
       AUTHOR.        SIMOTIME ENTERPRISES.
      *****************************************************************
      *           This routine was generated by SimoREC1              *
      *             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: 2008/10/23  Generation Time: 22:05:51:03    *
      *****************************************************************
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  IX-1  PIC 9(5) VALUE 0.
       01  RM-1  PIC 9(5) VALUE 0.
       01  RO-1  PIC 9(5) VALUE 0.
       01  IX-2  PIC 9(5) VALUE 0.
       01  RM-2  PIC 9(5) VALUE 0.
       01  RO-2  PIC 9(5) VALUE 0.

       COPY ASCEBCB1.
       COPY ASCEBCB2.

      *****************************************************************
       LINKAGE SECTION.
       COPY DATMRTB1.

      *****************************************************************
       PROCEDURE DIVISION using DATMRT01-RECORD.
           inspect DATMRT01-STATUS          converting E-INFO to A-INFO
           inspect DATMRT01-TYPE            converting E-INFO to A-INFO
           inspect DATMRT01-TEXT            converting E-INFO to A-INFO
      *    Decimal........ DATMRT01-NUMBER
           inspect DATMRT01-RECORD(52:9)    converting E-NUMB to A-NUMB
      *    Filler......... A Non-Unique Reference to a Data Item
           inspect DATMRT01-RECORD(61:20)   converting E-INFO to A-INFO
           GOBACK.
      *****************************************************************
      *           This routine was generated by SimoREC1              *
      *             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: 2008/10/23  Generation Time: 22:05:51:03    *
      *****************************************************************

Callable COBOL Conversion Routine for Record Type 02
(Next) (Previous) (Table-of-Contents)

The following routine (DATMRTR2.cbl) is called to convert a record type 02 from EBCDIC to ASCII.

       IDENTIFICATION DIVISION.
       PROGRAM-ID.    DATMRTR2.
       AUTHOR.        SIMOTIME ENTERPRISES.
      *****************************************************************
      *           This routine was generated by SimoREC1              *
      *             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: 2008/10/23  Generation Time: 22:05:51:21    *
      *****************************************************************
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  IX-1  PIC 9(5) VALUE 0.
       01  RM-1  PIC 9(5) VALUE 0.
       01  RO-1  PIC 9(5) VALUE 0.
       01  IX-2  PIC 9(5) VALUE 0.
       01  RM-2  PIC 9(5) VALUE 0.
       01  RO-2  PIC 9(5) VALUE 0.

       COPY ASCEBCB1.
       COPY ASCEBCB2.

      *****************************************************************
       LINKAGE SECTION.
       COPY DATMRTB2.

      *****************************************************************
       PROCEDURE DIVISION using DATMRT02-RECORD.
           inspect DATMRT02-STATUS          converting E-INFO to A-INFO
           inspect DATMRT02-TYPE            converting E-INFO to A-INFO
           inspect DATMRT02-TEXT            converting E-INFO to A-INFO
      *    Packed......... DATMRT02-NUMBER
      *    Filler......... A Non-Unique Reference to a Data Item
           inspect DATMRT02-RECORD(41:40)   converting E-INFO to A-INFO
           GOBACK.
      *****************************************************************
      *           This routine was generated by SimoREC1              *
      *             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: 2008/10/23  Generation Time: 22:05:51:21    *
      *****************************************************************

Callable COBOL Conversion Routine for Record Type 03
(Next) (Previous) (Table-of-Contents)

The following routine (DATMRTR3.cbl) is called to convert a record type 03 from EBCDIC to ASCII.

       IDENTIFICATION DIVISION.
       PROGRAM-ID.    DATMRTR3.
       AUTHOR.        SIMOTIME ENTERPRISES.
      *****************************************************************
      *           This routine was generated by SimoREC1              *
      *             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: 2008/10/23  Generation Time: 22:05:51:42    *
      *****************************************************************
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  IX-1  PIC 9(5) VALUE 0.
       01  RM-1  PIC 9(5) VALUE 0.
       01  RO-1  PIC 9(5) VALUE 0.
       01  IX-2  PIC 9(5) VALUE 0.
       01  RM-2  PIC 9(5) VALUE 0.
       01  RO-2  PIC 9(5) VALUE 0.

       COPY ASCEBCB1.
       COPY ASCEBCB2.

      *****************************************************************
       LINKAGE SECTION.
       COPY DATMRTB3.

      *****************************************************************
       PROCEDURE DIVISION using DATMRT03-RECORD.
           inspect DATMRT03-STATUS          converting E-INFO to A-INFO
           inspect DATMRT03-TYPE            converting E-INFO to A-INFO
           inspect DATMRT03-TEXT            converting E-INFO to A-INFO
      *    Binary......... DATMRT03-NUMBER
      *    Filler......... A Non-Unique Reference to a Data Item
           inspect DATMRT03-RECORD(24:57)   converting E-INFO to A-INFO
           GOBACK.
      *****************************************************************
      *           This routine was generated by SimoREC1              *
      *             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: 2008/10/23  Generation Time: 22:05:51:42    *
      *****************************************************************

The COBOL Copy Files
(Next) (Previous) (Table-of-Contents)

This section describes the three different record formats for the sequential file. For each record in the file the 1st byte is always the record status. An "A" indicates the record is "Active". The character "D" in the first position indicates the record is flagged for deletion.

The next two byte (or positions 2-3) identify the record type. Valid entries for record type are 01, 02 and 03. The following sections describe each of the record types and the associated copy file.

Copy File for Record Type 01
(Next) (Previous) (Table-of-Contents)

This copy file (DATMRTB1.cpy) defines the record layout for type "01" record.

      *****************************************************************
      *               DATMRTB1.CPY - a COBOL Copy File                *
      *       Copy File for a file with multiple record types.        *
      *          The Record Definition for a Type 1 record.           *
      *   A 48 byte text string and a signed-zoned-decimal number.    *
      *         Copyright (C) 1987-2013 SimoTime Enterprises          *
      *                     All Rights Reserved                       *
      *              Provided by SimoTime Enterprises                 *
      *        Our e-mail address is: helpdesk@simotime.com           *
      *     Also, visit our Web Site at http://www.simotime.com       *
      *****************************************************************
      *
       01  DATMRT01-RECORD.
           05  DATMRT01-STATUS         PIC X.
           05  DATMRT01-TYPE           PIC XX.
           05  DATMRT01-TEXT           PIC X(48).
           05  DATMRT01-NUMBER         PIC S9(9).
           05  FILLER                  PIC X(20).
      *
      ***  DATMRTB1 - End-of-Copy File - - - - - - - - - - - DATMRTB1 *
      *****************************************************************
      *

Copy File for Record Type 02
(Next) (Previous) (Table-of-Contents)

This copy file (DATMRTB2.cpy) defines the record layout for type "02" record.

      *****************************************************************
      *               DATMRTB2.CPY - a COBOL Copy File                *
      *       Copy File for a file with multiple record types.        *
      *          The Record Definition for a Type 2 record.           *
      *          A 32 byte text string and a packed number.           *
      *         Copyright (C) 1987-2013 SimoTime Enterprises          *
      *                     All Rights Reserved                       *
      *              Provided by SimoTime Enterprises                 *
      *        Our e-mail address is: helpdesk@simotime.com           *
      *     Also, visit our Web Site at http://www.simotime.com       *
      *****************************************************************
      *
       01  DATMRT02-RECORD.
           05  DATMRT02-STATUS         PIC X.
           05  DATMRT02-TYPE           PIC XX.
           05  DATMRT02-TEXT           PIC X(32).
           05  DATMRT02-NUMBER         PIC S9(9)        COMP-3.
           05  FILLER                  PIC X(40).
      *
      ***  DATMRTB2 - End-of-Copy File - - - - - - - - - - - DATMRTB2 *
      *****************************************************************
      *

Copy File for Record Type 03
(Next) (Previous) (Table-of-Contents)

This copy file (DATMRTB3.cpy) defines the record layout for type "03" record.

      *****************************************************************
      *               DATMRTB3.CPY - a COBOL Copy File                *
      *       Copy File for a file with multiple record types.        *
      *           The Record Definition for a Type 3 record.          *
      *           A 16 byte text string and a binary number.          *
      *         Copyright (C) 1987-2013 SimoTime Enterprises          *
      *                     All Rights Reserved                       *
      *              Provided by SimoTime Enterprises                 *
      *        Our e-mail address is: helpdesk@simotime.com           *
      *     Also, visit our Web Site at http://www.simotime.com       *
      *****************************************************************
      *
       01  DATMRT03-RECORD.
           05  DATMRT03-STATUS         PIC X.
           05  DATMRT03-TYPE           PIC XX.
           05  DATMRT03-TEXT           PIC X(16).
           05  DATMRT03-NUMBER         PIC S9(7)V99     COMP.
           05  FILLER                  PIC X(57).
      *
      ***  DATMRTB3 - End-of-Copy File - - - - - - - - - - - DATMRTB3 *
      *****************************************************************
      *

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

The purpose of this document is 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 document and the links to other documents are intended to provide a choice of alternatives.

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

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

SimoTime Enterprises 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 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, documentation or training material.

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

This section includes links to documents with additional information that are beyond the scope and purpose of this document.

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

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

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

Link to Internet   Link to Server   Explore the capabilities of the SimoZAPS Utility Program. This includes generating a COBOL program that will do the conversion of sequential and VSAM (KSDS) files between EBCDIC and ASCII while maintaining mainframe (or COBOL) numeric formats and integrity. 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.

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 to interpret the results of accessing VSAM data sets and/or QSAM files.

Downloads and Links, Internet Access Required
(Next) (Previous) (Table-of-Contents)

The following links will require an internet connect.

This suite of programs and documentation is available for download. 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 via Internet Connect for access to white papers, program examples and product information.

Explore The Micro Focus Web Site via Internet Connect for more information about products and services available from Micro Focus.

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

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.

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

This document was created and is copyrighted and maintained by SimoTime Enterprises.

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

We appreciate hearing from you.

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

Founded in 1987, SimoTime Enterprises 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. This includes the smallest thin client using the Internet and the very large mainframe systems. There is more to making the Internet work for your company's business than just having a nice looking WEB site. It is about combining the latest technologies and existing technologies with practical business experience. It's about the business of doing business and looking good in the process. Quite often, to reach larger markets or provide a higher level of service to existing customers it requires the newer Internet technologies to work in a complementary manner with existing corporate mainframe systems.

Whether you want to use the Internet to expand into new market segments or as a delivery vehicle for existing business functions simply give us a call or check the web site at http://www.simotime.com


Return-to-Top
Data File with Multiple Record Types, Processing and Conversion
Copyright © 1987-2013 SimoTime Enterprises  All Rights Reserved
When technology complements business
http://www.simotime.com