Edited Numeric Format
When technology complements business   Description & Discussion
Copyright © 1987-2008  SimoTime Enterprises, LLC  All Rights Reserved  http://www.simotime.com

 
Introduction Version 06.04.20
  Prepare a Numeric Field for Print or Display
 
  Binary Field, Prepare for Print or Display
  Packed-Decimal Field, Prepare for Print or Display
  Zoned-Decimal Field, Prepare for Print or Display
  Prepare a Numeric Field for Export
  Possibilities and Considerations
  Summary
 
  Software Agreement and Disclaimer
  Downloads and Links to Similar Pages
  Glossary of Terms
  Comments or Suggestions
  About SimoTime

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

This document will focus on the discussion of an edited numeric format (or using an edit mask) that is typically used by COBOL programmers that maintain or support Mainframe applications. The edited numeric format is typically used to prepare or convert numeric data that is stored in a variety of formats into a format that is easily read by human beings or easily exported to a non-Mainframe or non-COBOL environment such as an excel spreadsheet running on a Windows platform.

Note: The items in this document are appropriate for applications that are written in COBOL, Mainframe Assembler (HLASM) or PL/I. The IBM Mainframe architecture drove many of the numeric formats that existed in the early ANSI specifications for COBOL.and have been carried forward to the current COBOL ANSI specifications.

Prepare a Numeric Field for Print or Display
(Next) (Previous) (Table-of-Contents)

The following table shows the conversion of Zoned-Decimal (USAGE IS DISPLAY), Binary (USAGE IS COMP) and Packed-Decimal (USAGE IS COMP-3) fields with various values to a human readable field for printing or displaying. The edited field (or result field) will have the leading zeroes suppressed and contain an explicit decimal point. The trailing sign is a separate character. Since the edit mask contains a "-" (or minus sign) the sign will only print for negative numbers as a "-" or minus sign. The plus sign is a space character. If the value of the input field is greater than 999.99 then commas will be inserted and printed or displayed.

Input Output
Input Field Usage Value Hex ASCII Hex EBCDIC
PIC S9(5)V(2) DISPLAY 0 30 30 30 30 30 30 30 F0 F0 F0 F0 F0 F0 C0
  COMP   00 00 00 00 00 00 00 00
  COMP-3   00 00 00 0C 00 00 00 0C
  DISPLAY +1.23 30303030313233 F0 F0 F0 F0 F1 F2 C3
  COMP   00 00 00 7B 00 00 00 7B
  COMP-3   00 00 12 3C 00 00 12 3C
  DISPLAY +9876.54 30 30 39 38 37 36 35 F0 F0 F9 F8 F7 F6 C5
  COMP   00 0F 12 06 00 0F 12 06
  COMP-3   09 87 65 4C 09 87 65 4C
  DISPLAY -10.00 30 30 30 31 30 30 70 F0 F0 F0 F1 F0 F0 D0
  COMP   FF FF FC 18 FF FF FC 18
  COMP-3   00 01 00 0D 00 01 00 0D
Edit Mask Result 
PIC ZZ,ZZZ.99- .00 
  .00 
  .00 
  1.23 
  1.23 
  1.23 
  9,876.54 
  9,876.54 
  9,876.54 
  10.00-
  10.00-
  10.00-

The following sections will show snippets of COBOL code that may be used to edit (prepare or convert) the various numeric formats for printing or displaying. The technique used for the Binary, Packed-Decimal and Zoned-Decimal is the same.

Binary Field, Prepare for Print or Display
(Next) (Previous) (Table-of-Contents)

The following shows sample COBOL source code for preparing a binary field to be printed or displayed.

       WORKING-STORAGE SECTION.
       ...
       01  BINARY-FIELD            PIC S9(5)V(2)   USAGE IS COMP.
      *
       01  EDIT-DROP-LEAD-ZEROES   PIC ZZ,ZZZ.99-.
       ...
       PROCEDURE DIVISION.
      *    If the PACKED-DECIMAL-FIELD had more decimal positions
      *    than the EDIT-WITH-BLANK-FILL field then the following would
      *    truncate the decimal positions without rounding.
           move BINARY-FIELD to EDIT-DROP-LEAD-ZEROES 
      *    If the PACKED-DECIMAL-FIELD had more decimal positions
      *    than the EDIT-WITH-BLANK-FILL field then the following would
      *    do the proper rounding.
           add BINARY-FIELD to ZERO
                giving EDIT-DROP-LEAD-ZEROES ROUNDED

Packed-Decimal Field, Prepare for Print or Display
(Next) (Previous) (Table-of-Contents)

