Global Members
 Called Routines or Driver Programs
http://www.simotime.com
 Copyright © 1987-2010  SimoTime Enterprises  All Rights Reserved
When technology complements business    Copyright © 1987-2010  SimoTime Enterprises  All Rights Reserved
  Table of Contents Version 10.03.20 
  Introduction
  SimoBITS, Expand or Compress Eight Bits & Eight Bytes
 
  Expand, translate the bits of a one-byte field to bytes of an eight-byte field
  Compress, translate the bytes of an eight-byte field into bits of a one-byte field
  Call Interface with Copy File
  Source Code Listing
  SimoDATE, Provide Date Validation and Editing
  SimoDUMP, Provide Hex-Dump Information
  SimoEXEC, Driver Program for Net Express Applications
  SimoHEX4, Provide Hex-Dump Information
  SimoLOGS, Write to a Log File and Display to Console
  SimoPARS, Parse a Field by Keywords
  SimoSUB1, Substitute a String within a Field
  SimoTXTN, Convert Numbers to Words
 
  SimoTXTN, Call Interface with Copy File
  Source Code Listing for SimoTXTN
  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 sample programs performs global tasks and is divided into two categories, callable routines and driver programs.

SimoBITS, EXPAND or Compress Eight Bits & Eight Bytes
(Next) (Previous) (Table-of-Contents)

