COBOL Table Processing
Linear and Binary Access
  Table of Contents  v-24.01.01 - binbit01.htm 
  Introduction
  Sample Routines
  Create a Binary Table
  Compare the Tables of Binary Values
  Create 256-Byte String of Binary Values
  Create 512-Byte String of 2-Byte Text
  Job Scripts
  JCL Member
  CMD File
  COBOL Members
  COBOL Demonstration Program
  COBOL Copy File
  Summary
  Software Agreement and Disclaimer
  Downloads and Links
  Current Server or Internet Access
  Internet Access Required
  Glossary of Terms
  Contact or Feedback
  Company Overview
The SimoTime Home Page 

Table of Contents Previous Section Next Section Introduction

This suite of programs will create two data arrays (or table definitions) that may be used to display binary characters in a hexadecimal format. The two data tables will be saved as COBOL Copy Files. This example includes two COBOL programs with the JCL Members and Window Command Files for execution. The first COBOL program will create a table or 256 elements or a text string of 256 bytes that will contain the binary values from X'00' through X'FF'. The program will also create a 512 byte text string of two-byte pairs that may be used to display a field or text string in a hexadecimal dump format. Once the text strings of binary and display values are created they are written to files that may be used as a COBOL copy files by other programs.

The second COBOL program will use the copy files created by the first program to insert binary data into a text string and display the text string in a hexadecimal dump format.

The source code for the CMD file, the JCL member and the COBOL programs is provided and may be modified to fit your environment. The COBOL programs will run on an IBM, ZOS Mainframe System or in a Micro Focus environment on Windows.


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

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

Table of Contents Previous Section Next Section Sample Routines

The intent of this section is to provide a summary of the sub-routines by function and a quick link to the sub-routines within the main program.

Table of Contents Previous Section Next Section Create a Binary Table

This sub-routine shows how to create a text string of 256 bytes that will contain the binary values from X'00' through X'FF'.

Click on this link to view the code in the program that does the Create a Binary Table. This will be displayed in a separate window.

Table of Contents Previous Section Next Section Compare the Tables of Binary Values

This sub-routine will compare the contents of the table just created with a binary table that is predefined by a COBOL Copy file.

Click on this link to view the code in the program that does the Compare the Tables. This will be displayed in a separate window.

Table of Contents Previous Section Next Section Create 256-Byte String of Binary Values

In the mid-1980's IBM provided an extension to the ANSI/85 COBOL with their version of COBOL/2. This extension allowed a programmer to define any of the hexadecimal from X'00' through X'FF'. This capability was later included in the ANSI/2002 standard.

Click on this link to view the code in the program that does the Create a Copy File of Binary Values. This will be displayed in a separate window.

Table of Contents Previous Section Next Section Create 512-Byte String of 2-Byte Text

This section describes how to create a 512 byte text string consisting of two (2) byte pairs of data. Each two (2) byte pair represents a text string that shows the value of a hexadecimal byte. Each two (2) byte pair may be displayed or printed.

Click on this link to view the code in the program that does the Create a Copy File of Display Text. This will be displayed in a separate window.

Table of Contents Previous Section Next Section Job Scripts

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

Table of Contents Previous Section Next Section JCL Member

The following (BINBITJ1.jcl) is a sample of the Mainframe JCL needed to run this job.

