The Numbers Connection
When technology complements business   Managing the Numeric Formats
Copyright © 1987-2008 SimoTime Enterprises, LLC  All Rights Reserved  http://www.simotime.com

  Introduction
  Description of Various Numeric Formats
 
  Binary Format
  Packed Decimal Format
  Zoned Decimal Format
  Edited Numeric Format
  The Micro Focus Environment
 
  Setting Micro Focus Directives
  EBCDIC and ASCII
  Mainframe Express
  Net Express
  Managing Numeric Formats, Sample Programs
 
  Numeric Field, Introduction to Internal Numeric Structures
  Numeric Field, Right-Adjust and Zero-Fill
  Numeric Field, Commonly Used Formats and Sizes
  Numeric Field, Testing or Scanning
  Numeric Field, Printing and Editing
  Numeric Field, Leading Spaces and Zeroes
  Numeric Field, Convert Numbers to Words or Digits to Text
  Possibilities and Considerations
 
  S0C7 or RTS-163
  Numeric Conversion Techniques
  Summary
 
  Software Agreement and Disclaimer
  Downloads and Links to Similar Pages
  Glossary of Terms
  Comments or Suggestions
  About SimoTime
 
 Quick Connects 
The Assembler Connection
The COBOL Connection
The JCL Connection
The Numbers Connection
The SQL Connection
The VSAM-QSAM-SORT Connection
 References
ASCII / EBCDIC Tables
Data Management
File Status Codes
File Transfer Protocol
Glossary of Terms
Search Engines and Links
Training and Sel Study
Help Desk for SimoTime

Introduction
(Next) (Previous) (Table-of-Contents)

The Numbers Connection provides a suite of sample programs and documentation that provide techniques and processes for managing the various numeric formats used on an IBM Mainframe or the Micro Focus COBOL environments.

Description of Various Numeric Formats
(Next) (Previous) (Table-of-Contents)

This section provides an overview of the most commonly used numeric formats with links for additional detailed information and white papers.

Binary Format
(Next) (Previous) (Table-of-Contents)

This document describes the binary format. This numeric field format is coded in COBOL as "USAGE IS COMPUTATIONAL" and is usually coded in its abbreviated form of COMP. This may also be coded with the keyword BINARY. For additional detail refer to the Binary Field Format documentation available on the SimoTime web site.

Packed Decimal Format
(Next) (Previous) (Table-of-Contents)

This document describes the packed-decimal format. This numeric field format is coded in COBOL as "USAGE IS COMPUTATIONAL-3" and is usually coded in its abbreviated form of COMP-3. For additional detail refer to the Packed-Decimal Field Format documentation available on the SimoTime web site.

Zoned Decimal Format
(Next) (Previous) (Table-of-Contents)

This document describes the zoned-decimal format. This numeric field type is coded in COBOL as "USAGE IS DISPLAY" and is the default format if the USAGE clause is missing. For additional detail refer to the Zoned-Decimal Field Format documentation available on the SimoTime web site.

Edited Numeric Format
(Next) (Previous) (Table-of-Contents)

This document describes the edited numeric format. This is coded in COBOL using an "edit mask" in the picture clause. An example would be PIC ZZZ.99+. For additional detail refer to the Edited Field Format documentation available on the SimoTime web site.

The Micro Focus Environment
(Next) (Previous) (Table-of-Contents)

Micro Focus Directives
(Next) (Previous) (Table-of-Contents)

Management (i.e. processing, storage and retrieval) of the various numeric formats has been and continues to be a challenge on the mainframe. When transferring data files that contain the various numeric formats from the Mainframe to a Windows or UNIX platform the challenges are transferred along with the files. Micro Focus (on the Windows and UNIX platforms) offers a number of COBOL compiler directives to help deal with the challenges of managing the various numeric formats.

The sequence in which the directives are specified is also important since some directives will set other directives. For example, the DIALECT directive that specifies a mainframe dialect will set CHARSET(EBCDIC). If the desired encoding is ASCII then the CHARSET(ASCII) directive must follow the DIALECT directive.

