COBOL Coding Tricks
The Common and the Esoteric
  Table of Contents  v-24.01.01 - cbltrx01.htm 
  Introduction
  Sample Routines
  Date and Time
  Case Conversion
  EBCDIC and ASCII Conversion
  Redefine Data Structures
  Scan a Field, Reference Modification
  Numeric Testing & Initialization
  Right Adjust with Zero Fill
  Numeric Convert, Packed to Display
  Table Processing & Bubble Sort
  Swap the Content of Two Fields
  Field Swap, COBOL calls HLASM
  Field Swap, COBOL calls COBOL
  Calculate Elapsed Time
  JCL Member for Mainframe System
  Command File for Windows System
  COBOL Demonstration Program
  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 shows various COBOL coding techniques to perform tasks or provide function that may be considered outside the primary business processing requirements. The structuring and validation of data prior to processing by business logic is often required. In the world of programming there is usually more than one way to solve a programming challenge. This suite of programs presents a few tips and techniques to some of these programming challenges.

The source code for the CMD file, the JCL member and the COBOL programs is provided and may be modified to fit your environment.


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 Sample Routines

The intent of this section is to provide a summary of the sub-routines by function and a quick link to the sub-routines within the main program.

Table of Contents Previous Section Next Section Date and Time

This process uses two subroutines. The first sub-routine will call the second sub-routine to get the data and time and then post the information to SYSOUT. The second sub-routine will get the system data and time using the COBOL ACCEPT statement.

The date and time will be posted to SYSOUT in a variety of formats.

Click on this link to view the sub-routine in the program that does the Get System Date and Post to SYSOUT. To return to this point use the browser's "back" function.

Click on this link to view the sub-routine in the program that does the Get System Date and Time. To return to this point use the browser's "back" function.

Table of Contents Previous Section Next Section Case Conversion

This sub-routine will convert text strings of mixed case to all upper or lower case. A "before and after" snapshot of the text strings will be posted to SYSOUT.

The following two items are created in the COBOL WORKING-STORAGE section.

 
       01  UPPER-CASE  pic X(26) value 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.
       01  LOWER-CASE  pic X(26) value 'abcdefghijklmnopqrstuvwxyz'.
 

In the PROCEDURE DIVISION the following statement will convert a text string of mixed-case content to all upper case.

           inspect TEXT-STRING converting LOWER-CASE to UPPER-CASE

Click on this link to view the code in the program that does the Case Conversion. To return to this point use the browser's "back" function.

Table of Contents Previous Section Next Section EBCDIC and ASCII Conversion

WIP2

Table of Contents Previous Section Next Section Redefine Data Structures

This sub-routine shows how to access a single position within a field. This approach (using REDEFINES) works well for small fields. If larger fields are being scanned or parsed it may be a better approach to use reference modification that is described in the next section.

Click on this link to view the code in the program that does the Cobol Redefines Example. To return to this point use the browser's "back" function.

Table of Contents Previous Section Next Section Scan a Field, Reference Modification

This sub-routine will show two (2) examples of accessing individual bytes with a field or text string. The first example is similar to the preceding section that uses the REDEFINES capability of COBOL but uses explicit coding and Reference Modification.

The second example uses Reference Modification with a variable pointer to the byte to be accessed. This provides for a very efficient text scanning or parsing capability.

Click on this link to view the code in the program that does the Cobol Reference Modification. To return to this point use the browser's "back" function.

Table of Contents Previous Section Next Section Numeric Testing & Initialization

This segment of code will describe and demonstrate the COBOL techniques for checking the validity of a numeric field. The techniques for initializing both numeric and alphanumeric fields is included.

This example will use the following data structure.

 
       01  INITIALIZE-GROUP.
           05  INIT-TEXT-01       pic X(6)           value 'PREFIX'.
           05  INIT-ZDU1-01       pic 9(5)           value 12345.
           05  INIT-PDU1-01       pic 9(5)   COMP-3  value 12345.
           05  INIT-BNU1-01       pic 9(5)   COMP    value 12345.
           05  INIT-TEXT-02       pic X(6)           value 'SUFFIX'
 

The following is a sample of what is written to SYSOUT.

 
* CBLTRXC1 Starting NUMERIC-TESTING
* CBLTRXC1 T1, INIT-TEXT-01 is PREFIX
* CBLTRXC1 T1, INITIAL-TOTAL = 0037035
* CBLTRXC1 T1, INIT-TEXT-02 is SUFFIX
* CBLTRXC1 T2, INIT-TEXT-01 is
* CBLTRXC1 T2, INITIAL-TOTAL = 0000000
* CBLTRXC1 T2, INIT-TEXT-02 is
* CBLTRXC1 T3, INIT-TEXT-01 is XXXXXX
* CBLTRXC1 T3, INITIAL-TOTAL = 0000003
* CBLTRXC1 T3, INIT-TEXT-02 is XXXXXX
* CBLTRXC1 T4, A Numeric Field contains non-Numeric value…
* CBLTRXC1 Finished NUMERIC-TESTING
 

In the PROCEDURE DIVISION the following statements are used to initialize the individual fields within a group.

           initialize INITIALIZE-GROUP

or

 
           initialize INITIALIZE-GROUP replacing
                                       NUMERIC DATA by 1
                                       ALPHANUMERIC BY all 'X'
 

or

           move all SPACES to INITIALIZE-GROUP

Note:  The use of a "MOVE" of all SPACES at the group level is not a good practice when the group contains fields that are defined as numeric.

Click on this link to view the code in the program that does the Numeric Testing and Field Initialization To return to this point use the browser's "back" function.

Table of Contents Previous Section Next Section Right Adjust with Zero Fill

WIP2

Click on this link to view the code in the program that does the Right Adjust with Zero Fill. To return to this point use the browser's "back" function.

Table of Contents Previous Section Next Section Numeric Convert, Packed to Display

This sub-routine will do two conversions. The first conversion will add the value of a packed-decimal field to a zoned-decimal field with a sign-leading-separate. This will produce a new field that is a display-text field with an implied decimal point. The second conversion will add the value of a packed-decimal field to an edited-numeric field. This will produce a new field that is a display-text field with an explicit decimal point.

The approach of using the "add current-field to zero giving new-field" is used instead of a move. This will do proper rounding and correct decimal alignment if the source and target fields have different decimal positions.

