|
|||||
|
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.
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 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
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.
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
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
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
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 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
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 |
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.
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.
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. |
Check out The SimoTime Glossary for a list of terms and definitions used in the documents provided by SimoTime.
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.
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 |