The COBOL Connection
When technology complements business   COBOL Examples
Copyright © 1987-2008 SimoTime Enterprises, LLC  All Rights Reserved  http://www.simotime.com

  Introduction
 
  Introduction, Shared Callable Routines and Driver Programs
  Introduction, The Customer Master File
  Introduction, The Item Master File
  The Sample COBOL Programs
 
  Bit Manipulation with COBOL
  COBOL Call with Procedure Pointer & External Data Items
  Collating Sequences for EBCDIC and ASCII Environments
  Copy File with Replacing Function
  Data Access Programming Examples using COBOL
 
  Alternate Index with a VSAM, Keyed Sequential Data Set (KSDS)
  Callable Access, Sequential Files, 80-Byte Records
  Comma Delimited Files, Create a New File
  Comma Delimited Files, Read and Parse Existing File
  Embedded SQL, Relational Data Base
  Generation Data Group (GDG)
  QSAM processing with a Single COBOL Program
  QSAM processing using COBOL with a COBOL I/O Routine
  QSAM processing using COBOL with an Assembler I/O Routine
  Variable Length Records (process using Standard COBOL)
  Variable Length Records (with Byte-Stream I/O)
  Variable Length Records (Transfer, Share, Convert and Compare)
  VSAM, KSDS processing with a Single COBOL Program
  VSAM, KSDS processing using COBOL with a COBOL I/O Routine
  VSAM, KSDS processing using COBOL with an Assembler I/O Routine
  Large Files with Micro Focus (greater than 2-gig)
  Data Fields (Editing, Manipulating and Validating)
 
  Data Fields (Binary or Hexadecimal)
 
  Print or Display a Field with Binary Values
  Data Fields (Text or Alpha-numeric)
 
  Text Field, Justify Text within a Field (Center, Left or Right Justify)
  Text Field, Parse a Data String , Process Leading and Multiple, Embedded Spaces
  Text Field, Parse, Convert, Dump
  Text Field, Search and Replace a Text String (Different Lengths)
  Data Fields (Numeric)
 
  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, Convert Numbers to Words or Digits to Text
  Numeric Field, Leading Spaces and Zeroes
  Date Validation, Formatting and Conversion
  Date Calculation, Difference-in-Days
  Diagnostic Aids
 
  Diagnostic Aids, Hexadecimal Format, Display or Dump of Data Files
 
  Diagnostic Aids, Embedded or Non-Printable Characters in Source Code
  Diagnostic Aids, Hex-Dump of Fields or Data Items
  Diagnostic Aids, Hex-Dump of VSAM, KSDS
  Diagnostic Aids, Hex-Dump of Sequential or ASCII/Text Files
  Diagnostic Aids, Hex-Dump of VSAM, KSDS
  Diagnostic Aids, Snap Dump of Working Storage
  Diagnostic Aids, ABEND Routine for Micro Focus Environment
  Diagnostic Aids, Program Tracking and Elapsed Time
  Diagnostic Aids, Compare Directory Content
  Environment, Command Line & File Name for Net Express
  File Conversion, Volume 1, EBCDIC & ASCII, QSAM & VSAM
  File Conversion, Volume 2, Host to PC to Host
  File Status Codes, Program Example, Format and Display
  Floating Point Arithmetic
  Internal Reader (INTRDR), Submit a Job
  Mailing Labels, Read an Indexed File, Create and Sort a Sequential File
  Parameter Passing from JCL
  Record Layout from COBOL Copy File
  Street Address, Parsing, Editing and Formatting
  Table Processing, Define, Load, Search and Sort
 
  Table Processing, Define, Load, Search and Sort
  Table Processing, Bubble Sort
  Table Processing, Create or Define a Table of Binary Values
  Tips and Coding Techniques with COBOL
  Java and COBOL
 
  Java, COBOL and Micro Focus
  Java, COBOL and Bridgewater
  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 Self Study
Help Desk for SimoTime

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

The COBOL Connection provides a suite of sample programs (or COBOL programming examples) that are written using the IBM VS COBOL II dialect with few exceptions. For example, programs that access the system date may require the COBOL/390 dialect to be Y2K compliant. In many examples the programs are coded to the ANSII'85 standard with the exception of programs that use hexadecimal notation (i.e. value X'1F'). The Hexadecimal notation is a COBOL II syntax and is also part of the ANSI/2000 standard. The programs will also work with COBOL for MVS, COBOL/370 and COBOL/390. A few programs use Micro Focus syntax and are documented as such and will not run on the mainframe. These programs are intended for a Windows or UNIX platform running Micro Focus (or microfocus) COBOL. JCL members are provided to run the batch jobs as MVS batch jobs on an IBM mainframe or as a project with Micro Focus Mainframe Express (MFE) running on a PC with Windows. For more information about Micro Focus refer to http://www.microfocus.com.