//BINBITJ1 JOB SIMOTIME,CLASS=1,MSGCLASS=0,NOTIFY=CSIP1
//* *******************************************************************
//*       BINBITJ1.JCL - a JCL Member for Batch Job Processing        *
//*       This JCL Member is provided by SimoTime Technologies        *
//*           (C) Copyright 1987-2019 All Rights Reserved             *
//*             Web Site URL:   http://www.simotime.com               *
//*                   e-mail:   helpdesk@simotime.com                 *
//* *******************************************************************
//*
//* Text   - Describe how to create, define, access or process Text
//*          strings or tables with binary values.
//* Author - SimoTime Technologies
//* Date   - January 24, 1996
//*
//* The job will create two (2) COBOL Copy Files.
//*
//* 1. The 1st copy file will define a table with 256 elements of
//*    one byte binary values from x'00' through x'FF'.
//* 2. The 2nd copy file will define a table 2ith 256 elements of
//*    two byte display values that map to the binary values defined
//*    by the 1st copy file.
//*
//* This set of programs will run on a mainframe under MVS or on a
//* Personal Computer with Windows and Micro Focus Net Express.
//*
//*          ************
//*          * BINBITJ1 *
//*          ********jcl*
//*               *
//*               *
//*          ************     ************
//*          * BINBITC1 *-----*  SYSOUT  *
//*          ********cbl*  *  ************
//*               *        *
//*               *        *  ************
//*               *        *--* HEXDECB1 *
//*               *           *******rseq*
//*               *        *
//*               *        *  ************
//*               *        *--* HEXDSPB1 *
//*               *           *******rseq*
//*               *
//*               *
//*          ************     ************
//*          * BINBITC1 *-----*  SYSOUT  *
//*          ********cbl*  *  ************
//*               *        *
//*               *        *  ************
//*               *        *--* HEXDECB1 *
//*               *           *******pdsm*
//*               *        *
//*               *        *  ************
//*               *        *--* HEXDSPB1 *
//*               *           *******pdsm*
//*               *
//*          ************
//*          *   EOJ    *
//*          ********cbl*
//*
//* *******************************************************************
//* Step 1 of 3, Delete any previously created file...
//*
//CLEANUP1 EXEC PGM=IEFBR14
//HEXDECB1 DD  DSN=SIMOTIME.DATA.HEXDECB1,DISP=(MOD,DELETE,DELETE),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=FB,LRECL=80,BLKSIZE=800,DSORG=PS)
//HEXDSPB1 DD  DSN=SIMOTIME.DATA.HEXDSPB1,DISP=(MOD,DELETE,DELETE),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=FB,LRECL=80,BLKSIZE=800,DSORG=PS)
//*
//* *******************************************************************
//* Step 2 of 3, Create two Record Sequential Files (RSEQ)...
//*
//BINBITS1 EXEC PGM=BINBITC1
//STEPLIB  DD  DSN=SIMOTIME.DEMO.LOADLIB1,DISP=SHR
//HEXDECB1 DD  DSN=SIMOTIME.DATA.HEXDECB1,
//             DISP=(NEW,CATLG,DELETE),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=FB,LRECL=80,BLKSIZE=800,DSORG=PS)
//HEXDSPB1 DD  DSN=SIMOTIME.DATA.HEXDSPB1,
//             DISP=(NEW,CATLG,DELETE),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=FB,LRECL=80,BLKSIZE=800,DSORG=PS)
//SYSOUT   DD  SYSOUT=*
//*
//* *******************************************************************
//* Step 3 of 3, Create two PDS Members (PDSM)...
//*
//BINBITS1 EXEC PGM=BINBITC1
//STEPLIB  DD  DSN=SIMOTIME.DEMO.LOADLIB1,DISP=SHR
//HEXDECB1 DD  DSN=SIMOTIME.PDS.COBCPY7(HEXDECB1),
//             DISP=SHR
//HEXDSPB1 DD  DSN=SIMOTIME.PDS.COBCPY7(HEXDSPB1),
//             DISP=SHR
//SYSOUT   DD  SYSOUT=*
//

Table of Contents Previous Section Next Section CMD File

The following (BINBITE1.cmd) is a sample of the Windows CMD needed to run this job.

@echo OFF
rem  * *******************************************************************
rem  *               BINBITE1.CMD - a Windows Command File               *
rem  *         This program is provided by SimoTime Technologies         *
rem  *           (C) Copyright 1987-2019 All Rights Reserved             *
rem  *             Web Site URL:   http://www.simotime.com               *
rem  *                   e-mail:   helpdesk@simotime.com                 *
rem  * *******************************************************************
rem  *
rem  * Text   - Describe how to create, define, access or process Text
rem  *          strings or tables with binary values.
rem  * Author - SimoTime Technologies
rem  * Date   - January 24, 1996
rem  *
rem  * The job will create two (2) COBOL Copy Files.
rem  * 1. The 1st copy file will define a table with 256 elements of
rem  *    one byte binary values from x'00' through x'FF'.
rem  * 2. The 2nd copy file will define a table 2ith 256 elements of
rem  *    two byte display values that map to the binary values defined
rem  *    by the 1st copy file.
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  *          * BINBITE1 *
rem  *          ********cmd*
rem  *               *
rem  *               *
rem  *          ************     ************
rem  *          * BINBITC1 *-----*  SYSOUT  *
rem  *          ********cbl*  *  ************
rem  *               *        *
rem  *               *        *  ************
rem  *               *        *--* HEXDECB1 *
rem  *               *           *******rseq*
rem  *               *        *
rem  *               *        *  ************
rem  *               *        *--* HEXDSPB1 *
rem  *               *           *******rseq*
rem  *               *
rem  *               *
rem  *          ************     ************
rem  *          * BINBITC1 *-----*  SYSOUT  *
rem  *          ********cbl*  *  ************
rem  *               *        *
rem  *               *        *  ************
rem  *               *        *--* HEXDECB1 *
rem  *               *           *******lseq*
rem  *               *        *
rem  *               *        *  ************
rem  *               *        *--* HEXDSPB1 *
rem  *               *           *******lseq*
rem  *               *
rem  *          ************
rem  *          *   EOJ    *
rem  *          ********cbl*
rem  *
rem  * *******************************************************************
rem  * Step 1, Delete any previously created file...
rem  *
     set CmdName=BinBite1
     call ..\Env1BASE %CmdName%
     if "%SYSLOG%" == "" set syslog=c:\SimoLIBR\LOGS\SimoTime.LOG
