Table Processing
Bubble Sort
  Table of Contents  v-24.01.01 - cbltbl01.htm 
  Introduction
  Sample Routines
  Load the Table
  Sort Table By Postal Code
  Retrieve the Elements in the Table
  JCL Member for Execution
  CMD Member for Execution
  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 sample programs describes how to use COBOL to load a table with customer information and then sort the table using a bubble sort routine. The elements in the table will be sorted in postal code sequence.

The source code for the CMD file, the JCL member and the COBOL programs is provided and may be modified to fit your environment. The COBOL program will run on an IBM Mainframe System or in a Micro Focus environment on Windows.


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-2024
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 Load the Table

This sub-routine will read a record sequential file of eighty-byte records and load each record into an element of an in-memory table. The table contains one-hundred (100) elements.

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

Table of Contents Previous Section Next Section Sort Table By Postal Code

Once the table is loaded it will be sorted based on the postal code value.

Click on this link to view the code in the program that does the Sort Table By Postal Code. This will be displayed in a separate window.

Table of Contents Previous Section Next Section Retrieve the Elements in the Table

Next, the table will be processed sequentially to produce a file of mailing labels in postal code sequence.

Click on this link to view the code in the program that will Sequentially Retrieve the Elements in the Table. This will be displayed in a separate window.

Table of Contents Previous Section Next Section JCL Member for Execution

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

//CBLTBLJ1 JOB SIMOTIME,ACCOUNT,CLASS=1,MSGCLASS=0,NOTIFY=CSIP1
//* *******************************************************************
//*       CBLTBLJ1.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 table processing tasks.
//* Author - SimoTime Technologies
//* Date   - January 01, 1989
//*
//* This set of programs illustrate the use of COBOL programs that
//* perform table processing tasks.
//*
//* 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  *
//*   ************                    ************
//*        *                               *
//*   ************                    ************
//*   * CBLTBLJ1 *                    * CBLTBLE1 *
//*   ********jcl*                    ********cmd*
//*        *                               *
//*   ************                    ************
//*   * IEFBR14  *                    * If Exist *
//*   ********utl*                    *******stmt*
//*        *                               *
//*        *********************************
//*                        *
//*                        *
//*   ************    ************    ************
//*   * CURS0080 *----* CBLTBLC1 *----* LABEL1X6 *
//*   *******rseq*    ********cbl*    *******rseq*
//*                        *
//*                        *
//*                   ************
//*                   *   EOJ    *
//*                   ************
//*
//* *******************************************************************
//* Step 1 of 2, This job step will delete a previously created
//*              LABELS file.
//*
//CBLTBLS1 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 program....
//*
//CBLTBLS2 EXEC PGM=CBLTBLC1
//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 CMD Member for Execution

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

@echo OFF
rem  * *******************************************************************
rem  *               CBLTBLE1.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  *
rem  * Text   - COBOL code for table 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 table processing tasks.
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  * Step   1 of 2  Set the global environment variables...
rem  *
     setlocal
     set CmdName=CBLTBLE1
     call ..\ENV1BASE
     set path
     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 CBLTBLC1
     if not "%ERRORLEVEL%" == "0" set JobStatus=0010
     if not "%JobStatus%" == "0000" goto :EojNOK