The sample programs may also be compiled using Micro Focus Net Express running on a PC with Windows. In the Net Express environment adjustments for the ASCII environment, the mapping of the COBOL file names to the PC file names and replacing JCL with BAT or CMD files will be required. For more information about this environment contact the helpdesk@simotime.com. SimoTime does provide the predefined project files for Mainframe Express and Net Express running on Windows/2000, NT or XP.

Most of the COBOL programs may also be compiled and executed on a UNIX system or an AS/400. SimoTime does not formally test the sample programs in these environments. However, we do have customers that have used many of the sample programs in these environments.

Many of the applications (sometimes referred to as Legacy Applications) running on IBM Mainframes are written in COBOL and have been providing mission critical business information for ten years or longer. Some applications or parts of an application were written over twenty-five years ago. The mainframe continues to be the largest, single platform running applications that leverage the use of the COBOL language. However, it is important to note that COBOL source code that adheres to the ANSI'85 standard may be easily downloaded from the mainframe to a personal computer or UNIX system. Once downloaded it may be compiled and executed on a personal computer or a UNIX system.

The advantages and disadvantages of the proliferation, maintenance or replacement of COBOL applications are not discussed. The COBOL Connection uses a simple value proposition - Legacy Applications, longevity based on continued business value.

Introduction, Shared Callable Routines and Driver Programs
(Next) (Previous) (Table-of-Contents)

This is a collection of the common callable routines and driver programs that may be used by many of the COBOL sample programs provided by SimoTime Enterprises. The COBOL programs are written using the COBOL/2 or COBOL/390 dialect but also work with COBOL for MVS, COBOL/370 and COBOL/390. The date and logging routines require COBOL/390 to be Y2K compliant. Simply click on one of the following items for more informations

1. Learn more by viewing the documentation for the shared modules
2. Download an evaluation copy of the executables for the shared modules
3. Download an evaluation copy of the source code for the shared modules

Introduction, The Customer Master File
(Next) (Previous) (Table-of-Contents)

On the IBM Mainframe the Customer Master File is a VSAM Keyed Sequential Data Set (referred to as KSDS). On a Windows or UNIX System using Micro Focus the Customer Master File is an Indexed File or Key Sequenced File.

The Customer Master file contains variable length records with the minimum and average record length being the same length of 512 bytes. The key starts in the first position of the record and is 12 bytes in length. The record layout is defined in a COBOL copy file and contains text strings and various numeric formats including zoned-decimal, packed and binary.

This program suite provides an example of how to create and populate a Customer Master File. On the Mainframe System the file is a VSAM, Key-Sequenced-Data-Set (or KSDS). On a Windows or UNIX System the Micro Focus Indexed File format is used. The file contains 512 byte records and the key (or customer number) is twelve (12) bytes starting in the first position of each record. Simply click on one of the following items to  learn more or download this sample set of programs.

Introduction, The Item Master File
(Next) (Previous) (Table-of-Contents)

On the IBM Mainframe the Item Master File is a VSAM Keyed Sequential Data Set (referred to as KSDS). On a Windows or UNIX System using Micro Focus the Item Master File is an Indexed File or Key Sequenced File.

The Item Master file contains variable length records with the minimum and average record length being the same length of 512 bytes. The key starts in the first position of the record and is 12 bytes in length. The record layout is defined in a COBOL copy file and contains text strings and various numeric formats including zoned-decimal, packed and binary.

This program suite provides an example of how to create and populate the Item Master File. On the Mainframe System the file is a VSAM, Key-Sequenced-Data-Set (or KSDS). On a Windows or UNIX System the Micro Focus Indexed File format is used. The file contains 512 byte records and the key (or item number) is twelve (12) bytes starting in the first position of each record. Simply click on one of the following items to  learn more  or  download  this sample set of programs.

The Sample COBOL Programs
(Next) (Previous) (Table-of-Contents)

This section provides a brief description of each of the sample COBOL programs. Also, a link for downloading or accessing detailed information is provided.

Bit Manipulation
(Next) (Previous) (Table-of-Contents)

Bit manipulation is usually considered something that cannot be done using COBOL. This is an example of how COBOL can do bit-level manipulation. Both 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.

COBOL Call with Procedure Pointer & External Data Items
(Next) (Previous) (Table-of-Contents)