rem  *
     call SimoNOTE "*******************************************************%CmdName%"
     call SimoNOTE "Starting CmdName %CmdName%, V08.06.05, User is %USERNAME%"
     call SimoNOTE "StepInfo Delete previously created files"
     set HEXDECB1=%BaseLib1%\DATA\Wrk1\HEXDECB1.DAT
     set HEXDSPB1=%BaseLib1%\DATA\Wrk1\HEXDSPB1.DAT
     if exist %HEXDECB1% del %HEXDECB1%
     if exist %HEXDSPB1% del %HEXDSPB1%
rem  *
rem  * *******************************************************************
rem  * Step 2, Edit input, create a new output file...
rem  *
     call SimoNOTE "StepInfo Create Record Sequential files"
     run BINBITC1
     if not ERRORLEVEL = 0 set JobStatus=0020
     if not %JobStatus% == 0000 goto :EojNok
rem  *
     if exist %HEXDECB1% goto :Jump01
     set JobStatus=0020
     goto :EojNok
:Jump01
     if exist %HEXDSPB1% goto :Jump02
     set JobStatus=0030
     goto :EojNok
:Jump02
     call SimoNOTE "DataMake %HEXDECB1%"
     call SimoNOTE "DataMake %HEXDSPB1%"
rem  *
rem  * *******************************************************************
rem  * Step 3, Read Record Sequential Files, write Line Sequential Files.
rem  *
     call SimoNOTE "StepInfo Create Copy File, HexTable of 256 elements of 1 byte each"
     set GETRS080=%HEXDECB1%
     set PUTLS080=%BaseLib1%\DATA\Wrk1\HEXDECB1.CPY
     run CV80ARAL
     if not ERRORLEVEL = 0 set JobStatus=0031
     if not %JobStatus% == 0000 goto :EojNok
     call SimoNOTE "DataTake %GETRS080%"
     call SimoNOTE "DataMake %PUTLS080%"
rem  *
     call SimoNOTE "StepInfo Create Copy File, Display Table of 256 elements of 2 bytes each"
     set GETRS080=%HEXDSPB1%
     set PUTLS080=%BaseLib1%\DATA\Wrk1\HEXDSPB1.CPY
     run CV80ARAL
     if not ERRORLEVEL = 0 set JobStatus=0032
     if not %JobStatus% == 0000 goto :EojNok
     call SimoNOTE "DataTake %GETRS080%"
     call SimoNOTE "DataMake %PUTLS080%"
: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

Table of Contents Previous Section Next Section COBOL Members

There are two (2) COBOL source members in this suite of programs, a mainline (or demonstration) program, a callable bit-manipulation routine and a copy file that defines the pass area.

Table of Contents Previous Section Next Section COBOL Demonstration Program