The content of each of the fields will be displayed in a hexadecimal format to SYSOUT and SYSLOG.

Click on this link to view the code in the program that does the Numeric Conversion, Packed to Display. To return to this point use the browser's "back" function.

Table of Contents Previous Section Next Section Table Processing & Bubble Sort

A separate program is called for this example.

Click on this link to view the code in the program that does the Table Processing & Bubble Sort. This will be displayed in a separate window.

Table of Contents Previous Section Next Section Swap the Content of Two Fields

The following two test cases will show how to swap the content of two data strings (or fields) without using a 3rd intermediary field as a holding space.

Table of Contents Previous Section Next Section Field Swap, COBOL calls HLASM

The following takes advantage of the results of the XC (Exclusive OR) Instruction of HLASM to swap the contents of two data strings.

Click on this link to review the process that will use the XC Instruction of HLASM to swap the content of two data strings. This will be displayed in a separate window.

Table of Contents Previous Section Next Section Field Swap, COBOL calls COBOL

The following takes advantage of the results of the exclusive-OR (XOR) function to swap the contents of two data strings.

Click on this link to review the process that will use the XOR Function to swap the content of two data strings. This will be displayed in a separate window.

Table of Contents Previous Section Next Section Calculate Elapsed Time

WIP2

Click on this link to view the code in the program that does the Calculate Elapsed Time. To return to this point use the browser's "back" function.

Table of Contents Previous Section Next Section JCL Member for Mainframe System

The following (CBLTRXJ1.jcl) is a sample of the Mainframe JCL needed to run this job.

//CBLTRXJ1 JOB SIMOTIME,ACCOUNT,CLASS=1,MSGCLASS=0,NOTIFY=CSIP1
//* *******************************************************************
//*       CBLTRXJ1.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 code for commonly used processing tasks.
//* Author - SimoTime Technologies
//* Date   - January 01, 1989
//*
//* This set of programs illustrate the use of COBOL programs that
//* perform commonly used processing tasks. The tasks may be used to
//* solve a business requirement or for debugging purposes.
//*
//* This set of programs will run on a mainframe under MVS or on
//* a Personal Computer running Windows and Mainframe Express by
//* Micro Focus.
//*
//*   ************                    ************
//*   *  Entry   *                    *  Entry   *
//*   *   MVS    *                    * Windows  *
//*   ************                    ************
//*        *                               *
//*   ************                    ************
//*   * CBLTRXJ1 *                    * CBLTRXE1 *
//*   ********jcl*                    ********cmd*
//*        *                               *
//*   ************                         *
//*   * IEFBR14  *                         *
//*   ********utl*                         *
//*        *                               *
//*        *********************************
//*                        *
//*                        *
//*                   ************    ************
//*                   * CBLTRXC1 *----*  SYSOUT  *
//*                   ********cbl*    ************
//*                     *  *
//*                     *  *
//*                     *  *
//*        **************  *------CALL-----*
//*        *               *               *
//*        *               *          ************    ************
//*        *               *          * SIMODUMP *----*  SYSLOG  *
//*        *               *          ************    ************
//*        *               *
//*   ************         *
//*   *   EOJ    *         *------CALL-----*
//*   ************                         *
//*                                        *
//*                                        *
//*                                        *
//*                   ************    ************    ************
//*                   * CURS0080 *----* CBLTBLC1 *----* LABEL1X6 *
//*                   *******rseq*    ********cbl*    *******rseq*
//*
//* *******************************************************************
//* Step 1 of 2, This job step will delete a previously created
//*        Mailing Label file.
//*
//BLOWAWAY EXEC PGM=IEFBR14
//LABEL1X6 DD  DSN=SIMOTIME.DATA.LABEL1X6,DISP=(MOD,DELETE,DELETE),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=FB,LRECL=48,BLKSIZE=480,DSORG=PS)
//* *******************************************************************
//* Step 2 of 2, Execute the Sample programs....
//*
//CBLTRXS1 EXEC PGM=CBLTRXC1
//STEPLIB  DD  DSN=SIMOTIME.DEMO.LOADLIB1,DISP=SHR
//CURS0080 DD  DSN=SIMOTIME.DATA.CUST0080,DISP=SHR
//LABEL1X6 DD  DSN=SIMOTIME.DATA.LABEL1X6,DISP=(NEW,CATLG,DELETE),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=FB,LRECL=48,BLKSIZE=480,DSORG=PS)
//SYSOUT   DD  SYSOUT=*
//*

Table of Contents Previous Section Next Section Command File for Windows System

The following (CBLTRXE1.cmd) is a sample of the Windows CMD needed to run this job.

@echo OFF
rem  * *******************************************************************
rem  *               CBLTRXE1.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   - COBOL code for commonly used processing tasks.
rem  * Author - SimoTime Technologies
rem  * Date   - January 01, 1989
rem  *
rem  * This set of programs illustrate the use of COBOL programs that
rem  * perform commonly used processing tasks. The tasks may be used to
rem  * solve a business requirement or for debugging purposes.
rem  *
rem  * This set of programs will run on a mainframe under MVS or on
rem  * a Personal Computer running Windows and Mainframe Express by
rem  * Micro Focus.
rem  *
rem  *   ************                    ************
rem  *   *  Entry   *                    *  Entry   *
rem  *   *   MVS    *                    * Windows  *
rem  *   ************                    ************
rem  *        *                               *
rem  *   ************                    ************
rem  *   * CBLTRXJ1 *                    * CBLTRXE1 *
rem  *   ********jcl*                    ********cmd*
rem  *        *                               *
rem  *   ************                         *
rem  *   * IEFBR14  *                         *
rem  *   ********utl*                         *
rem  *        *                               *
rem  *        *********************************
rem  *                        *
rem  *                        *
rem  *                   ************    ************
rem  *                   * CBLTRXC1 *----*  SYSOUT  *
rem  *                   ********cbl*    ************
rem  *                     *  *
rem  *                     *  *
rem  *                     *  *
rem  *        **************  *------CALL-----*
rem  *        *               *               *
rem  *        *               *          ************    ************
rem  *        *               *          * SIMODUMP *----*  SYSLOG  *
rem  *        *               *          ************    ************
rem  *        *               *
rem  *   ************         *
rem  *   *   EOJ    *         *------CALL-----*
rem  *   ************                         *
rem  *                                        *
rem  *                                        *
rem  *                                        *
rem  *                   ************    ************    ************
rem  *                   * CURS0080 *----* CBLTBLC1 *----* LABEL1X6 *
rem  *                   *******rseq*    ********cbl*    *******rseq*
rem  *
rem  * ********************************************************************
rem  * Step   1 of 2  Set the global environment variables...
rem  *
     setlocal
     set CmdName=CBLTRXE1
     call ..\ENV1BASE
     set JobStatus=0000
     if "%SYSLOG%" == "" set syslog=c:\SimoLIBR\LOGS\SimoTime.LOG
