![]() |
Printed Report Price List for the Item Master File |
| When technology complements business | Copyright © 1987-2012 SimoTime Enterprises All Rights Reserved |
| The SimoTime Home Page |
Printing numeric fields, especially packed-decimal or binary (i.e. COMP-3 or COMP) requires special consideration. Also, signed, zoned-decimal fields will require special consideration. Most numeric fields will require some sort of editing before printing. This suite of programs provides examples of how a COBOL program may be used to properly print (or display) numeric fields.
The COBOL program is written using the IBM COBOL for OS/390 dialect and will also work with IBM Enterprise COBOL. A JCL member is provided to run the job as an MVS batch job on an IBM mainframe or as a project with Micro Focus Mainframe Express (MFE) running on a PC with Windows. A batch or command file is provided to run the job as a Windows batch job on a Wintel platform using Micro Focus Net Express.
This example illustrates the following functions.
| ||||
| Functions to be Described and Demonstrated |
The input to the sample program is the Item Master file. On the Mainframe this is a VSAM, Key-Sequenced-Data-Set (or KSDS) and with Micro Focus it is a Key-Sequenced or Indexed file. The output will be a printed report showing the item prices and quantity available. The item price is stored in the item master file in a packed-decimal format (i.e. COMP-3). The quantity available is calculated from two fields that are stored in the item master file in a binary (i.e. COMP) format. The quantity-available equals the quantity-on-hand minus the quantity-allocated.
This suite of samples programs will run on the following platforms.
| ||||||
| Operating Systems and Supporting Software |
This program will sequentially read the item master file and build a print line of text from the text fields and numeric fields that are packed and binary formats. Once the print line has been created it will be printed. It is actually written to a sequential file (spooling) that contains print control characters and data.
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Logic Zflow for the Price List Report Job |
Note: The light-green boxes are unique to the Mainframe and Micro Focus Enterprise Server/Studio (or Micro Focus Mainframe Express). The light-red boxes are unique to the PC with Windows and Micro Focus. The light-yellow boxes are decision points or program transitions in the processing logic. The light-blue boxes identify data structures such as Files, VSAM Data Sets or Relational Tables. The light-gray boxes identify a system function or information item.
Three command files are used to execute this example in the non-mainframe environment on a Windows platform with Micro Focus Net Express or Application Server. The first command file (NUMPRTE1.CMD) is used to map file names and execute the sample program. The second command file (Env1BASE.CMD) is used as a common, single point to set environment variables that are used across various applications or sample programs. The third command file (SimoNOTE.CMD) is used to display message to the screen and write to a log file.
The following is the Windows CMD (NUMPRTE1.CMD) required to run the sample COBOL program. This is a two step job. The first step (identified by the :DeleteQSAM statement) will delete the file that was created from a previous run of this job. The second step (identified by the :CreateQSAM statement) will execute the sample program.
@echo OFF
rem * *******************************************************************
rem * NUMPRTE1.CMD - a Windows Command File *
rem * This program is provided by SimoTime Enterprises *
rem * (C) Copyright 1987-2012 All Rights Reserved *
rem * Web Site URL: http://www.simotime.com *
rem * e-mail: helpdesk@simotime.com *
rem * *******************************************************************
rem *
rem * Text - Read the Item Master File, print a price list.
rem * Author - SimoTime Enterprises
rem * Date - January 24, 1996
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 *
setlocal
set CmdName=NUMPRTE1
call ..\Env1BASE %CmdName%
set JobStatus=0000
call SimoNOTE "*******************************************************%CmdName%"
call SimoNOTE "Starting JobName %CmdName%, User is %USERNAME%"
rem * *******************************************************************
rem * Step 1 Set File Mapping, Delete any previously created file...
rem *
:SetDeleteQSAM
call SimoNOTE "Identify JobStep DeleteQSAM"
set ITEMMAST=%BaseLib1%\DataLibA\DYN1\SIMOTIME.DATA.ITEMMAST.DAT
set ITMPRINT=%BaseLib1%\DataLibA\Wrk1\SIMOTIME.REPORT.ITMPRINT.DAT
if exist %ITMPRINT% del %ITMPRINT%
rem *
rem * *******************************************************************
rem * Step 2 Edit input, create a new output file...
rem *
:ExecuteNumericPrint
call SimoNOTE "Identify JobStep ExecuteNumericPrint"
run NUMPRTC1
if not "%ERRORLEVEL%" == "0" set JobStatus=0010
if not "%JobStatus%" == "0000" goto :EojNOK
rem *
if exist %ITMPRINT% (call SimoNOTE "Produced DataSet %ITMPRINT%"
goto :EojAOK)
set JobStatus=0020
if not "%JobStatus%" == "0000" goto :EojNOK
:EojAOK
call SimoNOTE "Finished CmdName %CmdName%, Job Status is %JobStatus% "
goto :End
:EojNOK
call SimoNOTE "ABENDING CmdName %CmdName%, Job Status is %JobStatus% "
goto :End
:End
call SimoNOTE "Conclude SysOut is %SYSOUT%"
endlocal
if not "%1" == "nopause" pause
The following Windows command file (Env1BASE.CMD) is used as a common, single point to set environment variables that are used across various applications or sample programs.
@echo OFF
rem * *******************************************************************
rem * ENV1BASE.CMD - a Windows Command File *
rem * This program is provided by SimoTime Enterprises *
rem * (C) Copyright 1987-2012 All Rights Reserved *
rem * Web Site URL: http://www.simotime.com *
rem * e-mail: helpdesk@simotime.com *
rem * *******************************************************************
rem *
rem * Text - Provide a single point to set common environment variables.
rem * Author - SimoTime Enterprises
rem * Date - January 24, 1996
rem *
rem * Set the commonly used environment variables. This is used to provide
rem * a single point for managing the commonly used environment variables.
rem *
set BaseLib1=c:\SimoSAM1\DEVL
set BaseLib8=c:\SimoSAM8
set SAM1ANIM=C:\SIMOSAM1\DEVL\SAM1SOL1\SAMBATG1\bin\x86\Debug
set BASEAPP=%BaseLib1%
set BASESYS=%BaseLib1%\SYS1
set BASECAT=%BaseLib1%\DATA
set SYSLOG=%BASESYS%\LOGS\SYSLOG_USER.DAT
set SYSOUT=%BASEAPP%\LOGS\SYSOUT_SIMSAM01.TXT
set SLZMSG=%BASEAPP%\LOGS\SLZMSG_USER.TXT
set PostNOTE=%BASEAPP%\LOGS\SYSOUT_SIMONOTE.TXT
set SimoNOTE=%BASEAPP%\LOGS\SYSOUT_SIMONOTE.TXT
set MIFOBASE="C:\Program Files (x86)\Micro Focus\Studio Enterprise Edition 6.0\Base"
set MIFOBIN=%MIFOBASE%\bin
rem *
set SimoLIBR=c:\SimoLIBR
set JESSERVERNAME=SIMOBATA
rem * set SIMOMODE=PAUSE
rem *
set MAINFRAME_FLOATING_POINT=true
set CobCpy=%BASEAPP%\CobCpy1;%BASEAPP%\CobCpy6;c:\SimoLIBR;%MIFOBASE%\SOURCE
set COBIDY=%BASEAPP%\COBIDY
rem * For large file support and record locking control of File Handler
set EXTFH=%BASESYS%\CONFIG\EXTFHBIG.CFG
rem * For Sort Resource Allocation and Performance
set SORTSPACE=1000000
set ES_ALLOC_OVERRIDE=%BASESYS%\CONFIG\CATMAPA1.cfg
set COBCONFIG_=%BASESYS%\CONFIG\diagnose.cfg
rem * Set environment for MFBSI (Micro Focus Batch Scheduling Interface)
set ES_EMP_EXIT_1=mfbsiemx
set MFBSI_DIR=%BASESYS%\LOGS\%ezServerName%
set MFBSIEOP_CMD=ENABLE
set MFBSIEOP_CSV=ENABLE
set MFBSIEOP_HTM=ENABLE
set MFBSIEOP_XML=ENABLE
rem * Set Behavior and Trace Flags for GETJOBDD
set JDDFLAGS=nnnWnnnn/nnnnnnnn
rem *
if "%SIMOPATH%" == "Y" goto JUMPPATH
set path=%MIFOBASE%;%MIFOBIN%;%PATH%;
set COBPATH=.;%BASEAPP%\LOADLIB;%BASESYS%\LOADLIB;C:\SimoLIBR
set LIBPATH=.;%BASEAPP%\LOADLIB;%BASESYS%\LOADLIB;C:\SimoLIBR
set TXDIR=%BASESYS%\LOADLIB;%MIFOBASE%
:JUMPPATH
set SIMOPATH=Y
set JobStatus=0000
call SimoNOTE "* Settings CmdName Env1BASE.CMD, Version 10.04.19"
call SimoNOTE "* BaseAPP is %BASEAPP%"
The following Windows command file (SimoNOTE.CMD) is used as display a message to the screen and write to a log file. The log file has a date and time stamp and may be used to track the success or failure of the execution of a command file.
@echo OFF rem * ******************************************************************* rem * This program is provided by SimoTime Enterprises * rem * (C) Copyright 1987-2012 All Rights Reserved * rem * Web Site URL: http://www.simotime.com * rem * e-mail: helpdesk@simotime.com * rem * ******************************************************************* rem * rem * Text - Display message on screen and write to a log file. rem * Author - SimoTime Enterprises rem * rem * This script may be called from other scripts and expects a single rem * parameter enclosed in double quotes. The double quotes will be rem * removed. Before writing to the log file a date and time stamp rem * will be inserted in front of the message text. rem * rem * Note: The tilde (~) removes leading/trailing double-quotes. rem * if "%SimoNOTE%" == "" set SimoNOTE=c:\SimoLIBR\LOGS\SimoTime.LOG echo %date% %time% %~1>> %SimoNOTE% echo %~1
The following is the JCL member (NUMPRTJ1.JCL) required to run the sample COBOL program in a mainframe-oriented environment. This is a two step job. The first step (identified by the //NUMPRTS1 statement) will delete the file that was created from a previous run of this job. The second step (identified by the //NUMPRTS2 statement) will execute the sample program.
The JOB and DD statements may need to be modified for different mainframe-oriented environments. The job may be executed on an IBM Mainframe System with ZOS or a Linux, UNIX or Windows System with Micro Focus Enterprise Server or Studio.
//NUMPRTJ1 JOB SIMOTIME,CLASS=1,MSGCLASS=0,NOTIFY=CSIP1 //* ******************************************************************* //* This JCL Member is provided by SimoTime Enterprises * //* (C) Copyright 1987-2012 All Rights Reserved * //* Web Site URL: http://www.simotime.com * //* e-mail: helpdesk@simotime.com * //* ******************************************************************* //* //* Text - Build print lines of text from packed and binary data. //* Author - SimoTime Enterprises //* Date - January 24, 1996 //* //* The job will show how to convert PACKED and BINARY fields to //* printable text fields. //* //* This set of programs will run on a mainframe under MVS or on a //* Personal Computer with Windows and Micro Focus Mainframe Express. //* or ES/MTO with the Batch Facility. //* //* ************ //* * NUMPRTJ1 * //* ********jcl* //* * //* ************ //* * IEFBR14 * //* ********utl* //* * //* ************ ************ ************ //* * ITEMMAST *-----* NUMPRTC1 *-----* ITMPRINT * //* ********dat* ********cbl* ********dat* //* * //* * //* ************ //* * EOJ * //* ************ //* //* ******************************************************************* //* Step 1 of 2, Delete any previously created file... //* //NUMPRTS1 EXEC PGM=IEFBR14 //DD1 DD DSN=SIMOTIME.DATA.ITMPRINT,DISP=(MOD,DELETE,DELETE), // STORCLAS=MFI, // SPACE=(TRK,5), // DCB=(RECFM=FB,LRECL=133,DSORG=PS) //* //* ******************************************************************* //* Step 2 of 2, Read item master and write to price list file. //* //NUMPRTS2 EXEC PGM=NUMPRTC1 //STEPLIB DD DSN=SIMOTIME.DEMO.LOADLIB1,DISP=SHR //ITEMMAST DD DSN=SIMOTIME.DATA.ITEMMAST,DISP=SHR //ITMPRINT DD DSN=SIMOTIME.REPORT.ITMPRINT, // DISP=(NEW,CATLG,DELETE), // STORCLAS=MFI, // SPACE=(TRK,5), // DCB=(RECFM=FB,LRECL=133,DSORG=PS) //SYSOUT DD SYSOUT=* //
The following is the source code (NUMPRTC1.CBL) for the sample COBOL program.
IDENTIFICATION DIVISION.
PROGRAM-ID. NUMPRTC1.
AUTHOR. SIMOTIME ENTERPRISES.
*****************************************************************
* Copyright (C) 1987-2012 SimoTime Enterprises. *
* *
* 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 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 expressed or implied warranty, *
* including the implied warranties of merchantability, fitness *
* for a particular purpose and non-infringement. SimoTime *
* Enterprises shall not be liable for any direct, indirect, *
* special or consequential damages resulting from the loss of *
* use, data or projects, whether in an action of contract or *
* tort, arising out of or in connection with the use or *
* performance of this software *
* *
* 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: NUMPRTC1.CBL
*****************************************************************
*
* NUMPRTC1 - Print text and various numeric field formats.
*
* DESCRIPTION
* -----------
* This set of programs is used to show the various numeric
* formats and how to edit for printing.
*
* This program illustrates the use of some of the commonly
* used numeric formats such as the display format(actual digits),
* the packed format (COMP-3) and the binary (COMP) formats.
*
* The COBOL programs are compiled with the ASSIGN(EXTERNAL)
* directive. This provides for external file mapping of file
* names.
*
* When running with Net Express the IBMCOMP an NOTRUNC directives
* will be required to maintain compatability with the mainframe
* format and field sizes for binary fields. The filetype(11) and
* ADV directive will be required to maintain the mainframe print
* format for the output file.
*
* This technique provides for the use of a single COBOL source
* program that will run on OS/390, Windows or Unix.
*
* This program will run on a Personal Computer with Windows
* and Micro Focus Net Express or Mainframe Express.
*
* This program will also run on an IBM Mainframe.
*
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT ITEMMAST-FILE ASSIGN TO ITEMMAST
ORGANIZATION IS INDEXED
ACCESS MODE IS SEQUENTIAL
RECORD KEY IS ITEM-NUMBER
FILE STATUS IS ITEMMAST-STATUS.
SELECT ITMPRINT-FILE ASSIGN TO ITMPRINT
ORGANIZATION IS SEQUENTIAL
ACCESS MODE IS SEQUENTIAL
FILE STATUS IS ITMPRINT-STATUS.
*****************************************************************
DATA DIVISION.
FILE SECTION.
FD ITEMMAST-FILE
DATA RECORD IS ITEMMAST-REC.
COPY ITEMCB01.
FD ITMPRINT-FILE
DATA RECORD IS ITMPRINT-REC
.
01 ITMPRINT-REC.
05 ITMPRINT-DATA-01 PIC X(00132).
*****************************************************************
* This program was created using the SYSMASK1.TXT file as input.*
* The SYSMASK1 provides for the sequential reading of the input *
* file and the sequential writing of the output file. *
* *
* If the output file is indexed then the input file must be in *
* sequence by the field that will be used to provide the key *
* for the output file. *
* *
* If the key field is not in sequence then refer to SYSMASK2 *
* to provide for a random add or update of the indexed file. *
* *
* This program mask will have the ASCII/EBCDIC table inserted *
* for use by the /TRANSLATE function of SimoZAPS. *
* *
* For additional information contact SimoTime Enterprises. *
* *
* Our e-mail address is: helpdesk@simotime.com *
* Also, visit our Web Site at http://www.simotime.com *
*****************************************************************
WORKING-STORAGE SECTION.
01 SIM-TITLE.
05 T1 pic X(11) value '* NUMPRTC1 '.
05 T2 pic X(34) value 'Sample Printing of Item File '.
05 T3 pic X(10) value 'v08.02.26 '.
05 T4 pic X(24) value ' http://www.simotime.com'.
01 SIM-COPYRIGHT.
05 C1 pic X(11) value '* NUMPRTC1 '.
05 C2 pic X(20) value 'Copyright 1987-2012 '.
05 C3 pic X(28) value '--- SimoTime Enterprises ---'.
05 C4 pic X(20) value ' All Rights Reserved'.
01 ITEMMAST-STATUS.
05 ITEMMAST-STATUS-L pic X.
05 ITEMMAST-STATUS-R pic X.
01 ITEMMAST-EOF pic X value 'N'.
01 ITEMMAST-OPEN-FLAG pic X value 'C'.
01 ITMPRINT-STATUS.
05 ITMPRINT-STATUS-L pic X.
05 ITMPRINT-STATUS-R pic X.
01 ITMPRINT-EOF pic X value 'N'.
01 ITMPRINT-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.
*****************************************************************
* Message Buffer used by the Z-DISPLAY-MESSAGE-TEXT routine. *
*****************************************************************
01 MESSAGE-BUFFER.
05 MESSAGE-HEADER pic X(11) value '* NUMPRTC1 '.
05 MESSAGE-TEXT.
10 MESSAGE-TEXT-1 pic X(68) value SPACES.
10 MESSAGE-TEXT-2 pic X(188) value SPACES.
*****************************************************************
01 PROGRAM-NAME pic X(8) value 'NUMPRTC1'.
01 APPL-RESULT pic S9(9) comp.
88 APPL-AOK value 0.
88 APPL-EOF value 16.
01 LINE-COUNT pic 9(5) value 66.
01 PRINT-HDR-1-LINE.
05 FILLER pic X(57) value SPACES.
05 FILLER pic X(17) value 'Item Master File'.
01 PRINT-HDR-2-LINE.
05 FILLER pic X(60) value SPACES.
05 FILLER pic X(10) value 'Price List'.
01 PRINT-HDR-3-LINE.
05 FILLER pic X(12) value ' Number'.
05 FILLER PIC X value SPACE.
05 FILLER pic X(11) value 'Description'.
05 FILLER PIC X(45) value SPACES.
05 FILLER pic X(11) value 'Price'.
05 FILLER PIC X value SPACE.
05 FILLER pic X(11) value 'Available'.
01 PRINT-DTL-1-LINE.
05 P-ITEM-NUMBER PIC X(12).
05 FILLER PIC X value SPACE.
05 P-ITEM-DESCRIPTION PIC X(48).
05 FILLER PIC X value SPACE.
05 P-ITEM-PRICE PIC Z,ZZZ,ZZZ.99-.
05 FILLER PIC X(6) value SPACE.
05 P-QTY-AVAILABLE PIC Z,ZZZ,ZZ9+.
01 ITEMMAST-TOTAL.
05 ITEMMAST-RDR pic 9(9) value 0.
05 filler pic X(3) value ' - '.
05 filler pic X(23) value 'Line count for ITEMMAST'.
01 ITMPRINT-TOTAL.
05 ITMPRINT-ADD pic 9(9) value 0.
05 filler pic X(3) value ' - '.
05 filler pic X(23) value 'Line count for ITMPRINT'.
*****************************************************************
PROCEDURE DIVISION.
perform Z-POST-COPYRIGHT
perform ITEMMAST-OPEN
perform ITMPRINT-OPEN
perform until ITEMMAST-STATUS not = '00'
perform ITEMMAST-READ
if ITEMMAST-STATUS = '00'
if LINE-COUNT > 60
move SPACES to ITMPRINT-REC
move PRINT-HDR-1-LINE to ITMPRINT-REC
perform ITMPRINT-WRITE-HDR-1
move PRINT-HDR-2-LINE to ITMPRINT-REC
perform ITMPRINT-WRITE
move PRINT-HDR-3-LINE to ITMPRINT-REC
perform ITMPRINT-WRITE
add 3 to ZERO giving LINE-COUNT
end-if
add 1 to ITEMMAST-RDR
perform BUILD-PRINT-LINE
perform ITMPRINT-WRITE
if ITMPRINT-STATUS = '00'
add 1 to ITMPRINT-ADD
add 1 to LINE-COUNT
end-if
end-if
end-perform
move ITEMMAST-TOTAL to MESSAGE-TEXT
perform Z-DISPLAY-MESSAGE-TEXT
move ITMPRINT-TOTAL to MESSAGE-TEXT
perform Z-DISPLAY-MESSAGE-TEXT
if APPL-EOF
move 'is Complete...' to MESSAGE-TEXT
else
move 'is ABENDING...' to MESSAGE-TEXT
end-if
perform Z-DISPLAY-MESSAGE-TEXT
perform ITMPRINT-CLOSE
perform ITEMMAST-CLOSE
GOBACK.
*****************************************************************
BUILD-PRINT-LINE.
*> TransCOPY...
move ITEM-NUMBER to P-ITEM-NUMBER
inspect P-ITEM-NUMBER replacing leading ZEROES by SPACE
move ITEM-DESCRIPTION to P-ITEM-DESCRIPTION
move ITEM-PRICE to P-ITEM-PRICE
subtract ITEM-QTY-ALLOCATED from ITEM-QTY-ONHAND
giving P-QTY-AVAILABLE
move SPACES to ITMPRINT-REC
move PRINT-DTL-1-LINE to ITMPRINT-REC
exit.
*****************************************************************
* I/O Routines for the INPUT File... *
*****************************************************************
ITEMMAST-CLOSE.
add 8 to ZERO giving APPL-RESULT.
close ITEMMAST-FILE
if ITEMMAST-STATUS = '00'
subtract APPL-RESULT from APPL-RESULT
else
add 12 to ZERO giving APPL-RESULT
end-if
if APPL-AOK
CONTINUE
else
move 'CLOSE Failure with ITEMMAST' to MESSAGE-TEXT
perform Z-DISPLAY-MESSAGE-TEXT
move ITEMMAST-STATUS to IO-STATUS
perform Z-DISPLAY-IO-STATUS
perform Z-ABEND-PROGRAM
end-if
exit.
*---------------------------------------------------------------*
ITEMMAST-READ.
read ITEMMAST-FILE
if ITEMMAST-STATUS = '00'
subtract APPL-RESULT from APPL-RESULT
else
if ITEMMAST-STATUS = '10'
add 16 to ZERO giving APPL-RESULT
else
add 12 to ZERO giving APPL-RESULT
end-if
end-if
if APPL-AOK
CONTINUE
else
if APPL-EOF
move 'Y' to ITEMMAST-EOF
else
move 'READ Failure with ITEMMAST' to MESSAGE-TEXT
perform Z-DISPLAY-MESSAGE-TEXT
move ITEMMAST-STATUS to IO-STATUS
perform Z-DISPLAY-IO-STATUS
perform Z-ABEND-PROGRAM
end-if
end-if
exit.
*---------------------------------------------------------------*
ITEMMAST-OPEN.
add 8 to ZERO giving APPL-RESULT.
open input ITEMMAST-FILE
if ITEMMAST-STATUS = '00'
subtract APPL-RESULT from APPL-RESULT
move 'O' to ITEMMAST-OPEN-FLAG
else
add 12 to ZERO giving APPL-RESULT
end-if
if APPL-AOK
CONTINUE
else
move 'OPEN Failure with ITEMMAST' to MESSAGE-TEXT
perform Z-DISPLAY-MESSAGE-TEXT
move ITEMMAST-STATUS to IO-STATUS
perform Z-DISPLAY-IO-STATUS
perform Z-ABEND-PROGRAM
end-if
exit.
*****************************************************************
* I/O Routines for the OUTPUT File... *
*****************************************************************
ITMPRINT-WRITE.
if ITMPRINT-OPEN-FLAG = 'C'
perform ITMPRINT-OPEN
end-if
write ITMPRINT-REC after advancing 1
if ITMPRINT-STATUS = '00'
subtract APPL-RESULT from APPL-RESULT
else
if ITMPRINT-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 ITMPRINT' to MESSAGE-TEXT
perform Z-DISPLAY-MESSAGE-TEXT
move ITMPRINT-STATUS to IO-STATUS
perform Z-DISPLAY-IO-STATUS
perform Z-ABEND-PROGRAM
end-if
exit.
ITMPRINT-WRITE-HDR-1.
if ITMPRINT-OPEN-FLAG = 'C'
perform ITMPRINT-OPEN
end-if
write ITMPRINT-REC after advancing page
if ITMPRINT-STATUS = '00'
subtract APPL-RESULT from APPL-RESULT
else
if ITMPRINT-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 ITMPRINT' to MESSAGE-TEXT
perform Z-DISPLAY-MESSAGE-TEXT
move ITMPRINT-STATUS to IO-STATUS
perform Z-DISPLAY-IO-STATUS
perform Z-ABEND-PROGRAM
end-if
exit.
*---------------------------------------------------------------*
ITMPRINT-OPEN.
add 8 to ZERO giving APPL-RESULT.
open OUTPUT ITMPRINT-FILE
if ITMPRINT-STATUS = '00'
subtract APPL-RESULT from APPL-RESULT
move 'O' to ITMPRINT-OPEN-FLAG
else
add 12 to ZERO giving APPL-RESULT
end-if
if APPL-AOK
CONTINUE
else
move 'OPEN Failure with ITMPRINT' to MESSAGE-TEXT
perform Z-DISPLAY-MESSAGE-TEXT
move ITMPRINT-STATUS to IO-STATUS
perform Z-DISPLAY-IO-STATUS
perform Z-ABEND-PROGRAM
end-if
exit.
*---------------------------------------------------------------*
ITMPRINT-CLOSE.
add 8 to ZERO giving APPL-RESULT.
close ITMPRINT-FILE
if ITMPRINT-STATUS = '00'
subtract APPL-RESULT from APPL-RESULT
move 'C' to ITMPRINT-OPEN-FLAG
else
add 12 to ZERO giving APPL-RESULT
end-if
if APPL-AOK
CONTINUE
else
move 'CLOSE Failure with ITMPRINT' to MESSAGE-TEXT
perform Z-DISPLAY-MESSAGE-TEXT
move ITMPRINT-STATUS to IO-STATUS
perform Z-DISPLAY-IO-STATUS
perform Z-ABEND-PROGRAM
end-if
exit.
*****************************************************************
* The following Z-ROUTINES provide administrative functions *
* for this program. *
*****************************************************************
* ABEND the program, post a message to the console and issue *
* a STOP RUN. *
*****************************************************************
Z-ABEND-PROGRAM.
if MESSAGE-TEXT not = SPACES
perform Z-DISPLAY-MESSAGE-TEXT
end-if
move 'PROGRAM-IS-ABENDING...' to MESSAGE-TEXT
perform Z-DISPLAY-MESSAGE-TEXT
add 12 to ZERO giving RETURN-CODE
STOP RUN.
* exit.
*****************************************************************
* Display CONSOLE messages... *
*****************************************************************
Z-DISPLAY-MESSAGE-TEXT.
if MESSAGE-TEXT-2 = SPACES
display MESSAGE-BUFFER(1:79)
else
display MESSAGE-BUFFER
end-if
move all SPACES to MESSAGE-TEXT
exit.
*****************************************************************
* Display the file status bytes. This routine will display as *
* four digits. If the full two byte file status is numeric it *
* will display as 00nn. If the 1st byte is a numeric nine (9) *
* the second byte will be treated as a binary number and will *
* display as 9nnn. *
*****************************************************************
Z-DISPLAY-IO-STATUS.
if IO-STATUS not NUMERIC
or IO-STAT1 = '9'
move IO-STAT1 to IO-STATUS-04(1:1)
subtract TWO-BYTES-BINARY from TWO-BYTES-BINARY
move IO-STAT2 to TWO-BYTES-RIGHT
add TWO-BYTES-BINARY to ZERO giving IO-STATUS-0403
move 'File Status is: nnnn' to MESSAGE-TEXT
move IO-STATUS-04 to MESSAGE-TEXT(17:4)
perform Z-DISPLAY-MESSAGE-TEXT
else
move '0000' to IO-STATUS-04
move IO-STATUS to IO-STATUS-04(3:2)
move 'File Status is: nnnn' to MESSAGE-TEXT
move IO-STATUS-04 to MESSAGE-TEXT(17:4)
perform Z-DISPLAY-MESSAGE-TEXT
end-if
exit.
*****************************************************************
Z-POST-COPYRIGHT.
display SIM-TITLE
display SIM-COPYRIGHT
exit.
*****************************************************************
* This program was generated by SimoZAPS *
* A product of SimoTime Enterprises *
* Our e-mail address is: helpdesk@simotime.com *
* Also, visit our Web Site at http://www.simotime.com *
* *
* Generation Date: 2006-03-30 Generation Time: 13:39:08:07 *
*****************************************************************
The following is the COBOL Copy File (ITEMCB01.CPY) that is used to define the record structure for the Item Master file.
*****************************************************************
* ITEMCB01.CPY - a COBOL Copy File *
* An Item Master File used by the Demo programs. *
* This is a VSAM Keyed-Sequential-Data-Set or Key-Indexed File. *
* Copyright (C) 1987-2012 SimoTime Enterprises *
* All Rights Reserved *
* Provided by SimoTime Enterprises *
* Our e-mail address is: helpdesk@simotime.com *
* Also, visit our Web Site at http://www.simotime.com *
*****************************************************************
*
01 ITEM-RECORD.
05 ITEM-NUMBER PIC X(12).
05 ITEM-DATA.
10 ITEM-DESCRIPTION PIC X(48).
10 ITEM-QTY-ONHAND PIC 9(7) COMP.
10 ITEM-QTY-ALLOCATED PIC 9(7) COMP.
10 ITEM-UNIT-OF-MEASURE PIC X(16).
10 ITEM-COST PIC S9(7)V9(2) COMP-3.
10 ITEM-PRICE PIC S9(7)V9(2) COMP-3.
10 ITEM-LADATE PIC X(8).
10 ITEM-LATIME PIC X(8).
10 ITEM-TOKEN PIC X(3).
10 ITEM-DISCOUNT OCCURS 3 TIMES.
15 ITEM-D-CODE PIC X.
15 ITEM-D-PERCENT PIC S9(3)V9(4).
10 FILLER PIC X(375).
*
*** ITEMCB01 - End-of-Copy File - - - - - - - - - - - ITEMCB01 *
*****************************************************************
*
The purpose of this document is to assist as a tutorial for new programmers or as a quick reference for experienced programmers. In the world of programming there are many ways to solve a problem. This document and the links to other documents are intended to provide a choice of alternatives.
Permission to use, copy, modify and distribute this software, documentation or training material for any purpose requires a fee to be paid to SimoTime Enterprises. Once the fee is received by SimoTime the latest version of the software, documentation or training material will be delivered and a license will be granted for use within an enterprise, provided the SimoTime copyright notice appear on all copies of the software. The SimoTime name or Logo may not be used in any advertising or publicity pertaining to the use of the software without the written permission of SimoTime Enterprises.
SimoTime Enterprises makes no warranty or representations about the suitability of the software, documentation or learning material for any purpose. It is provided "AS IS" without any expressed or implied warranty, including the implied warranties of merchantability, fitness for a particular purpose and non-infringement. SimoTime Enterprises shall not be liable for any direct, indirect, special or consequential damages resulting from the loss of use, data or projects, whether in an action of contract or tort, arising out of or in connection with the use or performance of this software, documentation or training material.
This section includes links to documents with additional information that is beyond the scope and purpose of this document. The first sub-section requires an internet connection, the second sub-section references locally available documents.
Note: A SimoTime License is required for the items to be made available on a local server.
The following links will require an internet connect.
A good place to start is The SimoTime Home Page for access to white papers, program examples and product information.
This suite of programs and documentation is available for download. Link to an Evaluation zPAK Option that includes the program members, documentation and control files.
Explore The Numbers Connection in the SimoTime Library for more examples of programs and documentation that describe and demonstrate techniques for understanding and processing the various numeric field formats used in a mainframe environment.
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 to interpret the results of accessing VSAM data sets and QSAM files.
Explore The Micro Focus Web Site for more information about products and services available from Micro Focus.
The following links may be accessible without an internet connection.
| Numeric Type | Description |
| Zoned Decimal | This document describes the zoned-decimal format. This is coded in COBOL as USAGE IS DISPLAY and is the default format if the USAGE clause is missing. Note: This is the slowest performer and uses the most storage space but is easiest to display on a screen or print to a printer. This encoding scheme may be unsigned (implied positive) or signed. This type of field will require special handling for the sign position when migrating from a mainframe (EBCDIC) to a Micro Focus (ASCII) environment. |
| Packed Decimal | This document describes the packed-decimal format. This is coded in COBOL as USAGE IS COMPUTATIONAL-3 and is usually coded in its abbreviated form of COMP-3. Note: The mainframe can perform arithmetic functions with this data format at the hardware (or micro-code) level. This type of encoding scheme was primarily used to save storage space. This encoding scheme may be unsigned (implied positive) or signed. When migrating from a mainframe (EBCDIC) to a Micro Focus (ASCII) environment this type of field should be left in its original format since this will be supported in the new environment. |
| Binary | This document describes the binary format. This is coded in COBOL as USAGE IS COMPUTATIONAL and is usually coded in its abbreviated form of COMP. This may also be coded with the keyword BINARY. Note: This format will save storage space but was primarily used for performance. Register arithmetic uses this format. This encoding scheme may be unsigned (implied positive) or signed. When migrating from a mainframe (EBCDIC) to a Micro Focus (ASCII) environment this type of field should be left in its original format since this will be supported in the new environment. |
| Edited Numeric | This document describes the edited numeric format. This is coded in COBOL using an edit mask in the picture clause. An example would be PIC ZZZ.99+. Note: This type of field is used for numbers that are to be displayed or printed and should be all text characters. This filed should be converted using standard conversion tables. |
| Floating Point | This format is used when a high level of precision is required or very large numbers are required. On the mainframe the default is to use the IBM 370 Floating Point Arithmetic. On Windows or UNIX using Micro Focus the default is to use the IEEE Standard for Floating Point Arithmetic. The IEEE standard provides a higher level of precision than 370. However, 370 provides for larger numbers by providing less precision. |
| numbug01 | The challenge with this program is that it is expected to process the various numeric items in the same manner as the mainframe. For example, a zoned-decimal field that contains leading spaces should not cause an ABEND (i.e. 163 error on Micro Focus) but should treat the leading spaces as zeroes and complete the arithmetic calculation. However, a packed-decimal field that contains non-numeric values would issue a S0C7 (referred to as a sock-seven) on the mainframe and should issue a 163 error in the Micro Focus environment. |
| numprt01 | Printing numeric fields, especially packed-decimal or binary (i.e. COMP-3 or COMP) requires special consideration. Also, signed, zoned-decimal fields will require special consideration. Most numeric fields will require some sort of editing before printing. This suite of programs provides examples of how a COBOL program may be used to properly print (or display) numeric fields. |
Explore The File Status Return Codes to interpret the results of accessing VSAM data sets and QSAM files.
Check out The SimoTime Glossary for a list of terms and definitions used in the documents provided by SimoTime.
This document was created and is maintained by SimoTime Enterprises.
If you have any questions, suggestions, comments or feedback please call or send an e-mail to: helpdesk@simotime.com
We appreciate hearing from you.
Founded in 1987, SimoTime Enterprises is a privately owned company. We specialize in the creation and deployment of business applications using new or existing technologies and services. We have a team of individuals that understand the broad range of technologies being used in today's environments. This includes the smallest thin client using the Internet and the very large mainframe systems. There is more to making the Internet work for your company's business than just having a nice looking WEB site. It is about combining the latest technologies and existing technologies with practical business experience. It's about the business of doing business and looking good in the process. Quite often, to reach larger markets or provide a higher level of service to existing customers it requires the newer Internet technologies to work in a complementary manner with existing corporate mainframe systems.
Whether you want to use the Internet to expand into new market segments or as a delivery vehicle for existing business functions simply give us a call or check the web site at http://www.simotime.com
| Return-to-Top |
| Printed Report from Item File with Packed and Binary Fields |
| Copyright © 1987-2012 SimoTime Enterprises All Rights Reserved |
| When technology complements business |
| http://www.simotime.com |