Numbers to Words
  Conversion Program for Digits to Text
http://www.simotime.com
When technology complements business    Copyright © 1987-2010  SimoTime Enterprises  All Rights Reserved
  Table of Contents Version 10.03.20 
  Introduction
 
  Programming Objectives
  Programming Input and Output
  Programming Requirements
  Programming Overview
  Callable Interface
  The CMD Members for Net Express
 
  CMD, Run the Application
  CMD, Create an Input File
  The JCL Members for OS/390 or Mainframe Express
 
  JCL, Run the Application
  JCL, Create an Input File
  The COBOL Demonstration Program
  The COBOL Conversion Routine
  The Copy File for Linkage Data Areas
  Summary
 
  Software Agreement and Disclaimer
  Downloads and Links to Similar Pages
  Comments or Suggestions
  About SimoTime

Introduction
(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, English-oriented text data string from a 12-digit numeric field. For example, if the numeric field contains 000000001234 then a text string is created with the following information.

One-Thousand-Two-Hundred-Thirty-Four

Depending and the request function the same numeric amount could be used to create the following text string with currency verbage in a format for printing checks.

Twelve-and-34/100-Dollars

Both COBOL programs are written using the COBOL/2 dialect but also work with COBOL for MVS and COBOL/370. A copy file (PASSTXTN.CPY) is provided for defining the data items of the pass area used by the two programs. A JCL member is provided to run the job as an MVS batch job on an IBM mainframe or as a project with Micro Focus Mainframe Express (MFE) running on a PC with Windows. Command files (.CMD) are provided for running on a PC with Windows using Micro Focus Net Express. The programs may be moved to a UNIX platform and executed using Micro Focus COBOL.

This program may serve as a tutorial for new programmers and as a reference for experienced programmers. Additional information is provided in the Downloads and Links to Similar Pages section of this document.

Programming Objectives
(Next) (Previous) (Table-of-Contents)

This example illustrates the following functions.

1. Demonstrate how to read a sequential file (or a Line Sequential file) containing numeric information and create a sequential file (or a Line Sequential file) containing a textual description of the number using Micro Focus COBOL (Net Express was used for the testing).
2. Demonstrate number or digits to text or word conversion.
3. Demonstrate how to edit a numeric field for currency sign and decimal point.
4. Demonstrate how to use JCL to run the job on a mainframe or PC with Mainframe Express.
5. Provide an example of a Window's CMD file to run the job on Windows using Micro Focus Net Express.

Programming Input and Output
(Next) (Previous) (Table-of-Contents)

The following is an example of an input file (TXTNGET1) that contains records with numeric values and editing specifications.

000000000123 DECIMAL0 -
000000000456 DECIMAL2 -
000000000789 DECIMAL2 - $ Dollars
123456789012 DECIMAL2 - $ Dollars
000000001200 DECIMAL0
000123456789 DECIMAL0 -
000000003995 DECIMAL2 - $ Dollars
12345        DECIMAL0 -   

The following is an example of the output file (TXTNPUT1) created from the preceding input file.

000000000123 000000000123 000000000123
000000000123 One-Hundred-Twenty-Three
000000000456 000000000456  4.56
000000000456 Four-and-56/100
000000000789 000000000789 $7.89
000000000789 Seven-and-89/100-Dollars
123456789012 123456789012 $1,234,567,890.12
123456789012 One-Billion-Two-Hundred-Thirty-Four-Million-Five-Hundred-Sixty-Seven-Thousand-Eight-Hundred-Ninety-and-12/100-Dollars
000000001200 000000001200 000000001200
000000001200 One Thousand Two Hundred
000123456789 000123456789 000123456789
000123456789 One-Hundred-Twenty-Three-Million-Four-Hundred-Fifty-Six-Thousand-Seven-Hundred-Eighty-Nine
000000003995 000000003995 $39.95
000000003995 Thirty-Nine-and-95/100-Dollars
12345        000000012345 000000012345
12345        Twelve-Thousand-Three-Hundred-Forty-Five

Programming Requirements
(Next) (Previous) (Table-of-Contents)

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

1. Executes on Windows/2000, Windows/NT and Windows/XP using Micro Focus Net Express and the CMD file provided.
2. May be ported to run on the UNIX platforms supported by Micro Focus COBOL.
3. Executes on a mainframe with MVS or Windows/2000, Windows/NT and Windows/XP using Micro Focus Mainframe Express and the JCL file provided.

Programming Overview
(Next) (Previous) (Table-of-Contents)

This program reads a data string (or field) containing numbers and creates a data string (or field) of text. The callable routine accepts a 12 digit data string and creates a 150 character text string.

Two formats may be specified for the numeric data string. The formats are zero decimal positions or two decimal positions. The numeric data string must be all digits. For the two-decimal format the right most two digits are assumed to be to the right of the decimal position. The remaining digits are assumed to be to the left of the decimal position.

The output to the text data string may be adjusted by specifying the delimiter character that is used between words and this is usually a hyphen (-). A suffix word may also be specified to append to the text data string.

The following is a block diagram of the Digits-to-Text application demonstration. The BLUE boxes are unique to the mainframe and Micro Focus Mainframe Express. The RED boxes are unique to the PC with Windows and Micro Focus Net Express. The GREEN boxes are platform independent and will execute on the mainframe or a PC with Windows. Also, the GREEN boxes may be ported to a UNIX platform that is supported by Micro Focus COBOL.

                   
 
CBLTXNJ1
jcl
     
CBLTXNE1
cmd
      The JCL or CMD member for running the application.
 
 
     
 
       
 
IEFBR14
utl
     
IF Exist
stmt
      Delete any previously created TXTNPUT1 file.
 
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
       
 
TXTNGET1
data
     
     
     
CBLTXNC1
CBL
     
     
     
TXTNPUT1
data
      Read the input file (TXTNGET1) containing the digits and control information and create a new file (TXTNPUT1) containing a text string.
     
 
 
         
     
 
     
     
     
SIMOTXTN
cbl
      Call SIMOTXTN to scan the digits and create a text field..
     
 
           
     
End-of-Job
EOJ
           
                   
Reads a data string containing numbers and create a data string of text

Callable Interface
(Next) (Previous) (Table-of-Contents)

A copyfile (PASSTXTN.CPY) is provided and defines the parameters for the pass area used by the calling demonstration program (CBLTXNC1.CBL) and the conversion routine (SIMOTXTN.CBL). The following table is an overview of the data strings used in the pass area.

Field Name Description
TXN-PASS-REQUEST This is an eight character data string and should contain one of the following in upper case.
DECIMAL0 The numeric data string has zero decimal positions.
DECIMAL2 The numeric data string has two implied decimal positions.
This calling program must provide one of the above as a request. Otherwise, a non-zero return code will be set in the following result field. This data string is not changed by the conversion routine.
TXN-PASS-RESULT This is a four byte binary data string and is used by the conversion routine to pass a return code. If the conversion request is successful the value in this data string will be zero.
TXN-PASS-DIGITS This is a 12 digit data string. The calling program must provide a numeric value in this data string and it must contain all digits. Otherwise, a non-zero return code will be set in the result data string. This data string is not changed by the conversion routine.
TXN-PASS-TXT-DELIMITER This data string allows the calling program to specify a character that will be used as the delimiter between words in the text data string. This data string is not changed by the conversion routine.
TXN-PASS-TXT-SUFFIX This data string allows the calling program to specify a suffix word that will be appended to the text field. This data string is not changed by the conversion routine.
TXN-PASS-TXT-LENGTH This is a three byte, numeric data string and is modified by the conversion routine. It is the length of the actual text string within the text data string.
TXN-PASS-TXT This is a 150 character data string and is modified by the conversion routine. It will contain the text information based on a valid request and a valid number.
TXN-PASS-NUM-SYMBOL Character (or currency symbol) used to insert in front of the edited numeric amount string.
TXN-PASS-NUM-LEFT-EDITED The numeric field edited for decimal, comma and currency symbol.
TXN-PASS-NUM-RIGHT-ADJUST The numeric field right adjusted.

The data strings should be initialized by the calling program to avoid problems with non-numeric values in the numeric data strings and low-values in the alphameric data strings instead of spaces. The following is an example of how to initialize the data strings used in the pass area or linkage items.

           INITIALIZE TXN-PASS-AREA

The following is an example of processing a simple numeric string with zero decimal positions and creating a text data string.

           MOVE 'DECIMAL0' TO TXN-PASS-REQUEST
           MOVE '-'        TO TXN-PASS-TXT-DELIMITER
           MOVE SPACES     TO TXN-PASS-TXT-SUFFIX
           ADD 123456789   TO ZERO GIVING TXN-PASS-DIGITS
           CALL 'SIMOTXTN' USING TXN-PASS-AREA

The preceding example will produce the following text string within the TXN-PASS-TXT field..

One-Hundred-Twenty-Three-Million-Four-Hundred-Fifty-Six-Thousand-Seven-Hundred-Eighty-Nine

The following is an example of reading a numeric dollar amount with two decimal positions and creating a text data string.

       01  TEST-DOLLAR-AMOUNT      PIC 9999999V99  VALUE 1256.98.

           . . .

           MOVE 'DECIMAL2'   TO TXN-PASS-REQUEST
           MOVE '-'          TO TXN-PASS-TXT-DELIMITER
           MOVE 'Dollars'    TO TXN-PASS-TXT-SUFFIX
           MULTIPLY DOLLAR-AMOUNT BY 100 GIVING TXN-PASS-DIGITS
           CALL 'SIMOTXTN'   USING TXN-PASS-AREA

The preceding example will produce the following text string within the TXN-PASS-TXT field.

One-Thousand-Two-Hundred-Fifty-Six-and-98/100-Dollars.

The CMD Members
(Next) (Previous) (Table-of-Contents)

This application has two CMD members. The first CMD member (CBLTXNE1.CMD) will execute the application. The second CMD member (CBLTXNE2.CMD) is used to create an input file for the application.

CMD, Run the Application
(Next) (Previous) (Table-of-Contents)

The following is the Windows CMD (CBLTXNE1.CMD) required to run the Digits-to-Text programs. The coding technique is used with the expectation the CMD would be used as a stand alone procedure.

@echo OFF
REM  * *******************************************************************
REM  *                   This program is provided by:                    *
REM  *                    SimoTime Enterprises, LLC                      *
REM  *           (C) Copyright 1987-2010 All Rights Reserved             *
REM  *             Web Site URL:   http://www.simotime.com               *
REM  *                   e-mail:   helpdesk@simotime.com                 *
REM  * *******************************************************************
REM  *
REM  * Text   - Create a Sequential Data Set on disk using ECHO function.
REM  * Author - SimoTime Enterprises
REM  * Date   - January 24, 1996
REM  *
REM  * The first job step (DeleteQSAM) will delete any previously created
REM  * file.
REM  *
REM  * The second job step (CreateQSAM) will create a new file that shows
REM  * the numbers converted to text strings. For this program to work
REM  * the COBOL program must be compiled with the ASSIGN(EXTERNAL) and
REM  * SEQUENTIAL(LINE) directives under Net Express.
REM  *
REM  * This set of programs will run on a Personal Computer with
REM  * Windows and Micro Focus Net Express.
REM  *
rem  * ********************************************************************
rem  * Step   1 of 2  Set the global environment variables,
rem  *                Delete any previously created file...
rem  *
     set JobStatus=0000
     set syslog=d:\simoNXE4\AN01\datawrk1\zxSysLog.LOG
rem  *
     SimoEXEC NOTE *******************************************************CblTxnE1
     SimoEXEC NOTE Starting JobName CblTxnE1
     SimoEXEC NOTE Identify JobStep DeleteQSAM
:DeleteQSAM
     set TXTNGET1=d:\SimoNXE4\AN01\DataAsc1\TXTNGET1.TXT
     set TXTNPUT1=d:\SimoNXE4\AN01\DataAsc1\TXTNPUT1.TXT
     if exist %TXTNPUT1% del %TXTNPUT1%
REM  *
REM  * *******************************************************************
REM  * Step   2 of 2  Create and populate a new QSAM file...
REM  *
:CreateQSAM
     SimoEXEC NOTE Identify JobStep CreateQSAM
     SimoEXEC EXEC CblTxnC1
     if ERRORLEVEL = 1 set JobStatus=0001
     if not "%JobStatus%" == "0000" goto :EojNOK
rem  *
     if exist %TXTNPUT1% goto :EojAok
     set JobStatus=0002
     goto :EojNok
:EojAok
     SimoEXEC NOTE Produced %TXTNPUT1%
     SimoEXEC NOTE Finished JobName CblTxnE1, Job Status is %JobStatus%
     goto :End
:EojNok
     SimoEXEC NOTE ABENDING JobName CblTxnE1, Job Status is %JobStatus%
:End
     if not "%1" == "nopause" pause

CMD, Create an Input File
(Next) (Previous) (Table-of-Contents)

The following is the Windows CMD (CBLTXNE2.CMD) required to create a sequential file that may be used as input for the application. The data for the input file is contained in the job stream.

@echo OFF
REM  * *******************************************************************
REM  *                   This program is provided by:                    *
REM  *                    SimoTime Enterprises, LLC                      *
REM  *           (C) Copyright 1987-2010 All Rights Reserved             *
REM  *             Web Site URL:   http://www.simotime.com               *
REM  *                   e-mail:   helpdesk@simotime.com                 *
REM  * *******************************************************************
REM  *
REM  * Text   - Create a Sequential Data Set on disk using ECHO function.
REM  * Author - SimoTime Enterprises
REM  * Date   - January 24, 1996
REM  *
REM  * The first job step (DeleteQSAM) will delete any previously created
REM  * file. The second job step (CreateQSAM) will create a new file.
REM  *
REM  * This set of programs will run on a Personal Computer with
REM  * Windows and Micro Focus Net Express.
rem  * ********************************************************************
rem  * Step   1 of 2  Set the global environment variables,
rem  *                Delete any previously created file...
rem  *
     JobStatus=0000
     set syslog=d:\simoNXE4\AN01\datawrk1\zxSysLog.LOG
:DeleteQSAM
     SimoEXEC NOTE *******************************************************CblTxnE2
     SimoEXEC NOTE Starting JobName CblTxnE2
     SimoEXEC NOTE Identify JobStep DeleteQSAM
     set TXTNGET1=d:\SimoNXE4\AN01\DataAsc1\TXTNGET1.TXT
     if exist %TXTNGET1% del %TXTNGET1%
REM  *
REM  * *******************************************************************
REM  * Step   2 of 2  Create and populate a new QSAM file...
REM  *
:CreateQSAM
     SimoEXEC NOTE Identify JobStep CreateQSAM
rem  *...:....1....:....2....:....3....:....4....:....5....:....6....:....7....:....8
echo 000000000123 DECIMAL0 -                                     >%TXTNGET1%
echo 000000000456 DECIMAL2 -                                    >>%TXTNGET1%
echo 000000000789 DECIMAL2 - $ Dollars                          >>%TXTNGET1%
echo 123456789012 DECIMAL2 - $ Dollars                          >>%TXTNGET1%
echo 000000001200 DECIMAL0                                      >>%TXTNGET1%
echo 000123456789 DECIMAL0 -                                    >>%TXTNGET1%
echo 000000003995 DECIMAL2 - $ Dollars                          >>%TXTNGET1%
echo 12345        DECIMAL0 -                                    >>%TXTNGET1%
     if exist %TXTNGET1% goto :EojAok
     set JobStatus=0002
     goto :EojNok
:EojAok
     SimoEXEC NOTE Produced %TXTNGET1%
     SimoEXEC NOTE Finished JobName CblTxnE2, Job Status is %JobStatus%
     goto :End
:EojNok
     SimoEXEC NOTE ABENDING JobName CblTxnE2, Job Status is %JobStatus%

:End
     if not "%1" == "nopause" pause

The JCL Members
(Next) (Previous) (Table-of-Contents)

This application has two JCL members. The first JCL member (CBLTXNJ1.JCL) will execute the application. The second JCL member (CBLTXNJ2.JCL) is used to create an input file for the application.

JCL, Run the Application
(Next) (Previous) (Table-of-Contents)

The following is the mainframe JCL (CBLTXNJ1.JCL) required to run the mainline program. The coding technique is used with the expectation the JCL would be used as a stand alone procedure. The job and DD statements will need to be modified for different mainframe environments.

//CBLTXNJ1 JOB SIMOTIME,ACCOUNT,CLASS=1,MSGCLASS=0,NOTIFY=CSIP1,
//             COND=(0,LT)
//* *******************************************************************
//*                   This program is provided by:                    *
//*                    SimoTime Enterprises, LLC                      *
//*           (C) Copyright 1987-2010 All Rights Reserved             *
//*             Web Site URL:   http://www.simotime.com               *
//*                   e-mail:   helpdesk@simotime.com                 *
//* *******************************************************************
//*
//* Text   - COBOL calls COBOL for Numeric to Text Translation
//* Author - SimoTime Enterprises
//* Date   - January 01, 1989
//*
//* This set of programs illustrate the use a COBOL program to create
//* a text string from a digit string. For example, a text string
//* containing the digits of 123 will create a text string of
//* One-Hundred-Twenty-Three.
//*
//* This set of programs will run on a mainframe under MVS or on
//* a Personal Computer running Windows and Mainframe Express or
//* Net Express by Micro Focus.
//*
//*                     ************
//*                     * CBLTXNJ1 *
//*                     ********jcl*
//*                          *
//*                     ************
//*                     * IEFBR14  *
//*                     ********utl*
//*                          *
//*    ************     ************     ************
//*    * TXTNGET1 *-----* CBLTXNC1 *-----* TXTNPUT1 *
//*    ********dat*     ********cbl*     ********dat*
//*                          *   *
//*                          *   *       ************
//*                          *   *-call--* SIMOTXTN *
//*                          *           ********cbl*
//*                          *
//*                     ************
//*                     *   EOJ    *
//*                     ************
//*
//*
//* *******************************************************************
//* Step   1 of 2  Delete any previously created file...
//*
//QSAMDELT EXEC PGM=IEFBR14
//TXTNPUT1 DD  DSN=SIMOTIME.DATA.TXTNPUT1,DISP=(MOD,DELETE,DELETE),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=FB,LRECL=80,BLKSIZE=800,DSORG=PS)
//*
//* *******************************************************************
//* Step   2 of 2  Edit input, create a new output file...
//*
//CBLTXNS1 EXEC PGM=CBLTXNC1
//STEPLIB  DD  DSN=SIMOTIME.DEMO.LOADLIB1,DISP=SHR
//TXTNGET1 DD  DSN=SIMOTIME.DATA.TXTNGET1,DISP=SHR
//TXTNPUT1 DD  DSN=SIMOTIME.DATA.TXTNPUT1,
//             DISP=(NEW,CATLG,DELETE),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=FB,LRECL=256,BLKSIZE=2560,DSORG=PS)
//SYSOUT   DD  SYSOUT=*
//*

JCL, Create an Input File
(Next) (Previous) (Table-of-Contents)

The following is the mainframe JCL (CBLTXNJ2.JCL) required to create a sequential file that may be used as input for the application. The data for the input file is contained in the job stream. The job and DD statements will need to be modified for different mainframe environments.

//CBLTXNJ2 JOB SIMOTIME,CLASS=1,MSGCLASS=0,NOTIFY=CSIP1
//* *******************************************************************
//*                   This program is provided by:                    *
//*                    SimoTime Enterprises, LLC                      *
//*           (C) Copyright 1987-2010 All Rights Reserved             *
//*             Web Site URL:   http://www.simotime.com               *
//*                   e-mail:   helpdesk@simotime.com                 *
//* *******************************************************************
//*
//* Text   - Create a Sequential Data Set on disk using IEBGENER.
//* Author - SimoTime Enterprises
//* Date   - January 24, 1996
//*
//* The first job step (DELTQSAM) will delete any previously created
//* file. The second job step (CRTQNAME) will create a new file.
//*
//* This set of programs will run on a mainframe under MVS or on a
//* Personal Computer with Windows and Micro Focus Mainframe Express.
//*
//* *******************************************************************
//* Step   1 of 2  Delete any previously created file...
//*
//TXNSTEP1 EXEC PGM=IEFBR14
//QSAM080E DD  DSN=SIMOTIME.DATA.TXTNGET1,DISP=(MOD,DELETE,DELETE),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=FB,LRECL=80,BLKSIZE=800,DSORG=PS)
//*
//* *******************************************************************
//* Step   2 of 2  Create and populate a new QSAM file...
//*
//TXNSTEP2 EXEC PGM=IEBGENER
//SYSPRINT DD  SYSOUT=*
//SYSIN    DD  DUMMY
//* :....1....:....2....:....3....:....4....:....5....:....6....:....7....:....8
//SYSUT1   DD  *
000000000123 DECIMAL0 -
000000000456 DECIMAL2 -
000000000789 DECIMAL2 - $ Dollars
123456789012 DECIMAL2 - $ Dollars
000000001200 DECIMAL0
000123456789 DECIMAL0 -
000000003995 DECIMAL2 - $ Dollars
12345        DECIMAL0 -
/*
//SYSUT2   DD  DSN=SIMOTIME.DATA.TXTNGET1,
//             DISP=(NEW,CATLG,DELETE),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=FB,LRECL=80,BLKSIZE=800,DSORG=PS)
//

The COBOL Demonstration Program
(Next) (Previous) (Table-of-Contents)

This program (CBLTXNC1.CBL) was written to be used as a teaching and learning aid. The accept and display functions of COBOL are used by this demonstration program to get the numeric values and display the text strings.

       IDENTIFICATION DIVISION.
       PROGRAM-ID.    CBLTXNC1.
       AUTHOR.        SIMOTIME ENTERPRISES.
      *****************************************************************
      * Copyright (C) 1987-2010 SimoTime Enterprises, LLC.            *
      *                                                               *
      * 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    *
      * Enterprises.                                                  *
      *                                                               *
      * 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.                                                  *
      *                                                               *
      * 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                                  *
      *                                                               *
      * SimoTime Enterprises                                          *
      * 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 Enterprises,  *
      * 15 Carnoustie Drive, Novato, CA 94949-5849.                   *
      *                                                               *
      *****************************************************************
      *      This program is provided by SimoTime Enterprises         *
      *        Our e-mail address is: helpdesk@simotime.com           *
      *     Also, visit our Web Site at http://www.simotime.com       *
      *                                                               *
      *****************************************************************
      * Source Member: CBLTXNC1.CBL
      * Copy Files:    PASSTXTN.CPY
      * Calls to:      SIMOTXTN
      *                Copy Files:    PASSTXTN.CPY
      *****************************************************************
      *
      *                     ************
      *                     * CBLTXNJ1 *
      *                     ********jcl*
      *                          *
      *                     ************
      *                     * IEFBR14  *
      *                     ********utl*
      *                          *
      *    ************     ************     ************
      *    * TXTNGET1 *-----* CBLTXNC1 *-----* TXTNPUT1 *
      *    ********dat*     ********cbl*     ********dat*
      *                          *   *
      *                          *   *       ************
      *                          *   ***call** SIMOTXTN *
      *                          *           ********cbl*
      *                          *
      *                     ************
      *                     *   EOJ    *
      *                     ************
      *
      *****************************************************************
      *
       ENVIRONMENT DIVISION.
       INPUT-OUTPUT SECTION.
       FILE-CONTROL.
           SELECT TXTNGET1-FILE ASSIGN to      TXTNGET1
                  ORGANIZATION  is SEQUENTIAL
                  ACCESS MODE   is SEQUENTIAL
                  FILE STATUS   is TXTNGET1-STATUS.
           SELECT TXTNPUT1-FILE ASSIGN to      TXTNPUT1
                  ORGANIZATION  is SEQUENTIAL
                  ACCESS MODE   is SEQUENTIAL
                  FILE STATUS   is TXTNPUT1-STATUS.

      *****************************************************************
       DATA DIVISION.
       FILE SECTION.
       FD TXTNGET1-FILE
           DATA RECORD    is TXTNGET1-RECORD
           .
       01 TXTNGET1-RECORD.
           05 TXTNGET1-DIGITS      pic X(12).
           05 filler               pic X.
           05 TXTNGET1-CONTROL     pic X(8).
           05 filler               pic X.
           05 TXTNGET1-DELIMITER   pic X.
           05 filler               pic X.
           05 TXTNGET1-PREFIX      pic X.
           05 filler               pic X.
           05 TXTNGET1-SUFFIX      pic X(16).
           05 filler               pic X(38).


       FD TXTNPUT1-FILE
           DATA RECORD    is TXTNPUT1-RECORD
           .
       01 TXTNPUT1-RECORD.
           05 TXTNPUT1-DIGITS            pic X(12).
           05 filler                     pic X.
           05 TXTNPUT1-TEXT.
              10 TXTNPUT1-RIGHT-ADJUSTED pic X(12).
              10 filler                  pic X.
              10 TXTNPUT1-EDITED-NUMBER  pic X(17).
              10 filler                  pic X(120).
           05 filler                     pic X(93).

       WORKING-STORAGE SECTION.
       01  SIM-TITLE.
           05  T1 pic X(11) value '* CBLTXNC1 '.
           05  T2 pic X(34) value 'Processing Numbers to Text        '.
           05  T3 pic X(10) value ' v04.03.17'.
           05  T4 pic X(24) value ' http://www.simotime.com'.
       01  SIM-COPYRIGHT.
           05  C1 pic X(11) value '* CBLTXNC1 '.
           05  C2 pic X(20) value 'Copyright 1987-2010 '.
           05  C3 pic X(28) value '  SimoTime Enterprises, LLC '.
           05  C4 pic X(20) value ' All Rights Reserved'.

       01  SIM-THANKS-01.
           05  C1 pic X(11) value '* CBLTXNC1 '.
           05  C2 pic X(32) value 'Thank you for using this sample '.
           05  C3 pic X(32) value 'by SimoTime Enterprises, LLC    '.
           05  C4 pic X(04) value '    '.

       01  SIM-THANKS-02.
           05  C1 pic X(11) value '* CBLTXNC1 '.
           05  C2 pic X(32) value 'Please send comments or suggesti'.
           05  C3 pic X(32) value 'ons to helpdesk@simotime.com    '.
           05  C4 pic X(04) value '    '.

       01  MESSAGE-BUFFER.
           05  MESSAGE-HEADER      pic X(11)   value '* CBLTXNC1 '.
           05  MESSAGE-TEXT.
               10  MESSAGE-TEXT-1  pic X(68)   value SPACES.
               10  MESSAGE-TEXT-2  pic X(188)  value SPACES.

       01 TXTNGET1-STATUS.
           05 TXTNGET1-STATUS-L     pic X.
           05 TXTNGET1-STATUS-R     pic X.
       01 TXTNGET1-EOF              pic X       value 'N'.
       01 TXTNGET1-OPEN-FLAG        pic X       value 'C'.

       01 TXTNPUT1-STATUS.
           05 TXTNPUT1-STATUS-L     pic X.
           05 TXTNPUT1-STATUS-R     pic X.
       01 TXTNPUT1-EOF              pic X       value 'N'.
       01 TXTNPUT1-OPEN-FLAG        pic X       value 'C'.

       01  IO-STATUS.
           05  IO-STAT1            pic X.
           05  IO-STAT2            pic X.

       01  TWO-BYTES.
           05  TWO-BYTES-LEFT      pic X.
           05  TWO-BYTES-RIGHT     pic X.
       01  TWO-BYTES-BINARY        redefines   TWO-BYTES pic 9(4) comp.

       01  APPL-RESULT             pic S9(9)   comp.
           88  APPL-AOK            value 0.
           88  APPL-EOF            value 16.

      *****************************************************************
      * The following copy file of the pass area for calling SIMODATE,
      * the date editing routine.
      *****************************************************************
       COPY PASSTXTN.

      *****************************************************************
       PROCEDURE DIVISION.
           perform Z-POST-COPYRIGHT

           perform EXAMPLE-01

           perform TXTNGET1-OPEN
           perform TXTNPUT1-OPEN

           perform until TXTNGET1-STATUS not = '00'
               perform TXTNGET1-READ
               if TXTNGET1-STATUS = '00'
                   move TXTNGET1-CONTROL    to TXN-PASS-REQUEST
                   move TXTNGET1-DIGITS     to TXN-PASS-DIGITS-R
                   move TXTNGET1-DELIMITER  to TXN-PASS-TXT-DELIMITER
                   move TXTNGET1-SUFFIX     to TXN-PASS-TXT-SUFFIX
                   move TXTNGET1-PREFIX     to TXN-PASS-NUM-SYMBOL
                   call 'SIMOTXTN' using TXN-PASS-AREA
                   if  TXN-PASS-RESULT = 0
                       move SPACES to TXTNPUT1-RECORD
                       move TXN-PASS-DIGITS-R to TXTNPUT1-DIGITS
                       move TXN-PASS-NUM-RIGHT-ADJUST
                         to TXTNPUT1-RIGHT-ADJUSTED
                       move TXN-PASS-NUM-LEFT-EDITED
                         to TXTNPUT1-EDITED-NUMBER
                       perform TXTNPUT1-WRITE
                       move SPACES to TXTNPUT1-RECORD
                       move TXN-PASS-DIGITS-R to TXTNPUT1-DIGITS
                       move TXN-PASS-TXT   to TXTNPUT1-TEXT
                       perform TXTNPUT1-WRITE
                   else
                       move TXTNGET1-DIGITS to TXTNPUT1-DIGITS
                       move 'Error in Processing' to TXTNPUT1-TEXT
                       move TXTNPUT1-RECORD to MESSAGE-TEXT
                       perform Z-DISPLAY-CONSOLE-MESSAGE
                       perform TXTNPUT1-WRITE
                   end-if
               end-if
           end-perform

           perform Z-THANK-YOU

           GOBACK.

      *****************************************************************
      * The following routines are in alphabetical sequence..         *
      *****************************************************************
      *
      *****************************************************************
       EXAMPLE-01.
           move 'DECIMAL2'         to TXN-PASS-REQUEST
           move '000000001898'     to TXN-PASS-DIGITS-R
           move '-'                to TXN-PASS-TXT-DELIMITER
           move 'Dollars         ' to TXN-PASS-TXT-SUFFIX
           move '$'                to TXN-PASS-NUM-SYMBOL
           call 'SIMOTXTN'      using TXN-PASS-AREA
           move TXN-PASS-TXT to MESSAGE-TEXT
           perform Z-DISPLAY-CONSOLE-MESSAGE
           move TXN-PASS-NUM-LEFT-EDITED to MESSAGE-TEXT
           perform Z-DISPLAY-CONSOLE-MESSAGE
           exit.
      *****************************************************************
      * I/O ROUTINES FOR TXTNGET1...                                   *
      *****************************************************************
       TXTNGET1-CLOSE.
           add 8 to ZERO giving APPL-RESULT.
           close TXTNGET1-FILE
           if TXTNGET1-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
           else
               add 12 to ZERO giving APPL-RESULT
           end-if
           if  APPL-AOK
               CONTINUE
           else
               move 'TXTNGET1-Failure-CLOSE...' to MESSAGE-TEXT
               perform Z-DISPLAY-CONSOLE-MESSAGE
               move TXTNGET1-STATUS to IO-STATUS
               perform Z-DISPLAY-IO-STATUS
               perform Z-ABEND-PROGRAM
           end-if
           exit.
      *---------------------------------------------------------------*
       TXTNGET1-READ.
           read TXTNGET1-FILE
           if TXTNGET1-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
           else
               if TXTNGET1-STATUS = '10'
                   add 16 to ZERO giving APPL-RESULT
               else
                   add 12 to ZERO giving APPL-RESULT
               end-if
           end-if
           if  APPL-AOK
               CONTINUE
           else
               if  APPL-EOF
                   move 'Y' to TXTNGET1-EOF
               else
                   move 'TXTNGET1-Failure-GET...' to MESSAGE-TEXT
                   perform Z-DISPLAY-CONSOLE-MESSAGE
                   move TXTNGET1-STATUS to IO-STATUS
                   perform Z-DISPLAY-IO-STATUS
                   perform Z-ABEND-PROGRAM
               end-if
           end-if
           exit.
      *---------------------------------------------------------------*
       TXTNGET1-OPEN.
           add 8 to ZERO giving APPL-RESULT.
           open input TXTNGET1-FILE
           if TXTNGET1-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
               move 'O' to TXTNGET1-OPEN-FLAG
           else
               add 12 to ZERO giving APPL-RESULT
           end-if
           if  APPL-AOK
               CONTINUE
           else
               move 'TXTNGET1-Failure-OPEN...' to MESSAGE-TEXT
               perform Z-DISPLAY-CONSOLE-MESSAGE
               move TXTNGET1-STATUS to IO-STATUS
               perform Z-DISPLAY-IO-STATUS
               perform Z-ABEND-PROGRAM
           end-if
           exit.

      *****************************************************************
      * I/O ROUTINES FOR TXTNPUT1...                                   *
      *****************************************************************
       TXTNPUT1-WRITE.
           if TXTNPUT1-OPEN-FLAG = 'C'
               perform TXTNPUT1-OPEN
           end-if
           write TXTNPUT1-RECORD
           if TXTNPUT1-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
           else
               if TXTNPUT1-STATUS = '10'
                   add 16 to ZERO giving APPL-RESULT
               else
                   add 12 to ZERO giving APPL-RESULT
               end-if
           end-if.
           if  APPL-AOK
               CONTINUE
           else
               move 'TXTNPUT1-Failure-WRITE...' to MESSAGE-TEXT
               perform Z-DISPLAY-CONSOLE-MESSAGE
               move TXTNPUT1-STATUS to IO-STATUS
               perform Z-DISPLAY-IO-STATUS
               perform Z-ABEND-PROGRAM
           end-if
           exit.
      *---------------------------------------------------------------*
       TXTNPUT1-OPEN.
           add 8 to ZERO giving APPL-RESULT.
           open output TXTNPUT1-FILE
           if TXTNPUT1-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
               move 'O' to TXTNPUT1-OPEN-FLAG
           else
               add 12 to ZERO giving APPL-RESULT
           end-if
           if  APPL-AOK
               CONTINUE
           else
               move 'TXTNPUT1-Failure-OPEN...' to MESSAGE-TEXT
               perform Z-DISPLAY-CONSOLE-MESSAGE
               move TXTNPUT1-STATUS to IO-STATUS
               perform Z-DISPLAY-IO-STATUS
               perform Z-ABEND-PROGRAM
           end-if
           exit.
      *---------------------------------------------------------------*
       TXTNPUT1-CLOSE.
           add 8 to ZERO giving APPL-RESULT.
           close TXTNPUT1-FILE
           if TXTNPUT1-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
               move 'C' to TXTNPUT1-OPEN-FLAG
           else
               add 12 to ZERO giving APPL-RESULT
           end-if
           if  APPL-AOK
               CONTINUE
           else
               move 'TXTNPUT1-Failure-CLOSE...' to MESSAGE-TEXT
               perform Z-DISPLAY-CONSOLE-MESSAGE
               move TXTNPUT1-STATUS to IO-STATUS
               perform Z-DISPLAY-IO-STATUS
               perform Z-ABEND-PROGRAM
           end-if
           exit.

      *****************************************************************
      * The following Z-Routines perform administrative tasks
      *****************************************************************

      *****************************************************************
      * ABEND the program, post a message to the console and issue    *
      * a STOP RUN.                                                   *
      *****************************************************************
       Z-ABEND-PROGRAM.
           if  MESSAGE-TEXT not = SPACES
               perform Z-DISPLAY-CONSOLE-MESSAGE
           end-if
           move 'PROGRAM-IS-ABENDING...'  to MESSAGE-TEXT
           perform Z-DISPLAY-CONSOLE-MESSAGE
           add 12 to ZERO giving RETURN-CODE
           STOP RUN
           exit.

      *****************************************************************
      * Display CONSOLE messages...                                   *
      *****************************************************************
       Z-DISPLAY-CONSOLE-MESSAGE.
           if MESSAGE-TEXT-2 = SPACES
               display MESSAGE-BUFFER(1:79) upon console
           else
               display MESSAGE-BUFFER upon console
           end-if
           move all SPACES to MESSAGE-TEXT
           exit.

      ****************************************************************
      * Display the file status bytes. This routine will display as   *
      * two digits if the full two byte file status is numeric. If    *
      * second byte is non-numeric then it will be treated as a       *
      * binary number.                                                *
      *****************************************************************
       Z-DISPLAY-IO-STATUS.
           if  IO-STATUS not NUMERIC
           or  IO-STAT1    = '9'
               subtract TWO-BYTES-BINARY from TWO-BYTES-BINARY
               move IO-STAT2 to TWO-BYTES-RIGHT
               display '* CBLTXNC1 File-Status-' IO-STAT1 '/'
                       TWO-BYTES-BINARY upon console
           else
               display '* CBLTXNC1 File-Status-' IO-STATUS upon console
           end-if
           exit.

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

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

The COBOL Conversion Routine
(Next) (Previous) (Table-of-Contents)

The following is the source listing for the conversion routine (SIMOTXTN.CBL). This routine does the actual creation of the text string.

       IDENTIFICATION DIVISION.
       PROGRAM-ID.    SIMOTXTN.
       AUTHOR.        SIMOTIME ENTERPRISES.
      *****************************************************************
      * Copyright (C) 1987-2010 SimoTime Enterprises, LLC.            *
      *                                                               *
      * 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    *
      * Enterprises.                                                  *
      *                                                               *
      * 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.                                                  *
      *                                                               *
      * 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                                  *
      *                                                               *
      * SimoTime Enterprises                                          *
      * 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 Enterprises,  *
      * 15 Carnoustie Drive, Novato, CA 94949-5849.                   *
      *                                                               *
      *****************************************************************
      *      This program is provided by SimoTime Enterprises         *
      *        Our e-mail address is: helpdesk@simotime.com           *
      *     Also, visit our Web Site at http://www.simotime.com       *
      *                                                               *
      *****************************************************************
      *
      *****************************************************************
      * Source Member: SIMOTXTN.CBL
      * Copy Files:    PASSTXTN.CPY
      *****************************************************************
      *
      * SIMOTXTN - A called routine for digit to text conversions.
      *
      * CALLING PROTOCOL
      * ----------------
      * Use standard COBOL calling procedures.
      *
      * DESCRIPTION
      * -----------
      * This program will do Digits to Text conversions.
      *
      ****************************************************************
      *
      * MAINTENANCE
      * -----------
      * 1989/02/27 Simmons, Created program.
      * 1989/02/27 Simmons, no changes to date
      *
      *****************************************************************
      *
       DATA DIVISION.
       WORKING-STORAGE SECTION.
      *
      *****************************************************************
      *    Data-structure for Title and Copyright...
      *****************************************************************
       01  SIM-TITLE.
           05  T1 pic X(11) value '* SIMOTXTN '.
           05  T2 pic X(34) value 'Convert Digits to a Text String   '.
           05  T3 pic X(10) value ' v04.01.12'.
           05  T4 pic X(24) value ' http://www.simotime.com'.
       01  SIM-COPYRIGHT.
           05  C1 pic X(11) value '* SIMOTXTN '.
           05  C2 pic X(20) value 'Copyright 1987-2010 '.
           05  C3 pic X(28) value '  SimoTime Enterprises, LLC '.
           05  C4 pic X(20) value ' All Rights Reserved'.

       01  FIRST-TIME              pic X       value 'Y'.

       01  MESSAGE-BUFFER.
           05  MESSAGE-HEADER      pic X(11)   value '* SIMOTXTN '.
           05  MESSAGE-TEXT        pic X(68).

       01  WORK-DIGITS-A.
           05  WORK-DIGITS-A1      pic X(3).
           05  WORK-DIGITS-A2      pic X(3).
           05  WORK-DIGITS-A3      pic X(3).
           05  WORK-DIGITS-A4      pic X(3).
       01  WORK-DIGITS-N           redefines WORK-DIGITS-A
                                   pic 9(12).

       01  WORK-DECIMAL-2A.
           05  WORK-DECIMAL-N1     pic 9(10).
           05  WORK-DECIMAL-N2     pic 9(2).

       01  TEXT-FOR-CENTS.
           05  filler              pic X(4)    value 'and-'.
           05  TEXT-CENT-AMOUNT    pic 9(2)    value 0.
           05  filler              pic X(5)    value '/100-'.
       01  TEXT-FOR-CENTS-A1       redefines TEXT-FOR-CENTS
                                   pic X(11).

       01  WORK-01                 pic X.
       01  WORK-03                 pic X(3).
       01  WORK-10                 pic X(10).
       01  I-X1                    pic 9(3)    value 0.
       01  I-X2                    pic 9(3)    value 0.
       01  DIGITS-FLAG             pic X       value 'N'.

       01  EDIT-WORD-0 pic X(17)   value '$@@@,@@@,@@@,@@@ '.
       01  EDIT-WORD-2 pic X(17)   value '$@,@@@,@@@,@@@.@@'.

      *****************************************************************
       LINKAGE SECTION.
       COPY PASSTXTN.

      *****************************************************************
       PROCEDURE DIVISION using TXN-PASS-AREA.

           if  FIRST-TIME not = 'N'
               perform Z-POST-COPYRIGHT
               move 'N' to FIRST-TIME
           end-if

           initialize TXN-PASS-RESULT
           initialize TXN-PASS-TXT-LENGTH
           move SPACES to TXN-PASS-TXT
           move SPACES to WORK-DIGITS-A
           move TXN-PASS-NUM-SYMBOL to EDIT-WORD-0(1:1)
           move TXN-PASS-NUM-SYMBOL to EDIT-WORD-2(1:1)
           perform EDIT-TXN-PASS-DIGITS

           evaluate TXN-PASS-REQUEST
               when 'DECIMAL0' perform CREATE-TEXT-FOR-ZERO-DECIMALS
               when 'DECIMAL2' perform CREATE-TEXT-FOR-TWO-DECIMALS
               when OTHER      perform Z-POST-INVALID-REQUEST
           end-evaluate

           add TXN-PASS-RESULT to ZERO giving RETURN-CODE
           GOBACK.

      *****************************************************************
       CREATE-TEXT-FOR-TWO-DECIMALS.
      *
      *    Validate the input string contains all digits...
      *
           perform VALIDATE-DIGITS-OR-ABEND
           move TXN-PASS-NUM-RIGHT-ADJUST to WORK-DECIMAL-2A
           add WORK-DECIMAL-N1 to ZERO giving WORK-DIGITS-N
           add WORK-DECIMAL-N2 to ZERO giving TEXT-CENT-AMOUNT
           perform CREATE-TEXT-02
           perform CREATE-LEFT-EDIT-2
           exit.

       CREATE-LEFT-EDIT-0.
           move TXN-PASS-NUM-RIGHT-ADJUST
             to TXN-PASS-NUM-LEFT-EDITED
           exit.

       CREATE-LEFT-EDIT-2.
           move EDIT-WORD-2 to TXN-PASS-NUM-LEFT-EDITED
           move TXN-PASS-NUM-SYMBOL to TXN-PASS-NUM-LEFT-EDITED(1:1)
           add 12 to ZERO giving I-X1
           add 17 to ZERO giving I-X2
           move TXN-PASS-NUM-RIGHT-ADJUST to WORK-DIGITS-A
           perform until I-X1 = 0
                      or I-X2 = 1
               if  TXN-PASS-NUM-LEFT-EDITED(I-X2:1) = '@'
                   move WORK-DIGITS-A(I-X1:1)
                     to TXN-PASS-NUM-LEFT-EDITED(I-X2:1)
                   subtract 1 from I-X1
                   subtract 1 from I-X2
               else
                   subtract 1 from I-X2
               end-if
           end-perform
           move 'N' to DIGITS-FLAG
           add 1 to ZERO giving I-X1
           perform until DIGITS-FLAG = 'Y'
               if  TXN-PASS-NUM-LEFT-EDITED(I-X1:1) = '0'
               or  TXN-PASS-NUM-LEFT-EDITED(I-X1:1) =
                   EDIT-WORD-2(I-X1:1)
                   add 1 to I-X1
               else
                   move 'Y' to DIGITS-FLAG
               end-if
               if  I-X1 > 13
                   move 'Y' to DIGITS-FLAG
               end-if
           end-perform

           if  I-X1 > 1
               subtract 1 from I-X1
               perform until I-X1 < 2
                   add 2 to ZERO giving I-X2
                   perform 15 times
                       move TXN-PASS-NUM-LEFT-EDITED(I-X2 + 1:1)
                         to TXN-PASS-NUM-LEFT-EDITED(I-X2:1)
                       add 1 to I-X2
                   end-perform
                   subtract 1 from I-X1
                   move SPACE to TXN-PASS-NUM-LEFT-EDITED(17:1)
               end-perform
           end-if
           exit.

      *****************************************************************
       CREATE-TEXT-FOR-ZERO-DECIMALS.
      *
      *    Validate the input string contains all digits...
      *
           perform VALIDATE-DIGITS-OR-ABEND
           add TXN-PASS-NUM-RIGHT-ADJUST to ZERO giving WORK-DIGITS-N
           perform CREATE-TEXT-02
           perform CREATE-LEFT-EDIT-0
           exit.

      *****************************************************************
       CREATE-TEXT-02.
      *
      *    Process a Zero value...
           if  TXN-PASS-NUM-RIGHT-ADJUST = 0
               if  TXN-PASS-REQUEST = 'DECIMAL2'
                   if  TXN-PASS-TXT-SUFFIX = SPACES
                       move 'Zero-and-00/100' to TXN-PASS-TXT
                       perform CREATE-TEXT-CALCULATE-LENGTH
                   else
                       move 'Zero-and-00/100-' to TXN-PASS-TXT
                       inspect TXN-PASS-TXT
                       replacing FIRST '                '
                       by TXN-PASS-TXT-SUFFIX
                       perform CREATE-TEXT-CALCULATE-LENGTH
                   end-if
               else
                   move 'Zero' to TXN-PASS-TXT
                   add 4 to ZERO giving TXN-PASS-TXT-LENGTH
               end-if
               move SPACES     to TXN-PASS-NUM-LEFT-EDITED
               move '$0.00***' to TXN-PASS-NUM-LEFT-EDITED(1:8)
               GOBACK
           end-if
      *
      *    Process when two-decimal positions and the value to the
      *    left of the decimal position is zero...
           if  WORK-DIGITS-N = 0
               move 'Zero-' to TXN-PASS-TXT
           end-if
      *
      *    Process the first group of three digits...
           if  WORK-DIGITS-A1 not = '000'
               move WORK-DIGITS-A1 to WORK-03
               perform CREATE-TEXT-THREE-DIGIT-GROUP
               inspect TXN-PASS-TXT
               replacing FIRST '        '   by 'Billion-'
           end-if
      *
      *    Process the second group of three digits...
           if  WORK-DIGITS-A2 not = '000'
               move WORK-DIGITS-A2 to WORK-03
               perform CREATE-TEXT-THREE-DIGIT-GROUP
               inspect TXN-PASS-TXT
               replacing FIRST '        '   by 'Million-'
           end-if
      *
      *    Process the third group of three digits...
           if  WORK-DIGITS-A3 not = '000'
               move WORK-DIGITS-A3 to WORK-03
               perform CREATE-TEXT-THREE-DIGIT-GROUP
               inspect TXN-PASS-TXT
               replacing FIRST '         '   by 'Thousand-'
           end-if
      *
      *    Process the fourth group of three digits...
           if  WORK-DIGITS-A4 not = '000'
               move WORK-DIGITS-A4 to WORK-03
               perform CREATE-TEXT-THREE-DIGIT-GROUP
           end-if
      *
      *    Add suffix info for two decimal positions...
           if  TXN-PASS-REQUEST = 'DECIMAL2'
               inspect TXN-PASS-TXT
               replacing FIRST '           ' by TEXT-FOR-CENTS-A1
           end-if
      *
      *    Add suffix to text string...
           inspect TXN-PASS-TXT
           replacing FIRST '                ' by TXN-PASS-TXT-SUFFIX
      *
      *    Remove trailing hyphen...
           inspect TXN-PASS-TXT replacing FIRST '- '   by '  '
      *
      *    Calculate the length of the text within the text string...
           perform CREATE-TEXT-CALCULATE-LENGTH
      *
      *    Replace word delimiter with user defined character...
           if  TXN-PASS-TXT-DELIMITER not = '-'
               inspect TXN-PASS-TXT
               replacing all '-' by TXN-PASS-TXT-DELIMITER
           end-if
           exit.

      *****************************************************************
       CREATE-TEXT-CALCULATE-LENGTH.
           add 1 to ZERO giving TXN-PASS-TXT-LENGTH
           perform until TXN-PASS-TXT-LENGTH = 150
                      or TXN-PASS-TXT(TXN-PASS-TXT-LENGTH:1) = SPACE
               add 1 to TXN-PASS-TXT-LENGTH
           end-perform
           subtract 1 from TXN-PASS-TXT-LENGTH
           exit.

      *****************************************************************
       CREATE-TEXT-THREE-DIGIT-GROUP.
           move SPACES to WORK-10
           move WORK-03(1:1) to WORK-01
           perform CREATE-TEXT-ONE-THRU-NINE
           if  WORK-10 not = SPACES
               inspect TXN-PASS-TXT
               replacing FIRST '          ' by WORK-10
               inspect TXN-PASS-TXT
               replacing FIRST '        '   by 'Hundred-'
           end-if

           if  WORK-03(2:1) = '1'
               perform CREATE-TEXT-FOR-TEEN
           else
               perform CREATE-TEXT-FOR-NON-TEEN
           end-if
           exit.

      *****************************************************************
       CREATE-TEXT-FOR-TEEN.
           move SPACES to WORK-10
           evaluate WORK-03(3:1)
               when '0' move 'Ten-      ' to WORK-10
               when '1' move 'Eleven-   ' to WORK-10
               when '2' move 'Twelve-   ' to WORK-10
               when '3' move 'Thirteen- ' to WORK-10
               when '4' move 'Fourteen- ' to WORK-10
               when '5' move 'Fifteen-  ' to WORK-10
               when '6' move 'Sixteen-  ' to WORK-10
               when '7' move 'Seventeen-' to WORK-10
               when '8' move 'Eighteen- ' to WORK-10
               when '9' move 'Nineteen- ' to WORK-10
           end-evaluate
           if  WORK-10 not = SPACES
               inspect TXN-PASS-TXT
               replacing FIRST '          ' by WORK-10
           end-if
           exit.

      *****************************************************************
       CREATE-TEXT-FOR-NON-TEEN.
           move SPACES to WORK-10
           evaluate WORK-03(2:1)
               when '2' move 'Twenty-   ' to WORK-10
               when '3' move 'Thirty-   ' to WORK-10
               when '4' move 'Forty-    ' to WORK-10
               when '5' move 'Fifty-    ' to WORK-10
               when '6' move 'Sixty-    ' to WORK-10
               when '7' move 'Seventy-  ' to WORK-10
               when '8' move 'Eighty-   ' to WORK-10
               when '9' move 'Ninety-   ' to WORK-10
           end-evaluate
           if  WORK-10 not = SPACES
               inspect TXN-PASS-TXT
               replacing FIRST '          ' by WORK-10
           end-if

           move SPACES to WORK-10
           move WORK-03(3:1) to WORK-01
           perform CREATE-TEXT-ONE-THRU-NINE
           if  WORK-10 not = SPACES
               inspect TXN-PASS-TXT
               replacing FIRST '          ' by WORK-10
           end-if
           exit.

      *****************************************************************
       CREATE-TEXT-ONE-THRU-NINE.
           evaluate WORK-01
               when '1' move 'One-      ' to WORK-10
               when '2' move 'Two-      ' to WORK-10
               when '3' move 'Three-    ' to WORK-10
               when '4' move 'Four-     ' to WORK-10
               when '5' move 'Five-     ' to WORK-10
               when '6' move 'Six-      ' to WORK-10
               when '7' move 'Seven-    ' to WORK-10
               when '8' move 'Eight-    ' to WORK-10
               when '9' move 'Nine-     ' to WORK-10
           end-evaluate

           exit.

      *****************************************************************
      *    Scan the input digets and create right-adjusted, numeric...
      *****************************************************************
       EDIT-TXN-PASS-DIGITS.
           add 1 to ZERO giving I-X1
           add 1 to ZERO giving I-X2
           move SPACES to WORK-DIGITS-A
           perform until I-X1 > 12
             if TXN-PASS-DIGITS-R(I-X1:1) = ','
             or TXN-PASS-DIGITS-R(I-X1:1) = '.'
                add 1 to I-X1
             else
                move TXN-PASS-DIGITS-R(I-X1:1) to WORK-DIGITS-A(I-X2:1)
                add 1 to I-X1
                add 1 to I-X2
             end-if
           end-perform
           if  WORK-DIGITS-A(12:1) = SPACE
               perform until WORK-DIGITS-A(12:1) not = SPACE
                   add 11 to ZERO giving I-X1
                   add 12 to ZERO giving I-X2
                   perform 11 times
                       move WORK-DIGITS-A(I-X1:1)
                         to WORK-DIGITS-A(I-X2:1)
                       subtract 1 from I-X1
                       subtract 1 from I-X2
                   end-perform
                   move '0' to WORK-DIGITS-A(1:1)
               end-perform
           end-if
           move WORK-DIGITS-A to TXN-PASS-NUM-RIGHT-ADJUST
           exit.

      *****************************************************************
      *    Validate that input string is all digits, if not ABEND...
      *****************************************************************
       VALIDATE-DIGITS-OR-ABEND.
           add 1 to ZERO giving I-X1
           perform 12 times
               if  TXN-PASS-NUM-RIGHT-ADJUST(I-X1:1) > 0
               and TXN-PASS-NUM-RIGHT-ADJUST(I-X1:1) < 9
               or  TXN-PASS-NUM-RIGHT-ADJUST(I-X1:1) = 0
               or  TXN-PASS-NUM-RIGHT-ADJUST(I-X1:1) = 9
                   add 1 to I-X1
               else
                   perform Z-POST-NOT-ALL-DIGITS
               end-if
           end-perform
           exit.

      *****************************************************************
      * The following Z-Routines perform administrative tasks
      *****************************************************************
       Z-POST-COPYRIGHT.
           display SIM-TITLE      upon console
           display SIM-COPYRIGHT  upon console
           exit.

      *****************************************************************
       Z-POST-INVALID-REQUEST.
           move 'INVALID REQUEST - ' to MESSAGE-TEXT
           move TXN-PASS-REQUEST     to MESSAGE-TEXT(19:8)
           perform Z-POST-MESSAGE
           add 16 to ZERO giving TXN-PASS-RESULT
           exit.

      *****************************************************************
       Z-POST-MESSAGE.
           display MESSAGE-BUFFER upon console
           move SPACES to MESSAGE-TEXT
           exit.

      *****************************************************************
       Z-POST-NOT-ALL-DIGITS.
           move 'Not all DIGITS - ' to MESSAGE-TEXT
           move TXN-PASS-DIGITS-R   to MESSAGE-TEXT(18:12)
           perform Z-POST-MESSAGE
           add 16 to ZERO giving TXN-PASS-RESULT
           move SPACES to TXN-PASS-TXT
           move 'ERROR, VOID this item...' to TXN-PASS-TXT
           GOBACK
           exit.

      *****************************************************************
      *      This program is provided by SimoTime Enterprises         *
      *        Our e-mail address is: helpdesk@simotime.com           *
      *     Also, visit our Web Site at http://www.simotime.com       *
      *****************************************************************

This program does not provide much visual information when it is executed on the mainframe. The real value to this program is when it is animated using Mainframe Express provided by Micro Focus. It is possible to watch the actual execution of each individual instruction and to immediately see the results.

The Copy File for Linkage Data Areas
(Next) (Previous) (Table-of-Contents)

This copy file (PASSTXTN.CPY) provides a convenient method for defining the data areas (or fields) that are used to pass information between the demo program and the digits to text conversion routine.

      *****************************************************************
      *           Data Structure used for calling SIMOTXTN            *
      *****************************************************************
      *         Copyright (C) 1987-2010 SimoTime Enterprises          *
      *                     All Rights Reserved                       *
      *****************************************************************
      *              Provided by SimoTime Enterprises                 *
      *        Our e-mail address is: helpdesk@simotime.com           *
      *     Also, visit our Web Site at http://www.simotime.com       *
      *****************************************************************
      *
      * The following is a summary of the fields used as linkage items.
      *
      * TXN-PASS-REQUEST       This is an eight character data string
      *                        and should contain one of the following
      *                        in upper case.
      *                        DECIMAL0 - The numeric data string has
      *                                   zero decimal positions.
      *                        DECIMAL2 - The numeric data string has
      *                                   two decimal positions.
      * TXN-PASS-RESULT        Zero       Request was successful
      *                        non-Zero   Request was invalid or failed
      * TXN-PASS-DIGITS        Numeric field provided by caller
      * TXN-PASS-TXT-DELIMITER Character used between words in text
      * TXN-PASS-TXT-SUFFIX    A word that is appended to text string
      * TXN-PASS-TXT-LENGTH    Length of text within text field
      * TXN-PASS-TXT           Text string created by conversion
      * TXN-PASS-NUM-SYMBOL    Character used to insert in front
      *                        of the edited numeric amount string.
      * TXN-PASS-NUM-LEFT-EDITED  The numeric field edited for decimal,
      *                           comma and currency symbol.
      * TXN-PASS-NUM-RIGHT-ADJUST The numeric field right adjusted.
      *
      *****************************************************************
       01  TXN-PASS-AREA.
      *    Control Information provided by calling program,
      *    the TXN-PASS-RESULT field may be modified by SimoTXTN.
           05  TXN-PASS-REQUEST            PIC X(8).
           05  TXN-PASS-RESULT             PIC 9(4).
           05  TXN-PASS-DIGITS             PIC 9(12).
           05  TXN-PASS-DIGITS-R           redefines TXN-PASS-DIGITS
                                           PIC X(12).
      *    Textual specifications supplied by calling program.
           05  TXN-PASS-TXT-DELIMITER      PIC X.
           05  TXN-PASS-TXT-SUFFIX         PIC X(16).
      *    Textual length and word string supplied by SimoTXTN routine.
           05  TXN-PASS-TXT-LENGTH         PIC 9(3).
           05  TXN-PASS-TXT                PIC X(150).
      *    Numeric editing currency symbol supplied by calling program.
           05  TXN-PASS-NUM-SYMBOL         PIC X.
      *    Left-justified with currency, commas, and decimal point,
      *    supplied by SimoTXTN routine.
           05  TXN-PASS-NUM-LEFT-EDITED    PIC X(17).
      *    Right-justified numeric value supplied by SimoTXTN.
           05  TXN-PASS-NUM-RIGHT-ADJUST   PIC 9(12).
      *!   PASSTXTN - End-of-Copy File...

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, copied and modified for specific situations as long as the copyright information is not removed or changed. 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)

You may download this example at http://www.simotime.com/sim4dzip.htm#COBOLDigitsToTextZip as a Z-Pack. The Z-Packs provide individual programming examples, documentation and test data files in a single package. The Z-Packs are usually in zip format to reduce the amount of time to download.

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 COBOL Connection in the SimoTime Library for more examples of mainframe COBOL techniques and sample code.

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

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
(Next) (Previous) (Table-of-Contents)

Founded in 1987, SimoTime Enterprises 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. 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-2010  SimoTime Enterprises  All Rights Reserved
When technology complements business
http://www.simotime.com