The SimoBITS routine (or callable program) uses an approach of converting the bit information in a single byte to or from an eight-byte field of COBOL accessible zeroes and ones. SimoBITS is written and tested using the VS COBOL II dialect. Also, SimoBITS will work with COBOL for MVS and COBOL/370. A suite of sample programs that illustrate the use of the SimoBITS routine is provided on the SimoTime Web Site. SimoBITS may be compiled and executed on an IBM mainframe or as a project with Micro Focus Mainframe Express (MFE) or Net Express running on a PC with Windows (refer to http://www.microfocus.com ).

Determining and changing the setting of a bit is possible using COBOL. An assembler routine or the use of a language extension is not required. The called COBOL routine (SIMOBITS) in this example provides two functions.

EXPAND - translate the bits of a one-byte field to bytes of an eight-byte field
(Next) (Previous) (Table-of-Contents)

For each bit that is ON (1) in the BTS-PASS-BITS field the corresponding byte in the BTS-PASS-BYTES field is set to a value of one. For each bit that is OFF (0) in the BTS-PASS-BITS field the corresponding byte in the BTS-PASS-BYTES field is set to a value of zero.

  Input BTS-PASS-BITS, a one byte field (8-bits)
  Output BTS-PASS-BYTES, an eight byte field
  Example  if  BTS-PASS-BITS = x'55'  then  BTS-PASS-BYTES will be '01010101'
     

COMPRESS - translate the bytes of an eight-byte field into bits of a one-byte field
(Next) (Previous) (Table-of-Contents)

For each byte that is a one in the BTS-PASS-BYTES field the corresponding bit in the BTS-PASS-BITS field is set to ON (1). For each byte that is zero in the BTS-PASS-BYTES field the corresponding bit in the BTS-PASS-BITS field is set to OFF (0).

  Input BTS-PASS-BYTES, an eight byte field
  Output BTS-PASS-BITS, a one byte field (8-bits)
  Example  if   BTS-PASS-BYTES = '01010101'  then  BTS-PASS-BITS will be set to x'55'
     

Call Interface with Copy File
(Next) (Previous) (Table-of-Contents)

The callable interface requires a data structure to be defined. A copy file (PASSBITS.CPY) is provided with the following source code.

      *****************************************************************
      *           Data Structure used for calling SIMOBITS.           *
      *****************************************************************
      *         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       *
      *****************************************************************
       01  BTS-PASS-AREA.
           05  BTS-PASS-REQUEST            PIC X(8).
           05  BTS-PASS-RESULT             PIC S9(9)   COMP.
           05  BTS-PASS-RECORD.
               10  BTS-PASS-BITS           PIC X.
               10  BTS-PASS-BYTES.
                   15  BTS-PASS-BYTE-01    PIC X.
                   15  BTS-PASS-BYTE-02    PIC X.
                   15  BTS-PASS-BYTE-03    PIC X.
                   15  BTS-PASS-BYTE-04    PIC X.
                   15  BTS-PASS-BYTE-05    PIC X.
                   15  BTS-PASS-BYTE-06    PIC X.
                   15  BTS-PASS-BYTE-07    PIC X.
                   15  BTS-PASS-BYTE-08    PIC X.
      *!   PASSBITS - End-of-Copy File...

The following will translate an eight character field of 0's and 1's to a one byte field with the bits set to match to 0's and 1's of the eight character field. Please note: the content of the BTS-PASS-REQUEST field must be upper case and contain 'COMPRESS'

      *****************************************************************
      * The coding required to do the call to the Byte-Bit Routine    *
      * (translate an 8-byte field to a 1-byte field).                *
      *****************************************************************
           MOVE '11111111'         to BTS-PASS-BYTES
           MOVE 'COMPRESS'         to BTS-PASS-REQUEST
           CALL 'SIMOBITS'      using BTS-PASS-AREA

In the preceding example the contents of BTS-PASS-BITS will be X'FF' or high-value upon return from the call to SIMOBITS.

The following will set the individual bytes of an eight character field to 0's or 1's based on the bit settings of a one byte field. Please note: the content of the BTS-PASS-REQUEST field must be upper case and contain 'EXPAND' followed by two spaces

      *****************************************************************
      * The coding required to do the call to the Byte-Bit Routine    *
      * (translate a 1-byte field to an 8-byte field).                *
      *****************************************************************
           MOVE X'55'              to BTS-PASS-BITS
           MOVE 'EXPAND  '         to BTS-PASS-REQUEST
           CALL 'SIMOBITS'      using BTS-PASS-AREA

In the preceding example the contents of BTS-PASS-BYTES will be '01010101' upon return from the call to SIMOBITS.

Source Code for SimoBITS Routine
(Next) (Previous) (Table-of-Contents)

The following (SIMOBITS.CBL) is the COBOL source code.

       IDENTIFICATION DIVISION.
       PROGRAM-ID.    SIMOBITS.
       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.This software contains confidential information   *
      *                                                               *
      * 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: SIMOBITS.CBL
      * Copy Files:    PASSBITS.CPY
      *****************************************************************
      *
      * SIMOBITS - A called routine for bit and byte conversions.
      *
      * CALLING PROTOCOL
      * ----------------
      * Use standard COBOL calling procedures.
      *
      * DESCRIPTION
      * -----------
      * This program will do Bit and Byte 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 '* SIMOBITS '.
           05  T2 pic X(34) value 'Convert between Bits and Bytes    '.
           05  T3 pic X(10) value ' v03.01.24'.
           05  T4 pic X(24) value ' http://www.simotime.com'.
       01  SIM-COPYRIGHT.
           05  C1 pic X(11) value '* SIMOBITS '.
           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 '* SIMOBITS '.
           05  MESSAGE-TEXT        pic X(68).

       01  TWO-BYTES.
           05  TWO-BYTES-01        pic X.
           05  TWO-BYTES-02        pic X.
       01  TWO-BYTES-BINARY        redefines   TWO-BYTES
                                   pic S9(4)   binary.

       01  IX-1                    pic 99      value 0.
       01  REGISTER-1              pic S9(5)   value 0.
      *****************************************************************
       LINKAGE SECTION.
       COPY PASSBITS.

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

       MAIN-ROUTINE.
           subtract BTS-PASS-RESULT from BTS-PASS-RESULT

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

           evaluate BTS-PASS-REQUEST
               when 'COMPRESS' perform COMPRESS-BYTES
               when 'EXPAND  ' perform EXPAND-BITS
               when OTHER      perform INVALID-REQUEST
           end-evaluate

           add BTS-PASS-RESULT to ZERO giving RETURN-CODE

           GOBACK.

      *****************************************************************
       INVALID-REQUEST.
           display '* SIMOBITS, INVALID REQUEST, ' BTS-PASS-REQUEST
           add 16 to ZERO giving BTS-PASS-RESULT
           exit.

      *****************************************************************
      * Input:  BTS-PASS-BYTES, an eight byte field
      * Output: BTS-PASS-BITS, a one byte field (8-bits)
      *
      * For each byte that is a one in the BTS-PASS-BYTES field the
      * corresponding bit in the BTS-PASS-BITS field is set to ON (1)
      *
      * For each byte that is zero in the BTS-PASS-BYTES field the
      * corresponding bit in the BTS-PASS-BITS field is set to OFF (0).
      *
      * Example:
      * BTS-PASS-BYTES = '01010101' then BTS-PASS-BITS set to x'55'
      *****************************************************************
       COMPRESS-BYTES.
           subtract TWO-BYTES-BINARY from TWO-BYTES-BINARY
           add 1   to ZERO giving IX-1
           add 128 to ZERO giving REGISTER-1
           perform until IX-1 GREATER THAN 8
               if  BTS-PASS-BYTES(IX-1:1) = '1'
                   add REGISTER-1 to TWO-BYTES-BINARY
               else
                   if  BTS-PASS-BYTES(IX-1:1) not = '0'
                       move '8-Byte string must be zeroes or ones...'
                         to MESSAGE-TEXT
                       perform Z-POST-MESSAGE
                       add 8 to IX-1
                       add 8 to ZERO giving BTS-PASS-RESULT
                   end-if
               end-if
               divide 2 INTO REGISTER-1
               add 1 to IX-1
           end-perform
           move TWO-BYTES-02 to BTS-PASS-BITS
           exit.

      *****************************************************************
      * Input:  BTS-PASS-BITS, a one byte field (8-bits)
      * OUTPUT: BTS-PASS-BYTES, an eight byte field
      *
      * For each bit that is on in BTS-PASS-BITS set the
      * corresponding byte in BTS-PASS-BYTES to a value of one.
      *
      * For each bit that is off in BTS-PASS-BITS set the
      * corresponding byte in BTS-PASS-BYTES to a value of zero.
      *
      * Example:
      * BTS-PASS-BITS = x'55' then BTS-PASS-BYTES will be '01010101'
      *****************************************************************
       EXPAND-BITS.
           subtract TWO-BYTES-BINARY from TWO-BYTES-BINARY
           add 1   to ZERO giving IX-1
           add 128 to ZERO giving REGISTER-1
           move BTS-PASS-BITS to TWO-BYTES-02
           perform 8 times
               if  TWO-BYTES-BINARY = REGISTER-1
               or  TWO-BYTES-BINARY > REGISTER-1
                   move '1' to BTS-PASS-BYTES(IX-1:1)
                   subtract REGISTER-1 from TWO-BYTES-BINARY
               else
                   move '0' to BTS-PASS-BYTES(IX-1:1)
               end-if
               divide 2 INTO REGISTER-1
               add 1 to IX-1
           end-perform
           exit.

      *****************************************************************
      *    Display the Copyright data-structure...
      *    ------------------------------------------------------------
       Z-POST-COPYRIGHT.
           display SIM-TITLE      upon console
           display SIM-COPYRIGHT  upon console
           exit.
       Z-POST-MESSAGE.
           display MESSAGE-BUFFER upon console
           move SPACES to MESSAGE-TEXT
           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       *
      *****************************************************************

SimoDATE, Provide Date Validation and Editing
(Next) (Previous) (Table-of-Contents)

This program ...

SimoDUMP, Provide Hex-Dump Information
(Next) (Previous) (Table-of-Contents)

This program ...

SimoEXEC, Driver Program for Net Express Applications
(Next) (Previous) (Table-of-Contents)

This is a driver program used with Micro Focus Net Express running on a Windows platform on a Personal Computer. Quite often the COBOL programs may be ported from an IBM Mainframe and were executed from a JCL (Job Control Language) script that passed a parameter. Also, the ability to write to a log file may be required as a replacement for the mainframe spool file function that shows the start, stop and status of the completed or abended job.

SimoHEX4, Provide Hex-Dump Information
(Next) (Previous) (Table-of-Contents)

This program ...

SimoLOGS, Write to a Log File and Display to Console
(Next) (Previous) (Table-of-Contents)

This program ...

SimoPARS, Parse a Field by Keywords
(Next) (Previous) (Table-of-Contents)

This program ...

SimoSUB1, Substitute a String within a Field
(Next) (Previous) (Table-of-Contents)

This program ...

SimoTXTN, Convert Numbers to Words
(Next) (Previous) (Table-of-Contents)

The SimoTXTN routine will create a 150-character 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

SimoTXTN, Call Interface with Copy File
(Next) (Previous) (Table-of-Contents)

The callable interface requires a data structure to be defined. A copy file (PASSTXTN.CPY) is provided with the following source code.

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

The following will translate a twelve digit field of "000000001898" to a 150 byte field of text..

      *****************************************************************
      * The coding required to do the call to the Numbers-to-Words    *
      * is as follows.                                                *
      *****************************************************************
           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

In the preceding example the contents of TXN-PASS-TEXT will be "Eighteen-and-98/100-Dollars" upon return from the call to SIMOTXTN. Also, the TXN-PASS-NUM-LEFT-EDITED field will contain "$18.98", the value will be left-justified with trailing spaces.

Source Code for SimoTXTN Routine
(Next) (Previous) (Table-of-Contents)

The following (SIMOTXTN.CBL) is the COBOL source code.

       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.This software contains confidential information   *
      *                                                               *
      * 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       *
      *****************************************************************

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

The purpose of this program is to provide examples ...

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.

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

You may download this example at http://www.simotime.com/sim4dzip.htm#COBOLCommaDelimitedFile or view the complete list of SimoTime Examples at http://www.simotime.com/sim4dzip.htm.
Note: You must be attached to the Internet to download or view the list.

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

The SimoZAPS Utility Program has the capability of generating a COBOL program that will do the conversion of sequential and VSAM (KSDS) files between EBCDIC and ASCII. SimoZAPPER can also read a sequential file in EBCDIC format and create an ASCII/CRLF file or VSAM KSDS file in ASCII format. The conversion tables may be viewed or modified to meet unique requirements. The Hexcess/2 function provides the capability of viewing, finding or patching the contents of a file in hexadecimal.

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

Check out  The VSAM - QSAM Connection  for more examples of mainframe VSAM and QSAM accessing techniques and sample code.

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

Check out  The SimoTime Library  for a wide range of topics for Programmers, Project Managers and Software Developers.

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

We appreciate your comments and feedback.

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