This suite of programs will describe how to use procedure pointers and external data items. A procedure pointer will be defined in a primary (or mainline) program. The procedure pointer will then be used to call a secondary program. A linkage section will not be required in the secondary program since the data will be accessed (or shared) using external data items. Both COBOL programs are written using the COBOL/390 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.

Collating Sequence for EBCDIC and ASCII Environments
(Next) (Previous) (Table-of-Contents)

This suite of sample programs describes the ASCII and EBCDIC sorting or collating sequences and provides an example of programming logic that will work in an EBCDIC environment (i.e. mainframe) but fail in an ASCII environment (i.e. PC with Windows or UNIX). The COBOL programs were written using the COBOL/390 dialect and will execute on an IBM Mainframe or the platforms supported by Micro Focus COBOL (i.e. Windows and UNIX). Simply click on one of the following items to learn more by viewing the documentation or download an evaluation copy of this sample set of programs.

Copy File with Replacing Function
(Next) (Previous) (Table-of-Contents)

This suite of sample programs describes how to use the replacing function with a copy file in a COBOL program. The COBOL programs were written using the COBOL/390 dialect and will execute on an IBM Mainframe or the platforms supported by Micro Focus COBOL (i.e. Windows and UNIX). Simply click on one of the following items to learn more by viewing the documentation or download an evaluation copy of this sample set of programs.

Note: The COBOL language also has an INSPECT REPLACING function that is used to replace characters or text strings within a field at program execution time. For more information about this function refer to the  Text Field, Search and Replace a Text String  section of this document..

Data Access Programming Examples using COBOL
(Next) (Previous) (Table-of-Contents)

This section contains links or references to programming examples that access various data bases or flat files. The COBOL programs were written using the COBOL/2 dialect but also work with COBOL for MVS and COBOL/370.

The examples read existing data sets. Therefore, it will be necessary to create the files or data sets prior to running the examples. To create the data sets refer to the following references.

JCL Name Description
CRTQ0080.JCL This example will create and populate a QSAM file.
CRTK0080.JCL This example will create a catalog entry for a VSAM, Keyed Sequential Data Set (KSDS).
KSD080J1.JCL This example will populate the VSAM, Keyed Sequential Data Set (KSDS) with data records.

Alternate Index for VSAM, KSDS
(Next) (Previous) (Table-of-Contents)

This program suite provides an example of how a COBOL program can process a VSAM, Keyed Sequential Data Set (KSDS) with a primary key and an alternate index. The COBOL programs are written using the COBOL/2 dialect but 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.

Callable Access, Sequential Files, 80-Byte Records
(Next) (Previous) (Table-of-Contents)

This program suite provides examples of accessing sequential files with 80-byte records via a simply call to an I/O routine. The COBOL programs are written using the COBOL/2 dialect but 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.

Comma Delimited Files, Create a New File
(Next) (Previous) (Table-of-Contents)

This suite of sample programs describes how to read a file of fixed field lengths and create a comma-delimited file of variable length fields with the leading and trailing spaces removed. Simply click on one of the following items to learn more or download this sample set of programs.

Comma Delimited Files, Read and Parse an Existing File
(Next) (Previous) (Table-of-Contents)

This suite of sample programs describes how to read an existing comma-delimited file and create a new column-oriented, fixed-field-length sequential file. Simply click on one of the following items to learn more or download this sample set of programs.

Embedded SQL, Relational Data Base
(Next) (Previous) (Table-of-Contents)

This suite of sample programs will show how to create, manipulate and delete a table within a relational data base. Simply click on one of the following items to learn more or download this sample set of programs.