rem  *
     call SimoNOTE "*******************************************************%CmdName%.cmd"
     call SimoNOTE "Starting JobName %CmdName%"
rem  * ********************************************************************
rem  * Step   2 of 2  Execute the sample program...
rem  *
     set CURS0080=%BaseLib1%\DATA\Asc1\SIMOTIME.DATA.QSAM0080.DAT
     set LABEL1X6=%BaseLib1%\DATA\Wrk1\SIMOTIME.DATA.LABEL1X6.DAT
     if exist %LABEL1X6% erase %LABEL1X6%
     run CBLTRXC1
     if not "%ERRORLEVEL%" == "0" set JobStatus=0010
     if not "%JobStatus%" == "0000" goto :EojNOK
:EojAOK
     call SimoNOTE "Produced %LABEL1X6%"
     call SimoNOTE "MSG_0001 Please review %SYSOUT%"
     call SimoNOTE "MSG_0002 Please review %SYSLOG%"
     start notepad %SYSOUT%
     start notepad %SYSLOG%
     call SimoNOTE "Finished JobName %CmdName%, Job Status is %JobStatus%"
     goto :End
:EojNOK
     call SimoNOTE "ABENDING JobName %CmdName%, Job Status is %JobStatus%"
     echo %CmdName% is ABENDING>>%BaseLib1%\LOGS\ABENDLOG.TXT
     goto :End
:End
     call SimoNOTE "Conclude SysLog is %SYSLOG%"
     if not "%1" == "nopause" pause
     endlocal

Table of Contents Previous Section Next Section COBOL Demonstration Program

