Numbers to Words
Conversion Program for Digits to Text
  Table of Contents  v-24.01.01 - cbltxn01.htm 
  Introduction
  Programming Objectives
  Programming Input and Output
  Programming Requirements
  Programming Overview
  The Callable Interface
  The CMD Members
  CMD, Run the Application
  CMD, Create an Input File
  The JCL Members
  JCL, Run the Application
  JCL, Create an Input File
  The COBOL Members
  The Primary Program
  The Conversion Routine
  The Copy File for the Linkage Section
  Summary
  Software Agreement and Disclaimer
  Downloads and Links
  Current Server or Internet Access
  Internet Access Required
  Glossary of Terms
  Contact or Feedback
  Company Overview
The SimoTime Home Page 

Table of Contents Previous Section Next Section Introduction

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 verbiage 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.


We have made a significant effort to ensure the documents and software technologies are correct and accurate. We reserve the right to make changes without notice at any time. The function delivered in this version is based upon the enhancement requests from a specific group of users. The intent is to provide changes as the need arises and in a timeframe that is dependent upon the availability of resources.

Copyright © 1987-2025
SimoTime Technologies and Services
All Rights Reserved

Table of Contents Previous Section Next Section Programming Objectives

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.
  Functionality Included in this Suite of Programs

Table of Contents Previous Section Next Section Programming Input and Output

The input is a record sequential file with eighty (80) byte, fixed length records. The output is a record sequential file with two-hundred-fifty-six (256) byte, fixed length records.

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

Table of Contents Previous Section Next Section Programming Requirements

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

1 Executes on Windows/XP, Windows/7 or Windows Server using Micro Focus Net Express and the CMD file provided.
2 May be ported to run on the Linux or UNIX platforms supported by Micro Focus COBOL.
3 Executes on a mainframe with MVS or Windows/XP using Micro Focus Mainframe Express and the JCL file provided.
  Operating Systems for Program Execution

Table of Contents Previous Section Next Section Programming Overview

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 logic flow for the Digits-to-Text application demonstration.

             
Entry Point
ZOS
Entry Point
Windows
   
   
CBLTXNJ1
jcl
CBLTXNE1
cmd
The JCL or CMD member for running the application.
   
   
IEFBR14
Utility
IF Exist
statement
Delete any previously created TXTNPUT1 file.
   
   
 
 
   
   
 
 
   
   
TXTNGET1
rseq
 
 
CBLTXNC1
cbl
   
   
TXTNPUT1
rseq
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.
   
EOJ
End-of-Job
 
Reads a data string containing numbers and create a data string of text

