COBOL Numeric Formats
Convert Numeric Formats using COBOL
  Table of Contents  v-24.01.01 - nbrcvt01.htm 
  Introduction
  Programming Objectives
  Programming Requirements
  Programming Overview
  Programming Output
  Review of Numeric Field Formats
  Common Numeric Formats
  EBCDIC and ASCII
  Hexadecimal Dump Format
  Additional Items to Consider
  Test Cases for Numeric Conversion
  100, Packed-Decimal to Text Strings
  101, Simple Packed Field
  102, Packed Field, Decimal Truncation
  103, Packed Field, Decimal Rounding
  104, Packed Field, Explicit Decimal Point
  200, Binary to Text Strings
  201, Simple Binary Field
  202, Binary Field, Decimal Truncation
  203, Binary Field, Decimal Rounding
  204, Binary Field, Explicit Decimal Point
  300, Zoned-Decimal to Text Strings
  301, Simple Zoned-Decimal Field
  302, Zoned Field, Decimal Truncation
  303, Zoned Field, Decimal Rounding
  304, Zoned Field, Explicit Decimal Point
  Job Scripts
  CMD, Convert & Hex Dump
  Convert & Hex Dump, Packed Fields
  Convert & Hex Dump, Binary Fields
  Convert & Hex Dump, Zoned-Decimal
  JCL, Convert & Hex Dump
  Convert & Hex Dump, Packed Fields
  Convert & Hex Dump, Binary Fields
  Convert & Hex Dump, Zoned-Decimal
  Bash Script, Convert & Hex Dump
  Convert & Hex Dump, Packed Fields
  Convert & Hex Dump, Binary Fields
  Convert & Hex Dump, Zoned-Decimal
  COBOL Demonstration Programs
  Convert a Packed Field
  Convert a Binary Field
  Convert a Zoned-Decimal Field
  Summary
  Software Agreement and Disclaimer
  Downloads and Links
  Current Server or Internet Access
  Internet Access Required
  Glossary of Terms
  Contact or Feedback
  Company Overview
The SimoTime Home Page 

Table of Contents Previous Section Next Section Introduction

This suite of test cases describes how to convert between the various numeric formats (or data types such as DISPLAY, COMP, COMP-3 or DECIMAL, BINARY and PACKED) used with COBOL and on an IBM Mainframe System. This example also illustrates how to display the actual hexadecimal (or Hex Dump) content of a numeric field using a callable dump routine.

This suite of test cases includes JCL Members for execution in a Mainframe-oriented environment such as an actual IBM Mainframe running ZOS or a Micro Focus environment such as Mainframe Express or Server Enterprise Edition. A suite of Windows command files is provided to run the jobs on a Windows System using Micro Focus COBOL technology. A suite of Bash Script Files is provided to run the jobs on a Linux or UNIX System with GnuCOBOL (formerly known as Open COBOL) being used to compile and execute the COBOL Programs.

A variety of numeric formats are used on an IBM Mainframe System, a Windows System, a UNIX System or a Linux System. Numeric formats include Binary, Packed Decimal and Zoned Decimal. The COBOL USAGE clause would be COMP, COMP-3 and DISPLAY. The DISPLAY format may be referred to as a character or text format.

In the wonderful world of programming there are many ways to solve a problem. This suite of programs is provided as a COBOL example of one of the possible solutions to the problem of determining the actual format, content and length of a numeric field and converting to a different format.


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

Table of Contents Previous Section Next Section Programming Objectives

This example illustrates the following functions.

1 Describe the commonly used Numeric field formats available in COBOL.
2 Describe the internal structure of the Numeric fields.
3 Show how to dump the actual hexadecimal value of a numeric field.
4 Show how to convert a simple packed numeric field to a display numeric field.
5 Show how to convert a packed numeric field with three (3) decimal positions to a display numeric field with two (2) decimal positions.
6 Provide an example of mainframe JCL to run the job on Windows using Micro Focus Mainframe Express (MFE) .
7 Provide an example of a Window's Command file to run the job on Windows using Micro Focus Net Express.
8 Provide an example of a Bash Script file to run the job on Linux using GnuCOBOL.
9 Maintain a single set of COBOL source code that will run on ZOS, Linux, UNIX or Windows.
10 Show how to convert various numeric fields to an edited text field that may be exported for use in an Excel spreadsheet. Refer to Examples 104, 204 and 304.
  A List of Functions for Managing the Various Numeric Formats

Table of Contents Previous Section Next Section Programming Requirements

This suite of example programs will run on the following platforms.

1 Executes on an IBM Mainframe running MVS or OS/390. The COBOL programs comply with ANSI/85 and run with COBOL/2, COBOL for MVS and COBOL for OS/390.
2 Executes on Windows/NT and Windows/XP using Micro Focus Mainframe Express (MFE).
3 Executes on Windows/NT and Windows/XP using Micro Focus Net Express and the CMD file provided.
4 May be ported to run on the Linux or UNIX platforms supported by Micro Focus COBOL or GnuCOBOL.
  A List of Program Requirements for Managing the Various Numeric Formats

Table of Contents Previous Section Next Section Programming Overview

The following is a flowchart of the job for executing the programs that show the conversion between the various numeric field types.

             
Entry Point
ZOS
Entry Point
Linux
Entry Point
Windows
   
   
   
NBRCVTJ1
jcl
nbrcvts1
sh
NBRCVTE1
cmd
JCL, Bash or CMD with an optional DD, export or SET statement to write to a log file.        
   
   
   
IEFBR14
Utility
rm
Linux CMD
IF Exist
statement
Delete previously created output files
   
   
 
 
   
   
 
 
   
   
NBRCVTC1
cbl
This member is a COBOL Demonstration program that calls the actual Hexadecimal Dump routine.
   
End of Job
End of Job?
   
   
   
   
Yes
No
   
   
   
SIMODUMP
cbl
 
 
SYSOUT
The SIMODUMP member is a COBOL Hexadecimal Dump routine that displays the dump information on the screen. The dump information is only displayed if the SIMODUMP-SYSOUT field contains SHOW or BOTH.
   
   
   
SIMOLOGS
cbl
 
 
SYSLOG
rseq
The SIMOLOGS member is a COBOL Write-to-Log routine that writes the dump information to a log file. This routine is only called if the SIMODUMP-REQUEST field contains FILE or BOTH.
   
   
   
   
EOJ
End-Of-Job
 
Overview of Numeric Conversion Alternatives