:EojAOK
     call SimoNOTE "Produced %LABEL1X6%"
     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 (CBLTBLC1.cbl) is a sample of a COBOL program.

       IDENTIFICATION DIVISION.
       PROGRAM-ID.    CBLTBLC1.
       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       *
      *                                                               *
      *****************************************************************
      * MAINTENANCE
      * -----------
      * 1994/02/27 Simmons, Created program.
      *
      *****************************************************************
      * Source Member: CBLTBLC1.CBL
      * Copy Files:    CU2SEQB1
      * Calls to:      none...
      *****************************************************************
      *                                                               *
      *                                   Record    Record     Key    *
      *  Function  Name     Organization  Format    Max-Min  Pos-Len  *
      *  INPUT     CURS0080 ASCII/CRLF    VARIABLE   00512            *
      *  OUTPUT    MEMCODEA ASCII/CRLF    VARIABLE   00512            *
      *                                                               *
      *****************************************************************
      * This program will load a table with data from a sequential
      * file. The maximum number of table entries for this sample is
      * fifty (50) items.
      *
      * After loading the table it will be sorted using a bubble sort
      * routine to arrange the items in Postal Code sequence.
      *
       ENVIRONMENT DIVISION.
       INPUT-OUTPUT SECTION.
       FILE-CONTROL.
           SELECT CURS0080-FILE  ASSIGN TO       CURS0080
                  ORGANIZATION IS SEQUENTIAL
                  ACCESS MODE  IS SEQUENTIAL
                  FILE STATUS  IS CURS0080-STATUS.
           SELECT LABEL1X6-FILE  ASSIGN TO       LABEL1X6
                  ORGANIZATION IS SEQUENTIAL
                  ACCESS MODE  IS SEQUENTIAL
                  FILE STATUS  IS LABEL1X6-STATUS.

      *****************************************************************
       DATA DIVISION.
       FILE SECTION.
       FD  CURS0080-FILE
           DATA RECORD    IS CUST-80-RECORD
           .
       COPY CUST80B1.

       FD  LABEL1X6-FILE
           DATA RECORD    IS LABEL1X6-RECORD
           .
       01  LABEL1X6-RECORD.
           05  LABEL1X6-LINE           PIC X(48).

      *****************************************************************
       WORKING-STORAGE SECTION.
      *****************************************************************
      *    Data-structure for Title and Copyright...
      *****************************************************************
       01  SIM-TITLE.
           05  T1 pic X(11) value '* CBLTBLC1 '.
           05  T2 pic X(34) value 'Example for Table Processing      '.
           05  T3 pic X(10) value ' v08.02.28'.
           05  T4 pic X(24) value ' http://www.simotime.com'.
       01  SIM-COPYRIGHT.
           05  C1 pic X(11) value '* CBLTBLC1 '.
           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 '* CBLTBLC1 '.
           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 '* CBLTBLC1 '.
           05  C2 pic X(32) value 'Please send all inquires or sugg'.
           05  C3 pic X(32) value 'estions to the helpdesk@simotime'.
           05  C4 pic X(04) value '.com'.

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

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

       01  IO-STATUS.
           05  IO-STAT1            pic X.
           05  IO-STAT2            pic X.
       01  TWO-BYTES.
           05  TWO-BYTES-LEFT      pic X.
           05  TWO-BYTES-RIGHT     pic X.
       01  TWO-BYTES-BINARY        redefines TWO-BYTES pic 9(4) comp.
       01  IO-STATUS-4             pic 9(4)  value 0.
       01  IO-STATUS-4A            redefines IO-STATUS-4 pic X(4).

      *****************************************************************
      * Message Buffer used by the Z-DISPLAY-MESSAGE-TEXT routine.    *
      *****************************************************************
       01  MESSAGE-BUFFER.
           05  MESSAGE-HEADER      pic X(11)   value '* CBLTBLC1 '.
           05  MESSAGE-TEXT.
               10  MESSAGE-TEXT-1  pic X(68)   value SPACES.
               10  MESSAGE-TEXT-2  pic X(188)  value SPACES.

      *****************************************************************
      *    Data-structure for environment variable get routine...
      *****************************************************************
       01  ENV-VAR-NAME            pic X(16)   value SPACES.
       01  ENV-VAR-VALUE           pic X(256)  value SPACES.

       01  ENV-VAR-SIZE            pic 9(3)    value 0.
       01  BUFFER-SIZE             pic 9(3)    value 80.
       01  PTR-01                  pic 9(3)    value 0.
       01  NUMB-01                 pic 9(3)    value 0.

       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  CURS0080-TOTAL.
           05  filler      pic X(23)   value 'Source member count is '.
           05  CURS0080-RDR  pic 9(9)    value 0.
           05  filler      pic X       value SPACE.
       01  CURS0080-TOTAL-2.
           05  filler      pic X(23)   value 'Total Lines of Code is '.
           05  TOTAL-LOC   pic 9(9)    value 0.
           05  filler      pic X(20)   value ' Total Hex count is '.
           05  TOTAL-ERR   pic 9(9)    value 0.

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

       01  WRK-202                 pic X(202)  value SPACES.
       01  ROUTINE-NAME            pic X(31).

       01  INSERT-COMMA.
           05  FILLER              pic X(2)    value ', '.
           05  WRK-18              pic X(18)   value SPACES.
       01  INSERT-COMMA-X          redefines INSERT-COMMA
                                   pic X(20).

       01  INSERT-SPACE.
           05  FILLER              pic X       value ' '.
           05  WRK-28              pic X(28)   value SPACES.
       01  INSERT-SPACE-X          redefines INSERT-SPACE
                                   pic X(29).

       01  TIX-1                   pic 9(3)    value 0.
       01  TIX-LO                  pic 9(3)    value 0.
       01  TIX-HI                  pic 9(3)    value 0.
       01  TIX-DIFF                pic 9(3)    value 0.
       01  TIX-CURR                pic 9(3)    value 0.
       01  TIX-SWAP-LO             pic 9(3)    value 0.
       01  TIX-SWAP-HI             pic 9(3)    value 0.
       01  NUMBER-OF-ACTIVE-ITEMS  pic 9(3)    value 0.

       COPY LABTABLE.

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

      *    Perform First-Time processing...
           perform Z-POST-COPYRIGHT

      *    Load the table with data from a file...
           perform LOAD-THE-TABLE

      *    Sort the table by Postal Code
           add TIX-1 to ZERO giving TIX-HI
           add 1 to ZERO giving TIX-LO
           perform SORT-TABLE-BY-POSTAL-CODE

      *    Write the Mailing Labels in Postal Code sequence...
           perform CREATE-LABELS-FROM-TABLE

      *    Possible Abnormal Termination (ABEND)...
           if  APPL-AOK
               if  CURS0080-EOF not = 'Y'
               or  LABEL1X6-EOF not = 'Y'
                   add 16 to ZERO giving APPL-RESULT
               end-if
           end-if
           if  not APPL-AOK
               move 'is ABENDING...' to MESSAGE-TEXT
               perform Z-DISPLAY-MESSAGE-TEXT
           end-if

      *    End-of-Job...
           if  TASK-FLAG-BANNER = 'Y'
               perform Z-THANK-YOU
           end-if

           GOBACK.

      *****************************************************************
      * CREATE-LABELS-FROM-TABLE
      * This routine will access the table sequentially and produce
      * mailing labels in postal code sequence.
      *
       CREATE-LABELS-FROM-TABLE.
           move 'CREATE-LABELS-FROM-TABLE' to ROUTINE-NAME
           perform Z-ROUTINE-STARTING
           add 1 to ZERO giving TIX-1
           perform LABEL1X6-OPEN
             perform until TIX-1 > NUMBER-OF-ACTIVE-ITEMS
      *        Put the First name to Last name separated by a
      *        space on line one (1) of the mailing label.
               move TABL-FIRST-NAME(TIX-1)      to LABEL1X6-LINE
               move TABL-LAST-NAME(TIX-1)      to WRK-28
               inspect LABEL1X6-LINE replacing
                       first '                             '
                       by INSERT-SPACE-X
               perform LABEL1X6-WRITE-WITH-CLEAR

               if  TABL-ADDRESS-1(TIX-1) not = SPACES
                   move TABL-ADDRESS-1(TIX-1)   to LABEL1X6-LINE
                   perform LABEL1X6-WRITE-WITH-CLEAR
               end-if
               if  TABL-ADDRESS-2(TIX-1) not = SPACES
                   move TABL-ADDRESS-2(TIX-1)   to LABEL1X6-LINE
                   perform LABEL1X6-WRITE-WITH-CLEAR
               end-if
      *        Put the City, State and Postal Code on a single line
      *        of the mailing label.
               move TABL-CITY(TIX-1)       to LABEL1X6-LINE
               move TABL-STATE(TIX-1)      to WRK-18
               inspect LABEL1X6-LINE replacing
                       first '                    '
                       by INSERT-COMMA-X
               move TABL-POSTAL-CODE(TIX-1)      to WRK-28
               inspect LABEL1X6-LINE replacing
                       first '                             '
                       by INSERT-SPACE-X
               perform LABEL1X6-WRITE-WITH-CLEAR

               perform LABEL1X6-WRITE-WITH-CLEAR
               perform LABEL1X6-WRITE-WITH-CLEAR
               if  TABL-ADDRESS-1(TIX-1) = SPACES
                   perform LABEL1X6-WRITE-WITH-CLEAR
               end-if
               if  TABL-ADDRESS-2(TIX-1) = SPACES
                   perform LABEL1X6-WRITE-WITH-CLEAR
               end-if
               add 1 to TIX-1
             end-perform
           perform LABEL1X6-CLOSE
           perform Z-ROUTINE-FINISHED
           exit.

      *****************************************************************
      * LOAD-THE-TABLE
      * This routine will read a file and load the records into a table
      * in memory. The maximum number of entries in the table is
      * one-hundred (100).
      *
       LOAD-THE-TABLE.
           move 'LOAD-THE-TABLE' to ROUTINE-NAME
           perform Z-ROUTINE-STARTING
           perform CURS0080-OPEN
           move ZERO to TIX-1
           perform until CURS0080-STATUS not = '00'
               perform CURS0080-READ
               if  CURS0080-STATUS = '00'
               and CUST-80-RECORD not = SPACES
                   add 1 to TIX-1
                   move CUST-80-LNAME  to TABL-LAST-NAME(TIX-1)
                   move CUST-80-FNAME  to TABL-FIRST-NAME(TIX-1)
                   move CUST-80-ZIP    to TABL-POSTAL-CODE(TIX-1)
                   move CUST-80-STREET to TABL-ADDRESS-1(TIX-1)
                   move SPACES         to TABL-ADDRESS-2(TIX-1)
                   move CUST-80-CITY   to TABL-CITY(TIX-1)
                   move CUST-80-STATE  to TABL-STATE(TIX-1)
               end-if
           end-perform
           add TIX-1 to ZERO giving NUMBER-OF-ACTIVE-ITEMS
           perform CURS0080-CLOSE
           perform Z-ROUTINE-FINISHED
           exit.

      *****************************************************************
      * SORT-TABLE-BY-POSTAL-CODE
      * This routine expects TIX-LO to be set to one (1) or point to
      * the first table to be processed. TIX-HI should be set to the
      * number of active entries in the table.
      *
       SORT-TABLE-BY-POSTAL-CODE.
           move 'SORT-TABLE-BY-POSTAL-CODE' to ROUTINE-NAME
           perform Z-ROUTINE-STARTING
           perform until TIX-HI = 0
      *        Prepare for a Low-to-High pass of Table...
               add TIX-LO to ZERO GIVING TIX-CURR
               move 0 to TIX-SWAP-HI
      *        Low-to-High pass of Table, reset High-Limit for Scan...
               perform until TIX-CURR not less than TIX-HI
                   if  TABL-POSTAL-CODE(TIX-CURR) GREATER THAN
                       TABL-POSTAL-CODE(TIX-CURR + 1)
                       move TABLE-OF-CUSTOMERS(TIX-CURR) to WRK-202
                       move TABLE-OF-CUSTOMERS(TIX-CURR + 1)
                         to TABLE-OF-CUSTOMERS(TIX-CURR)
                       move WRK-202 to TABLE-OF-CUSTOMERS(TIX-CURR + 1)
                       add TIX-CURR to ZERO giving TIX-SWAP-HI
                   end-if
                   add 1 to TIX-CURR
               end-perform
      *        Set a new HIGH-LIMIT for table scan...
               add TIX-SWAP-HI to ZERO giving TIX-HI

      *        Prepare for a High-to-Low pass of Table...
               add TIX-HI to ZERO giving TIX-CURR
               move 0 to TIX-LO
      *        High-to-Low pass of Table, reset Low-Limit for Scan...
               perform until TIX-CURR not greater than TIX-LO
                   if  TABL-POSTAL-CODE(TIX-CURR) GREATER THAN
                       TABL-POSTAL-CODE(TIX-CURR + 1)
                       move TABLE-OF-CUSTOMERS(TIX-CURR) to WRK-202
                       move TABLE-OF-CUSTOMERS(TIX-CURR + 1)
                         to TABLE-OF-CUSTOMERS(TIX-CURR)
                       move WRK-202 to TABLE-OF-CUSTOMERS(TIX-CURR + 1)
                       add TIX-CURR to ZERO giving TIX-SWAP-LO
                   end-if
                   subtract 1 from TIX-CURR
               end-perform
      *        Set a new LOW-LIMIT for table scan...
               add TIX-SWAP-LO to ZERO giving TIX-LO
           end-perform
           perform Z-ROUTINE-FINISHED
           exit.

      *****************************************************************
      * I/O ROUTINES FOR LABEL1X6...                                 *
      *****************************************************************
       LABEL1X6-CLOSE.
           add 8 to ZERO giving APPL-RESULT.
           close LABEL1X6-FILE
           if  LABEL1X6-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
           else
               add 12 to ZERO giving APPL-RESULT
           end-if
           if  APPL-AOK
               move 'Y' to LABEL1X6-EOF
           else
               move 'LABEL1X6-Failure-CLOSE...' to MESSAGE-TEXT
               perform Z-DISPLAY-MESSAGE-TEXT
               move LABEL1X6-STATUS to IO-STATUS
               perform Z-DISPLAY-IO-STATUS
               perform Z-ABEND-PROGRAM
           end-if
           exit.
      *---------------------------------------------------------------*
       LABEL1X6-WRITE-WITH-CLEAR.
           perform LABEL1X6-WRITE
           move SPACES to LABEL1X6-RECORD
           exit.

      *---------------------------------------------------------------*
       LABEL1X6-WRITE.
           write LABEL1X6-RECORD
           if  LABEL1X6-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
           else
               if  LABEL1X6-STATUS = '10'
                   add 16 to ZERO giving APPL-RESULT
               else
                   add 12 to ZERO giving APPL-RESULT
               end-if
           end-if
           if  APPL-AOK
               CONTINUE
           else
               if  APPL-EOF
                   move 'Y' to LABEL1X6-EOF
               else
                   move 'LABEL1X6-Failure-PUT...' to MESSAGE-TEXT
                   perform Z-DISPLAY-MESSAGE-TEXT
                   move LABEL1X6-STATUS to IO-STATUS
                   perform Z-DISPLAY-IO-STATUS
                   perform Z-ABEND-PROGRAM
               end-if
           end-if
           exit.
      *---------------------------------------------------------------*
       LABEL1X6-OPEN.
           add 8 to ZERO giving APPL-RESULT.
           open output LABEL1X6-FILE
           if  LABEL1X6-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
               move 'O' to LABEL1X6-OPEN-FLAG
           else
               add 12 to ZERO giving APPL-RESULT
           end-if
           if  APPL-AOK
               CONTINUE
           else
               move 'LABEL1X6-Failure-OPEN...' to MESSAGE-TEXT
               perform Z-DISPLAY-MESSAGE-TEXT
               move LABEL1X6-STATUS to IO-STATUS
               perform Z-DISPLAY-IO-STATUS
               perform Z-ABEND-PROGRAM
           end-if
           exit.

      *****************************************************************
      * I/O ROUTINES FOR TXTA06512...                                 *
      *****************************************************************
       CURS0080-CLOSE.
           add 8 to ZERO giving APPL-RESULT.
           close CURS0080-FILE
           if  CURS0080-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
           else
               add 12 to ZERO giving APPL-RESULT
           end-if
           if  APPL-AOK
               move 'Y' to CURS0080-EOF
           else
               move 'CURS0080-Failure-CLOSE...' to MESSAGE-TEXT
               perform Z-DISPLAY-MESSAGE-TEXT
               move CURS0080-STATUS to IO-STATUS
               perform Z-DISPLAY-IO-STATUS
               perform Z-ABEND-PROGRAM
           end-if
           exit.
      *---------------------------------------------------------------*
       CURS0080-READ.
           read CURS0080-FILE
           if  CURS0080-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
           else
               if  CURS0080-STATUS = '10'
                   add 16 to ZERO giving APPL-RESULT
               else
                   add 12 to ZERO giving APPL-RESULT
               end-if
           end-if
           if  APPL-AOK
               CONTINUE
           else
               if  APPL-EOF
                   move 'Y' to CURS0080-EOF
               else
                   move 'CURS0080-Failure-GET...' to MESSAGE-TEXT
                   perform Z-DISPLAY-MESSAGE-TEXT
                   move CURS0080-STATUS to IO-STATUS
                   perform Z-DISPLAY-IO-STATUS
                   perform Z-ABEND-PROGRAM
               end-if
           end-if
           exit.
      *---------------------------------------------------------------*
       CURS0080-OPEN.
           add 8 to ZERO giving APPL-RESULT.
           open input CURS0080-FILE
           if  CURS0080-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
               move 'O' to CURS0080-OPEN-FLAG
           else
               add 12 to ZERO giving APPL-RESULT
           end-if
           if  APPL-AOK
               CONTINUE
           else
               move 'CURS0080-Failure-OPEN...' to MESSAGE-TEXT
               perform Z-DISPLAY-MESSAGE-TEXT
               move CURS0080-STATUS to IO-STATUS
               perform Z-DISPLAY-IO-STATUS
               perform Z-ABEND-PROGRAM
           end-if
           exit.

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

      *****************************************************************
       Z-POST-COPYRIGHT.
           move SIM-TITLE to MESSAGE-BUFFER
           perform Z-DISPLAY-MESSAGE-TEXT
           move SIM-COPYRIGHT to MESSAGE-BUFFER
           perform Z-DISPLAY-MESSAGE-TEXT
           exit.

      *****************************************************************
      * Display the file status bytes. This routine will display as   *
      * four digits. If the full two byte file status is numeric it   *
      * will display as 00nn. If the 1st byte is a numeric nine (9)   *
      * the second byte will be treated as a binary number and will   *
      * display as 9nnn.                                              *
      *****************************************************************
       Z-DISPLAY-IO-STATUS.
           if  IO-STATUS not NUMERIC
           or  IO-STAT1 = '9'
               subtract TWO-BYTES-BINARY from TWO-BYTES-BINARY
               move IO-STAT2 to TWO-BYTES-RIGHT
               add TWO-BYTES-BINARY to ZERO giving IO-STATUS-4
               move IO-STAT1 to IO-STATUS-4A(1:1)
               move 'File Status is: nnnn' to MESSAGE-TEXT
               move IO-STATUS-4A to MESSAGE-TEXT(17:4)
               perform Z-DISPLAY-MESSAGE-TEXT
           else
               move '0000' to IO-STATUS-4A
               move IO-STATUS to IO-STATUS-4A(3:2)
               move 'File Status is: nnnn' to MESSAGE-TEXT
               move IO-STATUS-4A to MESSAGE-TEXT(17:4)
               perform Z-DISPLAY-MESSAGE-TEXT
           end-if
           exit.

      *****************************************************************
      * Display CONSOLE messages...                                   *
      *****************************************************************
       Z-DISPLAY-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 all SPACES to MESSAGE-TEXT
           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-DISPLAY-MESSAGE-TEXT
               move 'Starting ' to MESSAGE-TEXT
               move ROUTINE-NAME to MESSAGE-TEXT(10:32)
               perform Z-DISPLAY-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-DISPLAY-MESSAGE-TEXT
               move SPACES to ROUTINE-NAME
           end-if
           exit.


      *****************************************************************
       Z-THANK-YOU.
           move SIM-THANKS-01 to MESSAGE-BUFFER
           perform Z-DISPLAY-MESSAGE-TEXT
           move SIM-THANKS-02 to MESSAGE-BUFFER
           perform Z-DISPLAY-MESSAGE-TEXT
           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

