|
|
COBOL
Tables & Binary Values Create, Define, Access and Process http://www.simotime.com |
| When technology complements business | Copyright © 1987-2010 SimoTime Enterprises All Rights Reserved |
This example includes two COBOL programs with the JCL Members and Windows 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.
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.
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.
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.
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.
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 hexadeciaml 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.
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 //* ******************************************************************* //* This program is provided by: * //* SimoTime Enterprises, LLC * //* (C) Copyright 1987-2010 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 Enterprises //* Date - January 24, 1996 //* //* The job will use a COBOL copy file to define a Binary Text String //* that is redefined as a table. It will then create a Binary text //* string of the X'00' through X'FF' and build a new copy file. Next, //* the program will build a 512 byte text string for consisting of two //* (2) byte pairs that represent a single hexadecimal byte and may be //* displayed or printed. //* //* 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 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 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 Create two PDS Members (PDSM)... //* //BINBITS1 EXEC PGM=BINBITC1 //STEPLIB DD DSN=SIMOTIME.DEMO.LOADLIB1,DISP=SHR //HEXDECB1 DD DSN=SIMOTIME.PDS.COBCPY1(HEXDECB1), // DISP=SHR //HEXDSPB1 DD DSN=SIMOTIME.PDS.COBCPY1(HEXDSPB1), // DISP=SHR //SYSOUT DD SYSOUT=* // //
The following (BINBITE1.CMD) is a sample of the Windows CMD needed to run this job.
@echo OFF
rem * *******************************************************************
rem * This program is provided by: *
rem * SimoTime Enterprises, LLC *
rem * (C) Copyright 1987-2010 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 Enterprises
rem * Date - January 24, 1996
rem *
rem * The job will use a COBOL copy file to define a Binary Text String
rem * that is redefined as a table. It will then create a Binary text
rem * string of the X'00' through X'FF' and build a new copy file. Next,
rem * the program will build a 512 byte text string for consisting of two
rem * (2) byte pairs that represent a single hexadecimal byte and may be
rem * displayed or printed.
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 Env1PROD
if "%SYSLOG%" == "" set syslog=c:\SimoLIBR\LOGS\SimoTime.LOG
rem *
call SimoNOTE "*******************************************************%CmdName%"
call SimoNOTE "Starting JobName %CmdName%"
:DeleteQSAM
call SimoNOTE "Identify JobStep DeleteQSAM"
set HEXDECB1=%BaseLib1%\DataLibA\Wrk1\HEXDECB1.DAT
set HEXDSPB1=%BaseLib1%\DataLibA\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 *
:ExecuteTableRoutine
call SimoNOTE "Identify JobStep ExecuteTableRoutine"
run BINBITC1
if not ERRORLEVEL = 0 set JobStatus=0010
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
rem *
rem * *******************************************************************
rem * Step 3, Read Record Sequential Files, write Line Sequential Files.
rem *
set GETRS080=%HEXDECB1%
set PUTLS080=%BaseLib1%\DataLibA\Wrk1\HEXDECB1.CPY
run ARAL80C1
rem *
set GETRS080=%HEXDSPB1%
set PUTLS080=%BaseLib1%\DataLibA\Wrk1\HEXDSPB1.CPY
run ARAL80C1
:EojAok
call SimoNOTE "Produced DataSet %HEXDECB1%"
call SimoNOTE "Produced DataSet %HEXDSPB1%"
call SimoNOTE "Finished JobName %CmdName%, Job Status is %JobStatus%"
goto :End
:EojNok
call SimoNOTE "ABENDING JobName %CmdName%, Job Status is %JobStatus%"
:End
call SimoNOTE "Conclude SysLog is %SYSLOG%"
if not "%1" == "nopause" pause
The following (BINBITC1.CBL) is a sample of a COBOL program.
IDENTIFICATION DIVISION.
PROGRAM-ID. BINBITC1.
AUTHOR. SIMOTIME ENTERPRISES.
*****************************************************************
* Copyright (C) 1987-2010 SimoTime Enterprises, LLC. *
* *
* All rights reserved. Unpublished, all rights reserved under *
* copyright law and international treaty. Use of a copyright *
* notice is precautionary only and does not imply publication *
* or disclosure. *
* *
* Permission to use, copy, modify and distribute this software *
* for any non-commercial purpose and without fee is hereby *
* granted, provided the SimoTime copyright notice appear on all *
* copies of the software. The SimoTime name or Logo may not be *
* used in any advertising or publicity pertaining to the use *
* of the software without the written permission of SimoTime *
* Enterprises. *
* *
* Permission to use, copy, modify and distribute this software *
* for any commercial purpose requires a fee to be paid to *
* SimoTime Enterprises. Once the fee is received by SimoTime *
* the latest version of the software will be delivered and a *
* license will be granted for use within an enterprise, *
* provided the SimoTime copyright notice appear on all copies *
* of the software. The SimoTime name or Logo may not be used *
* in any advertising or publicity pertaining to the use of the *
* software without the written permission of SimoTime *
* Enterprises. *
* *
* SimoTime Enterprises makes no warranty or representations *
* about the suitability of the software for any purpose. It is *
* provided "AS IS" without any express or implied warranty, *
* including the implied warranties of merchantability, fitness *
* for a particular purpose and non-infringement. SimoTime *
* Enterprises shall not be liable for any direct, indirect, *
* special or consequential damages resulting from the loss of *
* use, data or projects, whether in an action of contract or *
* tort, arising out of or in connection with the use or *
* performance of this software *
* *
* SimoTime Enterprises *
* 15 Carnoustie Drive *
* Novato, CA 94949-5849 *
* 415.883.6565 *
* *
* RESTRICTED RIGHTS LEGEND *
* Use, duplication, or disclosure by the Government is subject *
* to restrictions as set forth in subparagraph (c)(1)(ii) of *
* the Rights in Technical Data and Computer Software clause at *
* DFARS 52.227-7013 or subparagraphs (c)(1) and (2) of *
* Commercial Computer Software - Restricted Rights at 48 *
* CFR 52.227-19, as applicable. Contact SimoTime Enterprises, *
* 15 Carnoustie Drive, Novato, CA 94949-5849. *
* *
*****************************************************************
* This program is provided by SimoTime Enterprises *
* Our e-mail address is: helpdesk@simotime.com *
* Also, visit our Web Site at http://www.simotime.com *
*****************************************************************
*
*****************************************************************
* Source Member: 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/Process Binary or Hex Data '.
05 T3 pic X(10) value ' v08.03.10'.
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-2010 '.
05 C3 pic X(28) value ' SimoTime Enterprises, LLC '.
05 C4 pic X(20) value ' All Rights Reserved'.
01 SIM-THANKS-01.
05 C1 pic X(11) value '* BINBITC1 '.
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 '* 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 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 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 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 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 HEXDSPB1-CLOSE
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 Enterprises *
* Our e-mail address is: helpdesk@simotime.com *
* Also, visit our Web Site at http://www.simotime.com *
*****************************************************************
The following (BIN256B1.CBL) is an example of a COBOL copy file that defines a table of 256, one (1) byte binary values.
*****************************************************************
* Copyright (C) 1987-2010 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 *
*****************************************************************
*
....:.*..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 ... Version 05.11.09
*
The purpose of this program is to provide examples for loading and processing tables within a COBOL program.
Permission to use, copy, modify and distribute this software for any commercial purpose requires a fee to be paid to SimoTime Enterprises. Once the fee is received by SimoTime the latest version of the software will be delivered and a license will be granted for use within an enterprise, provided the SimoTime copyright notice appear on all copies of the software. The SimoTime name or Logo may not be used in any advertising or publicity pertaining to the use of the software without the written permission of SimoTime Enterprises.
Permission to use, copy, modify and distribute this software for a non-commercial purpose and without fee is hereby granted, provided the SimoTime copyright notice appear on all copies of the software. The SimoTime name or Logo may not be used in any advertising or publicity pertaining to the use of the software without the written permission of SimoTime Enterprises.
SimoTime Enterprises makes no warranty or representations about the suitability of the software for any purpose. It is provided "AS IS" without any express or implied warranty, including the implied warranties of merchantability, fitness for a particular purpose and non-infringement. SimoTime Enterprises shall not be liable for any direct, indirect, special or consequential damages resulting from the loss of use, data or projects, whether in an action of contract or tort, arising out of or in connection with the use or performance of this software.
You may download this example at
http://www.simotime.com/sim4dzip.htm#zPackbinbit01
or view the complete list of SimoTime Examples at
http://www.simotime.com/sim4dzip.htm.
Note: You must be attached to the Internet to download a Z-Pack or view the list.
The following chart provides a list of the sample COBOL programs that do table processing.
| HTML Tag | Description |
| binbit01 | This suite of sample programs describes how to use COBOL to create a table or text string of binary values from X'00' through X'FF'. |
| cblbin01 | This suite of programs provides an example of how a COBOL program does various table functions such as a table load, a standard COBOL "SEARCH", a standard COBOL "SEARCH ALL", a user written binary search and a user written linear search. |
| cbltbl01 | This suite of sample programs describes how to use COBOL to load a table with customer information and then sort the table using a bubble sort routine. The elements in the table will be sorted in postal code sequence. |
| stamlr01 | The program has the ability to print 1,2, 3 or 4 across labels. This example uses a two-dimensional array to build the label-printing output. |
The hexadecimal dump of the parameter-buffer uses the same technique as describe in another SimoTime example that describes the dumping of a data string using COBOL. The name of the member that does the actual hexadecimal dump is called SimoDUMP. A copy file (PASSDUMP.CPY) is provided for defining the pass area.
The SimoZAPS Utility Program has the capability of generating a COBOL program that will do the conversion of sequential and VSAM (KSDS) files between EBCDIC and ASCII. SimoZAPS can also read a sequential file in EBCDIC format and create an ASCII/CRLF file or VSAM KSDS file in ASCII format. The conversion tables may be viewed or modified to meet unique requirements. The Hexcess/2 function provides the capability of viewing, finding or patching the contents of a file in hexadecimal.
This item will provide a link to an ASCII or EBCDIC translation table. A column for decimal, hexadecimal and binary is also included.
Check out The VSAM - QSAM Connection for more examples of mainframe VSAM and QSAM accessing techniques and sample code.
This document provides a quick summary of the File Status Key for VSAM data sets and QSAM files.
Check out The SimoTime Library for a wide range of topics for Programmers, Project Managers and Software Developers.
To review all the information available on this site start at The SimoTime Home Page .
Check out The SimoTime Glossary for a list of terms and definitions used in the documents provided by SimoTime.
If you have any questions, suggestions or comments please call or send an e-mail to: helpdesk@simotime.com
We appreciate your comments and feedback.
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 complimentary manner with existing corporate mainframe systems. Whether you want to use the Internet to expand into new market segments or as a delivery vehicle for existing business functions simply give us a call or check the web site at http://www.simotime.com
| Return-to-Top |
| Copyright © 1987-2010 SimoTime Enterprises All Rights Reserved |
| When technology complements business |
| http://www.simotime.com |
| Version 07.07.30 |