Color Associations: The  light-green  boxes are unique to SIMOTIME Technologies using an IBM Mainframe System or Micro Focus Enterprise Developer. The  light-red  boxes are unique to the SIMOTIME Technologies using a Linux, UNIX or Windows System and COBOL Technologies such as Micro Focus. The  light-yellow  boxes are SIMOTIME Technologies, Third-party Technologies, decision points or program transitions in the processing logic or program generations. The  light-blue  boxes identify the input/output data structures such as Documents, Spreadsheets, Data Files, VSAM Data Sets, Partitioned Data Set Members (PDSM's) or Relational Tables. The  light-gray  boxes identify a system function or an informational item.

Table of Contents Previous Section Next Section Programming Output

The following is a sample of the Dump information produced on an IBM Mainframe or Micro Focus Mainframe Express on the PC. This is an EBCDIC encoded environment.

Offset Hex..... ........ ........ ........ ebcdic.......... ascii...........
 1-016 F0F0F1F2 F3xxxxxx xxxxxxxx xxxxxxxx 00123........... ................

The following is a sample of the Dump information produced on a PC with Micro Focus COBOL and Net Express, version 4.0. This is an ASCII encoded environment.

Offset Hex..... ........ ........ ........ ebcdic.......... ascii...........
 1-016 30303132 33xxxxxx xxxxxxxx xxxxxxxx ................ 00123...........

For more information about the Hex-Dump format refer to the Hexadecimal Dump Format section of this document.

Table of Contents Previous Section Next Section Review of Numeric Field Formats

The following sections describe the various numeric field formats with techniques for displaying the contents of the actual value (hexadecimal) as stored in memory.

Table of Contents Previous Section Next Section Common Numeric Formats

The three most common mainframe numeric encoding formats are Zoned-Decimal, Packed-Decimal and Binary. The following shows how the numeric fields would be defined in a COBOL WORKING-STORAGE SECTION.

Numeric Field Type Coding Syntax Normally Coded (Minimum)
Binary
(a second coding alternative)
USAGE IS COMPUTATIONAL
USAGE IS BINARY
COMP
BINARY
Packed Decimal USAGE IS COMPUTATIONAL-3 COMP-3
Zoned Decimal USAGE IS DISPLAY Left blank, this is the default

The following is an example of actual COBOL source code.

      *    The following two lines show the syntax for a binary field
      *    1st line is full syntax,  2nd line is normally coded syntax.
       01  NUMERIC-BINARY-FULL  PIC S9(5)V99 USAGE IS COMPUTATIONAL.
       01  NUMERIC-BINARY-NORM  PIC S9(5)V99 COMP.
      *    The following two lines show the syntax for a packed field
      *    1st line is full syntax,  2nd line is normally coded syntax.
       01  NUMERIC-PACKED-FULL  PIC S9(5)V99 USAGE IS COMPUTATIONAL-3.
       01  NUMERIC-PACKED-NORM  PIC S9(5)V99 COMP-3.
      *    The following two lines show the syntax for a zoned field
      *    1st line is full syntax,  2nd line is normally coded syntax.
       01  NUMERIC-ZONED-FULL   PIC S9(5)V99 USAGE IS DISPLAY.
       01  NUMERIC-ZONED-NORM   PIC S9(5)V99.

Table of Contents Previous Section Next Section EBCDIC and ASCII

The following shows the picture (PIC) clause, how the item is displayed using the DISPLAY verb, the field as it is stored in memory for an EBCDIC environment, the field as it would be stored in memory for an ASCII environment.

,
Picture Clause DISPLAY Memory Content (EBCDIC) Memory Content (ASCII)
PIC 9(5) 00123 F0F0F1F2F3 3030313233
PIC S9(5) plus 00123 F0F0F1F2C3 3303013233
PIC S9(5) minus 00123- F0F0F1F2D3 3030313273
PIC S9(5) COMP-3 plus 00123 00123C 00123C
PIC S9(5) COMP-3 minus 00123- 00123D 00123D
PIC S9(5) COMP plus 00123 0000007B 00007B
PIC S9(5) COMP minus 00123- FFFFFF85 FFFF85

In addition to the ASCII and EBCDIC differences it is important to note the hardware differences. Most COBOL compilers hide this level of processing. However, it occasionally shows up as a problem.

Big Endian - within a multi-byte numeric representation the most significant byte has the lowest address. Processors such as the IBM 370 family, the PDP-10, the Motorola microprocessor family, and most of the various RISC architectures are big-endian.

Little Endian - within a sixteen or thirty-two bit word the bytes at lower addresses have lower significance. Processors such as the PDP-11 and VAX family of computers, the Intel microprocessors, and much of the communications and networking hardware are little-endian.

Table of Contents Previous Section Next Section Hexadecimal Dump Format

The following is an example of the Dump information produced on an IBM Mainframe or Micro Focus Mainframe Express on the PC that works with EBCDIC. The hexadecimal information is (highlighted in green) The possible translated, displayable EBCDIC characters are (highlighted in blue). The possible translated, displayable ASCII characters are (highlighted in red).

If the sample program is executed in the PC, ASCII environment the following would be displayed and written to the SYSOUT file.

*** 2008/05/22 09:23:42:10 * Dump0001 *
*** 2008/05/22 09:23:42:10 * Decode01 ********************************************************************
*** 2008/05/22 09:23:42:10 * Decode01 Starting Convert Packed to Display
*** 2008/05/22 09:23:42:10 * Review01 Starting... Length = 0003
*** 2008/05/22 09:23:42:10 *  Offset Hex..... ........ ........ ........ ebcdic.......... ascii...........
*** 2008/05/22 09:23:42:10 *   1-016 00123Fxx xxxxxxxx xxxxxxxx xxxxxxxx ................ ..?.............
*** 2008/05/22 09:23:42:10 * Review01 Complete... Length = 0003
*** 2008/05/22 09:23:42:10 * Result01 Starting... Length = 0005
*** 2008/05/22 09:23:42:10 *  Offset Hex..... ........ ........ ........ ebcdic.......... ascii...........
*** 2008/05/22 09:23:42:10 *   1-016 30303132 33xxxxxx xxxxxxxx xxxxxxxx ................ 00123...........
*** 2008/05/22 09:23:42:10 * Result01 Complete... Length = 0005
*** 2008/05/22 09:23:42:10 * Decode01 Finished Convert Packed to Display

Table of Contents Previous Section Next Section Additional Items to Consider

Numeric formats quite often require a conversion to another numeric format or data type prior to being printed, displayed or exported to a non-mainframe or non-COBOL environment. The Zoned-Decimal format may be used as the result field of a conversion process, for COBOL this is explicitly coded or defaulted as "USAGE IS DISPLAY".

This approach will work for unsigned numbers with zero decimal positions. If a signed number or an explicit decimal is required then a different data type will be required for the result of a conversion process. For this requirement an edited numeric result field may be used.

The following is a list of frequently asked questions about processing numeric fields and the impact of the various numeric types.

Item Question and Answer
1 A VSAM Keyed-Sequential-Data-Set (KSDS), the JCL and an update program are downloaded from an IBM Mainframe to a Windows platform. The program is then compiled using Micro Focus Mainframe Express and everything works as expected. The program is then ported to Micro Focus Net Express and the file open fails with a file status code of 39. Why does this happen?
The file status code of 39 indicates the actual file attributes do not match the program defined attributes. In this case what is happening is the BINARY (or COMP) fields are being calculated with different length. For example, on the IBM mainframe a PIC 9(7) COMP field will have an actual 4-byte length. On the PC this will default to a 3-byte length, this will result in different record lengths being calculated and a subsequent file status code of 39. For Micro Focus Net Express the COBOL compiler directives IBMCOMP and NOTRUNC must be used in order to access the data set.
2 How are PACKED and BINARY (i.e. COMP-3 or COMP) fields processed during an EBCDIC to ASCII conversion?
The PACKED and BINARY fields are identified during the copy file analysis step. During the generation of the callable COBOL routine a comment statement is inserted into the source code to identify the PACKED or BINARY field. The mainframe numeric encoding is maintained for the PACKED and BINARY fields.
3 Will the differences in the EBCDIC and ASCII collating sequence cause problems?
In an EBCDIC encoding scheme the numbers come after the letters and lower case precedes upper case. In an ASCII encoding scheme the numbers come before the letters and upper case precedes lower case. This is normally an arrangement or list sequencing issue that needs explaining to the business users prior to implementation and is usually accepted as a necessary change.
However, this may cause some problems if certain coding techniques were used. For example the following logic is correct in an EBCDIC environment but will fail in an ASCII environment, "If BYTE-01-CONTENT < SPACE or > 9 then non-printable character". This coding would need to be changed. Also, see the next items in this list for another exposure.
  Frequently Asked Questions

Table of Contents Previous Section Next Section Test Cases for Numeric Conversion

This section provides various test cases for converting different types of numeric fields. The IBM Mainframe and the COBOL programming language support a variety of numeric formats and each has its advantages and disadvantages. Refer to the Downloads and Links to Similar Pages section of this document for links that provide additional detail about numeric formats.

Refer to the Downloads and Links to Similar Pages section of this document for links that provide additional detail about numeric formats.

Table of Contents Previous Section Next Section 100, Packed-Decimal to Text Strings

This group of test cases will show the process for converting a packed-numeric format (COMPUTATIONAL-3 or COMP-3) to a text string or display format. The Source Field is defined as a Packed (or COMP-3) and the result fields are "USAGE IS DISPLAY" or a numeric edited field.

Table of Contents Previous Section Next Section 101, Simple Packed Field

This test case will show the process for converting a packed-numeric format to a display format. The Source Field is defined as a Packed (or COMP-3) field with 5 digits and zero decimal positions. The following is the WORKING-STORAGE definition for the source field.

       01  PACK-DECIMAL-UNSIGN     PIC 9(5)  COMP-3.

The Result Field is defined as a Display field with 5 digits and zero decimal positions. The following is the WORKING-STORAGE definition for the result field.

       01  DISPLAY-UNSIGN          PIC 9(5) VALUE 0.

The following PROCEDURE DIVISION statement shows how to convert from a PACKED to a DISPLAY (or unsigned Zoned-Decimal) numeric value.

            add PACK-DECIMAL-UNSIGN to ZERO giving DISPLAY-UNSIGN

The process of adding the packed field to zero giving a result in a display field is the same as doing an unpack of the packed field into a zoned-decimal (or display) field.

Refer to the COBOL Routine for Example-101 and view the COBOL source code for this numeric field conversion example.

Table of Contents Previous Section Next Section 102, Packed Field, Decimal Truncation

This test case will show the process for converting a packed-numeric format to a display (or zoned-decimal) format. The fewer decimal positions of the result field will cause the numeric value to be truncated. The Result field is also defined with a SIGN TRAILING SEPARATE that creates an additional byte to the field for the sign.

The Source Field is defined as a Packed (or COMP-3) field with 6 digits and 3 decimal positions. The following is the WORKING-STORAGE definition for the source field.

       01  PACK-DECIMAL-SIGN-6-3   PIC S9(6)V999  COMP-3.

The Result Field is defined as a Zoned Decimal (or USAGE IS DISPLAY) field with 7 digits and 2 decimal positions. The following is the WORKING-STORAGE definition for the result field.

       01  DISPLAY-SIGN-7-2        PIC S9(7)V99 SIGN TRAILING SEPARATE

The following PROCEDURE DIVISION statement shows how to convert from a PACKED to a DISPLAY (with SIGN TRAILING SEPARATE) numeric value.

           add PACK-DECIMAL-SIGN-6-3 to ZERO
               giving DISPLAY-SIGN-7-2      

Refer to the COBOL Routine for Example-102 and view the COBOL source code for this numeric field conversion example.

Table of Contents Previous Section Next Section 103, Packed Field, Decimal Rounding

This test case will show the process for converting a packed-numeric format to a display (or zoned-decimal) format. The fewer decimal positions of the result field will be rounded because of the ROUNDED keyword on the ADD statement. The Result field is also defined with a SIGN TRAILING SEPARATE that creates an additional byte to the field for the sign.

The Source Field is defined as a Packed (or COMP-3) field with 6 digits and 3 decimal positions. The following is the WORKING-STORAGE definition for the source field.

       01  PACK-DECIMAL-SIGN-6-3   PIC S9(6)V999  COMP-3.

The Result Field is defined as a Zoned Decimal (or USAGE IS DISPLAY) field with 7 digits and 2 decimal positions. The following is the WORKING-STORAGE definition for the result field.

       01  DISPLAY-SIGN-7-2        PIC S9(7)V99 SIGN TRAILING SEPARATE.

The following PROCEDURE DIVISION statement shows how to convert from a PACKED to a DISPLAY (with SIGN TRAILING SEPARATE) numeric value.

           add PACK-DECIMAL-SIGN-6-3 to ZERO  
               giving DISPLAY-SIGN-7-2 ROUNDED

Refer to the COBOL Routine for Example-103 and view the COBOL source code for this numeric field conversion example.

Table of Contents Previous Section Next Section 104, Packed Field, Explicit Decimal Point

This test case will show the process for converting a packed-numeric format to an edited numeric format. The fewer decimal positions of the result field will be rounded because of the ROUNDED keyword on the ADD statement. The mask for the Result field will cause an explicit decimal point to be inserted.

The Source Field is defined as a Packed (or COMP-3) field with 6 digits and 3 decimal positions. The following is the WORKING-STORAGE definition for the source field.

       01  PACK-DECIMAL-SIGN-6-3   PIC S9(6)V999  COMP-3.

The Result Field is defined as a Zoned Decimal (or USAGE IS DISPLAY) field with 7 digits and 2 decimal positions. The following is the WORKING-STORAGE definition for the result field.

       01  EDIT-FIELD-7-2          pic Z,ZZZ,ZZZ.99+.

The following PROCEDURE DIVISION statement shows how to convert from a PACKED to a EDITED numeric value.

           add PACK-DECIMAL-SIGN-6-3 to ZERO
               giving EDIT-FIELD-7-2 ROUNDED

Refer to the COBOL Routine for Example-104 and view the COBOL source code for this numeric field conversion example.

Table of Contents Previous Section Next Section 200, Binary to Text Strings

This group of test cases will show the process for converting a BINARY numeric format (COMPUTATIONAL or COMP) to a display format. The Source Field is defined as a BINARY (or COMP) and the result fields are "USAGE IS DISPLAY" or a numeric edited field.

Table of Contents Previous Section Next Section 201, Simple Binary Field

This test case will show the process for converting a binary numeric format to a display (or zoned-decimal) format. The Source Field is defined as a Binary (or COMP) field with 5 digits and zero decimal positions. The following is the WORKING-STORAGE definition for the source field.

       01  BINARY-UNSIGN           PIC 9(9)  COMP VALUE 0.

The Result Field is defined as a Zoned Decimal (or USAGE IS DISPLAY) field with 5 digits and zero decimal positions. The following is the WORKING-STORAGE definition for the result field.

       01  DISPLAY-UNSIGN          PIC 9(5) VALUE 0.

The following PROCEDURE DIVISION statement shows how to convert from a BINARY to a DISPLAY (or unsigned Zoned-Decimal) numeric value.

           add BINARY-UNSIGN to ZERO giving DISPLAY-UNSIGN

Refer to the COBOL Routine for Example-201 and view the COBOL source code for this numeric field conversion example.

Table of Contents Previous Section Next Section 202, Binary Field, Decimal Truncation

This test case will show the process for converting a binary numeric format to a display (or zoned-decimal) format. The fewer decimal positions of the result field will cause the numeric value to be truncated. The Result field is also defined with a SIGN TRAILING SEPARATE that creates an additional byte to the field for the sign.

The Source Field is defined as a Binary (or COMP) field with 6 digits and 3 decimal positions. The following is the WORKING-STORAGE definition for the source field.

       01  BINARY-SIGN-6-3         PIC S9(6)V999  COMP VALUE 0.

The Result Field is defined as a Zoned Decimal (or USAGE IS DISPLAY) field with 7 digits and 2 decimal positions. The following is the WORKING-STORAGE definition for the result field.

       01  DISPLAY-SIGN-7-2        PIC S9(7)V99 SIGN TRAILING SEPARATE.

The following PROCEDURE DIVISION statement shows how to convert from a BINARY to a DISPLAY (with SIGN TRAILING SEPARATE) numeric value.

           add BINARY-SIGN-6-3 to ZERO
               giving DISPLAY-SIGN-7-2

Refer to the COBOL Routine for Example-202 and view the COBOL source code for this numeric field conversion example.

Table of Contents Previous Section Next Section 203, Binary Field, Decimal Rounding

This test case will show the process for converting a binary numeric format to a display (or zoned-decimal) format. The fewer decimal positions of the result field will be rounded because of the ROUNDED keyword on the ADD statement. The Result field is also defined with a SIGN TRAILING SEPARATE that creates an additional byte to the field for the sign.

The Source Field is defined as a Binary (or COMP) field with 6 digits and 3 decimal positions. The following is the WORKING-STORAGE definition for the source field.

       01  BINARY-SIGN-6-3         PIC S9(6)V999  COMP VALUE 0.

The Result Field is defined as a Zoned Decimal (or USAGE IS DISPLAY) field with 7 digits and 2 decimal positions. The following is the WORKING-STORAGE definition for the result field.

       01  DISPLAY-SIGN-7-2        PIC S9(7)V99 SIGN TRAILING SEPARATE.

The following PROCEDURE DIVISION statement shows how to convert from a BINARY to a DISPLAY (with SIGN TRAILING SEPARATE) numeric value.

           add BINARY-SIGN-6-3 to ZERO        
               giving DISPLAY-SIGN-7-2 ROUNDED

Refer to the COBOL Routine for Example-203 and view the COBOL source code for this numeric field conversion example.

Table of Contents Previous Section Next Section 204, Binary Field, Explicit Decimal Point

This test case will show the process for converting a binary numeric format to an edited numeric format. The fewer decimal positions of the result field will be rounded because of the ROUNDED keyword on the ADD statement. The mask for the Result field will cause an explicit decimal point to be inserted.

The Source Field is defined as a Binary (or COMP) field with 6 digits and 3 decimal positions. The following is the WORKING-STORAGE definition for the source field.

       01  BINARY-SIGN-6-3         PIC S9(6)V999  COMP VALUE 0.

The Result Field is defined as a Zoned Decimal (or USAGE IS DISPLAY) field with 7 digits and 2 decimal positions. The following is the WORKING-STORAGE definition for the result field.

       01  EDIT-FIELD-7-2          pic Z,ZZZ,ZZZ.99+.

The following PROCEDURE DIVISION statement shows how to convert from a BINARY to a DISPLAY (with SIGN TRAILING SEPARATE) numeric value.

           add BINARY-SIGN-6-3 to ZERO        
               giving DISPLAY-SIGN-7-2 ROUNDED

Refer to the COBOL Routine for Example-204 and view the COBOL source code for this numeric field conversion example.

Table of Contents Previous Section Next Section 300, Zoned-Decimal to Text Strings

This group of test cases will show the process for converting a zoned-decimal-numeric format (USAGE IS DISPLAY) to a display format. The Source Field is defined as a Zoned-Decimal (or USAGE IS DISPLAY) and the result fields are "USAGE IS DISPLAY" or a numeric edited field.

Table of Contents Previous Section Next Section 301, Simple Zoned-Decimal Field

This test case will show the process for converting a zoned-decimal-numeric format to a display (or zoned-decimal) format. The Source Field is defined as a Zoned-Decimal (or USAGE IS DISPLAY) field with 5 digits and zero decimal positions. The following is the WORKING-STORAGE definition for the source field.

       01  ZONED-DECIMAL-UNSIGN     PIC 9(5)  VALUE 0.

The Result Field is defined as a Zoned Decimal (or USAGE IS DISPLAY) field with 5 digits and zero decimal positions. The following is the WORKING-STORAGE definition for the result field.

       01  DISPLAY-UNSIGN          PIC 9(5) VALUE 0.

The following PROCEDURE DIVISION statement shows how to convert from a ZONED-DECIMAL to a DISPLAY (or unsigned Zoned-Decimal) numeric value. Since this example uses an unsigned number the conversion is the same as a simple move. The source field content is already in a display format.

           add ZONED-DECIMAL-UNSIGN to ZERO giving DISPLAY-UNSIGN

Refer to the COBOL Routine for Example-301 and view the COBOL source code for this numeric field conversion example.

Table of Contents Previous Section Next Section 302, Zoned Field, Decimal Truncation

This test case will show the process for converting a zoned-decimal-numeric format to a display format. The fewer decimal positions of the result field will cause the numeric value to be truncated. The Result field is also defined with a SIGN TRAILING SEPARATE that creates an additional byte to the field for the sign.

The Source Field is defined as a Zoned Decimal field with 6 digits and 3 decimal positions. The following is the WORKING-STORAGE definition for the source field.

       01  ZONED-DECIMAL-SIGN-6-3   PIC S9(6)V999  VALUE 0.

The Result Field is defined as a Display field with 7 digits and 2 decimal positions. The following is the WORKING-STORAGE definition for the result field.

       01  DISPLAY-SIGN-7-2        PIC S9(7)V99 SIGN TRAILING SEPARATE.

The following PROCEDURE DIVISION statement shows how to convert from a ZONED-DECIMAL to a DISPLAY (with SIGN TRAILING SEPARATE) numeric value'

           add ZONED-DECIMAL-SIGN-6-3 to ZERO
               giving DISPLAY-SIGN-7-2       

Refer to the COBOL Routine for Example-302 and view the COBOL source code for this numeric field conversion example.

Table of Contents Previous Section Next Section 303, Zoned Field, Decimal Rounding

This test case will show the process for converting a zoned-decimal-numeric format to a display format. The fewer decimal positions of the result field will be rounded because of the ROUNDED keyword on the ADD statement. The Result field is also defined with a SIGN TRAILING SEPARATE that creates an additional byte to the field for the sign.

The Source Field is defined as a Zoned Decimal field with 6 digits and 3 decimal positions. The following is the WORKING-STORAGE definition for the source field.

       01  ZONED-DECIMAL-SIGN-6-3   pic S9(6)V999  VALUE 0.

The Result Field is defined as a Display field with 7 digits and 2 decimal positions. The following is the WORKING-STORAGE definition for the result field.

       01  DISPLAY-SIGN-7-2        PIC S9(7)V99 SIGN TRAILING SEPARATE.

The following PROCEDURE DIVISION statement shows how to convert from a ZONED-DECIMAL to a DISPLAY (with SIGN TRAILING SEPARATE) numeric value.

           add ZONED-DECIMAL-SIGN-6-3 to ZERO 
               giving DISPLAY-SIGN-7-2 ROUNDED

Refer to the COBOL Routine for Example-303 and view the COBOL source code for this numeric field conversion example.

Table of Contents Previous Section Next Section 304, Zoned Field, Explicit Decimal Point

This test case will show the process for converting a zoned-decimal-numeric format to an edited numeric format. The fewer decimal positions of the result field will be rounded because of the ROUNDED keyword on the ADD statement. The mask for the Result field will cause an explicit decimal point to be inserted.

The Source Field is defined as a Zoned Decimal field with 6 digits and 3 decimal positions. The following is the WORKING-STORAGE definition for the source field.

       01  ZONED-DECIMAL-SIGN-6-3   pic S9(6)V999  VALUE 0.

The Result Field is defined as a Display field with 7 digits and 2 decimal positions. The following is the WORKING-STORAGE definition for the result field.

       01  EDIT-FIELD-7-2          pic Z,ZZZ,ZZZ.99+.

The following PROCEDURE DIVISION statement shows how to convert from a ZONED-DECIMAL to an EDITED numeric value.

           add ZONED-DECIMAL-SIGN-6-3 to ZERO 
               giving EDIT-FIELD-7-2 ROUNDED 

Refer to the COBOL Routine for Example-304 and view the COBOL source code for this numeric field conversion example.

Table of Contents Previous Section Next Section Job Scripts

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

Table of Contents Previous Section Next Section CMD, Convert & Hex Dump

This section describes the three (3) Windows Command Files that will be used to set the environment and execute the COBOL programs that perform the sample numeric field conversions.

Table of Contents Previous Section Next Section Convert & Hex Dump, Packed Fields

The following (NBRCVTE1.cmd) is a sample of the Windows CMD needed to run this job in a non-Mainframe environment.

@echo OFF
     set CmdName=NBRCVTE1
rem  * *******************************************************************
rem  *               NBRCVTE1.cmd - a Windows Command File               *
rem  *         This program is provided by SimoTime Technologies         *
rem  *           (C) Copyright 1987-2019 All Rights Reserved             *
rem  *             Web Site URL:   http://www.simotime.com               *
rem  *                   e-mail:   helpdesk@simotime.com                 *
rem  * *******************************************************************
rem  *
rem  * Text    - Packed Numeric Format Conversion using COBOL
rem  * Author  - SimoTime Technologies
rem  * Date    - November 11, 2003
rem  * Version - 03.12.15
rem  *
rem  * This set of programs describes how to convert packed numeric
rem  * field formats used with COBOL and on an IBM Mainframe.
rem  *
rem  * This technique provides for the use of a single COBOL source
rem  * program that may be compiled and executed on an IBM Mainframe
rem  * with ZOS or VSE. The same COBOL source code may be compiled and
rem  * executed on a Windows or UNIX platform with Micro Focus.
rem  *
rem  * The COBOL programs are compiled with the ASSIGN(EXTERNAL)
rem  * directive. This provides for external file mapping of file names.
rem  *
rem  *   ************
rem  *   * NBRCVTE1 *
rem  *   ********cmd*
rem  *        *
rem  *        *
rem  *   ************     ************     ************
rem  *   *   RUN    ******* NBRCVTC1 ******* SIMODUMP *
rem  *   ************     ********gnt*     ********gnt*
rem  *        *                                 *
rem  *        *                            ************     ************
rem  *        *                            * SIMOLOGS ******* CONSOLE  *
rem  *        *                            ********gnt*  *  ************
rem  *        *                                          *
rem  *        *                                          *  ************
rem  *        *                                          ****  SYSLOG  *
rem  *        *                                             *******data*
rem  *        *
rem  *   ************
rem  *   *   EOJ    *
rem  *   ************
rem  *
rem  * *******************************************************************
rem  * Step 1 of 2,  Set the global environment variables...
rem  *
     call ..\ENV1BASE %CmdName%
rem  *
     call SimoNOTE "*******************************************************%CmdName%.CMD"
     call SimoNOTE "Starting JobName %CmdName%.CMD"
rem  *
rem  * *******************************************************************
rem  * Step 2 of 2, Execute the Number Format Analysis Program...
rem  *
     run NBRCVTC1
     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%"
     goto :End
:End
     call SimoNOTE "DataMake SYSOUT is %SYSOUT%"
     call SimoNOTE "DataMake SYSLOG is %SYSLOG%"
     if not "%1" == "nopause" pause

Table of Contents Previous Section Next Section Convert & Hex Dump, Binary Fields

The following (NBRCVTE2.cmd) is a sample of the Windows CMD needed to run this job in a non-Mainframe environment.

@echo OFF
     set CmdName=NBRCVTE2
rem  * *******************************************************************
rem  *               NBRCVTE2.cmd - a Windows Command File               *
rem  *         This program is provided by SimoTime Technologies         *
rem  *           (C) Copyright 1987-2019 All Rights Reserved             *
rem  *             Web Site URL:   http://www.simotime.com               *
rem  *                   e-mail:   helpdesk@simotime.com                 *
rem  * *******************************************************************
rem  *
rem  * Text    - Convert Binary numeric formats using COBOL
rem  * Author  - SimoTime Technologies
rem  * Date    - November 11, 2003
rem  * Version - 03.12.15
rem  *
rem  * This set of programs describes how to convert binary numeric
rem  * field formats used with COBOL and on an IBM Mainframe.
rem  *
rem  * This technique provides for the use of a single COBOL source
rem  * program that may be compiled and executed on an IBM Mainframe
rem  * with ZOS or VSE. The same COBOL source code may be compiled and
rem  * executed on a Windows or UNIX platform with Micro Focus.
rem  *
rem  * The COBOL programs are compiled with the ASSIGN(EXTERNAL)
rem  * directive. This provides for external file mapping of file names.
rem  *
rem  * When running with Net Express the IBMCOMP an NOTRUNC directives
rem  * will be required to maintain compatability with the mainframe
rem  * format and field sizes for binary fields.
rem  *
rem  *   ************
rem  *   * NBRCVTE2 *
rem  *   ********cmd*
rem  *        *
rem  *        *
rem  *   ************     ************     ************
rem  *   *   RUN    ******* NBRCVTC2 ******* SIMODUMP *
rem  *   ************     ********gnt*     ********gnt*
rem  *        *                                 *
rem  *        *                            ************     ************
rem  *        *                            * SIMOLOGS ******* CONSOLE  *
rem  *        *                            ********gnt*  *  ************
rem  *        *                                          *
rem  *        *                                          *  ************
rem  *        *                                          ****  SYSLOG  *
rem  *        *                                             *******data*
rem  *        *
rem  *   ************
rem  *   *   EOJ    *
rem  *   ************
rem  *
rem  * *******************************************************************
rem  * Step 1 of 2, Set the global environment variables...
rem  *
     call ..\ENV1BASE %CmdName%
rem  *
     call SimoNOTE "*******************************************************%CmdName%.CMD"
     call SimoNOTE "Starting JobName %CmdName%.CMD"
rem  *
rem  * *******************************************************************
rem  * Step 2 of 2, Execute the Number Format Conversion Program...
rem  *
     run NBRCVTC2
     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%"
     goto :End
:End
     call SimoNOTE "DataMake SYSOUT is %SYSOUT%"
     call SimoNOTE "DataMake SYSLOG is %SYSLOG%"
     if not "%1" == "nopause" pause

Table of Contents Previous Section Next Section Convert & Hex Dump, Zoned-Decimal

The following (NBRCVTE3.cmd) is a sample of the Windows CMD needed to run this job in a non-Mainframe environment.

@echo OFF
     set CmdName=NBRCVTE3
rem  * *******************************************************************
rem  *               NBRCVTE3.cmd - a Windows Command File               *
rem  *         This program is provided by SimoTime Technologies         *
rem  *           (C) Copyright 1987-2019 All Rights Reserved             *
rem  *             Web Site URL:   http://www.simotime.com               *
rem  *                   e-mail:   helpdesk@simotime.com                 *
rem  * *******************************************************************
rem  *
rem  * Text    - Packed Numeric Format Conversion using COBOL
rem  * Author  - SimoTime Technologies
rem  * Date    - November 11, 2003
rem  * Version - 03.12.15
rem  *
rem  * This set of programs describes how to convert zoned-decimal
rem  * numeric field formats used with COBOL and on an IBM Mainframe.
rem  *
rem  * This technique provides for the use of a single COBOL source
rem  * program that may be compiled and executed on an IBM Mainframe
rem  * with ZOS or VSE. The same COBOL source code may be compiled and
rem  * executed on a Windows or UNIX platform with Micro Focus.
rem  *
rem  * The COBOL programs are compiled with the ASSIGN(EXTERNAL)
rem  * directive. This provides for external file mapping of file names.
rem  *
rem  *   ************
rem  *   * NBRCVTE3 *
rem  *   ********cmd*
rem  *        *
rem  *        *
rem  *   ************     ************     ************
rem  *   *   RUN    ******* NBRCVTC3 ******* SIMODUMP *
rem  *   ************     ********gnt*     ********gnt*
rem  *        *                                 *
rem  *        *                            ************     ************
rem  *        *                            * SIMOLOGS ******* CONSOLE  *
rem  *        *                            ********gnt*  *  ************
rem  *        *                                          *
rem  *        *                                          *  ************
rem  *        *                                          ****  SYSLOG  *
rem  *        *                                             *******data*
rem  *        *
rem  *   ************
rem  *   *   EOJ    *
rem  *   ************
rem  *
rem  * *******************************************************************
rem  * Step 1 of 2, Set the global environment variables...
rem  *
     call ..\ENV1BASE %CmdName%
rem  *
     call SimoNOTE "*******************************************************%CmdName%.CMD"
     call SimoNOTE "Starting JobName %CmdName%.CMD"
rem  *
rem  * *******************************************************************
rem  * Step 1 of 1, Execute the Number Format Analysis Program...
rem  *
     run NBRCVTC3
     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%"
     goto :End
:End
     call SimoNOTE "DataMake SYSOUT is %SYSOUT%"
     call SimoNOTE "DataMake SYSLOG is %SYSLOG%"
     if not "%1" == "nopause" pause

Table of Contents Previous Section Next Section JCL, Convert & Hex Dump

The following is the mainframe JCL required to run the jobs in a ZOS oriented, Mainframe environment.

Table of Contents Previous Section Next Section Convert & Hex Dump, Packed Fields

The following (NBRCVTJ1.jcl) is a sample of the ZOS oriented JCL needed to run this job in a Mainframe-oriented environment.

//NBRCVTJ1 JOB SIMOTIME,ACCOUNT,CLASS=1,MSGCLASS=0,NOTIFY=CSIP1
//* *******************************************************************
//*        This program 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    - Packed Numeric Format Conversion using COBOL
//* Author  - SimoTime Technologies
//* Date    - November 11, 2003
//* Version - 03.12.15
//*
//* This set of programs describes how to convert packed numeric
//* field formats used with COBOL and on an IBM Mainframe.
//*
//* This technique provides for the use of a single COBOL source
//* program that may be compiled and executed on an IBM Mainframe
//* with ZOS or VSE. The same COBOL source code may be compiled and
//* executed on a Windows or UNIX platform with Micro Focus.
//*
//* *******************************************************************
//* Step   1 of 2  This job step will delete a previously created
//*        hex-dump file.
//*
//JOBSETUP EXEC PGM=IEFBR14
//SYSLOG   DD  DSN=SIMOTIME.DATA.SYSLOGT1,DISP=(MOD,DELETE,DELETE),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=V,LRECL=1055,DSORG=PS)
//*
//* *******************************************************************
//* Step   2 of 2  Execute the program.
//*
//NBRCVTX1 EXEC PGM=NBRCVTC1,PARM='SYSOUT(BOTH)'
//STEPLIB  DD  DSN=SIMOTIME.DEMO.LOADLIB1,DISP=SHR
//*            The following DD statement is for the logging file.
//SYSLOG   DD  DSN=SIMOTIME.DATA.SYSLOGT1,DISP=(NEW,CATLG,CATLG),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=V,LRECL=1055,DSORG=PS)
//*            The following DD statement is SYSOUT and is used when
//*            the COBOL program does a Display.
//SYSOUT   DD  SYSOUT=*
//*

Table of Contents Previous Section Next Section Convert & Hex Dump, Binary Fields

The following (NBRCVTJ2.jcl) is a sample of the ZOS oriented JCL needed to run this job in a Mainframe-oriented environment.

//NBRCVTJ2 JOB SIMOTIME,ACCOUNT,CLASS=1,MSGCLASS=0,NOTIFY=CSIP1
//* *******************************************************************
//*        This program 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    - Numeric Binary Format Conversion using COBOL
//* Author  - SimoTime Technologies
//* Date    - November 11, 2003
//* Version - 03.12.15
//*
//* This set of programs describes how to convert from binary
//* numeric formats used with COBOL and on an IBM Mainframe.
//*
//* 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.
//*
//* This technique provides for the use of a single COBOL source
//* program that may be compiled and executed on an IBM Mainframe
//* with ZOS or VSE. The same COBOL source code may be compiled and
//* executed on a Windows or UNIX platform with Micro Focus.
//*
//* *******************************************************************
//* Step   1 of 2  This job step will delete a previously created
//*        hex-dump file.
//*
//JOBSETUP EXEC PGM=IEFBR14
//SYSLOG   DD  DSN=SIMOTIME.DATA.SYSLOGT2,DISP=(MOD,DELETE,DELETE),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=V,LRECL=1055,DSORG=PS)
//*
//* *******************************************************************
//* Step   2 of 2  Execute the program.
//*
//NBRCVTX2 EXEC PGM=NBRCVTC2,PARM='SYSOUT(BOTH)'
//STEPLIB  DD  DSN=SIMOTIME.DEMO.LOADLIB1,DISP=SHR
//*            The following DD statement is for the logging file.
//SYSLOG   DD  DSN=SIMOTIME.DATA.SYSLOGT2,DISP=(NEW,CATLG,CATLG),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=V,LRECL=1055,DSORG=PS)
//*            The following DD statement is SYSOUT and is used when
//*            the COBOL program does a Display.
//SYSOUT   DD  SYSOUT=*
//*

Table of Contents Previous Section Next Section Convert & Hex Dump, Zoned-Decimal

The following (NBRCVTJ3.jcl) is a sample of the ZOS oriented JCL needed to run this job in a Mainframe-oriented environment.

//NBRCVTJ3 JOB SIMOTIME,ACCOUNT,CLASS=1,MSGCLASS=0,NOTIFY=CSIP1
//* *******************************************************************
//*        This program 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    - Numeric Zoned-Decimal Format Conversion using COBOL
//* Author  - SimoTime Technologies
//* Date    - November 11, 2003
//* Version - 03.12.15
//*
//* This set of programs describes how to convert from binary
//* numeric formats used with COBOL and on an IBM Mainframe.
//*
//* This technique provides for the use of a single COBOL source
//* program that may be compiled and executed on an IBM Mainframe
//* with ZOS or VSE. The same COBOL source code may be compiled and
//* executed on a Windows or UNIX platform with Micro Focus.
//*
//* *******************************************************************
//* Step   1 of 2  This job step will delete a previously created
//*        hex-dump file.
//*
//JOBSETUP EXEC PGM=IEFBR14
//SYSLOG   DD  DSN=SIMOTIME.DATA.SYSLOGT3,DISP=(MOD,DELETE,DELETE),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=V,LRECL=1055,DSORG=PS)
//*
//* *******************************************************************
//* Step   2 of 2  Execute the program.
//*
//NBRCVTX2 EXEC PGM=NBRCVTC3,PARM='SYSOUT(BOTH)'
//STEPLIB  DD  DSN=SIMOTIME.DEMO.LOADLIB1,DISP=SHR
//*            The following DD statement is for the logging file.
//SYSLOG   DD  DSN=SIMOTIME.DATA.SYSLOGT3,DISP=(NEW,CATLG,CATLG),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=V,LRECL=1055,DSORG=PS)
//*            The following DD statement is SYSOUT and is used when
//*            the COBOL program does a Display.
//SYSOUT   DD  SYSOUT=*
//*

Table of Contents Previous Section Next Section Bash Script, Convert & Hex Dump

The following is the Bash Shell Scripts required to run the jobs on a Linux or UNIX System. For this test case the COBOL programs were compiled and executed on a Linux (Ubuntu) System using GnuCOBOL.

Table of Contents Previous Section Next Section Convert & Hex Dump, Packed Fields

The following (nbrcvts1.sh) is the Bash Shell Script needed to run this job on a Linux or UNIX System using GnuCOBOL.

#!/bin/bash
   JOBNAME=nbrcvts1
#  * *******************************************************************
#  *       Bash Script File - provided by SimoTime Technologies        *
#  *           (C) Copyright 1987-2019 All Rights Reserved             *
#  *             Web Site URL:   http://www.simotime.com               *
#  *                   e-mail:   helpdesk@simotime.com                 *
#  * *******************************************************************
#  *
#  * Text    - Techniques for Converting Packed Numeric Fields
#  * Author  - SimoTime Technologies
#  * Date    - November 11, 2003
#  * Version - 06.07.16
#  *
#  * This job will execute a COBOL Program that will describe and
#  * demonstrate various techniques for managing and converting numeric
#  * values that are stored in memory using a Packed Decimal (or COMP-3)
#  * format.
#  *
#  *   ************
#  *   * nbrcvts1 *
#  *   *********sh*
#  *        *
#  *        *
#  *   ************     ************     ************
#  *   * cobcrun  ******* NBRCVTC1 ******* SIMODUMP *
#  *   ************     *********so*     *********so*
#  *        *                                 *
#  *        *                            ************     ************
#  *        *                            * SIMOLOGS ******* CONSOLE  *
#  *        *                            *********so*  *  ************
#  *        *                                          *
#  *        *                                          *  ************
#  *        *                                          ****  SYSLOG  *
#  *        *                                             *******data*
#  *   ************
#  *   *   EOJ    *
#  *   ************
#  *
#  * ********************************************************************
#  * Step 1 of 3, Prepare the System Environment...
#  *
#  *
   for textstring in $(cat ENV4SYS1.txt);
   do
#      # * The following statement will replace all occurences
#      # * of DL_BASESYS1 with the value of the BASESYS1
#      # * environment variable.
       textstring=${textstring//DL_BASESYS1/$BASESYS1}
#      # * The following statement will replace all occurences
#      # * of BASHUSER_JOBNAME with the value of the JOBNAME
#      # * environment variable.
       textstring=${textstring/DL_JOBNAME/$JOBNAME}
       export $textstring
       rc=$?
       if [ $rc != 0 ]
       then
          ((NOK_Count++))
          simonote.sh "#  $textstring - Return Code is $rc"
          JOBSTATUS=$rc
       else
          ((AOK_Count++))
       fi
   done
#  *
   simonote.sh "# BASESYS1........... $BASESYS1"
   simonote.sh "# SIMONOTE........... $SIMONOTE"
   simonote.sh "# COB_LIBS........... $COB_LIBS"
   simonote.sh "# COB_LIBRARY_PATH... $COB_LIBRARY_PATH"
#  *
   simonote.sh "****************************************************************$JOBNAME"
   simonote.sh "# Starting Job Name is $JOBNAME, User is $USER"
#  *
#  * ********************************************************************
#  * Step 2 of 3, Process Packed Decimal Numeric Values...
#  *
   simonote.sh "# Continue Step 2 of 3, Process Packed Decimal Numeric Values"
   cobcrun NBRCVTC1
#  *
#  * ********************************************************************
#  * Step 3 of 3, End of Job Processing...
#  *
   simonote.sh "# Continue Step 3 of 3, End of Job Processing..."
   simonote.sh "# Finished Job Name is $JOBNAME"


Table of Contents Previous Section Next Section Convert & Hex Dump, Binary Fields

The following (nbrcvts2.sh) is the Bash Shell Script needed to run this job on a Linux or UNIX System using GnuCOBOL.

#!/bin/bash
   JOBNAME=nbrcvts2
#  * *******************************************************************
#  *       Bash Script File - provided by SimoTime Technologies        *
#  *           (C) Copyright 1987-2019 All Rights Reserved             *
#  *             Web Site URL:   http://www.simotime.com               *
#  *                   e-mail:   helpdesk@simotime.com                 *
#  * *******************************************************************
#  *
#  * Text    - Techniques for Converting Binary Numeric Fields
#  * Author  - SimoTime Technologies
#  * Date    - November 11, 2003
#  * Version - 06.07.16
#  *
#  * This job will execute a COBOL Program that will describe and
#  * demonstrate various techniques for managing and converting numeric
#  * values that are stored in memory using a Binary (or COMP)
#  * format.
#  *
#  *   ************
#  *   * nbrcvts2 *
#  *   *********sh*
#  *        *
#  *        *
#  *   ************     ************     ************
#  *   * cobcrun  ******* NBRCVTC2 ******* SIMODUMP *
#  *   ************     *********so*     *********so*
#  *        *                                 *
#  *        *                            ************     ************
#  *        *                            * SIMOLOGS ******* CONSOLE  *
#  *        *                            *********so*  *  ************
#  *        *                                          *
#  *        *                                          *  ************
#  *        *                                          ****  SYSLOG  *
#  *        *                                             *******data*
#  *        *
#  *   ************
#  *   *   EOJ    *
#  *   ************
#  *
#  * ********************************************************************
#  * Step 1 of 3, Prepare the System Environment...
#  *
   for textstring in $(cat ENV4SYS1.txt);
   do
#      # * The following statement will replace all occurences
#      # * of DL_BASESYS1 with the value of the BASESYS1
#      # * environment variable.
       textstring=${textstring//DL_BASESYS1/$BASESYS1}
#      # * The following statement will replace all occurences
#      # * of BASHUSER_JOBNAME with the value of the JOBNAME
#      # * environment variable.
       textstring=${textstring/DL_JOBNAME/$JOBNAME}
       export $textstring
       rc=$?
       if [ $rc != 0 ]
       then
          ((NOK_Count++))
          simonote.sh "#  $textstring - Return Code is $rc"
          JOBSTATUS=$rc
       else
          ((AOK_Count++))
       fi
   done
#  *
   simonote.sh "# BASESYS1........... $BASESYS1"
   simonote.sh "# SIMONOTE........... $SIMONOTE"
   simonote.sh "# COB_LIBS........... $COB_LIBS"
   simonote.sh "# COB_LIBRARY_PATH... $COB_LIBRARY_PATH"
#  *
   simonote.sh "****************************************************************$JOBNAME"
   simonote.sh "# Starting Job Name is $JOBNAME, User is $USER"
#  *
#  * ********************************************************************
#  * Step 2 of 3, Process Binary Numeric Values...
#  *
   simonote.sh "# Continue Step 2 of 3, Process Binary Numeric Values..."
   cobcrun NBRCVTC2
#  *
#  * ********************************************************************
#  * Step 3 of 3, End of Job Processing...
#  *
   simonote.sh "# Continue Step 3 of 3, End of Job Processing..."
   simonote.sh "# Finished Job Name is $JOBNAME"


Table of Contents Previous Section Next Section Convert & Hex Dump, Zoned-Decimal

The following (nbrcvts3.sh) is the Bash Shell Script needed to run this job on a Linux or UNIX System using GnuCOBOL.

#!/bin/bash
   JOBNAME=nbrcvts3
#  * *******************************************************************
#  *       Bash Script File - provided by SimoTime Technologies        *
#  *           (C) Copyright 1987-2019 All Rights Reserved             *
#  *             Web Site URL:   http://www.simotime.com               *
#  *                   e-mail:   helpdesk@simotime.com                 *
#  * *******************************************************************
#  *
#  * Text    - Techniques for Converting Zoned Decimal Numeric Fields
#  * Author  - SimoTime Technologies
#  * Date    - November 11, 2003
#  * Version - 06.07.16
#  *
#  * This job will execute a COBOL Program that will describe and
#  * demonstrate various techniques for managing and converting numeric
#  * values that are stored in memory using a Zoned Decimal format.
#  *
#  *   ************
#  *   * nbrcvts3 *
#  *   *********sh*
#  *        *
#  *        *
#  *   ************     ************     ************
#  *   * cobcrun  ******* NBRCVTC3 ******* SIMODUMP *
#  *   ************     *********so*     *********so*
#  *        *                                 *
#  *        *                            ************     ************
#  *        *                            * SIMOLOGS ******* CONSOLE  *
#  *        *                            *********so*  *  ************
#  *        *                                          *
#  *        *                                          *  ************
#  *        *                                          ****  SYSLOG  *
#  *        *                                             *******data*
#  *        *
#  *   ************
#  *   *   EOJ    *
#  *   ************
#  *
#  * ********************************************************************
#  * Step 1 of 3, Prepare the System Environment...
#  *
#  *
   for textstring in $(cat ENV4SYS1.txt);
   do
#      # * The following statement will replace all occurences
#      # * of DL_BASESYS1 with the value of the BASESYS1
#      # * environment variable.
       textstring=${textstring//DL_BASESYS1/$BASESYS1}
#      # * The following statement will replace all occurences
#      # * of BASHUSER_JOBNAME with the value of the JOBNAME
#      # * environment variable.
       textstring=${textstring/DL_JOBNAME/$JOBNAME}
       export $textstring
       rc=$?
       if [ $rc != 0 ]
       then
          ((NOK_Count++))
          simonote.sh "#  $textstring - Return Code is $rc"
          JOBSTATUS=$rc
       else
          ((AOK_Count++))
       fi
   done
#  *
   simonote.sh "# BASESYS1........... $BASESYS1"
   simonote.sh "# SIMONOTE........... $SIMONOTE"
   simonote.sh "# COB_LIBS........... $COB_LIBS"
   simonote.sh "# COB_LIBRARY_PATH... $COB_LIBRARY_PATH"
#  *
   simonote.sh "****************************************************************$JOBNAME"
   simonote.sh "# Starting Job Name is $JOBNAME, User is $USER"
#  *
#  * ********************************************************************
#  * Step 2 of 3, Process Zoned Decimal Numeric Values...
#  *
   simonote.sh "# Continue Step 2 of 3, Process Zoned Decimal Numeric Values..."
   cobcrun NBRCVTC3
#  *
#  * ********************************************************************
#  * Step 3 of 3, End of Job Processing...
#  *
   simonote.sh "# Continue Step 3 of 3, End of Job Processing..."
   simonote.sh "# Finished Job Name is $JOBNAME"


Table of Contents Previous Section Next Section COBOL Demonstration Programs

This following three (3) COBOL programs show the level of detail required to convert a numeric field.

Table of Contents Previous Section Next Section Convert a Packed Field

This program (NBRCVTC1.cbl) was written to show various techniques for converting between various Packed numeric field formats used on the mainframe and/or with the COBOL programming language.

       IDENTIFICATION DIVISION.
       PROGRAM-ID.    NBRCVTC1.
       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: NBRCVTC1.CBL
      *****************************************************************
      *
      * NBRCVTC1 - Numeric format conversion for COBOL.
      *
      * DESCRIPTION
      * -----------
      * This set of programs is used to show how to convert between
      * the various numeric formats used with COBOL and on an IBM
      * Mainframe System.
      *
      * This program illustrates the use of some of the commonly
      * used numeric formats. It will show actual hex-dump content of
      * the fields along with the field length for 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.
      *
      * 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.
      *
      *****************************************************************
      *
      * MAINTENANCE
      * -----------
      * 1996/03/15 Simmons, Created program.
      * 1996/03/15 Simmons, No changes to date.
      *
      *****************************************************************
      *
       ENVIRONMENT DIVISION.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
      *****************************************************************
      *    Data-structure for Title and Copyright...
      *    ------------------------------------------------------------
       01  SIM-TITLE.
           05  T1 pic X(11) value '* NBRCVTC1 '.
           05  T2 pic X(34) value 'Numeric Packed Convert using COBOL'.
           05  T3 pic X(10) value ' v11.12.03'.
           05  T4 pic X(24) value ' http://www.simotime.com'.
       01  SIM-COPYRIGHT.
           05  C1 pic X(11) value '* NBRCVTC1 '.
           05  C2 pic X(20) value 'Copyright 1987-2019 '.
           05  C3 pic X(28) value '   SimoTime Technologies    '.
           05  C4 pic X(20) value ' All Rights Reserved'.

       01  SIM-THANKS-01.
           05  C1 pic X(11) value '* NBRCVTC1 '.
           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 '* NBRCVTC1 '.
           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 '* NBRCVTC1 '.
           05  MESSAGE-TEXT        pic X(68).

      *****************************************************************
      *    Coding techniques for various numeric formats...
      *    ------------------------------------------------------------
      *    The following shows the full syntax for ZONED-DECIMAL
      *01  DISPLAY-UNSIGN          PIC 9(5)  USAGE IS DISPLAY.
      *    However, it is usually coded as follows.
      *01  DISPLAY-UNSIGN          PIC 9(5).
      *    For Working Storage fields a value clause may be added to
      *    minimize or avoid the occurence of a "S0C7" or an error
      *    message of "Invalid value in numeric field" followed
      *    by a program ABEND. The value clause will cause the field
      *    to contain all ZEROES when the program is loaded. If the
      *    value clause is not used as follows the numeric field may
      *    contain spaces.
       01  DISPLAY-UNSIGN          PIC 9(5) VALUE 0.
      *
       01  DISPLAY-SIGN-7-2        PIC S9(7)V99 SIGN TRAILING SEPARATE.
       01  DISPLAY-SIGN-7-2-X      redefines DISPLAY-SIGN-7-2
                                   PIC X(10).

       01  EDIT-FIELD-7-2          pic Z,ZZZ,ZZZ.99+.

      *    ------------------------------------------------------------
      *    The following is the full syntax for PACKED-DECIMAL.
      *01  PACK-DECIMAL-UNSIGN     pic 9(5)  USAGE IS COMPUTATIONAL-3.
      *    However, it is usually coded as follows. The VALUE clause
      *    is optional and will initialize the field to ZEROES when
      *    the program is started.
       01  PACK-DECIMAL-UNSIGN     pic 9(5)  COMP-3 VALUE 0.
       01  PACK-DECIMAL-UNSIGN-X   redefines PACK-DECIMAL-UNSIGN
                                   pic X(3).
      *
       01  PACK-DECIMAL-SIGN-6-3   pic S9(6)V999  COMP-3 VALUE 0.
       01  PACK-DECIMAL-SIGN-6-3-X redefines PACK-DECIMAL-SIGN-6-3
                                   pic X(5).

       COPY PASSDUMP.

      *****************************************************************
       PROCEDURE DIVISION.
           perform FIRST-TIME-LOGIC

      * Show the process for converting a packed-numeric format to a
      * to a display (or unsigned ZONED-DECIMAL-decimal) format.
      * Source Field, Packed,  5 digits and zero decimal positions
      * Result Field, Display, 5 digits and zero decimal positions
           perform EXAMPLE-101

      * Show the process for converting a packed-numeric format to a
      * to a display (or ZONED-DECIMAL-decimal, SIGN TRAILING SEPARATE)
      * format.
      * Source Field, Packed,  6 digits and 3 decimal positions
      * Result Field, Display, 7 digits and 2 decimal positions
      * The fewer decimal positions of the result field will cause the
      * numeric value to be truncated.
           perform EXAMPLE-102

      * Show the process for converting a packed-numeric format to a
      * to a display (or ZONED-DECIMAL-decimal, SIGN TRAILING SEPARATE)
      * format.
      * Source Field, Packed,  6 digits and 3 decimal positions
      * Result Field, Display, 7 digits and 2 decimal positions
      * The fewer decimal positions of the result field will be
      * rounded because of the ROUNDED keyword on the ADD statement.
           perform EXAMPLE-103

      * Show the process for converting a packed-numeric format to an
      * edited numeric format with an explicit decimal point.
      * Source Field, Packed, 6 digits and 3 decimal positions
      * Result Field, Edited, 7 digits and 2 decimal positions
           perform EXAMPLE-104

           perform Z-THANK-YOU
           GOBACK.

      *****************************************************************
       DUMP-ASTERISK-ROW.
           move 'NOTE' to SIMODUMP-REQUEST
           move 'OUT2' to SIMODUMP-OUTPUT
           move all '*' to SIMODUMP-BUFFER
           call 'SIMODUMP' using SIMODUMP-PASS-AREA SIMODUMP-BUFFER
           exit.

      *****************************************************************
       DUMP-ASTERISK-ROW-2X.
           perform DUMP-ASTERISK-SINGLE
           perform DUMP-ASTERISK-ROW
           exit.

      *****************************************************************
       DUMP-ASTERISK-SINGLE.
           move 'NOTE' to SIMODUMP-REQUEST
           move 'OUT2' to SIMODUMP-OUTPUT
           move SPACES to SIMODUMP-BUFFER
           move '*'    to SIMODUMP-BUFFER(1:1)
           call 'SIMODUMP' using SIMODUMP-PASS-AREA SIMODUMP-BUFFER
           exit.

      *****************************************************************
       DUMP-NOTE.
           move 'NOTE' to SIMODUMP-REQUEST
           move 'OUT2' to SIMODUMP-OUTPUT
           call 'SIMODUMP' using SIMODUMP-PASS-AREA SIMODUMP-BUFFER
           exit.

      *****************************************************************
      * Convert Packed to Display
      * Show the process for converting a packed-numeric format to a
      * display (or zoned-decimal) format.
      * Source Field, Packed,  5 digits and zero decimal positions
      * Result Field, Display, 5 digits and zero decimal positions
      * Note: most of the following code is for the display (or dump)
      * of the numeric fields in a hexadecimal dump format.
      *****************************************************************
       EXAMPLE-101.
      *    Prepare to show the Number...
           move 'Decode01' to SIMODUMP-DUMP-ID
           perform DUMP-ASTERISK-ROW-2X
           move
           'Starting Convert Packed U(5.0) to Display U(5.0)'
           to SIMODUMP-BUFFER
           perform DUMP-NOTE
      *---------------------------------------------------------------*
      *    Place a numeric value in an unsigned packed field.
           add 123 to ZERO giving PACK-DECIMAL-UNSIGN
      *    Convert a Packed Field to a Display field.
      *    Attention! The following statement does the Convert!
           add PACK-DECIMAL-UNSIGN to ZERO giving DISPLAY-UNSIGN
      *---------------------------------------------------------------*
      *    Prepare to call the dump routine . . .
           move 'DUMP' to SIMODUMP-REQUEST
           move 'OUT2' to SIMODUMP-OUTPUT
      *    Dump the Packed Field . . .
           move 'Review01' to SIMODUMP-DUMP-ID
           add length of PACK-DECIMAL-UNSIGN-X
               to ZERO giving SIMODUMP-LENGTH
           call 'SIMODUMP'  using SIMODUMP-PASS-AREA
                                  PACK-DECIMAL-UNSIGN
      *    Show the hexadecimal content of the result after conversion
      *    Dump the Field defined as DISPLAY . . .
           move 'Result01' to SIMODUMP-DUMP-ID
           add length of DISPLAY-UNSIGN
               to ZERO giving SIMODUMP-LENGTH
           call 'SIMODUMP'  using SIMODUMP-PASS-AREA
                                  DISPLAY-UNSIGN
           move 'Decode01' to SIMODUMP-DUMP-ID
           move
           'Finished Convert Packed U(5.0) to Display U(5.0)'
           to SIMODUMP-BUFFER
           perform DUMP-NOTE
           exit.

      *****************************************************************
      * Different Decimal Positions
      * Show the process for converting a packed-numeric format to a
      * display (or zoned-decimal) format.
      * Source Field, Packed,  6 digits and 3 decimal positions
      * Result Field, Display, 7 digits and 2 decimal positions
      * The fewer decimal positions of the result field will cause the
      * numeric value to be truncated.
      * The Result field is also defined with a SIGN TRAILING SEPARATE
      * that creates an additional byte to the field for the sign.
      * Note: most of the following code is for the display (or dump)
      * of the numeric fields in a hexadecimal dump format.
      *****************************************************************
       EXAMPLE-102.
      *    Prepare to show the Number...
           move 'Decode02' to SIMODUMP-DUMP-ID
           perform DUMP-ASTERISK-ROW-2X
           move
           'Starting Convert Packed S(6.3) to Display S(7.2) Truncate'
           to SIMODUMP-BUFFER
           perform DUMP-NOTE
      *---------------------------------------------------------------*
      *    Place a numeric value in a signed packed field.
           add 123.456 to ZERO giving PACK-DECIMAL-SIGN-6-3
      *    Convert a Packed Field to a Display field.
      *    Attention! The following statement does the Convert!
           add PACK-DECIMAL-SIGN-6-3 to ZERO
               giving DISPLAY-SIGN-7-2
      *---------------------------------------------------------------*
      *    Prepare to call the dump routine . . .
           move 'DUMP' to SIMODUMP-REQUEST
           move 'OUT2' to SIMODUMP-OUTPUT
      *    Dump the Packed Field . . .
           move 'Review02' to SIMODUMP-DUMP-ID
           add length of PACK-DECIMAL-SIGN-6-3-X
               to ZERO giving SIMODUMP-LENGTH
           call 'SIMODUMP'  using SIMODUMP-PASS-AREA
                                  PACK-DECIMAL-SIGN-6-3
      *    Show the hexadecimal content of the result after conversion
      *    Dump the Field defined as DISPLAY . . .
           move 'Result02' to SIMODUMP-DUMP-ID
           add length of DISPLAY-SIGN-7-2
               to ZERO giving SIMODUMP-LENGTH
           call 'SIMODUMP'  using SIMODUMP-PASS-AREA
                                  DISPLAY-SIGN-7-2
           move 'Decode02' to SIMODUMP-DUMP-ID
           move
           'Finished Convert Packed S(6.3) to Display S(7.2) Truncate'
           to SIMODUMP-BUFFER
           perform DUMP-NOTE
           exit.

      *****************************************************************
      * Decimal Positions Rounded
      * Show the process for converting a packed-numeric format to a
      * display (or zoned-decimal) format.
      * Source Field, Packed,  6 digits and 3 decimal positions
      * Result Field, Display, 7 digits and 2 decimal positions
      * The fewer decimal positions of the result field will be
      * rounded because of the ROUNDED keyword on the ADD statement.
      * The Result field is also defined with a SIGN TRAILING SEPARATE
      * that creates an additional byte to the field for the sign.
      * Note: most of the following code is for the display (or dump)
      * of the numeric fields in a hexadecimal dump format.
      *****************************************************************
       EXAMPLE-103.
      *    Prepare to show the Number...
           move 'Decode03' to SIMODUMP-DUMP-ID
           perform DUMP-ASTERISK-ROW-2X
           move
           'Starting Convert Packed S(6.3) to Display S(7.2) Rounded'
           to SIMODUMP-BUFFER
           perform DUMP-NOTE
      *---------------------------------------------------------------*
      *    Place a numeric value in a signed packed field.
           add 123.456 to ZERO giving PACK-DECIMAL-SIGN-6-3
      *    Convert a Packed Field to a Display field.
      *    Attention! The following statement does the Convert!
           add PACK-DECIMAL-SIGN-6-3 to ZERO
               giving DISPLAY-SIGN-7-2 ROUNDED
      *---------------------------------------------------------------*
      *    Prepare to call the dump routine . . .
           move 'DUMP' to SIMODUMP-REQUEST
           move 'OUT2' to SIMODUMP-OUTPUT
      *    Dump the Packed Field . . .
           move 'Review03' to SIMODUMP-DUMP-ID
           add length of PACK-DECIMAL-SIGN-6-3-X
               to ZERO giving SIMODUMP-LENGTH
           call 'SIMODUMP'  using SIMODUMP-PASS-AREA
                                  PACK-DECIMAL-SIGN-6-3
      *    Show the hexadecimal content of the result after conversion
      *    Dump the Field defined as DISPLAY . . .
           move 'Result03' to SIMODUMP-DUMP-ID
           add length of DISPLAY-SIGN-7-2
               to ZERO giving SIMODUMP-LENGTH
           call 'SIMODUMP'  using SIMODUMP-PASS-AREA
                                  DISPLAY-SIGN-7-2
           move 'Decode03' to SIMODUMP-DUMP-ID
           move
           'Finished Convert Packed S(6.3) to Display S(7.2) Rounded'
           to SIMODUMP-BUFFER
           perform DUMP-NOTE
           exit.

      *****************************************************************
      * Include Explicit Decimal Point
      * Show the process for converting a packed-numeric format to an
      * edited numeric format with an explicit decimal point.
      * Source Field, Packed, 6 digits and 3 decimal positions
      * Result Field, Edited, 7 digits and 2 decimal positions
      * The fewer decimal positions of the result field will be
      * rounded because of the ROUNDED keyword on the ADD statement.
      * The mask for the Resulting edited field will cause a physical
      * decimal point to be inserted.
      * Note: most of the following code is for the display (or dump)
      * of the numeric fields in a hexadecimal dump format.
      *****************************************************************
       EXAMPLE-104.
      *    Prepare to show the Number...
           move 'Decode04' to SIMODUMP-DUMP-ID
           perform DUMP-ASTERISK-ROW-2X
           move
           'Starting Convert with Explicit Decimal Point Rounded'
           to SIMODUMP-BUFFER
           perform DUMP-NOTE
      *---------------------------------------------------------------*
      *    Place a value in a packed field and show the hexadecimal
      *    content of the source for conversion
           add 123456.789 to ZERO giving PACK-DECIMAL-SIGN-6-3
      *    Convert a Packed Field to a Display field.
      *    Attention! The following statement does the Convert!
           add PACK-DECIMAL-SIGN-6-3 to ZERO
               giving EDIT-FIELD-7-2 ROUNDED
      *---------------------------------------------------------------*
      *    Prepare to call the dump routine . . .
           move 'DUMP' to SIMODUMP-REQUEST
           move 'OUT2' to SIMODUMP-OUTPUT
      *    Dump the Packed Field . . .
           move 'Review04' to SIMODUMP-DUMP-ID
           add length of PACK-DECIMAL-SIGN-6-3-X
               to ZERO giving SIMODUMP-LENGTH
           call 'SIMODUMP'  using SIMODUMP-PASS-AREA
                                  PACK-DECIMAL-SIGN-6-3
      *    Show the hexadecimal content of the result after conversion
      *    Dump the Field defined as DISPLAY . . .
           move 'Result04' to SIMODUMP-DUMP-ID
           add length of EDIT-FIELD-7-2
               to ZERO giving SIMODUMP-LENGTH
           call 'SIMODUMP'  using SIMODUMP-PASS-AREA
                                  EDIT-FIELD-7-2
           move 'Decode04' to SIMODUMP-DUMP-ID
           move
           'Finished Convert with Explicit Decimal Point Rounded'
           to SIMODUMP-BUFFER
           perform DUMP-NOTE
           exit.

      *****************************************************************
       FIRST-TIME-LOGIC.
           perform Z-POST-COPYRIGHT.
           move 'OUT2' to SIMODUMP-OUTPUT
           move 'HIDE' to SIMODUMP-COPYRIGHT
           exit.

      *****************************************************************
      * The following Z-Routines perform administrative tasks         *
      * for this program.                                             *
      *****************************************************************
       Z-POST-CONSOLE-MESSAGE.
           display MESSAGE-BUFFER upon console
           move SPACES to MESSAGE-TEXT
           exit.

      *****************************************************************
       Z-POST-COPYRIGHT.
           display SIM-TITLE     upon console
           display SIM-COPYRIGHT upon console
           exit.

      *****************************************************************
       Z-POST-NOTE-AND-CLEAR.
           move 'NOTE' to SIMODUMP-REQUEST
           call 'SIMODUMP' using SIMODUMP-PASS-AREA SIMODUMP-BUFFER
           move SPACES to SIMODUMP-BUFFER
           exit.

      *****************************************************************
       Z-THANK-YOU.
           display SIM-THANKS-01 upon console
           display SIM-THANKS-02 upon console
           exit.
      *****************************************************************
      *      This example is provided by SimoTime Technologies        *
      *        Our e-mail address is: helpdesk@simotime.com           *
      *     Also, visit our Web Site at http://www.simotime.com       *
      *****************************************************************

Table of Contents Previous Section Next Section Convert a Binary Field

This program (NBRCVTC2.cbl) was written to show various techniques for converting between various Binary numeric field formats used on the mainframe and/or with the COBOL programming language.

       IDENTIFICATION DIVISION.
       PROGRAM-ID.    NBRCVTC2.
       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: NBRCVTC2.CBL
      *****************************************************************
      *
      * NBRCVTC2 - Numeric format conversion for COBOL.
      *
      * DESCRIPTION
      * -----------
      * This set of programs is used to show how to convert between
      * the various numeric formats used with COBOL and on an IBM
      * Mainframe System.
      *
      * This program illustrates the use of some of the commonly
      * used numeric formats. It will show actual hex-dump content of
      * the fields along with the field length for 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.
      *
      * 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.
      *
      *****************************************************************
      *
      * MAINTENANCE
      * -----------
      * 1996/03/15 Simmons, Created program.
      * 1996/03/15 Simmons, No changes to date.
      *
      *****************************************************************
      *
       ENVIRONMENT DIVISION.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
      *****************************************************************
      *    Data-structure for Title and Copyright...
      *    ------------------------------------------------------------
       01  SIM-TITLE.
           05  T1 pic X(11) value '* NBRCVTC2 '.
           05  T2 pic X(34) value 'Numeric Binary Convert using COBOL'.
           05  T3 pic X(10) value ' v08.05.31'.
           05  T4 pic X(24) value ' http://www.simotime.com'.
       01  SIM-COPYRIGHT.
           05  C1 pic X(11) value '* NBRCVTC2 '.
           05  C2 pic X(20) value 'Copyright 1987-2019 '.
           05  C3 pic X(28) value '   SimoTime Technologies    '.
           05  C4 pic X(20) value ' All Rights Reserved'.

       01  SIM-THANKS-01.
           05  C1 pic X(11) value '* NBRCVTC2 '.
           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 '* NBRCVTC2 '.
           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 '* NBRCVTC2 '.
           05  MESSAGE-TEXT        pic X(68).

      *****************************************************************
      *    Coding techniques for various numeric formats...
      *    ------------------------------------------------------------
      *    The following shows the full syntax for ZONED-DECIMAL
      *01  DISPLAY-UNSIGN          pic 9(5)  USAGE IS DISPLAY.
      *    However, it is usually coded as follows.
      *01  DISPLAY-UNSIGN          PIC 9(5).
      *    For Working Storage fields a value clause may be added to
      *    minimize or avoid the occurence of a "S0C7" or an error
      *    message of "Invalid value in numeric field" followed
      *    by a program ABEND. The value clause will cause the field
      *    to contain all ZEROES when the program is loaded. If the
      *    value clause is not used as follows the numeric field may
      *    contain spaces.
       01  DISPLAY-UNSIGN          PIC 9(5) VALUE 0.
      *
       01  DISPLAY-SIGN-7-2        PIC S9(7)V99 SIGN TRAILING SEPARATE.
       01  DISPLAY-SIGN-7-2-X      redefines DISPLAY-SIGN-7-2
                                   PIC X(10).

       01  EDIT-FIELD-7-2          pic Z,ZZZ,ZZZ.99+.

      *    ------------------------------------------------------------
      *    The following is the full syntax for BINARY.
      *01  BINARY--UNSIGN          pic 9(5)  USAGE IS COMPUTATIONAL.
      *    However, it is usually coded as follows. The VALUE clause
      *    is optional and will initialize the field to ZEROES when
      *    the program is started.
       01  BINARY-UNSIGN           pic 9(9)  COMP VALUE 0.
       01  BINARY-UNSIGN-X         redefines BINARY-UNSIGN
                                   pic X(4).
      *
       01  BINARY-SIGN-6-3         pic S9(6)V999  COMP VALUE 0.
       01  BINARY-SIGN-6-3-X       redefines BINARY-SIGN-6-3
                                   pic X(4).

       COPY PASSDUMP.

      *****************************************************************
       PROCEDURE DIVISION.
           perform FIRST-TIME-LOGIC

      * Show the process for converting a packed-numeric format to a
      * to a display (or unsigned ZONED-DECIMAL-decimal) format.
      * Source Field, Binary,  5 digits and zero decimal positions
      * Result Field, Display, 5 digits and zero decimal positions
           perform EXAMPLE-201

      * Show the process for converting a packed-numeric format to a
      * to a display (or ZONED-DECIMAL-decimal, SIGN TRAILING SEPARATE)
      * format.
      * Source Field, Binary,  6 digits and 3 decimal positions
      * Result Field, Display, 7 digits and 2 decimal positions
      * The fewer decimal positions of the result field will cause the
      * numeric value to be truncated.
           perform EXAMPLE-202

      * Show the process for converting a packed-numeric format to a
      * to a display (or ZONED-DECIMAL-decimal, SIGN TRAILING SEPARATE)
      * format.
      * Source Field, Binary,  6 digits and 3 decimal positions
      * Result Field, Display, 7 digits and 2 decimal positions
      * The fewer decimal positions of the result field will be
      * rounded because of the ROUNDED keyword on the ADD statement.
           perform EXAMPLE-203

      * Show the process for converting a packed-numeric format to an
      * edited numeric format with an explicit decimal point.
      * Source Field, Binary, 6 digits and 3 decimal positions
      * Result Field, Edited, 7 digits and 2 decimal positions
           perform EXAMPLE-204

           perform Z-THANK-YOU
           GOBACK.

      *****************************************************************
       DUMP-ASTERISK-ROW.
           move 'NOTE' to SIMODUMP-REQUEST
           move 'OUT2' to SIMODUMP-OUTPUT
           move all '*' to SIMODUMP-BUFFER
           call 'SIMODUMP' using SIMODUMP-PASS-AREA SIMODUMP-BUFFER
           exit.

      *****************************************************************
       DUMP-ASTERISK-ROW-2X.
           perform DUMP-ASTERISK-SINGLE
           perform DUMP-ASTERISK-ROW
           exit.

      *****************************************************************
       DUMP-ASTERISK-SINGLE.
           move 'NOTE' to SIMODUMP-REQUEST
           move 'OUT2' to SIMODUMP-OUTPUT
           move SPACES to SIMODUMP-BUFFER
           move '*'    to SIMODUMP-BUFFER(1:1)
           call 'SIMODUMP' using SIMODUMP-PASS-AREA SIMODUMP-BUFFER
           exit.

      *****************************************************************
       DUMP-NOTE.
           move 'NOTE' to SIMODUMP-REQUEST
           move 'OUT2' to SIMODUMP-OUTPUT
           call 'SIMODUMP' using SIMODUMP-PASS-AREA SIMODUMP-BUFFER
           exit.

      *****************************************************************
      * Convert Binary to Display
      * Show the process for converting a packed-numeric format to a
      * display (or zoned-decimal) format.
      * Source Field, Binary,  9 digits and zero decimal positions
      * Result Field, Display, 5 digits and zero decimal positions
      * Note: most of the following code is for the display (or dump)
      * of the numeric fields in a hexadecimal dump format.
      *****************************************************************
       EXAMPLE-201.
      *    Prepare to show the Number...
           move 'Dump0001' to SIMODUMP-DUMP-ID
           perform DUMP-ASTERISK-ROW-2X
      *
           move 'Starting Convert Binary to Display' to SIMODUMP-BUFFER
           perform DUMP-NOTE
      *---------------------------------------------------------------*
      *    Place a value in a binary field and show the hexadecimal
      *    content of the source for conversion
           move 'DUMP' to SIMODUMP-REQUEST
           move 'OUT2' to SIMODUMP-OUTPUT
           add length of BINARY-UNSIGN-X
               to ZERO giving SIMODUMP-LENGTH
           move SPACES to SIMODUMP-BUFFER
           add 123 to ZERO giving BINARY-UNSIGN
           move BINARY-UNSIGN-X to SIMODUMP-BUFFER
           call 'SIMODUMP' using SIMODUMP-PASS-AREA SIMODUMP-BUFFER
      *    Convert a Binary Field to a Display field and show the
      *    hexadecimal content of the result field after conversion.
      *    Note: the following single statement is all that is required
      *    to convert the Binary format to a display format.
           add BINARY-UNSIGN to ZERO giving DISPLAY-UNSIGN
      *    Show the hexadecimal content of the result after conversion
           move 'DUMP' to SIMODUMP-REQUEST
           move 'OUT2' to SIMODUMP-OUTPUT
           add length of DISPLAY-UNSIGN
               to ZERO giving SIMODUMP-LENGTH
           move SPACES to SIMODUMP-BUFFER
           move DISPLAY-UNSIGN to SIMODUMP-BUFFER
           call 'SIMODUMP' using SIMODUMP-PASS-AREA SIMODUMP-BUFFER
      *---------------------------------------------------------------*
           move 'Finished Convert Binary to Display' to SIMODUMP-BUFFER
           perform DUMP-NOTE
           exit.

      *****************************************************************
      * Different Decimal Positions
      * Show the process for converting a binary numeric format to a
      * display (or zoned-decimal) format.
      * Source Field, Binary,  6 digits and 3 decimal positions
      * Result Field, Display, 7 digits and 2 decimal positions
      * The fewer decimal positions of the result field will cause the
      * numeric value to be truncated.
      * The Result field is also defined with a SIGN TRAILING SEPARATE
      * that creates an additional byte to the field for the sign.
      * Note: most of the following code is for the display (or dump)
      * of the numeric fields in a hexadecimal dump format.
      *****************************************************************
       EXAMPLE-202.
      *    Prepare to show the Number...
           move 'Dump0002' to SIMODUMP-DUMP-ID
           perform DUMP-ASTERISK-ROW-2X
      *
           move
           'Starting Convert Binary (6.3) to Display (7.2) Truncation'
           to SIMODUMP-BUFFER
           perform DUMP-NOTE
      *---------------------------------------------------------------*
      *    Place a value in a Binary field and show the hexadecimal
      *    content of the source for conversion
           move 'DUMP' to SIMODUMP-REQUEST
           move 'OUT2' to SIMODUMP-OUTPUT
           add length of BINARY-SIGN-6-3-X
               to ZERO giving SIMODUMP-LENGTH
           move SPACES to SIMODUMP-BUFFER
           add 123.456 to ZERO giving BINARY-SIGN-6-3
           move BINARY-SIGN-6-3-X to SIMODUMP-BUFFER
           call 'SIMODUMP' using SIMODUMP-PASS-AREA SIMODUMP-BUFFER
      *    Convert a Binary Field to a Display field and show the
      *    hexadecimal content of the result field after conversion.
      *    Note: the following single statement is all that is required
      *    to convert the Binary format to a display format.
           add BINARY-SIGN-6-3 to ZERO
               giving DISPLAY-SIGN-7-2
      *    Show the hexadecimal content of the result after conversion
           move 'DUMP' to SIMODUMP-REQUEST
           move 'OUT2' to SIMODUMP-OUTPUT
           add length of DISPLAY-SIGN-7-2
               to ZERO giving SIMODUMP-LENGTH
           move SPACES to SIMODUMP-BUFFER
           move DISPLAY-SIGN-7-2-X to SIMODUMP-BUFFER
           call 'SIMODUMP' using SIMODUMP-PASS-AREA SIMODUMP-BUFFER
      *---------------------------------------------------------------*
           move
           'Finished Convert Binary (6.3) to Display (7.2) Truncation'
           to SIMODUMP-BUFFER
           perform DUMP-NOTE
           exit.

      *****************************************************************
      * Decimal Positions Rounded
      * Show the process for converting a Binary numeric format to a
      * display (or zoned-decimal) format.
      * Source Field, Binary,  6 digits and 3 decimal positions
      * Result Field, Display, 7 digits and 2 decimal positions
      * The fewer decimal positions of the result field will be
      * rounded because of the ROUNDED keyword on the ADD statement.
      * The Result field is also defined with a SIGN TRAILING SEPARATE
      * that creates an additional byte to the field for the sign.
      * Note: most of the following code is for the display (or dump)
      * of the numeric fields in a hexadecimal dump format.
      *****************************************************************
       EXAMPLE-203.
      *    Prepare to show the Number...
           move 'Dump00032' to SIMODUMP-DUMP-ID
           perform DUMP-ASTERISK-ROW-2X
      *
           move
           'Starting Convert Binary (2.3) to Display (7.2) Rounded'
           to SIMODUMP-BUFFER
           perform DUMP-NOTE
      *---------------------------------------------------------------*
      *    Place a value in a Binary field and show the hexadecimal
      *    content of the source for conversion
           move 'DUMP' to SIMODUMP-REQUEST
           move 'OUT2' to SIMODUMP-OUTPUT
           add length of BINARY-SIGN-6-3-X
               to ZERO giving SIMODUMP-LENGTH
           move SPACES to SIMODUMP-BUFFER
           add 123.456 to ZERO giving BINARY-SIGN-6-3
           move BINARY-SIGN-6-3-X to SIMODUMP-BUFFER
           call 'SIMODUMP' using SIMODUMP-PASS-AREA SIMODUMP-BUFFER
      *    Convert a Binary Field to a Display field and show the
      *    hexadecimal content of the result field after conversion.
      *    Note: the following single statement is all that is required
      *    to convert the packed format to a display format.
           add BINARY-SIGN-6-3 to ZERO
               giving DISPLAY-SIGN-7-2 ROUNDED
      *    Show the hexadecimal content of the result after conversion
           move 'DUMP' to SIMODUMP-REQUEST
           move 'OUT2' to SIMODUMP-OUTPUT
           add length of DISPLAY-SIGN-7-2
               to ZERO giving SIMODUMP-LENGTH
           move SPACES to SIMODUMP-BUFFER
           move DISPLAY-SIGN-7-2-X to SIMODUMP-BUFFER
           call 'SIMODUMP' using SIMODUMP-PASS-AREA SIMODUMP-BUFFER
      *---------------------------------------------------------------*
           move
           'Finished Convert Binary (6.3) to Display (7.2) Rounded'
           to SIMODUMP-BUFFER
           perform DUMP-NOTE
           exit.

      *****************************************************************
      * Include Explicit Decimal Point
      * Show the process for converting a binary numeric format to an
      * edited numeric format with an explicit decimal point.
      * Source Field, Binary, 6 digits and 3 decimal positions
      * Result Field, Edited, 7 digits and 2 decimal positions
      * The fewer decimal positions of the result field will be
      * rounded because of the ROUNDED keyword on the ADD statement.
      * The mask for the Resulting edited field will cause a physical
      * decimal point to be inserted.
      * Note: most of the following code is for the display (or dump)
      * of the numeric fields in a hexadecimal dump format.
      *****************************************************************
       EXAMPLE-204.
      *    Prepare to show the Number...
           move 'Dump0004' to SIMODUMP-DUMP-ID
           perform DUMP-ASTERISK-ROW-2X
      *
           move
           'Starting Convert with Explicit Decimal Point Rounded'
           to SIMODUMP-BUFFER
           perform DUMP-NOTE
      *---------------------------------------------------------------*
      *    Place a value in a Binary field and show the hexadecimal
      *    content of the source for conversion
           move 'DUMP' to SIMODUMP-REQUEST
           move 'OUT2' to SIMODUMP-OUTPUT
           add length of BINARY-SIGN-6-3-X
               to ZERO giving SIMODUMP-LENGTH
           move SPACES to SIMODUMP-BUFFER
           add 123456.789 to ZERO giving BINARY-SIGN-6-3
           move BINARY-SIGN-6-3-X to SIMODUMP-BUFFER
           call 'SIMODUMP' using SIMODUMP-PASS-AREA SIMODUMP-BUFFER
      *    Convert a Binary Field to an Edited field and show the
      *    hexadecimal content of the result field after conversion.
      *    Note: the following single statement is all that is required
      *    to convert the Binary format to a display format.
           add BINARY-SIGN-6-3 to ZERO
               giving EDIT-FIELD-7-2 ROUNDED
      *    Show the hexadecimal content of the result after conversion
           move 'DUMP' to SIMODUMP-REQUEST
           move 'OUT2' to SIMODUMP-OUTPUT
           add length of EDIT-FIELD-7-2
               to ZERO giving SIMODUMP-LENGTH
           move SPACES to SIMODUMP-BUFFER
           move EDIT-FIELD-7-2 to SIMODUMP-BUFFER
           call 'SIMODUMP' using SIMODUMP-PASS-AREA SIMODUMP-BUFFER
      *---------------------------------------------------------------*
           move
           'Finished Convert with Explicit Decimal Point Rounded'
           to SIMODUMP-BUFFER
           perform DUMP-NOTE
           exit.

      *****************************************************************
       FIRST-TIME-LOGIC.
           perform Z-POST-COPYRIGHT.
           move 'OUT2' to SIMODUMP-OUTPUT
           move 'HIDE' to SIMODUMP-COPYRIGHT
           exit.

      *****************************************************************
      * The following Z-Routines perform administrative tasks         *
      * for this program.                                             *
      *****************************************************************
       Z-POST-CONSOLE-MESSAGE.
           display MESSAGE-BUFFER upon console
           move SPACES to MESSAGE-TEXT
           exit.

      *****************************************************************
       Z-POST-COPYRIGHT.
           display SIM-TITLE     upon console
           display SIM-COPYRIGHT upon console
           exit.

      *****************************************************************
       Z-POST-NOTE-AND-CLEAR.
           move 'NOTE' to SIMODUMP-REQUEST
           call 'SIMODUMP' using SIMODUMP-PASS-AREA
           move SPACES to SIMODUMP-BUFFER
           exit.

      *****************************************************************
       Z-THANK-YOU.
           display SIM-THANKS-01 upon console
           display SIM-THANKS-02 upon console
           exit.
      *****************************************************************
      *      This example is provided by SimoTime Technologies        *
      *        Our e-mail address is: helpdesk@simotime.com           *
      *     Also, visit our Web Site at http://www.simotime.com       *
      *****************************************************************

Table of Contents Previous Section Next Section Convert a Zoned-Decimal Field

This program (NBRCVTC3.cbl) was written to show various techniques for converting between various Zoned-Decimal numeric field formats used on the mainframe and/or with the COBOL programming language.

       IDENTIFICATION DIVISION.
       PROGRAM-ID.    NBRCVTC3.
       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: NBRCVTC3.CBL
      *****************************************************************
      *
      * NBRCVTC3 - ZONED-DECIMAL-Decimal format conversion for COBOL.
      *
      * DESCRIPTION
      * -----------
      * This set of programs is used to show how to convert between
      * the various numeric formats used with COBOL and on an IBM
      * Mainframe System.
      *
      * The COBOL programs are compiled with the ASSIGN(EXTERNAL)
      * directive. This provides for external file mapping of file
      * names.
      *
      * 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.
      *
      *****************************************************************
      *
      * MAINTENANCE
      * -----------
      * 1996/03/15 Simmons, Created program.
      * 1996/03/15 Simmons, No changes to date.
      *
      *****************************************************************
      *
       ENVIRONMENT DIVISION.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
      *****************************************************************
      *    Data-structure for Title and Copyright...
      *    ------------------------------------------------------------
       01  SIM-TITLE.
           05  T1 pic X(11) value '* NBRCVTC3 '.
           05  T2 pic X(34) value 'Zoned Decimal Convert using COBOL '.
           05  T3 pic X(10) value ' v08.05.31'.
           05  T4 pic X(24) value ' http://www.simotime.com'.
       01  SIM-COPYRIGHT.
           05  C1 pic X(11) value '* NBRCVTC3 '.
           05  C2 pic X(20) value 'Copyright 1987-2019 '.
           05  C3 pic X(28) value '   SimoTime Technologies    '.
           05  C4 pic X(20) value ' All Rights Reserved'.

       01  SIM-THANKS-01.
           05  C1 pic X(11) value '* NBRCVTC3 '.
           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 '* NBRCVTC3 '.
           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 '* NBRCVTC3 '.
           05  MESSAGE-TEXT        pic X(68).

      *****************************************************************
      *    The following is the full syntax for ZONED-DECIMAL-DECIMAL
      *01  DISPLAY-UNSIGN     pic 9(5)  USAGE IS DISPLAY.
      *    However, it is usually coded as follows.
      *01  DISPLAY-UNSIGN     PIC 9(5).
      *    For Working Storage fields a value clause may be added to
      *    minimize or avoid the occurence of a "S0C7" or an error
      *    message of "Invalid value in numeric field" followed
      *    by a program ABEND. The value clause will cause the field
      *    to contain all ZEROES when the program is loaded. If the
      *    value clause is not used as follows the numeric field may
      *    contain spaces.
       01  DISPLAY-UNSIGN          PIC 9(5) VALUE 0.
      *
       01  DISPLAY-SIGN-7-2        PIC S9(7)V99 SIGN TRAILING SEPARATE.
       01  DISPLAY-SIGN-7-2-X      redefines DISPLAY-SIGN-7-2
                                   PIC X(10).

       01  EDIT-FIELD-7-2          pic Z,ZZZ,ZZZ.99+.

      *    ------------------------------------------------------------
      *    The following is the full syntax for BINARY.
      *01  ZONED-DECIMAL-UNSIGN     pic 9(5)  USAGE IS DISPLAY.
      *    However, it is usually coded as follows. The VALUE clause
      *    is optional and will initialize the field to ZEROES when
      *    the program is started.
       01  ZONED-DECIMAL-UNSIGN     pic 9(5)  VALUE 0.
       01  ZONED-DECIMAL-UNSIGN-X   redefines ZONED-DECIMAL-UNSIGN
                                    pic X(5).
      *
       01  ZONED-DECIMAL-SIGN-6-3   pic S9(6)V999  VALUE 0.
       01  ZONED-DECIMAL-SIGN-6-3-X redefines ZONED-DECIMAL-SIGN-6-3
                                    pic X(9).

       COPY PASSDUMP.

      *****************************************************************
       PROCEDURE DIVISION.
           perform FIRST-TIME-LOGIC

      * Show the process for converting a zoned decimal numeric format
      * to a display (or unsigned ZONED-DECIMAL-decimal) format.
      * Source Field, Binary,  5 digits and zero decimal positions
      * Result Field, Display, 5 digits and zero decimal positions
           perform EXAMPLE-301

      * Show the process for converting a zoned decimal numeric format
      * to a display (or ZONED-DECIMAL-decimal, SIGN TRAILING SEPARATE)
      * format.
      * Source Field, Binary,  6 digits and 3 decimal positions
      * Result Field, Display, 7 digits and 2 decimal positions
      * The fewer decimal positions of the result field will cause the
      * numeric value to be truncated.
           perform EXAMPLE-302

      * Show the process for converting a zoned decimal numeric format
      * to a display (or ZONED-DECIMAL-decimal, SIGN TRAILING SEPARATE)
      * format.
      * Source Field, Binary,  6 digits and 3 decimal positions
      * Result Field, Display, 7 digits and 2 decimal positions
      * The fewer decimal positions of the result field will be
      * rounded because of the ROUNDED keyword on the ADD statement.
           perform EXAMPLE-303

      * Show the process for converting a zoned decimal numeric format
      * to an edited numeric format with an explicit decimal point.
      * Source Field, Binary, 6 digits and 3 decimal positions
      * Result Field, Edited, 7 digits and 2 decimal positions
           perform EXAMPLE-304

           perform Z-THANK-YOU
           GOBACK.

      *****************************************************************
       DUMP-ASTERISK-ROW.
           move 'NOTE' to SIMODUMP-REQUEST
           move 'OUT2' to SIMODUMP-OUTPUT
           move all '*' to SIMODUMP-BUFFER
           call 'SIMODUMP' using SIMODUMP-PASS-AREA SIMODUMP-BUFFER
           exit.

      *****************************************************************
       DUMP-ASTERISK-ROW-2X.
           perform DUMP-ASTERISK-SINGLE
           perform DUMP-ASTERISK-ROW
           exit.

      *****************************************************************
       DUMP-ASTERISK-SINGLE.
           move 'NOTE' to SIMODUMP-REQUEST
           move 'OUT2' to SIMODUMP-OUTPUT
           move SPACES to SIMODUMP-BUFFER
           move '*'    to SIMODUMP-BUFFER(1:1)
           call 'SIMODUMP' using SIMODUMP-PASS-AREA SIMODUMP-BUFFER
           exit.

      *****************************************************************
       DUMP-NOTE.
           move 'NOTE' to SIMODUMP-REQUEST
           move 'OUT2' to SIMODUMP-OUTPUT
           call 'SIMODUMP' using SIMODUMP-PASS-AREA SIMODUMP-BUFFER
           exit.

      *****************************************************************
      * Convert Zoned Decimal to Display
      * Show the process for converting a zoned-decimal-numeric format
      * to a display (or ZONED-DECIMAL-decimal) format.
      * Since the source field is an unsigned numeric value the result
      * field will be the same as the source field.
      * Source Field, Binary,  9 digits and zero decimal positions
      * Result Field, Display, 5 digits and zero decimal positions
      * Note: most of the following code is for the display (or dump)
      * of the numeric fields in a hexadecimal dump format.
      *****************************************************************
       EXAMPLE-301.
      *    Prepare to show the Number...
           move 'Dump0001' to SIMODUMP-DUMP-ID
           perform DUMP-ASTERISK-ROW-2X
      *
           move 'Starting Convert Zoned Decimal to Display'
             to SIMODUMP-BUFFER
           perform DUMP-NOTE
      *---------------------------------------------------------------*
      *    Place a value in a Zoned Decimal field and show the
      *    hexadecimal content of the source for conversion
           move 'DUMP' to SIMODUMP-REQUEST
           move 'OUT2' to SIMODUMP-OUTPUT
           add length of ZONED-DECIMAL-UNSIGN-X
               to ZERO giving SIMODUMP-LENGTH
           move SPACES to SIMODUMP-BUFFER
           add 123 to ZERO giving ZONED-DECIMAL-UNSIGN
           move ZONED-DECIMAL-UNSIGN-X to SIMODUMP-BUFFER
           call 'SIMODUMP' using SIMODUMP-PASS-AREA SIMODUMP-BUFFER
      *    Convert a Zoned Decimal Field to a Display field and show the
      *    hexadecimal content of the result field after conversion.
      *    Note: the following single statement is all that is required
      *    to convert the Zoned Decimal format to a display format.
           add ZONED-DECIMAL-UNSIGN to ZERO giving DISPLAY-UNSIGN
      *    Show the hexadecimal content of the result after conversion
           move 'DUMP' to SIMODUMP-REQUEST
           move 'OUT2' to SIMODUMP-OUTPUT
           add length of DISPLAY-UNSIGN
               to ZERO giving SIMODUMP-LENGTH
           move SPACES to SIMODUMP-BUFFER
           move DISPLAY-UNSIGN to SIMODUMP-BUFFER
           call 'SIMODUMP' using SIMODUMP-PASS-AREA SIMODUMP-BUFFER
      *---------------------------------------------------------------*
           move 'Finished Convert Zoned Decimal to Display'
             to SIMODUMP-BUFFER
           perform DUMP-NOTE
           exit.

      *****************************************************************
      * Different Decimal Positions
      * Show the process for converting a Zoned Decimal numeric format
      * to a display (or ZONED-DECIMAL-decimal) format.
      * Source Field, Binary, 6 digits and 3 decimal positions
      * Result Field, Display,  7 digits and 2 decimal positions
      * The fewer decimal positions of the result field will cause the
      * numeric value to be truncated.
      * The Result field is also defined with a SIGN TRAILING SEPARATE
      * that creates an additional byte to the field for the sign.
      * Note: most of the following code is for the display (or dump)
      * of the numeric fields in a hexadecimal dump format.
      *****************************************************************
       EXAMPLE-302.
      *    Prepare to show the Number...
           move 'Dump0002' to SIMODUMP-DUMP-ID
           perform DUMP-ASTERISK-ROW-2X
      *
           move
           'Starting Zoned Decimal (6.3) to Display (7.2) Truncation'
           to SIMODUMP-BUFFER
           perform DUMP-NOTE
      *---------------------------------------------------------------*
      *    Place a value in a Zoned Decimal field and show the
      *    hexadecimal content of the source for conversion
           move 'DUMP' to SIMODUMP-REQUEST
           move 'OUT2' to SIMODUMP-OUTPUT
           add length of ZONED-DECIMAL-SIGN-6-3-X
               to ZERO giving SIMODUMP-LENGTH
           move SPACES to SIMODUMP-BUFFER
           add 123.456 to ZERO giving ZONED-DECIMAL-SIGN-6-3
           move ZONED-DECIMAL-SIGN-6-3-X to SIMODUMP-BUFFER
           call 'SIMODUMP' using SIMODUMP-PASS-AREA SIMODUMP-BUFFER
      *    Convert a Zoned Decimal Field to a Display field and show
      *    the hexadecimal content of a result field after conversion.
      *    Note: the following single statement is all that is required
      *    to convert the Zoned Decimal format to a display format.
           add ZONED-DECIMAL-SIGN-6-3 to ZERO
               giving DISPLAY-SIGN-7-2
      *    Show the hexadecimal content of the result after conversion
           move 'DUMP' to SIMODUMP-REQUEST
           move 'OUT2' to SIMODUMP-OUTPUT
           add length of DISPLAY-SIGN-7-2
               to ZERO giving SIMODUMP-LENGTH
           move SPACES to SIMODUMP-BUFFER
           move DISPLAY-SIGN-7-2-X to SIMODUMP-BUFFER
           call 'SIMODUMP' using SIMODUMP-PASS-AREA SIMODUMP-BUFFER
      *---------------------------------------------------------------*
           move
           'Finished Zoned Decimal (6.3) to Display (7.2) Truncation'
           to SIMODUMP-BUFFER
           perform DUMP-NOTE
           exit.

      *****************************************************************
      * Decimal Positions Rounded
      * Show the process for converting a Zoned Decimal numeric format
      * to a display (or ZONED-DECIMAL-decimal) format.
      * Source Field, Binary, 6 digits and 3 decimal positions
      * Result Field, Display,  7 digits and 2 decimal positions
      * The fewer decimal positions of the result field will be
      * rounded because of the ROUNDED keyword on the ADD statement.
      * The Result field is also defined with a SIGN TRAILING SEPARATE
      * that creates an additional byte to the field for the sign.
      * Note: most of the following code is for the display (or dump)
      * of the numeric fields in a hexadecimal dump format.
      *****************************************************************
       EXAMPLE-303.
      *    Prepare to show the Number...
           move 'Dump00032' to SIMODUMP-DUMP-ID
           perform DUMP-ASTERISK-ROW-2X
      *
           move
           'Starting Zoned Decimal (2.3) to Display (7.2) Rounded'
           to SIMODUMP-BUFFER
           perform DUMP-NOTE
      *---------------------------------------------------------------*
      *    Place a value in a Zoned Decimal field and show the
      *    hexadecimal content of the source for conversion
           move 'DUMP' to SIMODUMP-REQUEST
           move 'OUT2' to SIMODUMP-OUTPUT
           add length of ZONED-DECIMAL-SIGN-6-3-X
               to ZERO giving SIMODUMP-LENGTH
           move SPACES to SIMODUMP-BUFFER
           add 123.456 to ZERO giving ZONED-DECIMAL-SIGN-6-3
           move ZONED-DECIMAL-SIGN-6-3-X to SIMODUMP-BUFFER
           call 'SIMODUMP' using SIMODUMP-PASS-AREA SIMODUMP-BUFFER
      *    Convert a Zoned Decimal Field to a Display field and show
      *    the hexadecimal content of a result field after conversion.
      *    Note: the following single statement is all that is required
      *    to convert the packed format to a display format.
           add ZONED-DECIMAL-SIGN-6-3 to ZERO
               giving DISPLAY-SIGN-7-2 ROUNDED
      *    Show the hexadecimal content of the result after conversion
           move 'DUMP' to SIMODUMP-REQUEST
           move 'OUT2' to SIMODUMP-OUTPUT
           add length of DISPLAY-SIGN-7-2
               to ZERO giving SIMODUMP-LENGTH
           move SPACES to SIMODUMP-BUFFER
           move DISPLAY-SIGN-7-2-X to SIMODUMP-BUFFER
           call 'SIMODUMP' using SIMODUMP-PASS-AREA SIMODUMP-BUFFER
      *---------------------------------------------------------------*
           move
           'Finished Zoned Decimal (6.3) to Display (7.2) Rounded'
           to SIMODUMP-BUFFER
           perform DUMP-NOTE
           exit.

      *****************************************************************
      * Include Explicit Decimal Point
      * Show the process for converting a Zoned Decimal numeric format
      * to an edited numeric format with an explicit decimal point.
      * Source Field, Binary, 6 digits and 3 decimal positions
      * Result Field, Edited, 7 digits and 2 decimal positions
      * The fewer decimal positions of the result field will be
      * rounded because of the ROUNDED keyword on the ADD statement.
      * The mask for the Resulting edited field will cause a physical
      * decimal point to be inserted.
      * Note: most of the following code is for the display (or dump)
      * of the numeric fields in a hexadecimal dump format.
      *****************************************************************
       EXAMPLE-304.
      *    Prepare to show the Number...
           move 'Dump0004' to SIMODUMP-DUMP-ID
           perform DUMP-ASTERISK-ROW-2X
      *
           move
           'Starting Convert with Explicit Decimal Point Rounded'
           to SIMODUMP-BUFFER
           perform DUMP-NOTE
      *---------------------------------------------------------------*
      *    Place a value in a Zoned Decimal field and show the
      *    hexadecimal content of the source for conversion
           move 'DUMP' to SIMODUMP-REQUEST
           move 'OUT2' to SIMODUMP-OUTPUT
           add length of ZONED-DECIMAL-SIGN-6-3-X
               to ZERO giving SIMODUMP-LENGTH
           move SPACES to SIMODUMP-BUFFER
           add 123456.789 to ZERO giving ZONED-DECIMAL-SIGN-6-3
           move ZONED-DECIMAL-SIGN-6-3-X to SIMODUMP-BUFFER
           call 'SIMODUMP' using SIMODUMP-PASS-AREA SIMODUMP-BUFFER
      *    Convert a Zoned Decimal Field to an Edited field and show
      *    the hexadecimal content of a result field after conversion.
      *    Note: the following single statement is all that is required
      *    to convert the Zoned Decimal format to a display format.
           add ZONED-DECIMAL-SIGN-6-3 to ZERO
               giving EDIT-FIELD-7-2 ROUNDED
      *    Show the hexadecimal content of the result after conversion
           move 'DUMP' to SIMODUMP-REQUEST
           move 'OUT2' to SIMODUMP-OUTPUT
           add length of EDIT-FIELD-7-2
               to ZERO giving SIMODUMP-LENGTH
           move SPACES to SIMODUMP-BUFFER
           move EDIT-FIELD-7-2 to SIMODUMP-BUFFER
           call 'SIMODUMP' using SIMODUMP-PASS-AREA SIMODUMP-BUFFER
      *---------------------------------------------------------------*
           move
           'Finished Convert with Explicit Decimal Point Rounded'
           to SIMODUMP-BUFFER
           perform DUMP-NOTE
           exit.

      *****************************************************************
       FIRST-TIME-LOGIC.
           perform Z-POST-COPYRIGHT.
           move 'OUT2' to SIMODUMP-OUTPUT
           move 'HIDE' to SIMODUMP-COPYRIGHT
           exit.

      *****************************************************************
      * The following Z-Routines perform administrative tasks         *
      * for this program.                                             *
      *****************************************************************
       Z-POST-CONSOLE-MESSAGE.
           display MESSAGE-BUFFER upon console
           move SPACES to MESSAGE-TEXT
           exit.

      *****************************************************************
       Z-POST-COPYRIGHT.
           display SIM-TITLE     upon console
           display SIM-COPYRIGHT upon console
           exit.

      *****************************************************************
       Z-POST-NOTE-AND-CLEAR.
           move 'NOTE' to SIMODUMP-REQUEST
           call 'SIMODUMP' using SIMODUMP-PASS-AREA
           move SPACES to SIMODUMP-BUFFER
           exit.

      *****************************************************************
       Z-THANK-YOU.
           display SIM-THANKS-01 upon console
           display SIM-THANKS-02 upon console
           exit.
      *****************************************************************
      *      This example is provided by SimoTime Technologies        *
      *        Our e-mail address is: helpdesk@simotime.com           *
      *     Also, visit our Web Site at http://www.simotime.com       *
      *****************************************************************

Table of Contents Previous Section Next Section Summary

The purpose of this document is to assist a reader in developing a better understanding of the various numeric formats that are supported by an IBM Mainframe System. This document may be used to assist as a tutorial for new programmers or as a quick reference for experienced programmers.

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

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

Table of Contents Previous Section Next Section Software Agreement and Disclaimer

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

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

Table of Contents Previous Section Next Section Downloads and Links

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

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

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

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

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

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

Link to Internet   Link to Server   Explore the Numbers Connection for additional information about the structure and processing of numeric data items (or numeric fields).

Link to Internet   Link to Server   Explore The Binary or COMP format for numeric data strings. This numeric structure is supported by COBOL and may be explicitly defined with the "USAGE IS COMP" or "USAGE IS BINARY" clause.

Link to Internet   Link to Server   Explore The Edited for Display format for numeric data strings. This numeric structure is supported by COBOL and may be used with an edit-mask to prepare the presentation for readability by human beings.

Link to Internet   Link to Server   Explore The Packed-Decimal or COMP-3 format for numeric data strings. This numeric structure is supported by COBOL and may be explicitly defined with the "USAGE IS COMP-3" clause.

Link to Internet   Link to Server   Explore The Zoned-Decimal format for numeric data strings. This numeric structure is the default numeric for COBOL and may be explicitly defined with the "USAGE IS DISPLAY" clause.

Link to Internet   Link to Server   Explore How to do EBC to ASC Data Conversion of an 80 byte Data Structure. The data structure contains ASCII or EBCDIC Text Strings and Numeric Values that use a Binary, Packed Decimal or Zoned Decimal format. The binary strings will be bypassed, the numeric strings will be processed based on their numeric type and the text strings will be converted from EBC to ASC based on a user selected conversion table. This document will describe and demonstrate the conditional processing of individual string types within a data structure based on a COBOL copy file that defines the data structure.

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

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

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

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

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

Table of Contents Previous Section Next Section Internet Access Required

The following links will require an Internet connect.

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

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

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

Explore the GnuCOBOL Technologies available from SourceForge. SourceForge is an Open Source community resource dedicated to helping open source projects be as successful as possible. GnuCOBOL (formerly OpenCOBOL) is a COBOL compiler with run time support. The compiler (cobc) translates COBOL source to executable using intermediate C, designated C compiler and linker. This link will require an Internet Connection.

Table of Contents Previous Section Next Section Glossary of Terms

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

Table of Contents Previous Section Next Section Contact or Feedback

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

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

 

We appreciate hearing from you.

Table of Contents Previous Section Next Section Company Overview

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

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

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

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


Return-to-Top
COBOL Numeric Formats, Convert Numeric Formats using COBOL
Copyright © 1987-2025
SimoTime Technologies and Services
All Rights Reserved
When technology complements business
http://www.simotime.com