Directive
or
Function
Description
DIALECT The DIALECT(ENTCOBOL) should be the first directive specified. This will ensure a mainframe dialect.
CHARSET If the target environment is ASCII-encoded then use the CHARSET(ASCII) directive must follow the DIALECT directive that specifies a mainframe dialect.
IBMCOMP In word-storage mode every data item of USAGE COMP or COMP-5 occupies either two bytes or a multiple of four bytes.
NOTRUNC Truncate in binary to the capacity of the allocated storage, on all non-arithmetic stores into COMP, BINARY and COMP-4 items
DE-EDIT The DE-EDIT”1” directive may be required if the program being compiled does moving between edited numeric fields.
NUMPROC(PFD) Given X'sd', where s is the sign representation and d represents the digit, when you use NUMPROC(PFD), the compiler assumes that the sign in your data is one of the three preferred signs:
1. Signed positive or 0: X'C'
2. Signed negative: X'D'
3. Unsigned or alphanumeric: X'F'
The following is a list of the directives used to emulate the NUMPROC(PFD) environment.
HOSTNUMMOVE HOSTNUMCOMPARE NOSIGNFIXUP HOSTARITHMETIC CHECKNUM
NUMPROC(NOPFD) On the mainframe when the NUMPROC(NOPFD) compiler option is in effect, the compiler accepts any valid sign configuration. The preferred sign is always generated in the receiver. NUMPROC(NOPFD) is less efficient than NUMPROC(PFD), but you should use it whenever data that does not use preferred signs might exist. If an unsigned, external-decimal (or zoned-decimal) sender is moved to an alphanumeric receiver, the sign is unchanged (even with NUMPROC(NOPFD)).
The following is a list of the directives used to emulate the NUMPROC(NOPFD) environment.
HOSTNUMMOVE HOSTNUMCOMPARE SIGNFIXUP HOSTARITHMETIC CHECKNUM
DEFAULTBYTE"ii" The "ii" is a decimal value.
Set to DEFAULTBYTE"32" immediately by CHARSET"ASCII".
Set to DEFAULTBYTE"00" immediately by CHARSET"EBCDIC", MS, IBM-MS or PC1.
If you want to specify an EBCDIC space use DEFAULTBYTE"64".
Note 1: If the default byte is to be changed and the CHARSET directive is used then DEFAULTBYTE must follow the CHARSET directive.
Note 2: If a COBOL program processes a table and the index (or subscript for the table) is not initialized this will not produce an abnormal termination on the mainframe. However, if the program is ported to a Micro Focus environment with ASCII encoding the index will be initialized to spaces and this will cause a problem with an invalid subscript error. Changing the default byte to "00" for the ASCII encoded environment will correct the problem. Correcting the program to initialize the index (or subscript) would be a better solution to the problem.

Micro Focus EBCDIC and ASCII
(Next) (Previous) (Table-of-Contents)

When converting data files from a Mainframe EBCDIC-encoded format to a Micro Focus ASCII-encoded file format the packed (or COMP-3) and binary (or COMP) fields do not need to be converted because they are identical in either encoding scheme. The unsigned, zoned decimal is a simple conversion of the digits between EBCDIC and ASCII. The signed, zoned decimal requires special conversion for the units (or signed) position. This is explained in more detail in a separate document. For the link refer to the Zoned Decimal Format section of this document.

Micro Focus Mainframe Express (MFE)
(Next) (Previous) (Table-of-Contents)

Mainframe Express is the development environment that runs on a Windows platform and is used to develop, test and support COBOL-oriented applications that are intended to run on an IBM Mainframe with z/OS. The directives are preset to map to mainframe requirements. EBCDIC-encoding and support for mainframe numeric formats is supported in the Mainframe Express environment.

Micro Focus Net Express
(Next) (Previous) (Table-of-Contents)

Net Express is the development environment that runs on a Windows platform and is used to develop, test and support COBOL-oriented applications that are intended to run in a WIndows or UNIX environment. The default is to use the ASCII-encoding. If a mainframe application is being migrated to a Windows or UNIX environment then directives must be set to map to mainframe requirements for processing numeric fields.

Managing Numeric Formats, Sample Programs
(Next) (Previous) (Table-of-Contents)

This section provides links to sample programs that process, convert, print or export a variety of numeric data items that are stored in a variety of formats.

Numeric Field, Introduction to Internal Numeric Structures
(Next) (Previous) (Table-of-Contents)

This suite of example programs will describe the various numeric formats and their internal structures. The examples will also show how numeric fields may be converted from one format to another in preparation for printing, displaying or exporting to a non-mainframe or non-COBOL environment. The COBOL programs are written using the COBOL/2 dialect but also work with COBOL for MVS and COBOL/370. Simply click on one of the following items to learn more or download this sample set of programs.

Numeric Field, Right-Adjust and Zero-Fill
(Next) (Previous) (Table-of-Contents)