The following (BINBITC1.cbl) is a sample of a COBOL program that will create and access a binary table.

       IDENTIFICATION DIVISION.
       PROGRAM-ID.    BINBITC1.
       AUTHOR.        SIMOTIME TECHNOLOGIES.
      *****************************************************************
      * Copyright (C) 1987-2019 SimoTime Technologies.                *
      *                                                               *
      * All rights reserved.  Unpublished, all rights reserved under  *
      * copyright law and international treaty.  Use of a copyright   *
      * notice is precautionary only and does not imply publication   *
      * or disclosure.                                                *
      *                                                               *
      * Permission to use, copy, modify and distribute this software  *
      * for any non-commercial purpose and without fee is hereby      *
      * granted, provided the SimoTime copyright notice appear on all *
      * copies of the software. The SimoTime name or Logo may not be  *
      * used in any advertising or publicity pertaining to the use    *
      * of the software without the written permission of SimoTime    *
      * Technologies.                                                 *
      *                                                               *
      * Permission to use, copy, modify and distribute this software  *
      * for any commercial purpose requires a fee to be paid to       *
      * SimoTime Technologies. Once the fee is received by SimoTime   *
      * the latest version of the software will be delivered and a    *
      * license will be granted for use within an enterprise,         *
      * provided the SimoTime copyright notice appear on all copies   *
      * of the software. The SimoTime name or Logo may not be used    *
      * in any advertising or publicity pertaining to the use of the  *
      * software without the written permission of SimoTime           *
      * Technologies.                                                 *
      *                                                               *
      * SimoTime Technologies makes no warranty or representations    *
      * about the suitability of the software for any purpose. It is  *
      * provided "AS IS" without any expressed or implied warranty,   *
      * including the implied warranties of merchantability, fitness  *
      * for a particular purpose and non-infringement. SimoTime       *
      * Technologies shall not be liable for any direct, indirect,    *
      * special or consequential damages resulting from the loss of   *
      * use, data or projects, whether in an action of contract or    *
      * tort, arising out of or in connection with the use or         *
      * performance of this software                                  *
      *                                                               *
      * SimoTime Technologies                                         *
      * 15 Carnoustie Drive                                           *
      * Novato, CA 94949-5849                                         *
      * 415.883.6565                                                  *
      *                                                               *
      * RESTRICTED RIGHTS LEGEND                                      *
      * Use, duplication, or disclosure by the Government is subject  *
      * to restrictions as set forth in subparagraph (c)(1)(ii) of    *
      * the Rights in Technical Data and Computer Software clause at  *
      * DFARS 52.227-7013 or subparagraphs (c)(1) and (2) of          *
      * Commercial  Computer Software - Restricted Rights  at 48      *
      * CFR 52.227-19, as applicable.  Contact SimoTime Technologies, *
      * 15 Carnoustie Drive, Novato, CA 94949-5849.                   *
      *                                                               *
      *****************************************************************
      *      This program is provided by SimoTime Technologies        *
      *        Our e-mail address is: helpdesk@simotime.com           *
      *     Also, visit our Web Site at http://www.simotime.com       *
      *****************************************************************
      *
      *****************************************************************
      * Source Member: BINBITC1.CBL
      *****************************************************************
      *
      * BINBITC1 - Create, Define and process binary tables.
      *
      * CALLING PROTOCOL
      * ----------------
      * Use standard procedure to RUN or ANIMATE.
      *
      * DESCRIPTION
      * -----------
      * This program will call a COBOL routine to access a
      * routine to convert between bits and bytes..
      *
      *          ************
      *          * BINBITJ1 *
      *          ********jcl*
      *               *
      *               *
      *          ************     ************
      *          * BINBITC1 *-----*  SYSOUT  *
      *          ********cbl*  *  ************
      *               *        *
      *               *        *  ************
      *               *        *--* HEXDECB1 *
      *               *           *******rseq*
      *               *        *
      *               *        *  ************
      *               *        *--* HEXDSPB1 *
      *               *           *******rseq*
      *          ************
      *          *   EOJ    *
      *          ********cbl*
      *
      *
      *****************************************************************
      *
      * MAINTENANCE
      * -----------
      * 1989/02/27 Simmons, Created program.
      * 1997/03/17 Simmons, Updated for call to SIMOBITS.
      *
      *****************************************************************
      *
       ENVIRONMENT DIVISION.
       INPUT-OUTPUT SECTION.
       FILE-CONTROL.
           SELECT HEXDECB1-FILE  ASSIGN TO       HEXDECB1
                  ORGANIZATION  IS SEQUENTIAL
                  ACCESS MODE   IS SEQUENTIAL
                  FILE STATUS   IS HEXDECB1-STATUS.

           SELECT HEXDSPB1-FILE  ASSIGN TO       HEXDSPB1
                  ORGANIZATION  IS SEQUENTIAL
                  ACCESS MODE   IS SEQUENTIAL
                  FILE STATUS   IS HEXDSPB1-STATUS.

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

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

       WORKING-STORAGE SECTION.
      *****************************************************************
      *    Data-structure for Title and Copyright...
      *    ------------------------------------------------------------
       01  SIM-TITLE.
           05  T1 pic X(11) value '* BINBITC1 '.
           05  T2 pic X(34) value 'Create Binary Data and Copy Files '.
           05  T3 pic X(10) value ' v08.03.13'.
           05  T4 pic X(24) value ' http://www.simotime.com'.
       01  SIM-COPYRIGHT.
           05  C1 pic X(11) value '* BINBITC1 '.
           05  C2 pic X(20) value 'Copyright 1987-2019 '.
           05  C3 pic X(28) value '   SimoTime Technologies    '.
           05  C4 pic X(20) value ' All Rights Reserved'.

       01  SIM-THANKS-01.
           05  C1 pic X(11) value '* BINBITC1 '.
           05  C2 pic X(32) value 'Thank you for using this program'.
           05  C3 pic X(32) value ' provided from SimoTime Technolo'.
           05  C4 pic X(04) value 'gies'.

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

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

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

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

      *****************************************************************
      * Message Buffer used by the Z-DISPLAY-MESSAGE-TEXT routine.    *
      *    ------------------------------------------------------------
       01  MESSAGE-BUFFER.
           05  MESSAGE-HEADER      pic X(11)   value '* BINBITC1 '.
           05  MESSAGE-TEXT.
               10  MESSAGE-TEXT-1  pic X(68)   value SPACES.
               10  MESSAGE-TEXT-2  pic X(188)  value SPACES.

       01  IX-1           pic 9(3) value 0.
       01  IX-2           pic 9(3) value 0.
       01  IX-3           pic 9(3) value 0.

       01  BIN-WORK-256        pic X(256)  value LOW-VALUES.
       01  BIN-WORK-02A.
           05  BIN-WORK-02B    pic 9(3)    comp value 0.

       01  HEX-CHAR            pic X(16)   value '0123456789ABCDEF'.

       01  HEX-DECIMAL-GROUP.
           05  FILLER          PIC x(11) VALUE '       01  '.
           05  FILLER          PIC X(18) VALUE 'HEX-DECIMAL-GROUP.'.

       01  HEX-DECIMAL-TABLE.
           05  FILLER          PIC x(11) VALUE '       01  '.
           05  FILLER          PIC X(18) VALUE 'HEX-DECIMAL-REDEF '.
           05  FILLER          PIC X(06) VALUE SPACES.
           05  FILLER          PIC X(10) VALUE 'REDEFINES '.
           05  FILLER          PIC X(18) VALUE 'HEX-DECIMAL-GROUP.'.

       01  HEX-DECIMAL-TABLE-02.
           05  FILLER          PIC x(15) VALUE '           05  '.
           05  FILLER          PIC X(18) VALUE 'HEX-DECIMAL-TABLE '.
           05  FILLER          PIC X(02) VALUE SPACES.
           05  FILLER          PIC X(06) VALUE 'pic X '.
           05  FILLER          PIC X(18) VALUE 'OCCURS 256 TIMES. '.

       01  HEX-DECIMAL-BYTES.
           05  FILLER          PIC x(15) VALUE '           05  '.
           05  FILLER          PIC X(04) VALUE 'HEX-'.
           05  HEX-SYMBOL      PIC X(02) VALUE '00'.
           05  FILLER          PIC X(14) VALUE SPACES.
           05  FILLER          PIC X(15) VALUE "pic X  VALUE X'".
           05  HEX-VALUE       PIC X(02) VALUE '00'.
           05  FILLER          PIC X(02) VALUE "'.".

       01  HEX-DISPLAY-GROUP.
           05  FILLER          PIC x(11) VALUE '       01  '.
           05  FILLER          PIC X(18) VALUE 'HEX-DISPLAY-GROUP.'.

       01  HEX-DISPLAY-TABLE.
           05  FILLER          PIC x(11) VALUE '       01  '.
           05  FILLER          PIC X(18) VALUE 'HEX-DISPLAY-REDEF '.
           05  FILLER          PIC X(06) VALUE SPACES.
           05  FILLER          PIC X(10) VALUE 'REDEFINES '.
           05  FILLER          PIC X(18) VALUE 'HEX-DISPLAY-GROUP.'.

       01  HEX-DISPLAY-TABLE-02.
           05  FILLER          PIC x(15) VALUE '           05  '.
           05  FILLER          PIC X(18) VALUE 'HEX-DISPLAY-TABLE '.
           05  FILLER          PIC X(02) VALUE SPACES.
           05  FILLER          PIC X(07) VALUE 'pic XX '.
           05  FILLER          PIC X(18) VALUE 'OCCURS 256 TIMES. '.

       01  HEX-DISPLAY-BYTES.
           05  FILLER          PIC x(15) VALUE '           05  '.
           05  FILLER          PIC X(04) VALUE 'DSP-'.
           05  DSP-SYMBOL      PIC X(02) VALUE '00'.
           05  FILLER          PIC X(14) VALUE SPACES.
           05  FILLER          PIC X(14) VALUE "pic XX VALUE '".
           05  DSP-VALUE       PIC X(02) VALUE '00'.
           05  FILLER          PIC X(02) VALUE "'.".

       COPY BANNERB1.

       COPY BIN256B1.

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

           perform Z-POST-COPYRIGHT

           perform CREATE-A-BINARY-TABLE

           perform COMPARE-THE-TABLES

           perform CREATE-A-HEX-DECIMAL-COPY-FILE

           perform CREATE-A-HEX-DISPLAY-COPY-FILE

           perform Z-THANK-YOU.

           move ZERO to RETURN-CODE

           GOBACK.

      *****************************************************************
      * COMPARE-THE-TABLES
      * Compare hard-coded table from copy file to generated Table
      *
       COMPARE-THE-TABLES.
           if  BINARY-DATA = BIN-WORK-256
               move 'Binary Tables are equal' to MESSAGE-TEXT
           else
               move 'Binary Tables are NOT equal' to MESSAGE-TEXT
           end-if
           perform Z-DISPLAY-MESSAGE-TEXT
           exit.

      *****************************************************************
      * CREATE-A-BINARY-TABLE
      * This routine will create a 256 byte text string containing the
      * hexadecimal values from X'00' through X'FF'.
      *
       CREATE-A-BINARY-TABLE.
           add 1 to ZERO giving BIN-WORK-02B
           add 1 to ZERO giving IX-1
           move BIN-WORK-02A to BIN-WORK-256(IX-1:2)
           perform 127 times
               add 2 to IX-1
               add 514 to BIN-WORK-02B
               move BIN-WORK-02A to BIN-WORK-256(IX-1:2)
           end-perform

           exit.

      *****************************************************************
      * CREATE-A-HEX-DECIMAL-COPY-FILE
      * This routine will create a COBOL copy file defining a 256 byte
      * text string containing the hexadecimal values from X'00'
      * through X'FF'.
      *
       CREATE-A-HEX-DECIMAL-COPY-FILE.
           perform HEXDECB1-OPEN
           move SPACES to HEXDECB1-REC
           perform DO-DEC-BANNER
           move HEX-DECIMAL-GROUP to HEXDECB1-REC
           perform HEXDECB1-WRITE
           add 1 to ZERO giving IX-1
           add 1 to ZERO giving IX-2
           perform 256 times
             move HEX-CHAR(IX-1:1) to HEX-SYMBOL(1:1)
             move HEX-CHAR(IX-2:1) to HEX-SYMBOL(2:1)
             move HEX-SYMBOL to HEX-VALUE
             move HEX-DECIMAL-BYTES to HEXDECB1-REC
             perform HEXDECB1-WRITE
             add 1 to IX-2
             if IX-2 > 16
                add 1 to IX-1
                add 1 to ZERO giving IX-2
             end-if
           end-perform

           move HEX-DECIMAL-TABLE to HEXDECB1-REC
           perform HEXDECB1-WRITE

           move HEX-DECIMAL-TABLE-02 to HEXDECB1-REC
           perform HEXDECB1-WRITE

           perform DO-DEC-BANNER
           perform HEXDECB1-CLOSE
           exit.

      *****************************************************************
      * CREATE-A-HEX-DISPLAY-COPY-FILE
      * This routine will create a COBOL copy file defining a 512 byte
      * text string containing 256 two (2) byte pairs of text values
      * representing the hex values from X'00' through X'FF'. The two
      * (2) byte text pairs may be printed or displayed.
      *
       CREATE-A-HEX-DISPLAY-COPY-FILE.
           perform HEXDSPB1-OPEN
           move SPACES to HEXDSPB1-REC
           perform DO-DSP-BANNER
           move HEX-DISPLAY-GROUP to HEXDSPB1-REC
           perform HEXDSPB1-WRITE
           add 1 to ZERO giving IX-1
           add 1 to ZERO giving IX-2
           perform 256 times
             move HEX-CHAR(IX-1:1) to DSP-SYMBOL(1:1)
             move HEX-CHAR(IX-2:1) to DSP-SYMBOL(2:1)
             move DSP-SYMBOL to DSP-VALUE
             move HEX-DISPLAY-BYTES to HEXDSPB1-REC
             perform HEXDSPB1-WRITE
             add 1 to IX-2
             if IX-2 > 16
                add 1 to IX-1
                add 1 to ZERO giving IX-2
             end-if
           end-perform

           move HEX-DISPLAY-TABLE to HEXDSPB1-REC
           perform HEXDSPB1-WRITE

           move HEX-DISPLAY-TABLE-02 to HEXDSPB1-REC
           perform HEXDSPB1-WRITE

           perform DO-DSP-BANNER
           perform HEXDSPB1-CLOSE
           exit.

      *****************************************************************
       DO-DEC-BANNER.
           move ALL '*' to HEXDECB1-REC(7:65)
           perform HEXDECB1-WRITE
           move SB-01 to SB-TEXT(6:51)
           move SIMOTIME-BANNER to HEXDECB1-REC
           perform HEXDECB1-WRITE
           move SB-02 to SB-TEXT(6:51)
           move SIMOTIME-BANNER to HEXDECB1-REC
           perform HEXDECB1-WRITE
           move SB-03 to SB-TEXT(6:51)
           move SIMOTIME-BANNER to HEXDECB1-REC
           perform HEXDECB1-WRITE
           move ALL '*' to HEXDECB1-REC(7:65)
           perform HEXDECB1-WRITE
           exit.

      *****************************************************************
       DO-DSP-BANNER.
           move ALL '*' to HEXDSPB1-REC(7:65)
           perform HEXDSPB1-WRITE
           move SB-01 to SB-TEXT(6:51)
           move SIMOTIME-BANNER to HEXDSPB1-REC
           perform HEXDSPB1-WRITE
           move SB-02 to SB-TEXT(6:51)
           move SIMOTIME-BANNER to HEXDSPB1-REC
           perform HEXDSPB1-WRITE
           move SB-03 to SB-TEXT(6:51)
           move SIMOTIME-BANNER to HEXDSPB1-REC
           perform HEXDSPB1-WRITE
           move ALL '*' to HEXDSPB1-REC(7:65)
           perform HEXDSPB1-WRITE
           exit.

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

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

      *****************************************************************
      * The following Z-Routines perform administrative tasks         *
      * for this program.                                             *
      *****************************************************************
      * ABEND the program, post a message to the console and issue    *
      * a STOP RUN.                                                   *
      *****************************************************************
       Z-ABEND-PROGRAM.
           if  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.
           move SIM-TITLE to MESSAGE-BUFFER
           perform Z-DISPLAY-MESSAGE-TEXT
           move SIM-COPYRIGHT to MESSAGE-BUFFER
           perform Z-DISPLAY-MESSAGE-TEXT
           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 Technologies        *
      *        Our e-mail address is: helpdesk@simotime.com           *
      *     Also, visit our Web Site at http://www.simotime.com       *
      *****************************************************************