Color Associations: The  light-green  boxes are unique to SIMOTIME Technologies using an IBM Mainframe System or Micro Focus Enterprise Developer. The  light-red  boxes are unique to the SIMOTIME Technologies using a Linux, UNIX or Windows System and COBOL Technologies such as Micro Focus. The  light-yellow  boxes are SIMOTIME Technologies, Third-party Technologies, decision points or program transitions in the processing logic or program generations. The  light-blue  boxes identify the input/output data structures such as Documents, Spreadsheets, Data Files, VSAM Data Sets, Partitioned Data Set Members (PDSM's) or Relational Tables. The  light-gray  boxes identify a system function or an informational item.

Table of Contents Previous Section Next Section The Callable Interface

A copy file (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 alphamerical 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.

Table of Contents Previous Section Next Section The CMD Members

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.

Table of Contents Previous Section Next Section CMD, Run the Application

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
     set CmdName=CBLTXNE1
rem  * *******************************************************************
rem  *               CBLTXNE1.cmd - a Windows Command File               *
rem  *       This Job Script is provided by SimoTime Technologies        *
rem  *           (C) Copyright 1987-2019 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 Technologies
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  *
     call ..\ENV1BASE %CmdName%
     if "%SYSLOG%" == "" set syslog=c:\SimoLIBR\LOGS\SimoTime.LOG
rem  *
     call SIMONOTE "*******************************************************%CmdName%"
     call SIMONOTE "Starting CmdName %CmdName%, User is %USERNAME%"
     call SIMONOTE "StepInfo Delete previously created file"
:DeleteQSAM
     set TXTNGET1=%BaseLib1%\DATA\Asc1\TXTNGET1.DAT
     set TXTNPUT1=%BaseLib1%\DATA\Wrk1\TXTNPUT1.DAT
     if exist %TXTNPUT1% del %TXTNPUT1%
rem  *
rem  * *******************************************************************
rem  * Step   2 of 2  Create and populate a new QSAM file...
rem  *
:CreateQSAM
     call SIMONOTE "StepInfo Execute Digits to Text Conversion Program"
     call SIMONOTE "DataTake %TXTNGET1%"
     run CBLTXNC1
     if ERRORLEVEL 1 echo Error level is equal-to or Greater-than 1 . . .
     if ERRORLEVEL 1 set JobStatus=0010
     if not "%JobStatus%" == "0000" goto :EojNOK
rem  *
     if exist %TXTNPUT1% goto :EojAok
     set JobStatus=0002
     goto :EojNok
:EojAok
     call SIMONOTE "DataMake %TXTNPUT1%"
     call SIMONOTE "Finished CmdName %CmdName%, Job Status is %JobStatus% "
     goto :End
:EojNok
     call SIMONOTE "DataMake SYSOUT=%SYSOUT%"
     call SIMONOTE "ABENDING CmdName %CmdName%, Job Status is %JobStatus% "
:End
     if not "%1" == "nopause" pause

Table of Contents Previous Section Next Section CMD, Create an Input File

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
     set CmdName=CBLTXNE2
rem  * *******************************************************************
rem  *               CBLTXNE2.cmd - a Windows Command File               *
rem  *         This program is provided by SimoTime Technologies         *
rem  *           (C) Copyright 1987-2019 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 Technologies
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  *
     call ..\ENV1BASE %CmdName%
     if "%SYSLOG%" == "" set syslog=c:\SimoLIBR\LOGS\SimoTime.LOG
:DeleteQSAM
     call SIMONOTE "*******************************************************%CmdName%"
     call SIMONOTE "Starting CmdName %CmdName%, User is %USERNAME%"
     call SIMONOTE "StepInfo Delete previously created file"
     set TXTNGET1=%BaseLib1%\DATA\Txt1\TXTNGET1.TXT
     if exist %TXTNGET1% del %TXTNGET1%
rem  *
rem  * *******************************************************************
rem  * Step   2 of 2  Create and populate a new QSAM file...
rem  *
:CreateLSEQ
     call SIMONOTE "StepInfo Create the input file of program requests"
     call SIMONOTE "DataTake In-Stream Data"
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 not exist %TXTNGET1% set JobStatus=9001
     if not "%JobStatus%" == "0000" goto :EojNok
     call SIMONOTE "DataMake %TXTNGET1%"
:CreateRSEQ
     call SIMONOTE "StepInfo Convert LSEQ File to RSEQ80 File"
     set GETLS080=%BaseLib1%\DATA\TXT1\TXTNGET1.TXT
     set PUTRS080=%BaseLib1%\DATA\Asc1\TXTNGET1.DAT
     if exist %PUTRS080% del %PUTRS080%
     call SIMONOTE "DataTake %GETLS080%"
     call SIMONOTE "DataMake %PUTRS080%"
     run CV80ALAR
     if not exist %PUTRS080% set JobStatus=9002
     if not %JobStatus% == 0000 goto :EojNok
rem  *
:EojAok
     call SIMONOTE "Finished CmdName %CmdName%, Job Status is %JobStatus%"
     goto :End
:EojNok
     call SIMONOTE "ABENDING CmdName %CmdName%, Job Status is %JobStatus%"
:End
     call SIMONOTE "DataMake SYSOUT=%SYSOUT%"
     if not "%1" == "nopause" pause

Table of Contents Previous Section Next Section The JCL Members

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.

Table of Contents Previous Section Next Section JCL, Run the Application

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)
//* *******************************************************************
//*       CBLTXNJ1.JCL - a JCL Member for Batch Job Processing        *
//*       This JCL Member is provided by SimoTime Technologies        *
//*           (C) Copyright 1987-2019 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 Technologies
//* 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...
//*
//GETREADY 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...
//*
//BUILDNEW 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=*
//*

Table of Contents Previous Section Next Section JCL, Create an Input File

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
//* *******************************************************************
//*       CBLTXNJ2.JCL - a JCL Member for Batch Job Processing        *
//*       This JCL Member is provided by SimoTime Technologies        *
//*           (C) Copyright 1987-2019 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 Technologies
//* 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...
//*
//GETREADY 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...
//*
//BUILDNEW 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)
//

Table of Contents Previous Section Next Section The COBOL Members

This application has three COBOL members. The 1st member is the primary program that calls the 2nd member to create a text string based on a numeric string of digits. The 3rd member is a COBOL copy file that defines the data structure that is used as the pass area that is shared by the two programs.

Table of Contents Previous Section Next Section The Primary Program

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 TECHNOLOGIES.
      *****************************************************************
      * Copyright (C) 1987-2019 SimoTime Technologies.                *
      *                                                               *
      * 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    *
      * Technologies.                                                 *
      *                                                               *
      * Permission to use, copy, modify and distribute this software  *
      * for any commercial purpose requires a fee to be paid to       *
      * SimoTime Technologies. 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           *
      * Technologies.                                                 *
      *                                                               *
      * SimoTime Technologies makes no warranty or representations    *
      * about the suitability of the software for any purpose. It is  *
      * provided "AS IS" without any expressed or implied warranty,   *
      * including the implied warranties of merchantability, fitness  *
      * for a particular purpose and non-infringement. SimoTime       *
      * Technologies 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 Technologies                                         *
      * 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 Technologies, *
      * 15 Carnoustie Drive, Novato, CA 94949-5849.                   *
      *                                                               *
      *****************************************************************
      *      This program is provided by SimoTime Technologies        *
      *        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 'Process Numbers or Digits 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-2019 '.
           05  C3 pic X(28) value '   SimoTime Technologies    '.
           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 program'.
           05  C3 pic X(32) value ' provided from SimoTime Technolo'.
           05  C4 pic X(04) value 'gies'.

       01  SIM-THANKS-02.
           05  C1 pic X(11) value '* CBLTXNC1 '.
           05  C2 pic X(32) value 'Please send all inquires or sugg'.
           05  C3 pic X(32) value 'estions to the helpdesk@simotime'.
           05  C4 pic X(04) value '.com'.

       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 Technologies        *
      *        Our e-mail address is: helpdesk@simotime.com           *
      *     Also, visit our Web Site at http://www.simotime.com       *
      *****************************************************************

Table of Contents Previous Section Next Section The Conversion Routine

The following is the COBOL source member (SIMOTXTN.cbl) for the conversion routine. This routine does the actual creation of the text string.

       IDENTIFICATION DIVISION.
       PROGRAM-ID.    SIMOTXTN.
       AUTHOR.        SIMOTIME TECHNOLOGIES.
      *****************************************************************
      * Copyright (C) 1987-2019 SimoTime Technologies.                *
      *                                                               *
      * 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    *
      * Technologies.                                                 *
      *                                                               *
      * Permission to use, copy, modify and distribute this software  *
      * for any commercial purpose requires a fee to be paid to       *
      * SimoTime Technologies. 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           *
      * Technologies.                                                 *
      *                                                               *
      * SimoTime Technologies makes no warranty or representations    *
      * about the suitability of the software for any purpose. It is  *
      * provided "AS IS" without any expressed or implied warranty,   *
      * including the implied warranties of merchantability, fitness  *
      * for a particular purpose and non-infringement. SimoTime       *
      * Technologies 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 Technologies                                         *
      * 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 Technologies, *
      * 15 Carnoustie Drive, Novato, CA 94949-5849.                   *
      *                                                               *
      *****************************************************************
      *      This program is provided by SimoTime Technologies        *
      *        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 ' v06.03.03'.
           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-2019 '.
           05  C3 pic X(28) value '   SimoTime Technologies    '.
           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.

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

Table of Contents Previous Section Next Section The Copy File for the Linkage Section

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 or Pass Area used for calling SIMOTXTN.    *
      *****************************************************************
      *         Copyright (C) 1987-2019 SimoTime Technologies         *
      *                     All Rights Reserved                       *
      *****************************************************************
      *              Provided by SimoTime Technologies                *
      *        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 - - - - - - - - - - - PASSTXTN *
      *****************************************************************
      *

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.

Table of Contents Previous Section Next Section Summary

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. This document may be used to assist as a tutorial for new programmers or as a quick reference for experienced programmers.

In the world of programming there are many ways to solve a problem. This documentation and software were developed and tested on systems that are configured for a SIMOTIME environment based on the hardware, operating systems, user requirements and security requirements. Therefore, adjustments may be needed to execute the jobs and programs when transferred to a system of a different architecture or configuration.

SIMOTIME Services has experience in moving or sharing data or application processing across a variety of systems. For additional information about SIMOTIME Services or Technologies please contact us using the information in the  Contact or Feedback  section of this document.

Table of Contents Previous Section Next Section Software Agreement and Disclaimer

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

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

Table of Contents Previous Section Next Section Downloads and Links

This section includes links to documents with additional information that are beyond the scope and purpose of this document. The first group of documents may be available from a local system or via an internet connection, the second group of documents will require an internet connection.

Note: A SimoTime License is required for the items to be made available on a local system or server.

Table of Contents Previous Section Next Section Current Server or Internet Access

The following links may be to the current server or to the Internet.

Note: The latest versions of the SimoTime Documents and Program Suites are available on the Internet and may be accessed using the Link to Internet icon. If a user has a SimoTime Enterprise License the Documents and Program Suites may be available on a local server and accessed using the Link to Server icon.

Link to Internet   Link to Server   Explore the JCL Connection for more examples of JCL functionality with programming techniques and sample code.

Link to Internet   Link to Server   Explore the COBOL Connection for more examples of COBOL programming techniques and sample code.

Link to Internet   Link to Server   Explore An Enterprise System Model that describes and demonstrates how Applications that were running on a Mainframe System and non-relational data that was located on the Mainframe System were copied and deployed in a Microsoft Windows environment with Micro Focus Enterprise Server.

Link to Internet   Link to Server   Explore The ASCII and EBCDIC Translation Tables. These tables are provided for individuals that need to better understand the bit structures and differences of the encoding formats.

Link to Internet   Link to Server   Explore The File Status Return Codes that are used to interpret the results of accessing VSAM data sets and/or QSAM files.

Table of Contents Previous Section Next Section Internet Access Required

The following links will require an internet connect.

This suite of programs and documentation is available to download for review and evaluation purposes. Other uses will require a SimoTime Software License. Link to an Evaluation zPAK Option that includes the program members, documentation and control files.

A good place to start is The SimoTime Home Page for access to white papers, program examples and product information. This link requires an Internet Connection

Explore The Micro Focus Web Site for more information about products (including Micro Focus COBOL) and services available from Micro Focus. This link requires an Internet Connection.

Table of Contents Previous Section Next Section Glossary of Terms

Link to Internet   Link to Server   Explore the Glossary of Terms for a list of terms and definitions used in this suite of documents and white papers.

Table of Contents Previous Section Next Section Contact or Feedback

This document was created and is maintained by SimoTime Technologies. If you have any questions, suggestions, comments or feedback please use the following contact information.

1. Send an e-mail to our helpdesk.
1.1. helpdesk@simotime.com.
2. Our telephone numbers are as follows.
2.1. 1 415 763-9430 office-helpdesk
2.2. 1 415 827-7045 mobile

 

We appreciate hearing from you.

Table of Contents Previous Section Next Section Company Overview

SimoTime Technologies was founded in 1987 and 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. Our customers include small businesses using Internet technologies to corporations using very large mainframe systems.

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. We specialize in preparing applications and the associated data that are currently residing on a single platform to be distributed across a variety of platforms.

Preparing the application programs will require the transfer of source members that will be compiled and deployed on the target platform. The data will need to be transferred between the systems and may need to be converted and validated at various stages within the process. SimoTime has the technology, services and experience to assist in the application and data management tasks involved with doing business in a multi-system environment.

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
Convert Numbers or Digits to a Text String of Words
Copyright © 1987-2025
SimoTime Technologies and Services
All Rights Reserved
When technology complements business
http://www.simotime.com