This suite of programs provides an example of a routine that will Right-Adjust a text string within a field and fill the left-most or high-order bytes with zeroes. The resulting field is also tested for numeric values and a return code (RA12-RESPOND) is set to zero (0) if numeric and eight (8) if not numeric. Two COBOL programs are provided. The first program is a demonstration program that reads a file containing "RIGHTADJ-info" records and calls the second COBOL program that actually does the right-adjust, zero-fill processing. The COBOL programs are written using the COBOL/2 dialect but also work with COBOL for MVS and COBOL/370. Simply click on the following item to learn more or download this set of programs.

Numeric Field, Commonly Used Formats and Sizes
(Next) (Previous) (Table-of-Contents)

This suite of example programs will describe the use, format and size of some of the commonly used numeric fields of the COBOL programming language. This example also illustrates how to redefine a numeric field and how to display the actual hexadecimal content of a numeric field. The COBOL programs are written using the COBOL/2 dialect but also work with COBOL for MVS and COBOL/370. Simply click on one of the following items to learn more or download this sample set of programs.

Numeric Field, Testing or Scanning
(Next) (Previous) (Table-of-Contents)

This program suite provides an example of how a COBOL program can test a numeric field for a numeric value or scan a numeric field using reference modification. The COBOL programs are written using the COBOL/2 dialect but also work with COBOL for MVS and COBOL/370. Simply click on one of the following items to learn more or download this sample set of programs.

Numeric Field, Printing and Editing
(Next) (Previous) (Table-of-Contents)

This suite of example programs will describe how to prepare various numeric fields (i.e. packed or COMP-3, binary or COMP and signed, zoned decimal or USAGE IS DISPLAY) for printing. The COBOL programs are written using the COBOL/2 dialect but also work with COBOL for MVS and COBOL/370. Simply click on one of the following items to learn more or download this sample set of programs.

Numeric Field, Leading Spaces and Zeroes
(Next) (Previous) (Table-of-Contents)

This suite of example programs (COBOL, JCL and CMD files) will describe the process to compile and execute a COBOL program that is downloaded from a mainframe. The challenge with this program is that it is expected to process the various numeric items in the same manner as the mainframe. For example, a zoned-decimal field that contains leading spaces should not cause an ABEND (i.e. 163 error on Micro Focus) but should treat the leading spaces as zeroes and complete the arithmetic calculation. The COBOL programs are written using the COBOL/2 dialect but also work with COBOL for MVS and COBOL/370. Simply click on one of the following items to learn more or download this sample set of programs.

Numbers to Words or Digits to Text
(Next) (Previous) (Table-of-Contents)

This suite of programs provides an example of how a COBOL program calls a COBOL routine to create a 150-character text data string from a 12-digit numeric field. The COBOL programs are written using the COBOL/2 dialect but also work with COBOL for MVS and COBOL/370. Simply click on one of the following items to learn more or download this sample set of programs.

Possibilities and Considerations
(Next) (Previous) (Table-of-Contents)

This section provides information about additional Considerations and some coding techniques that may be used when processing numeric fields..

S0C7 or RTS-163
(Next) (Previous) (Table-of-Contents)