The purpose of this program is to provide examples for loading and processing tables within a COBOL program. This document may be used as a tutorial for new programmers or as a quick reference for experienced programmers.

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

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

Table of Contents Previous Section Next Section Software Agreement and Disclaimer

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

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

Table of Contents Previous Section Next Section Downloads and Links

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

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

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

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

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

Link to Internet   Link to Server   Explore How to Create a Simple Customer File for testing. This suite of programs will create an ASCII/Text file, an ASCII-encoded Sequential file and an EBCDIC-encoded Sequential file.

Link to Internet   Link to Server   Explore how to Create a Binary Table of binary values from X'00' through X'FF'. This example will use a Windows CMD File or JCL Member to execute a COBOL program.

Link to Internet   Link to Server   Explore various Table Processing Techniques using COBOL to perform functions such as a table load, a standard COBOL "SEARCH", a standard COBOL "SEARCH ALL", a user written binary search and a user written linear search.

Link to Internet   Link to Server   Explore how to use COBOL to Load a Table with customer information and then sort the table using a bubble sort routine. The elements in the table will be sorted in postal code sequence.

Link to Internet   Link to Server   Explore how to Produce 1, 2, 3 or 4 across Mailing Labels. This example uses a two-dimensional array to build the label-printing output.

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

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

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

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

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

Table of Contents Previous Section Next Section Internet Access Required

The following links will require an internet connect.

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

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

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

Table of Contents Previous Section Next Section Glossary of Terms

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

Table of Contents Previous Section Next Section Contact or Feedback

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

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

 

We appreciate hearing from you.

Table of Contents Previous Section Next Section Company Overview

SimoTime Technologies was founded in 1987 and is a privately owned company. We specialize in the creation and deployment of business applications using new or existing technologies and services. We have a team of individuals that understand the broad range of technologies being used in today's environments. Our customers include small businesses using Internet technologies to corporations using very large mainframe systems.

Quite often, to reach larger markets or provide a higher level of service to existing customers it requires the newer Internet technologies to work in a complementary manner with existing corporate mainframe systems. We specialize in preparing applications and the associated data that are currently residing on a single platform to be distributed across a variety of platforms.

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

Whether you want to use the Internet to expand into new market segments or as a delivery vehicle for existing business functions simply give us a call or check the web site at http://www.simotime.com


Return-to-Top
Table Processing, Bubble Sort
Copyright © 1987-2024
SimoTime Technologies and Services
All Rights Reserved
When technology complements business
http://www.simotime.com