Table of Contents Previous Section Next Section COBOL Copy File

The following (BIN256B1.cpy) is an example of a COBOL copy file that defines a table of 256, one (1) byte binary values.

      *****************************************************************
      *               BIN256B1.CPY - a COBOL Copy File                *
      *         Copyright (C) 1987-2018 SimoTime Technologies         *
      *                     All Rights Reserved                       *
      *              Provided by SimoTime Technologies                *
      *        Our e-mail address is: helpdesk@simotime.com           *
      *     Also, visit our Web Site at http://www.simotime.com       *
      *****************************************************************
      *
....:.*..1....:....2....:....3....:....4....:....5....:....6....:....7. ..:....8
       01  BINARY-DATA.
           05  FILLER pic X(16)
                          value X'000102030405060708090A0B0C0D0E0F'.    000-015
           05  FILLER pic X(16)
                          value X'101112131415161718191A1B1C1D1E1F'.    016-031
           05  FILLER pic X(16)
                          value X'202122232425262728292A2B2C2D2E2F'.    032-047
           05  FILLER pic X(16)
                          value X'303132333435363738393A3B3C3D3E3F'.    048-063
           05  FILLER pic X(16)
                          value X'404142434445464748494A4B4C4D4E4F'.    064-079
           05  FILLER pic X(16)
                          value X'505152535455565758595A5B5C5D5E5F'.    080=095
           05  FILLER pic X(16)
                          value X'606162636465666768696A6B6C6D6E6F'.    096-111
           05  FILLER pic X(16)
                          value X'707172737475767778797A7B7C7D7E7F'.    112-127
           05  FILLER pic X(16)
                          value X'808182838485868788898A8B8C8D8E8F'.    128-143
           05  FILLER pic X(16)
                          value X'909192939495969798999A9B9C9D9E9F'.    144-159
           05  FILLER pic X(16)
                          value X'A0A1A2A3A4A5A6A7A8A9AAABACADAEAF'.    160-175
           05  FILLER pic X(16)
                          value X'B0B1B2B3B4B5B6B7B8B9BABBBCBDBEBF'.    176-191
           05  FILLER pic X(16)
                          value X'C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF'.    192-207
           05  FILLER pic X(16)
                          value X'D0D1D2D3D4D5D6D7D8D9DADBDCDDDEDF'.    208-223
           05  FILLER pic X(16)
                          value X'E0E1E2E3E4E5E6E7E8E9EAEBECEDEEEF'.    224-239
           05  FILLER pic X(16)
                          value X'F0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF'.    240-255