The following shows sample COBOL source code for preparing a packed-decimal field to be printed or displayed.

       WORKING-STORAGE SECTION.
       ...
       01  PACKED-DECIMAL-FIELD    PIC S9(5)V(2)   USAGE IS COMP-3.
      *
       01  EDIT-DROP-LEAD-ZEROES   PIC ZZ,ZZZ.99-.
       ...
       PROCEDURE DIVISION.
      *    If the PACKED-DECIMAL-FIELD had more decimal positions
      *    than the EDIT-WITH-BLANK-FILL field then the following would
      *    truncate the decimal positions without rounding.
           move PACKED-DECIMAL-FIELD to EDIT-DROP-LEAD-ZEROES 
      *    If the PACKED-DECIMAL-FIELD had more decimal positions
      *    than the EDIT-WITH-BLANK-FILL field then the following would
      *    do the proper rounding.
           add PACKED-DECIMAL-FIELD to ZERO
                giving EDIT-DROP-LEAD-ZEROES ROUNDED

Zoned-Decimal Field, Prepare for Print or Display
(Next) (Previous) (Table-of-Contents)

The following shows sample COBOL source code for preparing a zoned-decimal field to be printed or displayed.

       WORKING-STORAGE SECTION.
       ...
       01  ZONED-DECIMAL-FIELD    PIC S9(5)V(2)   USAGE IS COMP-3.
      *
       01  EDIT-DROP-LEAD-ZEROES   PIC ZZ,ZZZ.99-.
       ...
       PROCEDURE DIVISION.
      *    If the PACKED-DECIMAL-FIELD had more decimal positions
      *    than the EDIT-WITH-BLANK-FILL field then the following would
      *    truncate the decimal positions without rounding.
           move ZONED-DECIMAL-FIELD to EDIT-DROP-LEAD-ZEROES 
      *    If the PACKED-DECIMAL-FIELD had more decimal positions
      *    than the EDIT-WITH-BLANK-FILL field then the following would
      *    do the proper rounding.
           add ZONED-DECIMAL-FIELD to ZERO
                giving EDIT-DROP-LEAD-ZEROES ROUNDED

Prepare a Numeric Field for Export
(Next) (Previous) (Table-of-Contents)

The following table show the conversion of Zoned-Decimal (USAGE IS DISPLAY), Binary (USAGE IS COMP) and Packed-Decimal (USAGE IS COMP-3) fields with various values to a text field for exporting.

Input Output
Input Field COBOL Usage Value Hex Value
PIC S9(5)V(2) DISPLAY 0 x'F0F0F0F0F0F0C0'
  COMP   x'00000000'
  COMP-3   x'00000C'
  DISPLAY 123 x'F0F0F0F0F1F2C3'
  COMP   x'0000007B'
  COMP-3   x'0000123C'
  DISPLAY 987654 x'F0F0F9F8F7F6C5'
  COMP   x'000F1206'
  COMP-3   x'0987654C'
Edit Mask Result
PIC +99999.99 +00000.00
  +00000.00
  +00000.00
  +00001.23
  +00001.23
  +00001.23
  +09876.54
  +09876.54
  +09876.54

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

This section describes possible situations that may need special consideration and may take additional time to properly address.

1. When moving values from numeric fields to edited fields be sure the number of digits are specified for both fields are the same. If the edited field is smaller then truncation occurs.
2. If fewer decimal positions will be printed or displayed and rounding is required the following technique will do a move with rounding.
    add NUMERIC-FIELD to ZERO giving EDITED-FIELD ROUNDED

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

The purpose of this document is to provide information about an edited numeric format that is typically used to prepare or convert numeric data that is stored in a variety of formats into a format that is easily read by human beings or may be exported to a non-mainframe environment such as an excel spreadsheet running in a Windows environment.

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

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

SimoTime Enterprises makes no warranty or representations about the suitability of the software, documentation or learning material for any purpose. It is provided "AS IS" without any 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, documentation or training material.

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

The Home Page for The SimoPATH Series  is the starting point to view information about training sessions and learning materials available from SimoTime Enterprises.

This item will provide a link to  an ASCII or EBCDIC translation table. A column for decimal, hexadecimal and binary is also included.

This document provides a quick summary of the  File Status Key  for VSAM data sets and QSAM files.

The hexadecimal dump of the parameter-buffer uses the same technique as describe in another SimoTime example that describes the dumping of a data string using COBOL. The name of the member that does the actual hexadecimal dump is called SimoDUMP. A copy file (PASSDUMP.CPY) is provided for defining the pass area.

You may view the complete list of examples at http://www.simotime.com/sim4dzip.htm and many are available as a SimoTime Z-Pack (a zip file package with sample source code, data and documentation).

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

The following table provides a list of white papers describing the numeric formats used on an IBM Mainframe system. A couple of sample COBOL programs are also included.

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+.
number01 This example describes some commonly used techniques for managing various numeric formats available on the mainframe.
spsnum01 This is an introductory, self-study course about the commonly used numeric formats available on the mainframe. The course material may be purchased from SimoTime. The documentation may be viewed online.

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

We appreciate your comments and feedback.

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 06.01.01