The following (CBLTRXC1.cbl) is a sample of the Micro Focus COBOL demonstration program. This program will not compile or execute on an IBM Mainframe because of the ORGANIZATION IS LINE SEQUENTIAL on the SELECT statement. If the statement was changed to read ORGANIZATION IS SEQUENTIAL it would run on an IBM Mainframe and "read from" and "write to" a sequential file. The program was tested using Micro Focus Net Express, version 5.0 running on Windows/XP.

       IDENTIFICATION DIVISION.
       PROGRAM-ID.    CBLTRXC1.
       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: CBLTRXC1.CBL
      * Copy Files:    PASSBITS.CPY
      * Calls to:      SIMOBITS
      *****************************************************************
      *
      * CBLTRXC1 - COBOL code for commonly used processing tasks.
      *
      * CALLING PROTOCOL
      * ----------------
      * Use standard procedure to RUN or ANIMATE.
      *
      * DESCRIPTION
      * -----------
      * This program shows how to to some common business or system
      * tasks. This program will also call a COBOL routine to access
      * and sort a table..
      *
      *  ************                    ************
      *  *  Entry   *                    *  Entry   *
      *  *   MVS    *                    * Windows  *
      *  ************                    ************
      *       *                               *
      *  ************                    ************
      *  * CBLTRXJ1 *                    * CBLTRXE1 *
      *  ********jcl*                    ********cmd*
      *       *                               *
      *  ************                         *
      *  * IEFBR14  *                         *
      *  ********utl*                         *
      *       *                               *
      *       *********************************
      *                       *
      *                       *
      *                  ************    ************
      *                  * CBLTRXC1 *----* DISPLAY  *
      *                  ********cbl*    ************
      *                    *      *
      *                    *      *
      *                    *      *
      *       **************      *---CALL----*
      *       *                               *
      *       *                               *
      *  ************                         *
      *  *   EOJ    *                         *
      *  ************                         *
      *                                       *
      *                                       *
      *                                       *
      *                  ************    ************    ************
      *                  * TXTA0512 *----* CBLTBLC1 *----* LABEL1X6 *
      *                  ********txt*    ********cbl*    ********txt*
      *
      *
      * This program calls CBLTBLC1 to process a table.
      *
      *****************************************************************
      *
      * MAINTENANCE
      * -----------
      * 1989/02/27 Simmons, Created program.
      * 1997/03/17 Simmons, Updated for call to SIMOBITS.
      *
      *****************************************************************
      *
       ENVIRONMENT DIVISION.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
      *****************************************************************
      *    Data-structure for Title and Copyright...
      *    -----------------------------------------------------------*
       01  SIM-TITLE.
           05  T1 pic X(11) value '* CBLTRXC1 '.
           05  T2 pic X(34) value 'Techniques and Common Routines'    .
           05  T3 pic X(10) value ' v11.11.03'.
           05  T4 pic X(24) value ' http://www.simotime.com'.
       01  SIM-COPYRIGHT.
           05  C1 pic X(11) value '* CBLTRXC1 '.
           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 '* CBLTRXC1 '.
           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 '* CBLTRXC1 '.
           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'.

      *****************************************************************
      *    Buffer used for posting messages to the console.
      *    -----------------------------------------------------------*
       01  MESSAGE-BUFFER.
           05  MESSAGE-HEADER      pic X(11)   value '* CBLTRXC1 '.
           05  MESSAGE-TEXT.
               10  MESSAGE-TEXT-1  pic X(68)   value SPACES.
               10  MESSAGE-TEXT-2  pic X(41)   value SPACES.
      *    End-of-Message-Buffer

       01  TASK-FLAGS.
           05  TASK-FLAG-BANNER    pic X       value 'Y'.
           05  TASK-FLAG-THANKS    pic X       value 'Y'.
           05  TASK-FLAG-DISPLAY   pic X       value 'Y'.
           05  TASK-FLAG-SYSOUT    pic X       value 'Y'.

       01  WORK-50                 pic X(50)   value SPACES.
       01  IX-1                    pic 9(3)    value 0.

       01  BASE-FIELD              pic X(3)    value 'ABC'.
       01  BASE-FIELD-X            redefines   BASE-FIELD.
           05  BASE-FIELD-X1       pic X.
           05  BASE-FIELD-X2       pic X.
           05  BASE-FIELD-X3       pic X.

       01  NUMBERS-GROUP-01.
           05  NBR-05-PACK-SIGN        pic S9(5)   comp-3 value 123.
           05  NBR-05-PACK-SIGN-X      redefines   NBR-05-PACK-SIGN
                                       pic X(3).
           05  FILLER                  pic X(13)   value SPACES.

           05  NBR-05-SIGN-LEAD-S      pic S9(5)   value 456
                                       SIGN LEADING SEPARATE.
           05  NBR-05-SIGN-LEAD-S-X    redefines   NBR-05-SIGN-LEAD-S
                                       pic X(6).
           05  FILLER                  pic X(10)   value SPACES.

           05  NBR-05-EDIT-SIGN        pic +ZZZ.99.
           05  FILLER                  pic X(09)   value SPACES.


       01  NBR-12-X                pic X(12)   value '123'.
       01  NBR-12                  redefines   NBR-12-X
                                   pic 9(12).

       01  ROUTINE-NAME            pic X(31).
       01  WORK-80                 pic X(80).

       01  UPPER-CASE  pic X(26) value 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.
       01  LOWER-CASE  pic X(26) value 'abcdefghijklmnopqrstuvwxyz'.

       01  MONTH-DATA.
           05  FILLER      pic X(9)    value 'January  '.
           05  FILLER      pic X(9)    value 'February '.
           05  FILLER      pic X(9)    value 'March    '.
           05  FILLER      pic X(9)    value 'April    '.
           05  FILLER      pic X(9)    value 'May      '.
           05  FILLER      pic X(9)    value 'June     '.
           05  FILLER      pic X(9)    value 'July     '.
           05  FILLER      pic X(9)    value 'August   '.
           05  FILLER      pic X(9)    value 'September'.
           05  FILLER      pic X(9)    value 'October  '.
           05  FILLER      pic X(9)    value 'November '.
           05  FILLER      pic X(9)    value 'December '.
       01  MONTH-TABLE     redefines   MONTH-DATA.
           05  MONTH-TEXT  pic X(9)    occurs 12 times.
       01  MM-IDX          pic 99      value 0.

       01  TODAY-IN-TEXT.
           05  FILLER      pic X(9)    value 'Today is '.
           05  TODAY-WORD  pic X(18)   value SPACES.
      *****************************************************************
      *    Working Storage items for the Z-ROUTINES...
      *    -----------------------------------------------------------*
       01  Z-DATE-01.
           05  Z-DATE-01-CC   pic 9(02).
           05  Z-DATE-01-YY   pic 9(02).
           05  Z-DATE-01-MM   pic 9(02).
           05  Z-DATE-01-DD   pic 9(02).
       01  Z-TIME-01.
           05  Z-TIME-01-HH   pic X(02).
           05  Z-TIME-01-NN   pic X(02).
           05  Z-TIME-01-SS   pic X(02).
           05  Z-TIME-01-TT   pic X(02).

       01  Z-DATE-TIME-02.
           05  Z-DATE-02.
               10  Z-DATE-02-CC   pic 9(02).
               10  Z-DATE-02-YY   pic 9(02).
               10  FILLER         pic X        value '/'.
               10  Z-DATE-02-MM   pic 9(02).
               10  FILLER         pic X        value '/'.
               10  Z-DATE-02-DD   pic 9(02).
           05  filler             pic x(3)     value ' - '.
           05  Z-TIME-02.
               10  Z-TIME-02-HH   pic 9(02).
               10  FILLER         pic X        value ':'.
               10  Z-TIME-02-MM   pic 9(02).
               10  FILLER         pic X        value ':'.
               10  Z-TIME-02-SS   pic 9(02).
               10  FILLER         pic X        value '.'.
               10  Z-TIME-02-TT   pic 9(02).

       01  Z-DATE-TIME-03.
           05  Z-DATE-03.
               10  Z-DATE-03-CC   pic 9(02).
               10  Z-DATE-03-YY   pic 9(02).
               10  FILLER         pic X        value '/'.
               10  Z-DATE-03-MM   pic 9(02).
               10  FILLER         pic X        value '/'.
               10  Z-DATE-03-DD   pic 9(02).
           05  filler             pic x(3)     value ' - '.
           05  Z-TIME-03.
               10  Z-TIME-03-HH   pic 9(02).
               10  FILLER         pic X        value ':'.
               10  Z-TIME-03-MM   pic 9(02).
               10  FILLER         pic X        value ':'.
               10  Z-TIME-03-SS   pic 9(02).
               10  FILLER         pic X        value '.'.
               10  Z-TIME-03-TT   pic 9(02).

       01  ELASPED-TIME-X.
           05  ELAPSED-TIME       pic ZZ,ZZZ.99.

       01  INITIALIZE-GROUP.
           05  INIT-TEXT-01       pic X(6)           value 'PREFIX'.
           05  INIT-ZDU1-01       pic 9(5)           value 12345.
           05  INIT-PDU1-01       pic 9(5)   COMP-3  value 12345.
           05  INIT-BNU1-01       pic 9(5)   COMP    value 12345.
           05  INIT-TEXT-02       pic X(6)           value 'SUFFIX'.
       01  INITIAL-TOTAL          pic 9(7)           value 0.

       01  Z-WORK-12              pic X(12)   value SPACES.
       01  Z-X12                  pic 9(3)    value 0.

       01  DUMP-HEADER.
           05  filler pic X value '*'.
           05  filler pic X value ' '.
           05  H1 pic X(7)  value ' Offset'.
           05  filler pic X value ' '.
           05  H2 pic X(35) value 'Hex..... ........ ........ ........'.
           05  filler pic X value ' '.
           05  H3 pic X(16) value 'ebcdic..........'.
           05  filler pic X value ' '.
           05  H4 pic X(16) value 'ascii...........'.

       COPY PASSDUMP.
       COPY ASCEBCB1.

      *****************************************************************
       PROCEDURE DIVISION.

           if  TASK-FLAG-BANNER = 'Y'
               perform Z-POST-COPYRIGHT
           end-if

      *    Show an example of accessing the system date and time.
           perform GET-SYSTEM-DATE

      *    Show how to use the INSPECT statement to do case conversion.
           perform CASE-CONVERSION

      *    Show how to convert between ASCII and EBCDIC using the
      *    INSPECT statement.
           perform ASCII-EBCDIC-CONVERSION

      *    Show an example of a COBOL REDEFINES
           perform COBOL-REDEFINES-EXAMPLE

           perform COBOL-REFERENCE-MODIFICATION

      *    Show how to test for a numeric value within a field.
           perform NUMERIC-TESTING

      *    Show a Right-Adjust and Zero-fill.
           perform RIGHT-ADJUST-ZERO-FILL

      *    Show how to convert from a NUMERIC, PACKED field to a
      *    display, numeric field.
           perform NUMERIC-PACKED-TO-DISPLAY

      *    Show an example of table processing
           perform TABLE-PROCESSING-BUBBLE-SORT

           perform Z-GET-DATE-AND-TIME

           if  TASK-FLAG-THANKS = 'Y'
               perform Z-THANK-YOU
           end-if

           GOBACK.

      * HTML-TAG                   
      *****************************************************************
       ASCII-EBCDIC-CONVERSION.
           move 'ASCII-EBCDIC-CONVERSION' to ROUTINE-NAME
           perform Z-ROUTINE-STARTING

           perform Z-ROUTINE-FINISHED
           exit.

      * HTML-TAG                    
      *****************************************************************
      * This routine requires the following items.
      *      Z-DATE-TIME-02 will contain the stop time
      *      Z-DATE-TIME-03 will contain the start time
      * This routine will provide the follow item.
      *      ELAPSED-TIME   will be calculated by the sub-routine.
      *
       CALCULATE-ELAPSED-TIME.
           if  Z-DATE-TIME-02 > Z-DATE-TIME-03
               compute
                   ELAPSED-TIME = (Z-TIME-02-HH * 3600
                                   + Z-TIME-02-MM * 60
                                   + Z-TIME-02-SS
                                   + Z-TIME-02-TT / 100)
                                -
                                  (Z-TIME-03-HH * 3600
                                   + Z-TIME-03-MM * 60
                                   + Z-TIME-03-SS
                                   + Z-TIME-03-TT / 100)
           else
               move ZEROES to ELAPSED-TIME
           end-if
           exit.

      * HTML-TAG                          
      *****************************************************************
      * This routine will convert text strings of mixed case to all
      * upper or lower case.
      *
       CASE-CONVERSION.
           move 'CASE-CONVERSION' to ROUTINE-NAME
           perform Z-ROUTINE-STARTING

           move 'Before - Please make this all upper case'
             to MESSAGE-TEXT
           perform Z-POST-MESSAGE
           move 'After  - Please make this all upper case'
             to MESSAGE-TEXT
      *    Do the case conversion . . .
           inspect MESSAGE-TEXT converting LOWER-CASE to UPPER-CASE
           perform Z-POST-MESSAGE

           move 'BEFORE - PLEASE MAKE THIS ALL LOWER CASE'
             to MESSAGE-TEXT
           perform Z-POST-MESSAGE
           move 'AFTER  - PLEASE MAKE THIS ALL LOWER CASE'
             to MESSAGE-TEXT
      *    Do the case conversion . . .
           inspect MESSAGE-TEXT converting UPPER-CASE to LOWER-CASE
           perform Z-POST-MESSAGE

           perform Z-ROUTINE-FINISHED
           exit.

      * HTML-TAG                   
      *****************************************************************
       COBOL-REDEFINES-EXAMPLE.
           move 'COBOL-REDEFINES-EXAMPLE' to ROUTINE-NAME
           perform Z-ROUTINE-STARTING

      *    Display the full three (3) byte field
           move 'Base-Field    ' to MESSAGE-TEXT
           move BASE-FIELD       to MESSAGE-TEXT(17:3)
           perform Z-POST-MESSAGE
      *    Display the 1st byte of the field using the REDEFINE
           move 'Base-Field-X1 ' to MESSAGE-TEXT
           move BASE-FIELD-X1    to MESSAGE-TEXT(17:1)
           perform Z-POST-MESSAGE
      *    Display the 2nd byte of the field using the REDEFINE
           move 'Base-Field-X2 ' to MESSAGE-TEXT
           move BASE-FIELD-X2    to MESSAGE-TEXT(17:1)
           perform Z-POST-MESSAGE
      *    Display the 3rd byte of the field using the REDEFINE
           move 'Base-Field-X3 ' to MESSAGE-TEXT
           move BASE-FIELD-X3    to MESSAGE-TEXT(17:1)
           perform Z-POST-MESSAGE

           perform Z-ROUTINE-FINISHED
           exit.

      * HTML-TAG              
      *****************************************************************
       COBOL-REFERENCE-MODIFICATION.
           move 'COBOL-REFERENCE-MODIFICATION' to ROUTINE-NAME
           perform Z-ROUTINE-STARTING

           move 'Access each byte in a text string, Explicit Code'
           to MESSAGE-TEXT
           perform Z-POST-MESSAGE
      *    Display the full three (3) byte field
           move 'Base-Field      ' to MESSAGE-TEXT
           move BASE-FIELD         to MESSAGE-TEXT(17:3)
           perform Z-POST-MESSAGE
      *    Reference and display the 1st byte of the field
           move 'Base-Field(1:1) ' to MESSAGE-TEXT
           move BASE-FIELD(1:1)    to MESSAGE-TEXT(17:1)
           perform Z-POST-MESSAGE
      *    Reference and display the 2nd byte of the field
           move 'Base-Field(2:1) ' to MESSAGE-TEXT
           move BASE-FIELD(2:1)    to MESSAGE-TEXT(17:1)
           perform Z-POST-MESSAGE
      *    Reference and display the 3rd byte of the field
           move 'Base-Field(3:1) ' to MESSAGE-TEXT
           move BASE-FIELD(3:1)    to MESSAGE-TEXT(17:1)
           perform Z-POST-MESSAGE

           move 'Access each byte in a text string, Perform loop'
           to MESSAGE-TEXT
           perform Z-POST-MESSAGE
      *    Display the full three (3) byte field
           move 'Text String     ' to MESSAGE-TEXT
           move UPPER-CASE         to MESSAGE-TEXT(17:26)
           perform Z-POST-MESSAGE
      *    Reference and display each byte of the field
           perform varying IX-1 from 1 by 1 until IX-1 > 26
               move 'Byte nnn is the character ' to MESSAGE-TEXT
               inspect MESSAGE-TEXT replacing first 'nnn' by IX-1
               move UPPER-CASE(IX-1:1) to MESSAGE-TEXT(27:1)
               perform Z-POST-MESSAGE
           end-perform

           perform Z-ROUTINE-FINISHED
           exit.

      * HTML-TAG                           
      *****************************************************************
       GET-SYSTEM-DATE.
           move 'GET-SYSTEM-DATE' to ROUTINE-NAME
           perform Z-ROUTINE-STARTING

           perform Z-GET-DATE-AND-TIME

           move Z-DATE-01            to MESSAGE-TEXT
           move 'System Date   ' to MESSAGE-TEXT(14:14)
           perform Z-POST-MESSAGE
           move Z-TIME-01            to MESSAGE-TEXT
           move 'System Time   ' to MESSAGE-TEXT(14:14)
           perform Z-POST-MESSAGE

           move Z-DATE-02            to MESSAGE-TEXT
           move 'Formatted Date' to MESSAGE-TEXT(14:14)
           perform Z-POST-MESSAGE
           move Z-TIME-02            to MESSAGE-TEXT
           move 'Formatted Time' to MESSAGE-TEXT(14:14)
           perform Z-POST-MESSAGE

           if  Z-DATE-01-MM GREATER THAN 0
           and                 LESS THAN 13
               move MONTH-TEXT(Z-DATE-01-MM) to TODAY-WORD
               inspect TODAY-WORD replacing all SPACES by '*'
               inspect TODAY-WORD replacing first '**' by ' *'
               inspect TODAY-WORD replacing first '**' by Z-DATE-01-DD
               inspect TODAY-WORD replacing first '**' by ', '
               inspect TODAY-WORD replacing first '**' by Z-DATE-01-CC
               inspect TODAY-WORD replacing first '**' by Z-DATE-01-YY
               inspect TODAY-WORD replacing all '*' by SPACES
               move TODAY-IN-TEXT to MESSAGE-TEXT
               perform Z-POST-MESSAGE
           else
               move 'INVALID Month requested...' to MESSAGE-TEXT
               perform Z-POST-MESSAGE
           end-if
           perform Z-ROUTINE-FINISHED
           exit.

      * HTML-TAG                  
      *****************************************************************
       NUMERIC-PACKED-TO-DISPLAY.
           move 'NUMERIC-PACKED-TO-DISPLAY' to ROUTINE-NAME
           perform Z-ROUTINE-STARTING

      *    The following statement will place the arithmetic value of
      *    the packed-decimal field into the zone-decimal field with
      *    the SIGN LEADING SEPARATE.
      *    The actual value will be x'4EF0F0F1F2F3'. This results in
      *    converting the packed-decimal field. Both fields have an
      *    implied decimal point.
           add NBR-05-PACK-SIGN to ZERO giving NBR-05-SIGN-LEAD-S

      *    The following statement will place the arithmetic value of
      *    the packed-decimal field into the edited print field. The
      *    actual value will be x'4E4040F14BF2F3'. This results in
      *    converting the packed-decimal field but has leading spaces.
           add NBR-05-PACK-SIGN to ZERO giving NBR-05-EDIT-SIGN

      *    The preceding two (2) statements do the conversion of the
      *    packed-decimal field to a display-text field.
      *    The following will post a hexadecimal dump of the various
      *    fields with the possible ASCII or EBCDIC display.
      *    The hexadecimal dump information is posted to both the
      *    SYSOUT and SYSLOG files.

           move 'DUMP' to SIMODUMP-REQUEST
           move 'HIDE' to SIMODUMP-COPYRIGHT
           if  TASK-FLAG-SYSOUT = 'Y'
               move 'LOG1' to SIMODUMP-OUTPUT
           else
               move 'OPR2' to SIMODUMP-OUTPUT
           end-if
           move 'PACKED01' to SIMODUMP-DUMP-ID
           add length of NUMBERS-GROUP-01
                      to             ZERO
                  giving  SIMODUMP-LENGTH
           move NUMBERS-GROUP-01 to SIMODUMP-BUFFER
           call 'SIMODUMP' using SIMODUMP-PASS-AREA
                                 SIMODUMP-BUFFER
           move 'Info_MSG Display Working Storage dump' to MESSAGE-TEXT
           perform Z-POST-MESSAGE
           move DUMP-HEADER to MESSAGE-TEXT
           perform Z-POST-MESSAGE
           move SIMODUMP-LINES(1) to MESSAGE-TEXT
           perform Z-POST-MESSAGE
           move SIMODUMP-LINES(2) to MESSAGE-TEXT
           perform Z-POST-MESSAGE
           move SIMODUMP-LINES(3) to MESSAGE-TEXT
           perform Z-POST-MESSAGE

           perform Z-ROUTINE-FINISHED
           exit.

      * HTML-TAG                          
      *****************************************************************
       NUMERIC-TESTING.
      *    This segment of code will describe and demonstrate the
      *    COBOL techniques for checking the validity of a numeric
      *    field. The techniques for initializing both numeric and
      *    alphanumeric fields is included.
      *
      *    Data Structure used for this example is as follows:
      *
      *01  INITIALIZE-GROUP.
      *    05  INIT-TEXT-01       pic X(6)           value 'PREFIX'.
      *    05  INIT-ZDU1-01       pic 9(5)           value 12345.
      *    05  INIT-PDU1-01       pic 9(5)   COMP-3  value 12345.
      *    05  INIT-BNU1-01       pic 9(5)   COMP    value 12345.
      *    05  INIT-TEXT-02       pic X(6)           value 'SUFFIX'.
      *01  INITIAL-TOTAL          pic 9(7)           value 0.
      *
           move 'NUMERIC-TESTING' to ROUTINE-NAME
           perform Z-ROUTINE-STARTING
      *---------------------------------------------------------------*
      *    T1, Test the program default values of the group numerics
      *    for validity and display results.
      *
           if  INIT-ZDU1-01 is NUMERIC
           and INIT-PDU1-01 is NUMERIC
               compute INITIAL-TOTAL = INIT-ZDU1-01
                                     + INIT-PDU1-01
                                     + INIT-BNU1-01
               display '* CBLTRXC1 T1, INIT-TEXT-01 is ' INIT-TEXT-01
               display '* CBLTRXC1 T1, INITIAL-TOTAL = ' INITIAL-TOTAL
               display '* CBLTRXC1 T1, INIT-TEXT-02 is ' INIT-TEXT-02
           else
               move 'T1, A Numeric Field contains non-Numeric value...'
                 to MESSAGE-TEXT
               perform Z-POST-MESSAGE
           end-if

      *---------------------------------------------------------------*
      *    T2, Initialize the fields as a group. This should initialize
      *        the text strings to spaces and the numerics to Zeroes.
      *        Test the numerics for validity and display results.
      *
           initialize INITIALIZE-GROUP
           if  INIT-ZDU1-01 is NUMERIC
           and INIT-PDU1-01 is NUMERIC
               compute INITIAL-TOTAL = INIT-ZDU1-01
                                     + INIT-PDU1-01
                                     + INIT-BNU1-01
               display '* CBLTRXC1 T2, INIT-TEXT-01 is ' INIT-TEXT-01
               display '* CBLTRXC1 T2, INITIAL-TOTAL = ' INITIAL-TOTAL
               display '* CBLTRXC1 T2, INIT-TEXT-02 is ' INIT-TEXT-02
           else
               move 'T2, A Numeric Field contains non-Numeric value...'
                 to MESSAGE-TEXT
               perform Z-POST-MESSAGE
           end-if

      *---------------------------------------------------------------*
      *    T3, Initialize the fields as a group using the "replacing"
      *        function of the INITIALIZE. The following segment of
      *        code should initialize the text strings to all X's and
      *        the numerics to 1.
      *        Test the numerics for validity and display results.
      *
           initialize INITIALIZE-GROUP replacing
                                       NUMERIC DATA by 1
                                       ALPHANUMERIC BY all 'X'
           if  INIT-ZDU1-01 is NUMERIC
           and INIT-PDU1-01 is NUMERIC
               compute INITIAL-TOTAL = INIT-ZDU1-01
                                     + INIT-PDU1-01
                                     + INIT-BNU1-01
               display '* CBLTRXC1 T3, INIT-TEXT-01 is ' INIT-TEXT-01
               display '* CBLTRXC1 T3, INITIAL-TOTAL = ' INITIAL-TOTAL
               display '* CBLTRXC1 T3, INIT-TEXT-02 is ' INIT-TEXT-02
           else
               move 'T3, A Numeric Field contains non-Numeric value...'
                 to MESSAGE-TEXT
               perform Z-POST-MESSAGE
           end-if

      *---------------------------------------------------------------*
      *    T4, Move all spaces to the group item. The following
      *        segment of code should move all spaces to all the fields
      *        under the group item. This should produce an invalid
      *        result when the numeric fields are tested for validity.
      *
      *        The use of a "MOVE" of all SPACES at the group level is
      *        not a good practice when the group contains fields that
      *        are defined as numeric.
      *
           move all SPACES to INITIALIZE-GROUP
           if  INIT-ZDU1-01 is NUMERIC
           and INIT-PDU1-01 is NUMERIC
               compute INITIAL-TOTAL = INIT-ZDU1-01
                                     + INIT-PDU1-01
                                     + INIT-BNU1-01
               display '* CBLTRXC1 T4, INIT-TEXT-01 is ' INIT-TEXT-01
               display '* CBLTRXC1 T4, INITIAL-TOTAL = ' INITIAL-TOTAL
               display '* CBLTRXC1 T4, INIT-TEXT-02 is ' INIT-TEXT-02
           else
               move 'T4, A Numeric Field contains non-Numeric value...'
                 to MESSAGE-TEXT
               perform Z-POST-MESSAGE
           end-if

           perform Z-ROUTINE-FINISHED
           exit.

      * HTML-TAG                     
      *****************************************************************
      *
       RIGHT-ADJUST-ZERO-FILL.
           move 'RIGHT-ADJUST-ZERO-FILL' to ROUTINE-NAME
           perform Z-ROUTINE-STARTING

           move '123         ' to NBR-12-X
           perform RIGHT-ADJUST-ZERO-FILL-02

           move '12345       ' to NBR-12-X
           perform RIGHT-ADJUST-ZERO-FILL-02

           move '1234567     ' to NBR-12-X
           perform RIGHT-ADJUST-ZERO-FILL-02

           perform Z-ROUTINE-FINISHED
           exit.
      *---------------------------------------------------------------*
       RIGHT-ADJUST-ZERO-FILL-02.
      *    Test for Numeric content before the Right-Adjust, leading,
      *    trailing or embedded space characters should cause a
      *    non-numeric condition to exist.
           if  NBR-12 NUMERIC
               move 'NBR-12 AOK...' to MESSAGE-TEXT
               move NBR-12           to MESSAGE-TEXT(14:12)
               perform Z-POST-MESSAGE
           else
               move 'NBR-12 NOK...' to MESSAGE-TEXT
               move NBR-12           to MESSAGE-TEXT(14:12)
               perform Z-POST-MESSAGE
           end-if

      *    Do the Right-Adjust with Zero-Fill
           move NBR-12-X to Z-WORK-12
           perform Z-RIGHT-ADJUST-Z-WORK-12
           move Z-WORK-12 to NBR-12-X

      *    Test for Numeric content after the Right-Adjust
           if  NBR-12 NUMERIC
               move 'NBR-12 AOK...' to MESSAGE-TEXT
               move NBR-12           to MESSAGE-TEXT(14:12)
               perform Z-POST-MESSAGE
           else
               move 'NBR-12 NOK...' to MESSAGE-TEXT
               move NBR-12           to MESSAGE-TEXT(14:12)
               perform Z-POST-MESSAGE
           end-if
           exit.

      * HTML-TAG                         
      *****************************************************************
      *
       TABLE-PROCESSING-BUBBLE-SORT.
           move 'TABLE-PROCESSING-BUBBLE-SORT' to ROUTINE-NAME
           perform Z-ROUTINE-STARTING
      *    Get and Post the Starting Time
           perform Z-GET-DATE-AND-TIME
           move Z-DATE-TIME-02 to Z-DATE-TIME-03
           move 'Starting Time ' to MESSAGE-TEXT
           move Z-DATE-TIME-03   to MESSAGE-TEXT(15:24)
           perform Z-POST-MESSAGE

           call 'CBLTBLC1'

      *    Get and Post the Finished Time
           perform Z-GET-DATE-AND-TIME
           move 'Finished Time ' to MESSAGE-TEXT
           move Z-DATE-TIME-02   to MESSAGE-TEXT(15:24)
           perform Z-POST-MESSAGE

           perform CALCULATE-ELAPSED-TIME

           move 'Elapsed Time ' to MESSAGE-TEXT
           move ELAPSED-TIME    to MESSAGE-TEXT(30:9)
           move 'Seconds'       to MESSAGE-TEXT(40:7)
           perform Z-POST-MESSAGE

           perform Z-ROUTINE-FINISHED
           exit.

      * HTML-TAG                         
      *****************************************************************
      * The following Z-Routines perform administrative tasks         *
      * for this program.                                             *
      *****************************************************************
      * This routine requires COBOL for 390 dialect because of the
      * use of the YYYYMMDD on the ACCEPT statement.
      *
       Z-GET-DATE-AND-TIME.
           accept Z-DATE-01 from DATE YYYYMMDD
           accept Z-TIME-01 from TIME

           move 'ccyy/mm/dd'   to Z-DATE-02
           move Z-DATE-01(1:4) to Z-DATE-02(1:4)
           move Z-DATE-01(5:2) to Z-DATE-02(6:2)
           move Z-DATE-01(7:2) to Z-DATE-02(9:2)

           move 'hh:mm:ss.00'  to Z-TIME-02
           move Z-TIME-01(1:2) to Z-TIME-02(1:2)
           move Z-TIME-01(3:2) to Z-TIME-02(4:2)
           move Z-TIME-01(5:2) to Z-TIME-02(7:2)
           move Z-TIME-01(7:2) to Z-TIME-02(10:2)

           exit.

      *****************************************************************
       Z-POST-COPYRIGHT.
           if  TASK-FLAG-SYSOUT = 'Y'
               display SIM-TITLE
               display SIM-COPYRIGHT
           else
               display SIM-TITLE     upon console
               display SIM-COPYRIGHT upon console
           end-if
           exit.

      *****************************************************************
       Z-POST-MESSAGE.
           if  TASK-FLAG-SYSOUT = 'Y'
               display MESSAGE-BUFFER
           else
               display MESSAGE-BUFFER upon console
           end-if
           move SPACES to MESSAGE-TEXT
           exit.

      *****************************************************************
       Z-POST-MESSAGE-TEXT.
           if  MESSAGE-TEXT-2 = SPACES
               if  TASK-FLAG-SYSOUT = 'Y'
                   display MESSAGE-BUFFER(1:79)
               else
                   display MESSAGE-BUFFER(1:79) upon console
               end-if
           else
               if  TASK-FLAG-SYSOUT = 'Y'
                   display MESSAGE-BUFFER
               else
                   display MESSAGE-BUFFER upon console
               end-if
           end-if
           move SPACES to MESSAGE-TEXT
           exit.

      *****************************************************************
      * Delete all characters to the right of the first space then
      * right-adjust with zero fill. This routine works with a single,
      * twelve character field and does not require a work area.
      *****************************************************************
       Z-RIGHT-ADJUST-Z-WORK-12.
      *    The following INSPECT statement will erase to end-of-field
      *    any characters after the first space character.
           inspect Z-WORK-12
                   replacing CHARACTERS by ' ' after initial ' '

      *    The following IF logic is for performance. It quickly
      *    reduces the number of loops for the PERFORM logic.
           if  Z-WORK-12(7:6) = SPACES
               if  Z-WORK-12(4:3) = SPACES
                   move Z-WORK-12(1:3) to Z-WORK-12(10:3)
                   move all ZEROES     to Z-WORK-12(1:9)
               else
                   move Z-WORK-12(1:6) to Z-WORK-12(7:6)
                   move all ZEROES     to Z-WORK-12(1:6)
               end-if
           else
               if  Z-WORK-12(10:3) = SPACES
      *            The following three MOVE statements are used to
      *            avoid a potential problem with an overlapping MOVE.
                   move Z-WORK-12(7:3) to Z-WORK-12(10:3)
                   move Z-WORK-12(4:3) to Z-WORK-12(7:3)
                   move Z-WORK-12(1:3) to Z-WORK-12(4:3)
                   move all ZEROES     to Z-WORK-12(1:3)
               end-if
           end-if

           perform until Z-WORK-12(12:1) not = SPACE
               if  Z-WORK-12(12:1) = SPACE
                   add 11 to ZERO giving Z-X12
                   perform 11 times
                     move Z-WORK-12(Z-X12:1) to Z-WORK-12(Z-X12 + 1:1)
                     subtract 1 from Z-X12
                   end-perform
                   move ZERO to Z-WORK-12(1:1)
               end-if
           end-perform
           exit.

      *****************************************************************
       Z-ROUTINE-STARTING.
           if  TASK-FLAG-DISPLAY = 'Y'
               move all '-' to MESSAGE-TEXT(1:64)
               move     '*' to MESSAGE-TEXT(1:1)
               move     '*' to MESSAGE-TEXT(64:1)
               perform Z-POST-MESSAGE-TEXT
               move 'Starting ' to MESSAGE-TEXT
               move ROUTINE-NAME to MESSAGE-TEXT(10:32)
               perform Z-POST-MESSAGE-TEXT
           end-if
           exit.

      *****************************************************************
       Z-ROUTINE-FINISHED.
           if  TASK-FLAG-DISPLAY = 'Y'
               move 'Finished ' to MESSAGE-TEXT
               move ROUTINE-NAME to MESSAGE-TEXT(10:32)
               perform Z-POST-MESSAGE-TEXT
               move SPACES to ROUTINE-NAME
           end-if
           exit.

      *****************************************************************
       Z-THANK-YOU.
           if  TASK-FLAG-SYSOUT = 'Y'
               display SIM-THANKS-01
               display SIM-THANKS-02
           else
               display SIM-THANKS-01 upon console
               display SIM-THANKS-02 upon console
           end-if
           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 Summary

This suite of programs shows various COBOL coding techniques to perform tasks or provide function that may be considered outside the primary business processing requirements. 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.

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 Extended List of Software Technologies that are available for review and evaluation. The software technologies (or Z-Packs) provide individual programming examples, documentation and test data files in a single package. The Z-Packs are usually in zip format to reduce the amount of time to download.

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
COBOL Coding Tricks, the Common and the Esoteric
Copyright © 1987-2025
SimoTime Technologies and Services
All Rights Reserved
When technology complements business
http://www.simotime.com