Generation Data Groups (GDG's)
(Next) (Previous) (Table-of-Contents)

This suite of sample programs describes how to define a Generation Data Group (GDG). Once the GDG is defined the creation of a Generation Date Set (referred to as a generation or GDS) within the group is discussed. The COBOL program is written using the COBOL/2 dialect but works 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.

QSAM processing with a Single COBOL Program
(Next) (Previous) (Table-of-Contents)

This program suite provides an example of how a single COBOL program is used to access a QSAM or Sequential file. The COBOL programs are written using COBOL/2 dialect but also works 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.

QSAM processing using COBOL with a COBOL I/O Routine
(Next) (Previous) (Table-of-Contents)

This program suite provides an example of how a mainline COBOL program calls a mainframe COBOL I/O routine to access a QSAM or Sequential file. The I/O routine will also display the file status codes when an I/O error occurs. 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.

QSAM processing using COBOL with an Assembler I/O Routine
(Next) (Previous) (Table-of-Contents)

This program suite provides an example of how a mainline COBOL program calls a mainframe Assembler I/O routine to access a QSAM sequential file. The COBOL program is written using the COBOL/2 dialect but also work with COBOL for MVS and COBOL/370. The assembler IO routine is written in IBM Mainframe Assembler, it will compile using Assembler/H or HLASM. Simply click on one of the following items to learn more or download this sample set of programs.

Variable Length Records (process using Standard COBOL)
(Next) (Previous) (Table-of-Contents)

This program suite provides an example of how to create and access a sequential file containing variable length records using standard SELECT and FD statements. The COBOL programs are written using the COBOL/2 dialect but also works 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.

Variable Length Records (using Byte-Stream I/O)
(Next) (Previous) (Table-of-Contents)

This program suite provides an example of how to transfer and convert a sequential file containing variable length records. The example includes a description of how to use FTP to download a file without doing a conversion on the Mainframe System. The COBOL programs are written using the Micro Focus dialect and requires Micro Focus Net Express or Micro Focus Mainframe Express. Simply click on one of the following items to learn more or download this sample set of programs.

Variable Length Records (Transfer, Share, Convert, Compare)
(Next) (Previous) (Table-of-Contents)

This program suite provides an example of how to Transfer, Share, Convert and Compare record and line sequential files containing variable length records. The example includes a description of how to use FTP to download a file without doing a conversion on the Mainframe System. The COBOL programs are written using the Micro Focus dialect and requires Micro Focus Net Express. Simply click on one of the following items to learn more or download this sample set of programs.

VSAM, KSDS processing with a Single COBOL Program
(Next) (Previous) (Table-of-Contents)

This program suite provides an example of how a single COBOL program is used to access a VSAM data set. The COBOL programs are written using COBOL/2 dialect but also works 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.

VSAM, KSDS processing using COBOL with a COBOL I/O Routine
(Next) (Previous) (Table-of-Contents)

This program suite provides an example of how a mainline COBOL program calls a mainframe COBOL I/O routine to access a VSAM data set. The I/O routine will also display the file status codes when an I/O error occurs. 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.

VSAM, KSDS processing using COBOL with an Assembler I/O Routine
(Next) (Previous) (Table-of-Contents)

This program suite provides an example of how a mainline COBOL program calls a mainframe Assembler I/O routine to access a VSAM data set. The COBOL program is written using the COBOL/2 dialect but also work with COBOL for MVS and COBOL/370. The assembler IO routine is written in IBM Mainframe Assembler, it will compile using Assembler/H or HLASM. Simply click on one of the following items to learn more or download this sample set of programs.

Large Files with Micro Focus (greater than 2-gig)
(Next) (Previous) (Table-of-Contents)

This program suite provides an example of how to access large files using Micro Focus COBOL. The COBOL program is 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.

Data Fields (Editing, Manipulating and Validating)
(Next) (Previous) (Table-of-Contents)

This section contains links or references to programming examples that process data at the field level. The COBOL programs were written using the COBOL/2 dialect but also work with COBOL for MVS and COBOL/370.

On an EBCDIC or ASCII encoded system each byte is made-up of eight bits. Many of the bytes represent the alphabet, numbers or special characters such as the ampersand or decimal point. The remaining bytes are used for various purposes such as control characters for printing, displaying or transferring data. The COBOL language works with data fields. A field may be a single byte or a string of bytes.

A field may be defined as a text-oriented string of data that contains alpha-numeric values. These fields normally contain values that are printable (i.e. letters, number or special characters). However, this type of field may contain any of the 256 characters. On the mainframe this does not usually cause a serious problem since the print and display managers replace non-printable or non-display values with spaces when the field is moved to the I/O buffer. This can be confusing and a hexadecimal dump of the memory containing the data string would be required to view the actual content. This type of field will be discussed in more detail in the following section about text fields.

A field may be defined as a numeric field that should only contain numeric values. It is possible to get non-numeric values into this type of field and this can cause a serious problem that requires special handling. On the mainframe is an arithmetic operation is attempted on using a numeric field that contains a non-numeric value a program check level 7 will occur. This is also referred to as an S0C7 check (or Sock-Seven check). With Micro Focus this condition will give a 163 error message that states a non-numeric value in a numeric field. Numeric fields come in a variety of different formats that will be discussed in the following section about numeric fields.

Data Fields (Hexadecimal Content)
(Next) (Previous) (Table-of-Contents)

This section will focus on data fields (or data strings) that may have hexadecimal content that is not alphabetic and numeric values.

Print or Display a Field with Binary Values
(Next) (Previous) (Table-of-Contents)

This program suite provides an example of a routine that will replace non-display or non-print values with spaces prior to displaying or printing. The example also shows what happens if a display is attempted with the binary or non-display characters in the text string. The COBOL program is 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.

Data Fields (Text or Alpha-Numeric Content and Definition)
(Next) (Previous) (Table-of-Contents)

This section will focus on data fields (or data strings) that may have alphabetic and numeric content. The various examples will show how the fields are defined and typical processing techniques used with alpha-numeric fields.

Text Field, Justify Text within a Field (Center, Right or Left Justification)
(Next) (Previous) (Table-of-Contents)

This suite of programs provides an example of a routine that will center a text string within a field. It also shows how to left or right justify a text string within a field. Two COBOL programs are provided. The first program is a demonstration program that reads a file containing the JUSTIFY information records and calls the second COBOL program that actually does the text justification. 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.

Text Field, Parse a Data String , Process Leading and Multiple, Embedded Spaces
(Next) (Previous) (Table-of-Contents)

This program suite provides an example of how a COBOL program can parse a data string using reference modification. This example will also show how to create a new field (or data string) with the leading spaces removed and the multiple, embedded spaces replaced with a single space. The length of the text within the new field (or data string) is also calculated. 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.

Text Field, Pass, Parse and Convert a Data String
(Next) (Previous) (Table-of-Contents)

This suite of programs provides examples of how to parse, edit, modify, format and display (standard or hexadecimal dump) various words within a data string. The editing and formatting of a date field are used in this example. 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.

Text Field, Search and Replace a Text String
(Next) (Previous) (Table-of-Contents)

The objective of this suite of programs is to replace a text string within a field based on a search argument with a text string based on a replacement value of a different length. 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 by viewing the documentation or download an evaluation copy of this sample set of programs.

Note: The COBOL language also has a REPLACING function that is used to replace text strings in a COBOL copy file at compile time. For more information about this function refer to the  Copy File with Replacing Function  section of this document..

Data Fields (Numeric Content and Definition)
(Next) (Previous) (Table-of-Contents)

This section will focus on data fields (or data strings) that have numeric content only. The various examples will show how the fields are defined and typical processing techniques used with numeric fields. The following list provides links to additional SimoTime documents about numeric data fields.

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 on-line.

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.

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.

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.

Date Processing Routine
(Next) (Previous) (Table-of-Contents)

This is an example of a callable routine that will validate, format or convert dates. The program will accept a gregorian date in the ccyymmdd, ccyy/mm/dd, ccyy/m/d format then check for numeric values for ccyymmdd. The month and day will also be checked for a valid range of 1-12 and 1-nn according to the month. It also provides conversion to julian and text. For example, 2001/01/15 will be converted to a julian date of 2001015 and a text string of January 15, 2001. 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.

Date Difference Routine
(Next) (Previous) (Table-of-Contents)

This is an example of a callable routine that will calculate the difference between two gregorian dates in the ccyymmdd format. Allowances have been made for leap years with the four-year and four-hundred-year cycles. 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.

Diagnostic Aids
(Next) (Previous) (Table-of-Contents)

This section provides documentation and examples of programs that may be used to assist in a program debugging effort in a development environment or to track the results of program execution in a development or production environment.

Diagnostic Aids, Hexadecimal Format, Display or Dump of Data Files
(Next) (Previous) (Table-of-Contents)

This sub-section contains examples of how to process hexadecimal data using COBOL. The ability to convert a text string or a record within a file to its hexadecimal value and display the information can be quite useful when debugging a program. The ability to write the information to a log file can be useful when trying to isolate an intermittent problem. The examples provide two hexadecimal dump formats, The first is primarily for data strings and the second is for records within a file. Examples of the dump formats are included in the following programs. The programs also have the capability of performing in an ASCII or EBCDIC environment.

Diagnostic Aids, Embedded Hex or Non-Printable Characters in Source Code
(Next) (Previous) (Table-of-Contents)

This suite of programs provides an example of how to identify and process embedded hexadecimal or non-printable characters in a text string or 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.

Diagnostic Aids, Hex-Dump of Fields or Data Items
(Next) (Previous) (Table-of-Contents)

This suite of programs provides a demonstration program and a callable program to display a data string in a hexadecimal format for both EBCDIC and ASCII. Both 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.

Diagnostic Aids, Hex-Dump of Sequential or ASCII/Text Files
(Next) (Previous) (Table-of-Contents)

This suite of sample programs describes Sequential File I/O and HEX-Dump formatting. The programs describe how to dump the input records to an output file in Hexadecimal format. This suite of programs will r