....:.*..1....:....2....:....3....:....4....:....5....:....6....:....7. ..:....8
      *
       01  B-INFO          redefines BINARY-DATA pic X(256).
       01  BINARY-TABLE    redefines BINARY-DATA.
           05  BINARY-BYTE pic X     occurs 256 times.
      *
      ***  BIN256B1 - End-of-Copy File - - - - - - - - - - - BIN256B1 *
      *****************************************************************
      *

Table of Contents Previous Section Next Section Summary

This suite of programs will create two data arrays (or table definitions) that may be used to display binary characters in a hexadecimal format. The two data tables will be saved as COBOL Copy Files. This document may be used to assist as a tutorial for new programmers or as a quick reference for experienced programmers.

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

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

Table of Contents Previous Section Next Section Software Agreement and Disclaimer

Permission to use, copy, modify and distribute this software, documentation or training material for any purpose requires a fee to be paid to SimoTime Technologies. Once the fee is received by SimoTime the latest version of the software, documentation or training material will be delivered and a license will be granted for use within an enterprise, provided the SimoTime copyright notice appear on all copies of the software. The SimoTime name or Logo may not be used in any advertising or publicity pertaining to the use of the software without the written permission of SimoTime Technologies.

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

Table of Contents Previous Section Next Section Downloads and Links