On the mainframe a program check interrupt 7 (or S0C7 that is often referred to as a Sock-Seven error) occurs when attempting to process a numeric field when the field contains non-numeric characters. In the Micro Focus environment an RTS-163 (Run Time System) error occurs. In both cases the program is abnormally terminated (ABEND's).

Numeric Conversion Techniques
(Next) (Previous) (Table-of-Contents)

With COBOL is very simple to convert between the various numeric formats. Simply used the Working Storage definitions of the fields and move from one format to the other. The conversion will take place during the move process. For example, the following shows the working storage definition of a packed-decimal field and an edited numeric field that will have a leading sign and an explicit decimal point.

      *    The following defines a signed, packed-decimal field.
      *    The length of this field is 3 bytes & contains 5 digits.
       01  PACK-DECIMAL-S3V2   pic S9(3)V99 COMP-3 value 0.

      *    The following defines an edited field for numeric
      *    values and will contain an explicit decimal point. This
      *    is standard COBOL coding and is ANSI/85 compliant.
      *    The length of this field is 7 bytes.
       01  PRINT-NUMBER        pic +ZZZ.99.

The following shows the move statement that will move the content of a packed-decimal field to an edited numeric field and convert the numeric format in the process of doing the move.

       PROCEDURE DIVISION.

      *    The following statement will place a value into the 
      *    packed-decimal field. The actual value will be x'00123C'.
           add 1.23 to ZERO giving PACK-DECIMAL-S3V2

      *    The following statement will place the arithmetic value of
      *    the packed-decimal field into the edited print field. The
      *    actual value will be x'4E4040F14BF2F3'. This results in
      *    converting the packed-decimal field but has leading spaces.
           move PACK-DECIMAL-S3V2 to PRINT-NUMBER

      *    The following statement will replace the leading spaces 
      *    with zeroes. The resulting value will be x'4EF0F0F14BF2F3'.
           inspect PRINT-NUMBER replacing all SPACE by ZERO
      *    The preceding 2 statements are the only statements required  
      *    to do the conversion from packed-decimal to zone-decimal.    
      *    The additional code in this section is used to display the   
      *    input and result field values in hexadecimal dump format.    

Summary
(Next) (Previous) (Table-of-Contents)

The purpose of this document is to assist as a tutorial for new programmers or as a quick reference for experienced programmers. These sample programs are made available on an "as-is" basis and may be downloaded in accordance with the Software Agreement and Disclaimer that is explained in the following section of this document. As always, it is the programmer's responsibility to thoroughly test all programs.

Software Agreement and Disclaimer
(Next) (Previous) (Table-of-Contents)

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

Permission to use, copy, modify and distribute this software for a non-commercial purpose and without fee is hereby granted, provided the SimoTime copyright notice appear on all copies of the software. The SimoTime name or Logo may not be used in any advertising or publicity pertaining to the use of the software without the written permission of SimoTime Enterprises.

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

If you have any questions, suggestions or comments please call or send an e-mail to: helpdesk@simotime.com

Downloads and Links to Similar Pages
(Next) (Previous) (Table-of-Contents)

Please view the complete list of SimoTime Z-Pack Examples at http://www.simotime.com/sim4dzip.htm.

Note: You must be attached to the Internet to download a Z-Pack or view the list.

Check out The Assembler Connection in the SimoTime Library for more examples of mainframe Assembler techniques and sample code.

Check out The COBOL Connection in the SimoTime Library for more examples of mainframe COBOL techniques and sample code.

Check out   The SQL Connection in the SimoTime Library for more mainframe SQL examples.

Check out The VSAM - QSAM Connection in the SimoTime Library for more examples of mainframe VSAM and QSAM coding techniques and sample code.

The following table provides a quick link to the commonly used numeric formats.

Numeric Type Description
Zoned Decimal This document describes the zoned-decimal format. This is coded in COBOL as USAGE IS DISPLAY and is the default format if the USAGE clause is missing.
Packed Decimal This document describes the packed-decimal format. This is coded in COBOL as USAGE IS COMPUTATIONAL-3 and is usually coded in its abbreviated form of COMP-3.
Binary This document describes the binary format. This is coded in COBOL as USAGE IS COMPUTATIONAL and is usually coded in its abbreviated form of COMP. This may also be coded with the keyword BINARY.
Edited Numeric This document describes the edited numeric format. This is coded in COBOL using an edit mask in the picture clause. An example would be PIC ZZZ.99+.

Check out The SimoTime Library for a wide range of topics for Programmers, Project Managers and Software Developers.

To review all the information available on this site start at The SimoTime Home Page.

Glossary of Terms
(Next) (Previous) (Table-of-Contents)

Check out  The SimoTime Glossary  for a list of terms and definitions used in the documents provided by SimoTime.

Comments or Suggestions
(Next) (Previous) (Table-of-Contents)

If you have any questions, suggestions or comments please call or send an e-mail to: helpdesk@simotime.com.

About SimoTime Enterprises, LLC
(Next) (Previous) (Table-of-Contents)

Founded in 1987, SimoTime Enterprises is a privately owned, Limited Liability Corporation located in Novato, California. We specialize in the creation and deployment of business applications using new or existing technologies and services. We have a team of individuals that understand the broad range of technologies being used in today's environments. This includes the smallest thin client using the Internet and the very large mainframe systems. There is more to making the Internet work for your company's business than just having a nice looking WEB site. It is about combining the latest technologies and existing technologies with practical business experience. It's about the business of doing business and looking good in the process. Quite often, to reach larger markets or provide a higher level of service to existing customers it requires the newer Internet technologies to work in a complementary manner with existing corporate mainframe systems. Whether you want to use the Internet to expand into new market segments or as a delivery vehicle for existing business functions simply give us a call or check the web site at http://www.simotime.com.


Return-to-Top
Copyright © 1987-2008  SimoTime Enterprises, LLC  All Rights Reserved
When technology complements business
http://www.simotime.com
Version 05.11.11