|
Hexadecimal Dump Callable COBOL Hex-Dump Routine |
![]() |
| The SimoTime Home Page |
The DISPLAY function of COBOL will display a message upon a user's console or the system operator's console in an MVS environment. It is quite often used to display information in routines that are performing an abnormal termination of a program. Also, it is still being used as a debugging tool. This approach provides valuable information when a failure occurs. However, there are times when a field or data string may have information that contains non-printable/displayable characters. A callable routine that would display a field or data string in a hexadecimal dump (Hex-Dump) format along with a possible EBCDIC and ASCII interpretation could be an effective tool in providing this information.
This suite of programs provides a demonstration program and a callable program to display a data string in a Hex-Dump format for both EBCDIC and ASCII. Both COBOL programs were written and tested using the COBOL/2 dialect. Also, both COBOL programs will work with COBOL for MVS and COBOL/370. A JCL member is provided to run the job as an MVS batch job on an IBM mainframe or with Micro Focus technologies that support the execution of a mainframe-oriented application running on a Linux, UNIX or Windows platform.
In the world of programming there are many ways to solve a problem. This suite of programs is provided as a COBOL example of a possible solution for producing hexadecimal dump information without an assembler subroutine.
Note: The source code for this example is available from the SimoTime Library under Download Directory at www.simotime.com.
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-2025
SimoTime Technologies and Services
All Rights Reserved
The following flowchart provides a quick overview of processing logic used with the hexadecimal dump routine.
|
| Field | Description | ||||||||||
| SIMODUMP-REQUEST |
|
||||||||||
| SIMODUMP-RESULT | This is an indicator as to the success or failure of the request. A value of zero (0000) indicates the routine was successful in displaying the dump information. A non-zero value indicates a failure. | ||||||||||
| SIMODUMP-DUMP-ID | This is an eight character field that is used to identify the dump. When multiple calls are made to the dump routine it is less confusing if each dump request has a unique identifier. | ||||||||||
| SIMODUMP-OUTPUT | Type of request, must be one of the following and must be upper-case.
|
||||||||||
| SIMODUMP-COPYRIGHT |
|
||||||||||
| SIMODUMP-IDX | Index for table that contains the dump information | ||||||||||
| SIMODUMP-LINES | This is a table with eight entries of eigty bytes. Each entry contains a line of dump information. | ||||||||||
| SIMODUMP-LENGTH | The length or number of characters to be displayed. This must be a value from 1-128. If a value other than 1-128 is passed then 128 will be assumed. | ||||||||||
| SIMODUMP-BUFFER | A 128 byte buffer containing the information to be displayed. |
This section provides the sample command file (CBLHBXE1.cmd) required to run the dump programs on a PC with Micro Focus Net Express.
@echo OFF
set CmdName=CBLHBXE1
rem * *******************************************************************
rem * Job Script - a Windows Command File *
rem * Provided by SimoTime Technologies and Services *
rem * (C) Copyright 1987-2023 All Rights Reserved *
rem * Web Site URL: http://www.simotime.com *
rem * e-mail: helpdesk@simotime.com *
rem * *******************************************************************
rem *
rem * Text - Processing Numeric Fields
rem * Author - SimoTime Technologies and Services
rem * Date - January 24, 1996
rem *
rem * *******************************************************************
rem * Step 1, Delete any previously created file...
rem *
call ..\ENV1BASE %CmdName%
if "%SYSLOG%" == "" set syslog=c:\SimoLIBR\LOGS\SimoTime.LOG
rem *
call SimoNOTE "*******************************************************%CmdName%"
call SimoNOTE "* Starting JobName %CmdName%"
run CBLHBXC1
if not ERRORLEVEL = 0 set JobStatus=0010
if not %JobStatus% == 0000 goto :EojNok
:EojAok
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
This section provides the sample JCL required to run the dump programs on a mainframe with MVS or on a PC with Micro Focus Mainframe Express. The JOB, STEPLIB and DD statements will need to be changed for a specific mainframe environment.
The first example shows the JCL when the logging to a file is not used. The dump information will be displayed to the screen. If the calling program should request a log-to-file (i.e. SIMODUMP-REQUEST = 'FILE' on OPEN failure would occur since there is no DD statement for the logging file (SYSLOG). The dump routine would then assume 'SHOW' and display the dump information to the screen.
The second example shows the use of the logging function that writes the dump information to a file (SYSLOG).
The following is the mainframe JCL (CBLHBXJ1.jcl) required to run the mainline program. The JOB and STEPLIB statements will need to be changed for a specific mainframe environment. Since this JCL member does not have a DD statement for the SYSLOG file the SimoLOGS routine will fail on the OPEN and post a message to the console and simply display the dump information to the console. The file I/O error for the SYSLOG file and the dump information will be written to the spool file.
//CBLHBXJ1 JOB SIMOTIME,ACCOUNT,CLASS=1,MSGCLASS=0,NOTIFY=CSIP1, // COND=(0,LT) //* ******************************************************************* //* CBLHBXJ1.JCL - a JCL Member for Batch Job Processing * //* This JCL Member is provided by SimoTime Technologies * //* (C) Copyright 1987-2019 All Rights Reserved * //* Web Site URL: http://www.simotime.com * //* e-mail: helpdesk@simotime.com * //* ******************************************************************* //* //* Text - COBOL calls COBOL for Hexadecimal Dump of a data buffer. //* Author - SimoTime Technologies //* Date - January 01, 1989 //* //* This set of programs illustrate the use of COBOL for displaying //* a data buffer in hexadecimal format. //* //* Since this JCL member does not have a DD statement for the SYSLOG //* file the SimoLOGS routine will fail on the OPEN and post a message //* to the console and simply display the dump information to the //* console. The file I/O error for the SYSLOG file and the dump //* information will be written to the spool file. //* //* This set of programs will run on a mainframe under MVS or on a //* Personal Computer with Windows and Micro Focus Mainframe Express. //* //* ************ //* * CBLHBXJ1 * //* ********jcl* //* * //* * //* ************ ************ ************ //* * CBLHBXC1 ******* SIMODUMP ******** CONSOLE * //* ********cbl* ********cbl* ******dsply* //* * //* * //* ************ ************ //* * SIMOLOGS ******* SYSLOG * //* ********cbl* *******file* //* //* ******************************************************************* //* Step 1 of 1, This is a single step job. //* //CBLHBXX1 EXEC PGM=CBLHBXC1 //STEPLIB DD DSN=MFI01.SIMOPROD.LOADLIB1,DISP=SHR //SYSOUT DD SYSOUT=* //*
The following is the mainframe JCL (CBLHBXJ2.jcl) required to run the mainline program. The JOB, STEPLIB and DD statements will need to be changed for a specific mainframe environment.
//CBLHBXJ2 JOB SIMOTIME,ACCOUNT,CLASS=1,MSGCLASS=0,NOTIFY=CSIP1, // COND=(0,LT) //* ******************************************************************* //* CBLHBXJ2.JCL - a JCL Member for Batch Job Processing * //* This JCL Member is provided by SimoTime Technologies * //* (C) Copyright 1987-2019 All Rights Reserved * //* Web Site URL: http://www.simotime.com * //* e-mail: helpdesk@simotime.com * //* ******************************************************************* //* //* Text - COBOL calls COBOL for Hexadecimal Dump of a data buffer. //* Author - SimoTime Technologies //* Date - January 01, 1989 //* //* This set of programs illustrate the use of COBOL for displaying //* a data buffer in hexadecimal format. This job may also write //* to a log file (SYSLOG). //* //* ************ //* * CBLHBXJ1 * //* ********jcl* //* * //* * //* ************ //* * IEFBR14 * //* ************ //* * //* * //* ************ ************ ************ //* * CBLHBXC1 *-----* SIMODUMP *-----* Console * //* ********cbl* ************ ************ //* * //* * //* ************ ************ //* * SIMOLOGS *-----* SYSLOG * //* ************ ************ //* //* //* 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 previous log file and create new log file... //* //JOBSETUP EXEC PGM=IEFBR14 //LOGHBX DD DSN=SIMOTIME.DATA.LOGHBX01,DISP=(MOD,DELETE,DELETE), // STORCLAS=MFI, // SPACE=(TRK,10), // DCB=(RECFM=V,LRECL=1055,DSORG=PS) //HBXCRT01 EXEC PGM=IEFBR14 //LOGHBX DD DSN=SIMOTIME.DATA.LOGHBX01,DISP=(NEW,CATLG,DELETE), // STORCLAS=MFI, // SPACE=(TRK,10), // DCB=(RECFM=V,LRECL=1055,DSORG=PS) //* //* ******************************************************************* //* Step 2 of 2, Write dump info to new QSAM log file... //* //CBLHBX22 EXEC PGM=CBLHBXC1 //STEPLIB DD DSN=MFI01.SIMOPROD.LOADLIB1,DISP=SHR //SYSLOG DD DSN=SIMOTIME.DATA.LOGHBX01,DISP=SHR //SYSOUT DD SYSOUT=* //*
This program (CBLHBXC1.cbl) was written to test and demonstrate the calling of the COBOL program (SIMODUMP.CBL) that does the display of a data buffer in the hexadecimal format.
IDENTIFICATION DIVISION.
PROGRAM-ID. CBLHBXC1.
AUTHOR. SIMOTIME TECHNOLOGIES.
*****************************************************************
* Copyright (C) 1987-2023 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: CBLHBXC1.CBL
* Copy Files PASSDUMP.CPY
* Calls to: SIMODUMP may call SIMOLOGS
*****************************************************************
*
* CBLHBXC1 - Call SIMODUMP to build hexadecimal dump information.
*
* CALLING PROTOCOL
* ----------------
* Use standard procedure to EXECUTE, RUN or ANIMATE.
*
* DESCRIPTION
* -----------
* This is a demonstration program to show how to call the
* COBOL Hexadecimal Dump Routine.
*
* ************
* * CBLHBXJ1 *
* ********jcl*
* *
* *
* ************ ************ ************
* * CBLHBXC1 ******* SIMODUMP ******* SYSOUT *
* ********cbl* ********cbl* ************
* * *
* * *
* * ************ ************
* * * SIMOLOGS ******* SYSLOG *
* * ********cbl* *******file*
* *
* ************
* * EOJ *
* ************
*
*****************************************************************
*
* MAINTENANCE
* -----------
* 1989/02/27 Simmons, Created program.
* 1997/03/17 Simmons, Updated for COBOL/2.
*
*****************************************************************
*
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
*****************************************************************
* Data-structure for Title and Copyright...
* ------------------------------------------------------------
01 SIM-TITLE.
05 T1 pic X(11) value '* CBLHBXC1 '.
05 T2 pic X(34) value 'COBOL Hexadecimal Dump Routine '.
05 T3 pic X(10) value ' v23.01.01'.
05 T4 pic X(24) value ' http://www.simotime.com'.
01 SIM-COPYRIGHT.
05 C1 pic X(11) value '* CBLHBXC1 '.
05 C2 pic X(20) value 'Copyright 1987-2023 '.
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 '* CBLHBXC1 '.
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 '* CBLHBXC1 '.
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'.
*****************************************************************
* Buffer used for posting messages to the console.
* ------------------------------------------------------------
01 MESSAGE-BUFFER.
05 MESSAGE-HEADER pic X(11) value '* CBLHBXC1 '.
05 MESSAGE-TEXT.
10 MESSAGE-TEXT-1 pic X(68).
10 MESSAGE-TEXT-2 pic X(41).
01 TWO-BYTES.
05 TWO-BYTES-01 pic X.
05 TWO-BYTES-02 pic X.
01 TWO-BYTES-BINARY redefines TWO-BYTES
pic S9(3) comp.
*****************************************************************
* Work fields used for testing call to SIMODUMP.
* ------------------------------------------------------------
01 ASC pic X(10) value X'30313233343536373839'.
01 PACK-BINARY pic X(12) value X'0000615C4040404000000A01'.
01 ALPHABET-UPPER pic X(26) value 'ABCDEFGHIJKLMNOPQRSTUVWZYZ'.
01 NUMERIC-BUFFER-01.
05 filler pic X(8) value 'PIC-9 '.
05 NB-PIC-9 pic 9(8) value 123.
05 filler pic X(8) value 'PIC-9P '.
05 NB-PIC-9-PLUS pic S9(8) value 123.
05 filler pic X(8) value 'PIC-9M '.
05 NB-PIC-9-MINUS pic S9(8) value -123.
05 filler pic X(8) value 'PIC-9Z '.
05 NB-PIC-9-ZERO pic S9(8) value 0.
05 filler pic X(8) value 'COMP-3 '.
05 NB-COMP-3 pic 9(15) comp-3 value 123.
05 filler pic X(8) value 'COMP-3P '.
05 NB-COMP-3-PLUS pic S9(15) comp-3 value 123.
05 filler pic X(8) value 'COMP-3M '.
05 NB-COMP-3-MINUS pic S9(15) comp-3 value -123.
05 filler pic X(8) value 'COMP-3Z '.
05 NB-COMP-3-ZERO pic S9(15) comp-3 value 0.
01 NUMERIC-BUFFER-02.
05 filler pic X(8) value 'COMP '.
05 NB-COMP pic 9(9) comp value 123.
05 filler pic X(4) value is SPACES.
05 filler pic X(8) value 'COMP/P '.
05 NB-COMP-PLUS pic S9(9) comp value 123.
05 filler pic X(4) value is SPACES.
05 filler pic X(8) value 'COMP/M '.
05 NB-COMP-MINUS pic S9(9) comp value -123.
05 filler pic X(4) value is SPACES.
05 filler pic X(8) value 'COMP/Z '.
05 NB-COMP-ZERO pic S9(9) comp value 0.
05 filler pic X(4) value is SPACES.
05 filler pic X(64) value is SPACES.
01 IX-1 pic 9999 value 0.
01 IX-2 pic 9999 value 0.
01 USER-STRING-01 pic X(16) value 'USER String 0001'.
COPY PASSDUMP.
*****************************************************************
PROCEDURE DIVISION.
perform Z-POST-COPYRIGHT.
perform INITIALIZE-PASS-AREA
perform POST-TEXT-INFO-TO-SYSOUT
perform DUMP-USER-STRING
perform DUMP-BUFFER-TO-SYSOUT.
perform DUMP-BUFFER-FOR-ALL.
perform DUMP-NUMERIC-BUFFER.
perform Z-THANK-YOU.
GOBACK.
*****************************************************************
* Post a Text Note to SYSOUT.
*****************************************************************
POST-TEXT-INFO-TO-SYSOUT.
move 'NOTE' to SIMODUMP-REQUEST
move 'OUT1' to SIMODUMP-OUTPUT
move 'SHOW' to SIMODUMP-COPYRIGHT
move 'TXTINFO1' to SIMODUMP-DUMP-ID
move SPACES to SIMODUMP-BUFFER
move 'Text String ' to SIMODUMP-BUFFER
add 12 to ZERO giving SIMODUMP-LENGTH
call 'SIMODUMP' using SIMODUMP-PASS-AREA
SIMODUMP-BUFFER
move SIMODUMP-REQUEST to MESSAGE-TEXT(57:4)
move SIMODUMP-RESULT to MESSAGE-TEXT(61:4)
move SIMODUMP-OUTPUT to MESSAGE-TEXT(65:4)
perform Z-POST-MESSAGE
exit.
*****************************************************************
DUMP-USER-STRING.
move 'DUMP' to SIMODUMP-REQUEST
move 'OUT1' to SIMODUMP-OUTPUT
move 'SHOW' to SIMODUMP-COPYRIGHT
move 'USERINFO' to SIMODUMP-DUMP-ID
add length of USER-STRING-01 to ZERO giving SIMODUMP-LENGTH
call 'SIMODUMP' using SIMODUMP-PASS-AREA
USER-STRING-01
exit.
*****************************************************************
* Move information to DUMP BUFFER and display the information.
*****************************************************************
DUMP-BUFFER-TO-SYSOUT.
move 'DUMP-BUFFER-TO-SYSOUT is starting' to MESSAGE-TEXT
perform Z-POST-MESSAGE
move 'DUMP' to SIMODUMP-REQUEST
move 'OUT1' to SIMODUMP-OUTPUT
add 128 to ZERO giving SIMODUMP-LENGTH
move 'DISPLAY1' to SIMODUMP-DUMP-ID
move ALPHABET-UPPER to SIMODUMP-BUFFER
move '[]{}()' to SIMODUMP-BUFFER(33:6)
move PACK-BINARY to SIMODUMP-BUFFER(49:12)
move ASC to SIMODUMP-BUFFER(65:10)
move 'end' to SIMODUMP-BUFFER(126:3)
call 'SIMODUMP' using SIMODUMP-PASS-AREA
SIMODUMP-BUFFER
move 'DUMP-BUFFER-TO-SYSOUT is complete' to MESSAGE-TEXT
move SIMODUMP-REQUEST to MESSAGE-TEXT(57:4)
move SIMODUMP-RESULT to MESSAGE-TEXT(61:4)
move SIMODUMP-OUTPUT to MESSAGE-TEXT(65:4)
perform Z-POST-MESSAGE
exit.
*****************************************************************
* Create the full 256 character set and display in hex-dump
* using two calls of 128 bytes each.
*****************************************************************
DUMP-BUFFER-FOR-ALL.
move 'DUMP-BUFFER-FOR-ALL is starting' to MESSAGE-TEXT
perform Z-POST-MESSAGE
move 'DUMP' to SIMODUMP-REQUEST
move 'OUT2' to SIMODUMP-OUTPUT
move 'HIDE' to SIMODUMP-COPYRIGHT
add 128 to ZERO giving SIMODUMP-LENGTH
move 'LOGTEST1' to SIMODUMP-DUMP-ID
subtract TWO-BYTES-BINARY from TWO-BYTES-BINARY
add 1 to ZERO giving IX-1
add 1 to ZERO giving IX-2
perform 128 times
move TWO-BYTES-02 to SIMODUMP-BUFFER(IX-1:1)
add 1 to TWO-BYTES-BINARY
add 1 to IX-1
end-perform
call 'SIMODUMP' using SIMODUMP-PASS-AREA
SIMODUMP-BUFFER
add 1 to ZERO giving IX-1
move 'LOGTEST2' to SIMODUMP-DUMP-ID
perform 128 times
move TWO-BYTES-02 to SIMODUMP-BUFFER(IX-1:1)
add 1 to TWO-BYTES-BINARY
add 1 to IX-1
end-perform
call 'SIMODUMP' using SIMODUMP-PASS-AREA
SIMODUMP-BUFFER
move 'SHOW' to SIMODUMP-COPYRIGHT
move 'DUMP-BUFFER-FOR-ALL is complete' to MESSAGE-TEXT
move SIMODUMP-REQUEST to MESSAGE-TEXT(57:4)
move SIMODUMP-RESULT to MESSAGE-TEXT(61:4)
move SIMODUMP-OUTPUT to MESSAGE-TEXT(65:4)
perform Z-POST-MESSAGE
exit.
*****************************************************************
* Display various numeric values and formats.
*****************************************************************
DUMP-NUMERIC-BUFFER.
move 'DUMP-NUMERIC-BUFFER is starting' to MESSAGE-TEXT
perform Z-POST-MESSAGE
move 'DUMP' to SIMODUMP-REQUEST
move 'OPR2' to SIMODUMP-OUTPUT
add 128 to ZERO giving SIMODUMP-LENGTH
move 'NUMERIC1' to SIMODUMP-DUMP-ID
move NUMERIC-BUFFER-01 to SIMODUMP-BUFFER
call 'SIMODUMP' using SIMODUMP-PASS-AREA
SIMODUMP-BUFFER
move 'NUMERIC2' to SIMODUMP-DUMP-ID
move NUMERIC-BUFFER-02 to SIMODUMP-BUFFER
call 'SIMODUMP' using SIMODUMP-PASS-AREA
SIMODUMP-BUFFER
move 'DUMP-NUMERIC-BUFFER is complete' to MESSAGE-TEXT
move SIMODUMP-REQUEST to MESSAGE-TEXT(57:4)
move SIMODUMP-RESULT to MESSAGE-TEXT(61:4)
move SIMODUMP-OUTPUT to MESSAGE-TEXT(65:4)
perform Z-POST-MESSAGE
exit.
*****************************************************************
INITIALIZE-PASS-AREA.
move 'DUMP' to SIMODUMP-REQUEST
move 'OPR1' to SIMODUMP-REQUEST
move 'SHOW' to SIMODUMP-COPYRIGHT
move 'HEXDUMP1' to SIMODUMP-DUMP-ID
move 0 to SIMODUMP-RESULT
add 128 to ZERO giving SIMODUMP-LENGTH
move all SPACES to SIMODUMP-BUFFER
exit.
*****************************************************************
* The following Z-Routines perform administrative tasks *
* for this program. *
*****************************************************************
Z-POST-COPYRIGHT.
display SIM-TITLE
display SIM-COPYRIGHT
exit.
*****************************************************************
Z-POST-MESSAGE.
if MESSAGE-TEXT-2 = SPACES
display MESSAGE-BUFFER(1:79)
else
display MESSAGE-BUFFER
end-if
move SPACES to MESSAGE-TEXT
exit.
*****************************************************************
Z-THANK-YOU.
display SIM-THANKS-01
display SIM-THANKS-02
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 *
*****************************************************************
This program (SIMODUMP.cbl) was written to be used as a debugging aid. It uses the DISPLAY function of COBOL to display hexadecimal dump information of a data field. This program requires a copy file (TAB4DUMP.CPY) that is included in the downloadable package for this set of sample programs.
IDENTIFICATION DIVISION.
PROGRAM-ID. SIMODUMP.
*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: SIMODUMP.CBL
* Copy Files: PASSDUMP.CPY
* HEXTABLE.CPY
* Calls to: SIMOLOGS is optional
*****************************************************************
*
* SIMODUMP - Call SIMOLOGS to build hexadecimal dump information.
*
* CALLING PROTOCOL
* ----------------
* Use standard procedure to EXECUTE, RUN or ANIMATE.
*
* DESCRIPTION
* -----------
* This set of programs illustrate the use of COBOL for displaying
* a data buffer in hexadecimal format.
*
* ************
* * CBLHBXJ1 *
* ********jcl*
* *
* ************
* * CBLHBXC1 *
* ********cbl*
* *
* ************ ************ ************
* * CBLHBXC1 *-----* SIMODUMP *-----* CONSOLE *
* ********cbl* ********cbl* ******dsply*
* *
* *
* ************ ************
* * SIMOLOGS *-----* CBLHBXD1 *
* ********cbl* *******file*
*
*****************************************************************
*
* MAINTENANCE
* -----------
* 1989/02/27 Simmons, Created program.
* 1997/03/17 Simmons, Updated for COBOL/2.
*
*****************************************************************
*
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
*****************************************************************
* Data-structure for Title and Copyright...
* ------------------------------------------------------------
01 SIM-TITLE.
05 T1 pic X(11) value '* SIMODUMP '.
05 T2 pic X(34) value 'COBOL Hexadecimal Dump Routine '.
05 T3 pic X(10) value ' v16.06.15'.
05 T4 pic X(24) value ' http://www.simotime.com'.
01 SIM-COPYRIGHT.
05 C1 pic X(11) value '* SIMODUMP '.
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'.
*****************************************************************
* Buffer used for posting messages to the console.
* ------------------------------------------------------------
01 MESSAGE-BUFFER.
05 MESSAGE-HEADER pic X(011) value '* SIMODUMP '.
05 MESSAGE-TEXT.
10 MESSAGE-TEXT-1 pic X(068) value SPACES.
10 MESSAGE-TEXT-2 pic X(188) value SPACES.
01 MSG-LSB pic 9(3) value 256.
*****************************************************************
* Buffer used for posting dump information to the console.
* ------------------------------------------------------------
01 DUMP-BUFFER.
05 DUMP-TEXT pic X(79).
*****************************************************************
01 TWO-BYTES.
05 TWO-BYTES-01 pic X.
05 TWO-BYTES-02 pic X.
01 TWO-BYTES-BINARY redefines TWO-BYTES
pic S9(3) comp.
01 IX-0 pic 9999 value 0.
01 IX-1 pic 9999 value 0.
01 IX-2 pic 9999 value 0.
01 IX-3 pic 9999 value 0.
01 IX-4 pic 9999 value 0.
01 IX-5 pic 9999 value 0.
01 IP-1 pic 9(5) value 0.
01 IP-2 pic 9(5) value 0.
01 POSITION-PTR pic 9(7) value 0.
01 LOOP-QUIT pic X value 'N'.
01 WA-4 pic X(4) value LOW-VALUES.
01 WA-5 pic X(5) value is SPACES.
01 WA-8 pic X(9) value '00000000'.
01 BUFFER-SIZE-LIMIT-GROUP.
05 BUFFER-SIZE-LIMIT pic 9(5) value 128.
01 BUFFER-LENGTH pic 9999 value 0.
01 LINE-LENGTH pic 9999 value 0.
01 DUMP-HEADER.
* 05 filler pic X value '*'.
05 filler pic X value ' '.
05 H1 pic X(8) value 'Position'.
05 filler pic X value ' '.
05 H2 pic X(35) value 'Hex..... ........ ........ ........'.
05 filler pic X value ' '.
05 H3 pic X(16) value 'ebcdic..........'.
05 filler pic X value ' '.
05 H4 pic X(16) value 'ascii...........'.
01 DUMP-LINE.
* 05 filler pic X value '*'.
05 filler pic X value ' '.
05 D1 pic X(8) value ' x00-x0F'.
05 filler pic X value ' '.
05 D2 pic X(35) value 'xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx'.
05 filler pic X value ' '.
05 D3 pic X(16) value '................'.
05 filler pic X value ' '.
05 D4 pic X(16) value '................'.
01 X-DUMP-LINE.
* 05 filler pic X value '*'.
05 filler pic X value ' '.
05 X1 pic X(8) value ' x00-x0F'.
05 filler pic X value ' '.
05 X2 pic X(35) value 'xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx'.
05 filler pic X value ' '.
05 X3 pic X(16) value '................'.
05 filler pic X value ' '.
05 X4 pic X(16) value '................'.
01 ADDRESS-OFFSET-HEX.
05 A0 pic X(8) value ' x00-x0F'.
05 A1 pic X(8) value ' x10-x1F'.
05 A2 pic X(8) value ' x20-x2F'.
05 A3 pic X(8) value ' x30-x3F'.
05 A4 pic X(8) value ' x40-x4F'.
05 A5 pic X(8) value ' x50-x5F'.
05 A6 pic X(8) value ' x60-x6F'.
05 A7 pic X(8) value ' x70-x7F'.
01 ADDRESS-OFFSET-DEC.
05 B0 pic X(8) value ' 1-016'.
05 B1 pic X(8) value ' 17-032'.
05 B2 pic X(8) value ' 33-048'.
05 B3 pic X(8) value ' 49-064'.
05 B4 pic X(8) value ' 65-080'.
05 B5 pic X(8) value ' 81-096'.
05 B6 pic X(8) value ' 97-112'.
05 B7 pic X(8) value ' 113-128'.
01 DUMP-STATUS-LINE.
05 DS-DUMP-STATUS pic X(08) value 'Starting'.
05 filler pic X(2) value ', '.
05 filler pic X(15) value 'SIMODUMP-ID is '.
05 DS-DUMP-ID pic X(8) value 'HEXDUMP1'.
05 filler pic X(2) value ', '.
05 filler pic X(20) value 'Dump Buffer size is '.
05 DS-LENGTH pic 9999 value 0.
01 MESSAGE-0004-1.
05 filler pic X(9) value 'Warning, '.
05 filler pic X(29) value 'SIMODUMP-LENGTH is invalid, '.
05 filler pic X(29) value 'must be value from 1 to 128. '.
01 MESSAGE-0004-2.
05 filler pic X(9) value 'Warning, '.
05 filler pic X(29) value 'Assuming length of 128 bytes.'.
01 MESSAGE-0008-1.
05 filler pic X(9) value 'Warning, '.
05 filler pic X(24) value 'SIMODUMP-OUTPUT must be '.
05 filler pic X(12) value 'OUT1, OUT2, '.
05 filler pic X(19) value 'OPR1, OPR2 or LOG1.'.
01 MESSAGE-0008-2.
05 filler pic X(9) value 'Warning, '.
05 filler pic X(22) value 'Assuming OUT1 mode.'.
01 FIRST-TIME pic X value 'Y'.
01 USR-PTR-GROUP.
05 USR-PTR-VALUE usage is pointer.
01 USR-PTR-LENGTH pic 99 value 0.
01 USR-PTR-DUMP-ADDR pic X(8) value '00000000'.
01 HEX-OFFSET-GROUP.
05 HEX-OFFSET-VALUE pic 9(9) comp.
01 HEX-OFFSET-LENGTH pic 99 value 0.
01 HEX-OFFSET-DUMP-ADDR pic X(8) value '00000000'.
01 DEC-POSITION-GROUP.
05 DEC-POSITION-VALUE pic 9(8).
01 DEC-POSITION-LENGTH pic 99 value 0.
01 ADDRESS-DUMP-FMT-64.
05 ADDRESS-DUMP-FMT-32A pic X(8) value '00000000'.
05 ADDRESS-DUMP-FMT-32B pic X(8) value '00000000'.
*****************************************************************
* Pass area for call SIMOLOGS.
* ------------------------------------------------------------
COPY PASSLOGS.
COPY HEXTABLE.
*****************************************************************
LINKAGE SECTION.
COPY PASSDUMP.
*****************************************************************
PROCEDURE DIVISION using SIMODUMP-PASS-AREA, SIMODUMP-BUFFER.
if FIRST-TIME = 'Y'
perform FIRST-TIME-PROCESSING
end-if
evaluate SIMODUMP-REQUEST
when 'NOTE' perform ACTION-IS-POST-TEXT-INFO
when 'DUMP' perform ACTION-IS-POST-DUMP-INFO
when 'USER' perform ACTION-IS-POST-USER-INFO
when other move 'DUMP' to SIMODUMP-REQUEST
perform ACTION-IS-POST-DUMP-INFO
end-evaluate
GOBACK.
*****************************************************************
ACTION-IS-POST-TEXT-INFO.
move SIMODUMP-DUMP-ID to MESSAGE-TEXT
move SIMODUMP-BUFFER(1:68) to MESSAGE-TEXT(10:68)
perform Z-DISPLAY-MESSAGE-BUFFER
exit.
*****************************************************************
ACTION-IS-POST-DUMP-INFO.
perform EDIT-PASS-AREA
set USR-PTR-VALUE to address of SIMODUMP-BUFFER
move ZERO to HEX-OFFSET-VALUE
add 1 to ZERO giving DEC-POSITION-VALUE
move USR-PTR-GROUP to WA-4
perform ADDRESS-FORMATTING
move WA-8 to USR-PTR-DUMP-ADDR
move WA-8 to ADDRESS-DUMP-FMT-32B
display '* SIMODUMP ADDR is ' ADDRESS-DUMP-FMT-64
if SIMODUMP-OUTPUT = 'LOG1'
or = 'OUT1'
or = 'OUT2'
or = 'OPR1'
or = 'OPR2'
move 'Starting' to DS-DUMP-STATUS
move SIMODUMP-DUMP-ID to DS-DUMP-ID
move SIMODUMP-LENGTH to DS-LENGTH
move DUMP-STATUS-LINE to MESSAGE-TEXT
perform Z-POST-MESSAGE-BUFFER
move DUMP-HEADER to MESSAGE-TEXT
perform Z-POST-MESSAGE-TEXT
end-if
perform DUMP-PROCESSING
* move SIMOLOGS-REQUEST to SIMODUMP-OUTPUT
move SIMOLOGS-STATUS to SIMODUMP-RESULT
exit.
*****************************************************************
ACTION-IS-POST-USER-INFO.
if SIMODUMP-BUFFER(1:7) = 'FORMAT='
evaluate SIMODUMP-BUFFER(8:8)
when 'ADDRESS ' move ' Address' to H1
when 'POSITION' move 'Position' to H1
when 'OFFSET ' move ' Offset' to H1
end-evaluate
end-if
if SIMODUMP-BUFFER(1:6) = 'LIMIT='
perform until SIMODUMP-BUFFER(11:1) not = SPACE
if SIMODUMP-BUFFER(11:1) = ' '
move SIMODUMP-BUFFER(10:1) to SIMODUMP-BUFFER(11:1)
move SIMODUMP-BUFFER(09:1) to SIMODUMP-BUFFER(10:1)
move SIMODUMP-BUFFER(08:1) to SIMODUMP-BUFFER(09:1)
move SIMODUMP-BUFFER(07:1) to SIMODUMP-BUFFER(08:1)
move ZERO to SIMODUMP-BUFFER(7:1)
end-if
end-perform
move SIMODUMP-BUFFER(7:5) to BUFFER-SIZE-LIMIT-GROUP
if BUFFER-SIZE-LIMIT is NUMERIC
move 'Accepted User Request, increase Buffer Size '
to MESSAGE-TEXT
move 'maximum limit to ' to MESSAGE-TEXT(45:17)
move BUFFER-SIZE-LIMIT-GROUP to MESSAGE-TEXT(62:5)
perform Z-POST-MESSAGE-BUFFER
else
add 128 to ZERO giving BUFFER-SIZE-LIMIT
move 'Rejected User Request to increase Buffer '
to MESSAGE-TEXT
move 'Size maximum, reset to ' to MESSAGE-TEXT(42:23)
move BUFFER-SIZE-LIMIT-GROUP to MESSAGE-TEXT(64:5)
perform Z-POST-MESSAGE-BUFFER
end-if
end-if
exit.
ACTION-IS-POST-USER-INFO-OLD.
move DUMP-HEADER to MESSAGE-TEXT
move '* Pos' to MESSAGE-TEXT(1:9)
move '* ....Pos' to MESSAGE-TEXT(1:9)
perform Z-POST-MESSAGE-TEXT
move SPACES to D1
add 1 to ZERO giving POSITION-PTR
move 'N' to LOOP-QUIT
add 1 to ZERO giving IX-1
perform until LOOP-QUIT = 'Y'
add 1 to ZERO giving IX-2
add 1 to ZERO giving IX-3
add 1 to ZERO giving IX-4
if SIMODUMP-LENGTH - IX-1 > 16
add 16 to ZERO giving LINE-LENGTH
else
compute LINE-LENGTH = SIMODUMP-LENGTH - IX-1 + 1
move 'Y' to LOOP-QUIT
end-if
* display 'DEBUG ' SIMODUMP-LENGTH ' ' LINE-LENGTH ' ' IX-1
move X2 to D2
move X3 to D3
move X4 to D4
perform until LINE-LENGTH = 0
* Get table element
subtract TWO-BYTES-BINARY from TWO-BYTES-BINARY
move SIMODUMP-BUFFER(IX-1:1) to TWO-BYTES-02
add TWO-BYTES-BINARY to 1 giving IX-5
move TAB-X1(IX-5) to WA-5
move WA-5(1:2) to D2(IX-2:2)
* Increment to next position in hex-dump area of buffer
add 2 to IX-2
if IX-2 = 9
or IX-2 = 18
or IX-2 = 27
add 1 to IX-2
end-if
* EBCDIC Print Character and increment to next position
move WA-5(3:1) to D3(IX-3:1)
add 1 to IX-3
* ASCII Print Character and increment to next position
move WA-5(4:1) to D4(IX-4:1)
add 1 to IX-4
* Increment pointer to next input buffer byte
add 1 to IX-1
subtract 1 from LINE-LENGTH
end-perform
*
move POSITION-PTR to D1
move DUMP-LINE to MESSAGE-TEXT
perform Z-POST-MESSAGE-TEXT
add 16 to POSITION-PTR
end-perform
exit.
*****************************************************************
ADDRESS-FORMATTING.
add 1 to ZERO giving IP-1
add 1 to ZERO giving IP-2
perform 4 times
subtract TWO-BYTES-BINARY from TWO-BYTES-BINARY
move WA-4(IP-1:1) to TWO-BYTES-02
add TWO-BYTES-BINARY to 1 giving IX-5
move TAB-X1(IX-5) to WA-5
move WA-5(1:2) to WA-8(IP-2:2)
add 1 to IP-1
add 2 to IP-2
end-perform
exit.
*****************************************************************
DUMP-PROCESSING.
add 1 to ZERO giving IX-0
add 1 to ZERO giving IX-1
add 1 to ZERO giving IX-5
subtract SIMODUMP-IDX from SIMODUMP-IDX
add SIMODUMP-LENGTH to ZERO giving BUFFER-LENGTH
if BUFFER-LENGTH greater than 15
add 16 to ZERO giving LINE-LENGTH
else
add BUFFER-LENGTH to ZERO giving LINE-LENGTH
end-if
perform until BUFFER-LENGTH = 0
add 1 to ZERO giving IX-2
add 1 to ZERO giving IX-3
add 1 to ZERO giving IX-4
move X-DUMP-LINE to DUMP-LINE
move DEC-POSITION-GROUP to D1
evaluate H1
when ' Address' move USR-PTR-GROUP to WA-4
perform ADDRESS-FORMATTING
move WA-8 to D1
when ' Offset' move HEX-OFFSET-GROUP to WA-4
perform ADDRESS-FORMATTING
move WA-8 to D1
end-evaluate
add 8 to IX-0
perform DUMP-SINGLE-LINE
if BUFFER-LENGTH greater than 15
subtract 16 from BUFFER-LENGTH
set USR-PTR-VALUE up by 16
add 16 to HEX-OFFSET-VALUE
add 16 to DEC-POSITION-VALUE
else
subtract BUFFER-LENGTH from BUFFER-LENGTH
set USR-PTR-VALUE to address of SIMODUMP-BUFFER
move ZERO to HEX-OFFSET-VALUE
add 1 to ZERO giving DEC-POSITION-VALUE
end-if
if BUFFER-LENGTH greater than 15
add 16 to ZERO giving LINE-LENGTH
else
add BUFFER-LENGTH to ZERO giving LINE-LENGTH
end-if
end-perform
exit.
*****************************************************************
DUMP-SINGLE-LINE.
perform until LINE-LENGTH = 0
* Get table element
subtract TWO-BYTES-BINARY from TWO-BYTES-BINARY
move SIMODUMP-BUFFER(IX-1:1) to TWO-BYTES-02
add TWO-BYTES-BINARY to 1 giving IX-5
move TAB-X1(IX-5) to WA-5
move WA-5(1:2) to D2(IX-2:2)
* Increment to next position in hex-dump area of buffer
add 2 to IX-2
if IX-2 = 9
or IX-2 = 18
or IX-2 = 27
add 1 to IX-2
end-if
* EBCDIC Print Character and increment to next position
move WA-5(3:1) to D3(IX-3:1)
add 1 to IX-3
* ASCII Print Character and increment to next position
move WA-5(4:1) to D4(IX-4:1)
add 1 to IX-4
* Increment pointer to next input buffer byte
add 1 to IX-1
subtract 1 from LINE-LENGTH
end-perform
move DUMP-LINE to DUMP-TEXT
if SIMODUMP-IDX < 8
add 1 to SIMODUMP-IDX
move DUMP-LINE to SIMODUMP-LINES(SIMODUMP-IDX)
end-if
if SIMODUMP-OUTPUT = 'LOG1'
or = 'OUT2'
or = 'OPR2'
move DUMP-LINE to SIMOLOGS-MESSAGE
perform POST-TO-LOG-FILE
else
move DUMP-LINE to MESSAGE-TEXT
perform Z-POST-MESSAGE-TEXT
end-if
exit.
*****************************************************************
EDIT-PASS-AREA.
perform EDIT-PASS-AREA-SYSOUT
perform EDIT-PASS-AREA-LENGTH
exit.
EDIT-PASS-AREA-LENGTH.
subtract SIMODUMP-RESULT from SIMODUMP-RESULT
if SIMODUMP-LENGTH not NUMERIC
add 128 to ZERO giving SIMODUMP-LENGTH
add 4 to ZERO giving SIMODUMP-RESULT
end-if
if SIMODUMP-LENGTH less than 1
or SIMODUMP-LENGTH greater than BUFFER-SIZE-LIMIT
add 4 to ZERO giving SIMODUMP-RESULT
add 128 to ZERO giving SIMODUMP-LENGTH
end-if
if SIMODUMP-RESULT not = ZERO
move MESSAGE-0004-1 to MESSAGE-TEXT
perform Z-POST-MESSAGE-BUFFER
move MESSAGE-0004-2 to MESSAGE-TEXT
perform Z-POST-MESSAGE-BUFFER
end-if
exit.
EDIT-PASS-AREA-SYSOUT.
if SIMODUMP-OUTPUT = 'NONE'
or = 'OUT1'
or = 'OUT2'
or = 'OPR1'
or = 'OPR2'
or = 'LOG1'
subtract SIMODUMP-RESULT from SIMODUMP-RESULT
else
add 4 to ZERO giving SIMODUMP-RESULT
move 'OPR1' to SIMODUMP-OUTPUT
move MESSAGE-0008-1 to MESSAGE-TEXT
perform Z-POST-MESSAGE-BUFFER
move MESSAGE-0008-2 to MESSAGE-TEXT
perform Z-POST-MESSAGE-BUFFER
end-if
exit.
*****************************************************************
FIRST-TIME-PROCESSING.
add 8 to ZERO giving SIMODUMP-RESULT
if SIMODUMP-COPYRIGHT not = 'HIDE'
perform POST-COPYRIGHT
end-if
add 1 to ZERO giving SIMODUMP-IDX
perform 8 times
move SPACES to SIMODUMP-LINES(SIMODUMP-IDX)
add 1 to SIMODUMP-IDX
end-perform
subtract SIMODUMP-IDX from SIMODUMP-IDX
move 'N' to FIRST-TIME
exit.
*****************************************************************
POST-COPYRIGHT.
move SIM-TITLE to MESSAGE-TEXT
perform Z-POST-MESSAGE-TEXT
move SIM-COPYRIGHT to MESSAGE-TEXT
perform Z-POST-MESSAGE-TEXT
exit.
*****************************************************************
POST-TO-LOG-FILE.
add 16 to ZERO giving SIMOLOGS-STATUS
* move DUMP-BUFFER to SIMOLOGS-MESSAGE
call 'SIMOLOGS' using SIMOLOGS-PASS-AREA
if SIMOLOGS-STATUS not = ZERO
move 'OPR1' to SIMODUMP-OUTPUT
add SIMOLOGS-STATUS to ZERO giving SIMODUMP-RESULT
end-if
exit.
*****************************************************************
Z-DISPLAY-MESSAGE-BUFFER.
perform Z-CALCULATE-MSG-LENGTH
if SIMODUMP-OUTPUT(1:3) = 'OUT'
display MESSAGE-BUFFER(1:MSG-LSB)
else
display MESSAGE-BUFFER(1:MSG-LSB) upon console
end-if
move SPACES to MESSAGE-TEXT
exit.
*****************************************************************
Z-POST-MESSAGE-BUFFER.
evaluate SIMODUMP-OUTPUT(1:4)
when 'OUT1' perform Z-POST-MESSAGE-BUFFER-2-SYSOUT
when other perform Z-POST-MESSAGE-BUFFER-2-SYSOUT
end-evaluate
exit.
*****************************************************************
Z-POST-MESSAGE-TEXT.
evaluate SIMODUMP-OUTPUT(1:4)
when 'OUT1' perform Z-POST-MESSAGE-TEXT-TO-SYSOUT
when other perform Z-POST-MESSAGE-TEXT-TO-SYSOUT
end-evaluate
exit.
*****************************************************************
Z-POST-MESSAGE-BUFFER-2-SYSOUT.
perform Z-CALCULATE-MSG-LENGTH
display MESSAGE-BUFFER(1:MSG-LSB)
move all SPACES to MESSAGE-TEXT
exit.
*****************************************************************
Z-POST-MESSAGE-TEXT-TO-SYSOUT.
perform Z-CALCULATE-MSG-LENGTH
display MESSAGE-TEXT(1:MSG-LSB - 11)
move all SPACES to MESSAGE-TEXT
exit.
*****************************************************************
Z-CALCULATE-MSG-LENGTH.
add 267 to ZERO giving MSG-LSB
if MESSAGE-TEXT-2 = SPACES
subtract 188 from MSG-LSB
else
perform until MSG-LSB < 12
or MESSAGE-BUFFER(MSG-LSB:1) not = SPACE
if MESSAGE-BUFFER(MSG-LSB:1) = SPACE
subtract 1 from MSG-LSB
end-if
end-perform
end-if
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 *
*****************************************************************
This program (SIMOLOGS.cbl) performs the necessary I/O to write to a log file (SYSLOG). If the logging function is used (i.e. SIMODUMP-REQUEST contains a value of 'FILE' or 'BOTH' ) then a DD statement is required in the JCL. This program uses a Y2K (Year 2000) compliant date access function and required the COBOL/390 dialect.
*set ASSIGN(EXTERNAL) NOOPTIONAL-FILE SEQUENTIAL(LINE)
IDENTIFICATION DIVISION.
PROGRAM-ID. SIMOLOGS.
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: SIMOLOGS.CBL
*****************************************************************
*
* SIMOLOGS - Call SIMOLOGS to write record to the Message file.
*
* CALLING PROTOCOL
* ----------------
* Use standard procedure to EXECUTE, RUN or ANIMATE.
*
* DESCRIPTION
* -----------
* This program will write a message to the SYSLOG file.
*
* REQUIREMENTS
* ------------
* The COBOL/390 dialect is required for Y2K date processing.
* The following directives are required for Micro Focus.
* ASSIGN(EXTERNAL) Map COBOL file name to externally defined name
* SEQUENTIAL(LINE) Treat COBOL SEQUENTIAL as a LINE SEQUENTIAL
* NOOPTIONAL-FILE The OPEN EXTEND file must exist or post error
*
*****************************************************************
*
* MAINTENANCE
* -----------
* 1997/12/18 Simmons, Created program.
* 1997/12/18 Simmons, No changes to date.
*
*****************************************************************
*
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
*****************************************************************
SELECT SYSLOG-FILE
ASSIGN to SYSLOG
ORGANIZATION is SEQUENTIAL
ACCESS MODE is SEQUENTIAL
FILE STATUS is SYSLOG-LOG-STATUS.
*****************************************************************
*
DATA DIVISION.
FILE SECTION.
*
*****************************************************************
FD SYSLOG-FILE
DATA RECORD IS SYSLOG-RECORD
RECORDING MODE is V
RECORD is VARYING in SIZE from 64 to 1051
DEPENDING ON MESSAGE-LENGTH.
01 SYSLOG-RECORD.
05 SYSLOG-DAY pic X(3).
05 filler pic X.
05 SYSLOG-DATE pic X(10).
05 filler pic X.
05 SYSLOG-TIME pic X(11).
05 filler pic X.
05 SYSLOG-DATA pic X(1024).
*****************************************************************
WORKING-STORAGE SECTION.
01 SYSLOG-LOG-STATUS.
05 SYSLOG-LOG-STAT1 pic X.
05 SYSLOG-LOG-STAT2 pic X.
01 IO-STATUS.
05 IO-STAT1 pic X.
05 IO-STAT2 pic X.
01 TWO-BYTES.
05 TWO-BYTES-LEFT pic X.
05 TWO-BYTES-RIGHT pic X.
01 TWO-BYTES-BINARY redefines TWO-BYTES pic 9(4) comp.
01 SYSLOG-OPEN-FLAG pic X value 'N'.
01 FIRST-TIME pic X value 'Y'.
01 MESSAGE-BUFFER.
05 MESSAGE-HEADER pic X(11) value '* SIMOLOGS '.
05 MESSAGE-TEXT pic X(68).
01 APPL-RESULT pic S9(9) comp.
88 APPL-AOK value 0.
88 APPL-EOF value 16.
01 WORK-04 pic X(4).
01 LINE-LENGTH pic 9(5) value 80.
01 WORK-DATE.
05 WORK-DATE-08 pic X(8).
01 WORK-TIME pic X(8).
01 SYSOUT-LENGTH pic 9(5) value 121.
01 MESSAGE-LENGTH pic 9(5) value 1024.
01 COUNTER-LENGTH pic 9(5) value 1024.
01 DISPLAY-LEN pic 9(5) value 1024.
01 DISPLAY-POS pic 9(5) value 1.
01 LOG-DATE pic X(10) value 'yyyy/nn/nn'.
01 LOG-TIME pic X(11) value 'nn:nn:nn:nn'.
COPY PASSDUMP.
*****************************************************************
LINKAGE SECTION.
COPY PASSLOGS.
*****************************************************************
PROCEDURE DIVISION using SIMOLOGS-PASS-AREA.
add 8 to ZERO giving SIMOLOGS-STATUS
move SIMOLOGS-REQUEST to WORK-04
evaluate WORK-04
* Display to System Operator Console...
when 'OPR1' perform DETERMINE-LENGTH-OF-MESSAGE
perform DISPLAY-SIMOLOGS-MESSAGE
when 'OPR2' perform DETERMINE-LENGTH-OF-MESSAGE
perform WRITE-TO-LOG
perform DISPLAY-SIMOLOGS-MESSAGE
* No Display, Write to SYSLOG File
when 'LOG1' perform DETERMINE-LENGTH-OF-MESSAGE
perform WRITE-TO-LOG
* Display to user-defined SYSOUT device...
when 'OUT1' perform DETERMINE-LENGTH-OF-MESSAGE
perform DISPLAY-SIMOLOGS-MESSAGE
when 'OUT2' perform DETERMINE-LENGTH-OF-MESSAGE
perform WRITE-TO-LOG
perform DISPLAY-SIMOLOGS-MESSAGE
when 'DUMP' perform DUMP-BUFFER
when 'MAKE' add 1 to ZERO giving DISPLAY-POS
add 80 to ZERO giving DISPLAY-LEN
perform SIMOLOGS-OPEN-OUTPUT
perform SIMOLOGS-CLOSE
when OTHER perform DETERMINE-LENGTH-OF-MESSAGE
perform DISPLAY-SIMOLOGS-MESSAGE
end-evaluate
if APPL-AOK
subtract SIMOLOGS-STATUS from SIMOLOGS-STATUS
end-if
GOBACK.
*****************************************************************
DUMP-BUFFER.
perform DETERMINE-LENGTH-OF-MESSAGE
perform WRITE-TO-LOG
exit.
*****************************************************************
DETERMINE-LENGTH-OF-MESSAGE.
add 1024 to ZERO giving MESSAGE-LENGTH
if SIMOLOGS-MESSAGE(513:512) = SPACES
add 512 to ZERO giving MESSAGE-LENGTH
if SIMOLOGS-MESSAGE(257:256) = SPACES
add 256 to ZERO giving MESSAGE-LENGTH
if SIMOLOGS-MESSAGE(129:128) = SPACES
add 128 to ZERO giving MESSAGE-LENGTH
if SIMOLOGS-MESSAGE(65:64) = SPACES
add 64 to ZERO giving MESSAGE-LENGTH
end-if
end-if
else
if SIMOLOGS-MESSAGE(385:128) = SPACES
add 384 to ZERO giving MESSAGE-LENGTH
end-if
end-if
else
if SIMOLOGS-MESSAGE(769:256) = SPACES
add 768 to ZERO giving MESSAGE-LENGTH
else
if SIMOLOGS-MESSAGE(897:128) = SPACES
add 896 to ZERO giving MESSAGE-LENGTH
end-if
end-if
end-if
perform
until MESSAGE-LENGTH = 0
or SIMOLOGS-MESSAGE(MESSAGE-LENGTH:1) not = SPACE
if SIMOLOGS-MESSAGE(MESSAGE-LENGTH:1) = SPACE
subtract 1 from MESSAGE-LENGTH
end-if
end-perform
add MESSAGE-LENGTH to ZERO giving SYSOUT-LENGTH
add 27 to MESSAGE-LENGTH
exit.
*****************************************************************
* Display Messages to SYSOUT Device or SYSTEM Operator Console *
*****************************************************************
DISPLAY-SIMOLOGS-MESSAGE.
add SYSOUT-LENGTH to ZERO giving COUNTER-LENGTH
if WORK-04(1:3) = 'OUT'
add 121 to LINE-LENGTH
else
add 80 to LINE-LENGTH
end-if
add 1 to ZERO giving DISPLAY-POS
perform until COUNTER-LENGTH < 1
if COUNTER-LENGTH > LINE-LENGTH
add LINE-LENGTH to ZERO giving DISPLAY-LEN
else
add COUNTER-LENGTH to ZERO giving DISPLAY-LEN
end-if
perform DISPLAY-SIMOLOGS-MESSAGE-02
add DISPLAY-LEN to DISPLAY-POS
*
if DISPLAY-LEN > ZERO
and DISPLAY-LEN < COUNTER-LENGTH
subtract DISPLAY-LEN from COUNTER-LENGTH
else
move ZERO to COUNTER-LENGTH
end-if
end-perform
exit.
*---------------------------------------------------------------*
DISPLAY-SIMOLOGS-MESSAGE-02.
if work-04(1:3) = 'OUT'
display SIMOLOGS-MESSAGE(DISPLAY-POS:DISPLAY-LEN)
else
display SIMOLOGS-MESSAGE(DISPLAY-POS:DISPLAY-LEN)
upon console
end-if
exit.
*****************************************************************
GET-DATE-AND-TIME.
accept WORK-DATE from DATE YYYYMMDD
accept WORK-TIME from TIME
move WORK-DATE(1:4) to LOG-DATE(1:4)
move WORK-DATE(5:2) to LOG-DATE(6:2)
move WORK-DATE(7:2) to LOG-DATE(9:2)
move WORK-TIME(1:2) to LOG-TIME(1:2)
move WORK-TIME(3:2) to LOG-TIME(4:2)
move WORK-TIME(5:2) to LOG-TIME(7:2)
move WORK-TIME(7:2) to LOG-TIME(10:2)
exit.
*****************************************************************
WRITE-TO-LOG.
if SYSLOG-OPEN-FLAG not = 'Y'
perform SIMOLOGS-OPEN-EXTEND
end-if
if SYSLOG-OPEN-FLAG = 'Y'
perform GET-DATE-AND-TIME
move all SPACES to SYSLOG-RECORD
move '***' to SYSLOG-DAY
move LOG-DATE to SYSLOG-DATE
move LOG-TIME to SYSLOG-TIME
move SIMOLOGS-MESSAGE to SYSLOG-DATA
perform SIMOLOGS-WRITE
perform SIMOLOGS-CLOSE
move 'N' to SYSLOG-OPEN-FLAG
else
move 'Failed to OPEN the SYSLOG File' to MESSAGE-TEXT
perform Z-DISPLAY-CONSOLE-MESSAGE
if SIMOLOGS-REQUEST = 'OUT2'
move 'OUT1' to SIMOLOGS-REQUEST
move 'Display messages upon SYSOUT Device'
to MESSAGE-TEXT
perform Z-DISPLAY-CONSOLE-MESSAGE
else
move 'OPR1' to SIMOLOGS-REQUEST
move 'Display messages upon System Operator Console'
to MESSAGE-TEXT
perform Z-DISPLAY-CONSOLE-MESSAGE
end-if
end-if
exit.
*****************************************************************
* I/O ROUTINES TO CREATE THE MESSAGE FILE, SIMOLOGS...
*****************************************************************
SIMOLOGS-WRITE.
if MESSAGE-LENGTH > 1051
add 1051 to MESSAGE-LENGTH giving MESSAGE-LENGTH
end-if
if MESSAGE-LENGTH < 64
add 64 to MESSAGE-LENGTH giving MESSAGE-LENGTH
end-if
write SYSLOG-RECORD.
if SYSLOG-LOG-STATUS = '00'
subtract APPL-RESULT from APPL-RESULT
else
if SYSLOG-LOG-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 'FAILED-WRITE, Log file, SYSLOG' to MESSAGE-TEXT
perform Z-DISPLAY-CONSOLE-MESSAGE
move SYSLOG-LOG-STATUS to IO-STATUS
perform Z-DISPLAY-IO-STATUS
* perform Z-ABEND-PROGRAM
end-if
exit.
*---------------------------------------------------------------*
SIMOLOGS-OPEN-EXTEND.
add 8 to ZERO giving APPL-RESULT.
open EXTEND SYSLOG-FILE
if SYSLOG-LOG-STATUS = '00'
* move 'SYSLOG, Open as EXTEND file' to MESSAGE-TEXT
* perform Z-DISPLAY-CONSOLE-MESSAGE
subtract APPL-RESULT from APPL-RESULT
move 'Y' to SYSLOG-OPEN-FLAG
else
close SYSLOG-FILE
* move 'SYSLOG, Open as OUTPUT file' to MESSAGE-TEXT
* perform Z-DISPLAY-CONSOLE-MESSAGE
open output SYSLOG-FILE
if SYSLOG-LOG-STATUS = '00'
subtract APPL-RESULT from APPL-RESULT
move 'Y' to SYSLOG-OPEN-FLAG
end-if
end-if
if APPL-AOK
CONTINUE
else
move 'FAILED-OPEN, Log file, SYSLOG' to MESSAGE-TEXT
perform Z-DISPLAY-CONSOLE-MESSAGE
move SYSLOG-LOG-STATUS to IO-STATUS
perform Z-DISPLAY-IO-STATUS
* perform Z-ABEND-PROGRAM
end-if
exit.
*---------------------------------------------------------------*
SIMOLOGS-OPEN-OUTPUT.
add 8 to ZERO giving APPL-RESULT.
open OUTPUT SYSLOG-FILE
if SYSLOG-LOG-STATUS = '00'
* move 'SYSLOG, Open as OUTPUT file' to MESSAGE-TEXT
* perform Z-DISPLAY-CONSOLE-MESSAGE
subtract APPL-RESULT from APPL-RESULT
move 'Y' to SYSLOG-OPEN-FLAG
else
close SYSLOG-FILE
* move 'SYSLOG, Open as OUTPUT file' to MESSAGE-TEXT
* perform Z-DISPLAY-CONSOLE-MESSAGE
open output SYSLOG-FILE
if SYSLOG-LOG-STATUS = '00'
subtract APPL-RESULT from APPL-RESULT
move 'Y' to SYSLOG-OPEN-FLAG
end-if
end-if
if APPL-AOK
CONTINUE
else
move 'FAILED-OPEN, Log file, SYSLOG' to MESSAGE-TEXT
perform Z-DISPLAY-CONSOLE-MESSAGE
move SYSLOG-LOG-STATUS to IO-STATUS
perform Z-DISPLAY-IO-STATUS
* perform Z-ABEND-PROGRAM
end-if
exit.
*---------------------------------------------------------------*
SIMOLOGS-CLOSE.
add 8 to ZERO giving APPL-RESULT.
close SYSLOG-FILE
if SYSLOG-LOG-STATUS = '00'
subtract APPL-RESULT from APPL-RESULT
else
add 12 to ZERO giving APPL-RESULT
end-if
if APPL-AOK
CONTINUE
else
move 'FAILED-CLOSE, Log file, SYSLOG' to MESSAGE-TEXT
perform Z-DISPLAY-CONSOLE-MESSAGE
move SYSLOG-LOG-STATUS to IO-STATUS
perform Z-DISPLAY-IO-STATUS
* perform Z-ABEND-PROGRAM
end-if
exit.
*****************************************************************
* The following Z-Routines perform administrative functions *
* for this program. *
*****************************************************************
*****************************************************************
* ABEND the program and return to caller... *
*****************************************************************
Z-ABEND-PROGRAM.
if MESSAGE-TEXT not = SPACES
perform Z-DISPLAY-CONSOLE-MESSAGE
end-if
move 'Writing to log file is ABENDING...' to MESSAGE-TEXT
perform Z-DISPLAY-CONSOLE-MESSAGE
add 12 to ZERO giving RETURN-CODE
GOBACK.
*****************************************************************
* Display the file status bytes. This routine will display as *
* two digits if the full two byte file status is numeric. If *
* second byte is non-numeric then it will be treated as a *
* binary number. *
*****************************************************************
Z-DISPLAY-IO-STATUS.
if IO-STATUS NUMERIC
display '* SIMOLOGS FILE-STATUS-' IO-STATUS upon console
else
subtract TWO-BYTES-BINARY from TWO-BYTES-BINARY
move IO-STAT2 to TWO-BYTES-RIGHT
display '* SIMOLOGS FILE-STATUS-'
IO-STAT1 '/' TWO-BYTES-BINARY upon console
end-if
exit.
*****************************************************************
* Display a message generated by this program. *
*****************************************************************
Z-DISPLAY-CONSOLE-MESSAGE.
display MESSAGE-BUFFER upon console
move SPACES to 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 *
*****************************************************************
The following is the copy file (PASSDUMP.cpy) used for the pass area when calling the dump routine.
*****************************************************************
* PASSDUMP is a COBOL Copy File *
* Data Structure or Pass Area used for calling SIMODUMP. *
* Copyright (C) 1987-2019 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 *
*****************************************************************
* Values for SIMODUMP-REQUEST *
* DUMP Dump the Buffer in Hexadecimal format *
* NOTE Display or Write the text to the screen or log file *
* *
* Values for SIMODUMP-SYSOUT *
* OPR1 Display dump information on operator console *
* OPR2 Display to operator console and write to log file *
* OUT1 Display dump information to SYSOUT device *
* OUT2 Display to SYSOUT device and write to log file *
* LOG1 Write dump information to the log file (SYSLOG) *
* NONE Do not output to screen or file, put dump info in *
* pass area table and return to caller. *
* *
* Values for SIMODUMP-COPYRIGHT *
* HIDE Do not display the copyright information. Any other *
* entry will display the copyright information. *
*****************************************************************
01 SIMODUMP-PASS-AREA.
* Initial information is provided by the calling program,
* The SIMODUMP-REQUEST field will be modified to "DUMP" if it
* does not contain a valid entry.
* The SIMODUMP-RESULT field may also be modified by the
* SimoDUMP routine.
05 SIMODUMP-REQUEST PIC X(4).
05 SIMODUMP-RESULT PIC 9999.
* The following are not modified by the SimoDUMP routine...
05 SIMODUMP-DUMP-ID PIC X(8).
05 SIMODUMP-OUTPUT PIC X(4).
05 SIMODUMP-COPYRIGHT PIC X(4).
* The following are modified by the SimoDUMP routine...
05 SIMODUMP-IDX PIC 99.
05 SIMODUMP-LINES PIC X(80) OCCURS 8 TIMES.
* The following are not modified by the SimoDUMP routine...
05 SIMODUMP-LENGTH PIC 9(4).
01 SIMODUMP-BUFFER PIC X(128).
*
*** PASSDUMP - End-of-Copy File - - - - - - - - - - - PASSDUMP *
*****************************************************************
*
The following is the copy file (HEXTABLE.cpy) of the conversion table used by the dump routine.
*****************************************************************
* HEXTABLE is a COBOL Copy File *
* Table for Hexadecimal Dump and Display. *
* Copyright (C) 1987-2019 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 *
*****************************************************************
* *
* The following table contains 256, 5-byte elements. *
* *
* The format of the table elements is as follows *
* Byte Function *
* 1-2 Two-byte hexadecimal print value *
* 3 Print character for EBCDIC *
* 4 Print character for ASCII *
* 5 0 - non-printable *
* 1 - printable for EBCDIC *
* 2 - printable for ASCII *
* 3 - printable for Both *
* *
* Notice the technique used for an ASCII apostrophe (X'27') *
* and an EBCDIC apostrphe (X'7D'). The value content is *
* enclosed in double quotes to allow for the definition of *
* an apostrophe (or single quote) within the field. *
* Please Note: This feature requires the COBOL/390 dialect. *
* Version 18.07.15 *
*****************************************************************
*
01 TABLE-OF-DATA.
05 HEX-00 PIC X(5) VALUE '00..0'.
05 HEX-01 PIC X(5) VALUE '01..0'.
05 HEX-02 PIC X(5) VALUE '02..0'.
05 HEX-03 PIC X(5) VALUE '03..0'.
05 HEX-04 PIC X(5) VALUE '04..0'.
05 HEX-05 PIC X(5) VALUE '05..0'.
05 HEX-06 PIC X(5) VALUE '06..0'.
05 HEX-07 PIC X(5) VALUE '07..0'.
05 HEX-08 PIC X(5) VALUE '08..0'.
05 HEX-09 PIC X(5) VALUE '09..0'.
05 HEX-0A PIC X(5) VALUE '0A..0'.
05 HEX-0B PIC X(5) VALUE '0B..0'.
05 HEX-0C PIC X(5) VALUE '0C..0'.
05 HEX-0D PIC X(5) VALUE '0D..0'.
05 HEX-0E PIC X(5) VALUE '0E..0'.
05 HEX-0F PIC X(5) VALUE '0F..0'.
05 HEX-10 PIC X(5) VALUE '10..0'.
05 HEX-11 PIC X(5) VALUE '11..0'.
05 HEX-12 PIC X(5) VALUE '12..0'.
05 HEX-13 PIC X(5) VALUE '13..0'.
05 HEX-14 PIC X(5) VALUE '14..0'.
05 HEX-15 PIC X(5) VALUE '15..0'.
05 HEX-16 PIC X(5) VALUE '16..0'.
05 HEX-17 PIC X(5) VALUE '17..0'.
05 HEX-18 PIC X(5) VALUE '18..0'.
05 HEX-19 PIC X(5) VALUE '19..0'.
05 HEX-1A PIC X(5) VALUE '1A..0'.
05 HEX-1B PIC X(5) VALUE '1B..0'.
05 HEX-1C PIC X(5) VALUE '1C..0'.
05 HEX-1D PIC X(5) VALUE '1D..0'.
05 HEX-1E PIC X(5) VALUE '1E..0'.
05 HEX-1F PIC X(5) VALUE '1F..0'.
05 HEX-20 PIC X(5) VALUE '20. 2'.
05 HEX-21 PIC X(5) VALUE '21.!2'.
05 HEX-22 PIC X(5) VALUE '22."2'.
05 HEX-23 PIC X(5) VALUE '23.#2'.
05 HEX-24 PIC X(5) VALUE '24.$2'.
05 HEX-25 PIC X(5) VALUE '25.%2'.
05 HEX-26 PIC X(5) VALUE '26.&2'.
05 HEX-27 PIC X(5) VALUE "27.'2".
05 HEX-28 PIC X(5) VALUE '28.(2'.
05 HEX-29 PIC X(5) VALUE '29.)2'.
05 HEX-2A PIC X(5) VALUE '2A.*2'.
05 HEX-2B PIC X(5) VALUE '2B.+2'.
05 HEX-2C PIC X(5) VALUE '2C.,2'.
05 HEX-2D PIC X(5) VALUE '2D.-2'.
05 HEX-2E PIC X(5) VALUE '2E..2'.
05 HEX-2F PIC X(5) VALUE '2F./2'.
05 HEX-30 PIC X(5) VALUE '30.02'.
05 HEX-31 PIC X(5) VALUE '31.12'.
05 HEX-32 PIC X(5) VALUE '32.22'.
05 HEX-33 PIC X(5) VALUE '33.32'.
05 HEX-34 PIC X(5) VALUE '34.42'.
05 HEX-35 PIC X(5) VALUE '35.52'.
05 HEX-36 PIC X(5) VALUE '36.62'.
05 HEX-37 PIC X(5) VALUE '37.72'.
05 HEX-38 PIC X(5) VALUE '38.82'.
05 HEX-39 PIC X(5) VALUE '39.92'.
05 HEX-3A PIC X(5) VALUE '3A.:2'.
05 HEX-3B PIC X(5) VALUE '3B.;2'.
05 HEX-3C PIC X(5) VALUE '3C.<2'.
05 HEX-3D PIC X(5) VALUE '3D.=2'.
05 HEX-3E PIC X(5) VALUE '3E.>2'.
05 HEX-3F PIC X(5) VALUE '3F.?2'.
05 HEX-40 PIC X(5) VALUE '40 @3'.
05 HEX-41 PIC X(5) VALUE '41.A2'.
05 HEX-42 PIC X(5) VALUE '42.B2'.
05 HEX-43 PIC X(5) VALUE '43.C2'.
05 HEX-44 PIC X(5) VALUE '44.D2'.
05 HEX-45 PIC X(5) VALUE '45.E2'.
05 HEX-46 PIC X(5) VALUE '46.F2'.
05 HEX-47 PIC X(5) VALUE '47.G2'.
05 HEX-48 PIC X(5) VALUE '48.H2'.
05 HEX-49 PIC X(5) VALUE '49.I2'.
05 HEX-4A PIC X(5) VALUE '4A.J2'.
05 HEX-4B PIC X(5) VALUE '4B.K3'.
05 HEX-4C PIC X(5) VALUE '4C<L3'.
05 HEX-4D PIC X(5) VALUE '4D(M3'.
05 HEX-4E PIC X(5) VALUE '4E+N3'.
05 HEX-4F PIC X(5) VALUE '4F|O3'.
05 HEX-50 PIC X(5) VALUE '50&P3'.
05 HEX-51 PIC X(5) VALUE '51.Q2'.
05 HEX-52 PIC X(5) VALUE '52.R2'.
05 HEX-53 PIC X(5) VALUE '53.S2'.
05 HEX-54 PIC X(5) VALUE '54.T2'.
05 HEX-55 PIC X(5) VALUE '55.U2'.
05 HEX-56 PIC X(5) VALUE '56.V2'.
05 HEX-57 PIC X(5) VALUE '57.W2'.
05 HEX-58 PIC X(5) VALUE '58.X2'.
05 HEX-59 PIC X(5) VALUE '59.Y2'.
05 HEX-5A PIC X(5) VALUE '5A!Z3'.
05 HEX-5B PIC X(5) VALUE '5B$[3'.
05 HEX-5C PIC X(5) VALUE '5C*\3'.
05 HEX-5D PIC X(5) VALUE '5D)]3'.
05 HEX-5E PIC X(5) VALUE '5E;^3'.
05 HEX-5F PIC X(5) VALUE '5F¬_3'.
05 HEX-60 PIC X(5) VALUE '60-`3'.
05 HEX-61 PIC X(5) VALUE '61/a3'.
05 HEX-62 PIC X(5) VALUE '62.b2'.
05 HEX-63 PIC X(5) VALUE '63.c2'.
05 HEX-64 PIC X(5) VALUE '64.d2'.
05 HEX-65 PIC X(5) VALUE '65.e2'.
05 HEX-66 PIC X(5) VALUE '66.f2'.
05 HEX-67 PIC X(5) VALUE '67.g2'.
05 HEX-68 PIC X(5) VALUE '68.h2'.
05 HEX-69 PIC X(5) VALUE '69.i2'.
05 HEX-6A PIC X(5) VALUE '6A¦j3'.
05 HEX-6B PIC X(5) VALUE '6B,k3'.
05 HEX-6C PIC X(5) VALUE '6C%l3'.
05 HEX-6D PIC X(5) VALUE '6D_m3'.
05 HEX-6E PIC X(5) VALUE '6E>n3'.
05 HEX-6F PIC X(5) VALUE '6F?o3'.
05 HEX-70 PIC X(5) VALUE '70.p2'.
05 HEX-71 PIC X(5) VALUE '71.q2'.
05 HEX-72 PIC X(5) VALUE '72.r2'.
05 HEX-73 PIC X(5) VALUE '73.s2'.
05 HEX-74 PIC X(5) VALUE '74.t2'.
05 HEX-75 PIC X(5) VALUE '75.u2'.
05 HEX-76 PIC X(5) VALUE '76.v2'.
05 HEX-77 PIC X(5) VALUE '77.w2'.
05 HEX-78 PIC X(5) VALUE '78.x2'.
05 HEX-79 PIC X(5) VALUE '79`y3'.
05 HEX-7A PIC X(5) VALUE '7A:z3'.
05 HEX-7B PIC X(5) VALUE '7B#{3'.
05 HEX-7C PIC X(5) VALUE '7C@|3'.
05 HEX-7D PIC X(5) VALUE "7D'}3".
05 HEX-7E PIC X(5) VALUE '7E=~3'.
05 HEX-7F PIC X(5) VALUE '7F".1'.
05 HEX-80 PIC X(5) VALUE '80..0'.
05 HEX-81 PIC X(5) VALUE '81a.1'.
05 HEX-82 PIC X(5) VALUE '82b.1'.
05 HEX-83 PIC X(5) VALUE '83c.1'.
05 HEX-84 PIC X(5) VALUE '84d.1'.
05 HEX-85 PIC X(5) VALUE '85e.1'.
05 HEX-86 PIC X(5) VALUE '86f.1'.
05 HEX-87 PIC X(5) VALUE '87g.1'.
05 HEX-88 PIC X(5) VALUE '88h.1'.
05 HEX-89 PIC X(5) VALUE '89i.1'.
05 HEX-8A PIC X(5) VALUE '8A..0'.
05 HEX-8B PIC X(5) VALUE '8B..0'.
05 HEX-8C PIC X(5) VALUE '8C..0'.
05 HEX-8D PIC X(5) VALUE '8D..0'.
05 HEX-8E PIC X(5) VALUE '8E..0'.
05 HEX-8F PIC X(5) VALUE '8F..0'.
05 HEX-90 PIC X(5) VALUE '90..0'.
05 HEX-91 PIC X(5) VALUE '91j.1'.
05 HEX-92 PIC X(5) VALUE '92k.1'.
05 HEX-93 PIC X(5) VALUE '93l.1'.
05 HEX-94 PIC X(5) VALUE '94m.1'.
05 HEX-95 PIC X(5) VALUE '95n.1'.
05 HEX-96 PIC X(5) VALUE '96o.1'.
05 HEX-97 PIC X(5) VALUE '97p.1'.
05 HEX-98 PIC X(5) VALUE '98q.1'.
05 HEX-99 PIC X(5) VALUE '99r.1'.
05 HEX-9A PIC X(5) VALUE '9A..0'.
05 HEX-9B PIC X(5) VALUE '9B..0'.
05 HEX-9C PIC X(5) VALUE '9C..0'.
05 HEX-9D PIC X(5) VALUE '9D..0'.
05 HEX-9E PIC X(5) VALUE '9E..0'.
05 HEX-9F PIC X(5) VALUE '9F..0'.
05 HEX-A0 PIC X(5) VALUE 'A0..0'.
05 HEX-A1 PIC X(5) VALUE 'A1~.1'.
05 HEX-A2 PIC X(5) VALUE 'A2s.1'.
05 HEX-A3 PIC X(5) VALUE 'A3t.1'.
05 HEX-A4 PIC X(5) VALUE 'A4u.1'.
05 HEX-A5 PIC X(5) VALUE 'A5v.1'.
05 HEX-A6 PIC X(5) VALUE 'A6w¦3'.
05 HEX-A7 PIC X(5) VALUE 'A7x.1'.
05 HEX-A8 PIC X(5) VALUE 'A8y.1'.
05 HEX-A9 PIC X(5) VALUE 'A9z.1'.
05 HEX-AA PIC X(5) VALUE 'AA..0'.
05 HEX-AB PIC X(5) VALUE 'AB..0'.
05 HEX-AC PIC X(5) VALUE 'AC.¬2'.
05 HEX-AD PIC X(5) VALUE 'AD..0'.
05 HEX-AE PIC X(5) VALUE 'AE..0'.
05 HEX-AF PIC X(5) VALUE 'AF..0'.
05 HEX-B0 PIC X(5) VALUE 'B0^.1'.
05 HEX-B1 PIC X(5) VALUE 'B1..0'.
05 HEX-B2 PIC X(5) VALUE 'B2..0'.
05 HEX-B3 PIC X(5) VALUE 'B3..0'.
05 HEX-B4 PIC X(5) VALUE 'B4..0'.
05 HEX-B5 PIC X(5) VALUE 'B5..0'.
05 HEX-B6 PIC X(5) VALUE 'B6..0'.
05 HEX-B7 PIC X(5) VALUE 'B7..0'.
05 HEX-B8 PIC X(5) VALUE 'B8..0'.
05 HEX-B9 PIC X(5) VALUE 'B9..0'.
05 HEX-BA PIC X(5) VALUE 'BA[.1'.
05 HEX-BB PIC X(5) VALUE 'BB].1'.
05 HEX-BC PIC X(5) VALUE 'BC..0'.
05 HEX-BD PIC X(5) VALUE 'BD..0'.
05 HEX-BE PIC X(5) VALUE 'BE..0'.
05 HEX-BF PIC X(5) VALUE 'BF..0'.
05 HEX-C0 PIC X(5) VALUE 'C0{.1'.
05 HEX-C1 PIC X(5) VALUE 'C1A.1'.
05 HEX-C2 PIC X(5) VALUE 'C2B.1'.
05 HEX-C3 PIC X(5) VALUE 'C3C.1'.
05 HEX-C4 PIC X(5) VALUE 'C4D.1'.
05 HEX-C5 PIC X(5) VALUE 'C5E.1'.
05 HEX-C6 PIC X(5) VALUE 'C6F.1'.
05 HEX-C7 PIC X(5) VALUE 'C7G.1'.
05 HEX-C8 PIC X(5) VALUE 'C8H.1'.
05 HEX-C9 PIC X(5) VALUE 'C9I.1'.
05 HEX-CA PIC X(5) VALUE 'CA..0'.
05 HEX-CB PIC X(5) VALUE 'CB..0'.
05 HEX-CC PIC X(5) VALUE 'CC..0'.
05 HEX-CD PIC X(5) VALUE 'CD..0'.
05 HEX-CE PIC X(5) VALUE 'CE..0'.
05 HEX-CF PIC X(5) VALUE 'CF..0'.
05 HEX-D0 PIC X(5) VALUE 'D0}.1'.
05 HEX-D1 PIC X(5) VALUE 'D1J.1'.
05 HEX-D2 PIC X(5) VALUE 'D2K.1'.
05 HEX-D3 PIC X(5) VALUE 'D3L.1'.
05 HEX-D4 PIC X(5) VALUE 'D4M.1'.
05 HEX-D5 PIC X(5) VALUE 'D5N.1'.
05 HEX-D6 PIC X(5) VALUE 'D6O.1'.
05 HEX-D7 PIC X(5) VALUE 'D7P.1'.
05 HEX-D8 PIC X(5) VALUE 'D8Q.1'.
05 HEX-D9 PIC X(5) VALUE 'D9R.1'.
05 HEX-DA PIC X(5) VALUE 'DA..0'.
05 HEX-DB PIC X(5) VALUE 'DB..0'.
05 HEX-DC PIC X(5) VALUE 'DC..0'.
05 HEX-DD PIC X(5) VALUE 'DD..0'.
05 HEX-DE PIC X(5) VALUE 'DE..0'.
05 HEX-DF PIC X(5) VALUE 'DF..0'.
05 HEX-E0 PIC X(5) VALUE 'E0\.1'.
05 HEX-E1 PIC X(5) VALUE 'E1..0'.
05 HEX-E2 PIC X(5) VALUE 'E2S.1'.
05 HEX-E3 PIC X(5) VALUE 'E3T.1'.
05 HEX-E4 PIC X(5) VALUE 'E4U.1'.
05 HEX-E5 PIC X(5) VALUE 'E5V.1'.
05 HEX-E6 PIC X(5) VALUE 'E6W.1'.
05 HEX-E7 PIC X(5) VALUE 'E7X.1'.
05 HEX-E8 PIC X(5) VALUE 'E8Y.1'.
05 HEX-E9 PIC X(5) VALUE 'E9Z.1'.
05 HEX-EA PIC X(5) VALUE 'EA..0'.
05 HEX-EB PIC X(5) VALUE 'EB..0'.
05 HEX-EC PIC X(5) VALUE 'EC..0'.
05 HEX-ED PIC X(5) VALUE 'ED..0'.
05 HEX-EE PIC X(5) VALUE 'EE..0'.
05 HEX-EF PIC X(5) VALUE 'EF..0'.
05 HEX-F0 PIC X(5) VALUE 'F00.1'.
05 HEX-F1 PIC X(5) VALUE 'F11.1'.
05 HEX-F2 PIC X(5) VALUE 'F22.1'.
05 HEX-F3 PIC X(5) VALUE 'F33.1'.
05 HEX-F4 PIC X(5) VALUE 'F44.1'.
05 HEX-F5 PIC X(5) VALUE 'F55.1'.
05 HEX-F6 PIC X(5) VALUE 'F66.1'.
05 HEX-F7 PIC X(5) VALUE 'F77.1'.
05 HEX-F8 PIC X(5) VALUE 'F88.1'.
05 HEX-F9 PIC X(5) VALUE 'F99.1'.
05 HEX-FA PIC X(5) VALUE 'FA..0'.
05 HEX-FB PIC X(5) VALUE 'FB..0'.
05 HEX-FC PIC X(5) VALUE 'FC..0'.
05 HEX-FD PIC X(5) VALUE 'FD..0'.
05 HEX-FE PIC X(5) VALUE 'FE..0'.
05 HEX-FF PIC X(5) VALUE 'FF..0'.
01 TABLE-OF-PRINT REDEFINES TABLE-OF-DATA.
05 TAB-X1 PIC X(5) OCCURS 256 TIMES.
*
*** HEXTABLE - End-of-Copy File - - - - - - - - - - - HEXTABLE *
*****************************************************************
*
The primary purpose of the document is to describe a callable routine that will display a field or data string in a hexadecimal dump (Hex-Dump) format along with a possible EBCDIC and ASCII interpretation. 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.
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.
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.
The following links may be to the current server or to the Internet.
Explore the COBOL Connection for more examples of COBOL programming techniques and sample code.
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.
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.
Explore The File Status Return Codes that are used to interpret the results of accessing VSAM data sets and/or QSAM files.
The following links will require an internet connect.
This suite of programs and documentation is available to download for review and evaluation purposes. Other uses will require a SimoTime Software License. Link to an Evaluation zPAK Option that includes the program members, documentation and control files.
A good place to start is The SimoTime Home Page for access to white papers, program examples and product information. This link requires an Internet Connection
Explore The Micro Focus Web Site for more information about products (including Micro Focus COBOL) and services available from Micro Focus. This link requires an Internet Connection.
Explore the Glossary of Terms for a list of terms and definitions used in this suite of documents and white papers.
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.
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 |
| Hexadecimal Dump Routine using COBOL |
| Copyright © 1987-2025 SimoTime Technologies and Services All Rights Reserved |
| When technology complements business |
| http://www.simotime.com |