This section includes links to documents with additional information that are beyond the scope and purpose of this document. The first group of documents may be available from a local system or via an internet connection, the second group of documents will require an internet connection.

Note: A SimoTime License is required for the items to be made available on a local system or server.

Table of Contents Previous Section Next Section Current Server or Internet Access

The following links may be to the current server or to the Internet.

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

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

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

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

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

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

Table of Contents Previous Section Next Section Internet Access Required

The following links will require an internet connect.

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

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

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

Table of Contents Previous Section Next Section Glossary of Terms

Link to Internet   Link to Server   Explore the Glossary of Terms for a list of terms and definitions used in this suite of documents and white papers.

Table of Contents Previous Section Next Section Contact or Feedback

This document was created and is maintained by SimoTime Technologies. If you have any questions, suggestions, comments or feedback please use the following contact information.

1. Send an e-mail to our helpdesk.
1.1. helpdesk@simotime.com.
2. Our telephone numbers are as follows.
2.1. 1 415 763-9430 office-helpdesk
2.2. 1 415 827-7045 mobile

 

We appreciate hearing from you.

Table of Contents Previous Section Next Section Company Overview

SimoTime Technologies was founded in 1987 and is a privately owned company. We specialize in the creation and deployment of business applications using new or existing technologies and services. We have a team of individuals that understand the broad range of technologies being used in today's environments. Our customers include small businesses using Internet technologies to corporations using very large mainframe systems.

Quite often, to reach larger markets or provide a higher level of service to existing customers it requires the newer Internet technologies to work in a complementary manner with existing corporate mainframe systems. We specialize in preparing applications and the associated data that are currently residing on a single platform to be distributed across a variety of platforms.

Preparing the application programs will require the transfer of source members that will be compiled and deployed on the target platform. The data will need to be transferred between the systems and may need to be converted and validated at various stages within the process. SimoTime has the technology, services and experience to assist in the application and data management tasks involved with doing business in a multi-system environment.

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


Return-to-Top
Create and Process Tables or Text Strings containing Binary Values using COBOL
Copyright © 1987-2024
SimoTime Technologies and Services
All Rights Reserved
When technology complements business
http://www.simotime.com