Callable SORT
COBOL and Sorting
  Table of Contents  v-16.01.01 - cbsort01.htm 
  Introduction
  Program Overview & Diagram
  Program Objectives
  Program Requirements
  Program Input and Output
  The JCL Members
  Execute, COBOL with a Called SORT
  Create a Test Data File for SORT Input
  The CMD Files
  Execute, COBOL with a Called SORT
  Create a Test Data File for SORT Input
  The COBOL Program
  Summary
  Software Agreement and Disclaimer
  Downloads and Links
  Current Server or Internet Access
  Internet Access Required
  Glossary of Terms
  Comments or Feedback
  Company Overview
The SimoTime Home Page 

Table of Contents Previous Section Next Section Introduction

This suite of programs will describe and demonstrate by example how to use a COBOL program to call the SORT program to sort the records in a data file in ascending order by the surname that is located in positions 8-22.


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-2017
SimoTime Technologies
All Rights Reserved

Table of Contents Previous Section Next Section Program Overview & Diagram

The following shows the logic flow for the jobs with a COBOL Program calling SORT.

             
Entry Point
ZOS
Entry Point
Windows
   
   
CBSORTJ1
jcl
CBSORTW1
cmd
Submit the Job
   
   
IEFBR14
Utility
IF Exist
statement
Delete previously created output files
   
   
 
 
   
   
 
 
   
   
SORTG080
rseq
 
 
CBSORTC1
cbl
   
   
SORTP080
rseq
COBOL call SORT
   
   
   
   
   
SORT
utl
SORT Utility Program
   
EOJ
End-Of-Job
 
Logic Flow for the Jobs with a COBOL Program calling SORT

Color Associations: The  light-green  boxes are unique to the Mainframe and Micro Focus Enterprise Server/Studio (or Micro Focus Mainframe Express). The  light-red  boxes are unique to a Windows System and Micro Focus technologies. The  light-yellow  boxes are decision points or program transitions in the processing logic or program generations. The  light-blue  boxes identify the input/output data structures such as Documents, Spreadsheets, Data Files, VSAM Data Sets or Relational Tables. The  light-gray  boxes identify a system function or information item.

Table of Contents Previous Section Next Section Program Objectives

This example illustrates the following functions.

1 Demonstrate how to use a COBOL program to call the SORT program.
2 Demonstrate how to use a Windows Command file to map file names and execute the program.
3 Demonstrate how to use JCL to map file names and execute the program.
4 Demonstrate how to use a Windows Command file to create and convert test files.
5 Demonstrate how to use JCL to create test files.
  Functionality Included in this Suite of Programs

Table of Contents Previous Section Next Section Program Requirements

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

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

Table of Contents Previous Section Next Section Program Input and Output

The input is a record sequential file with eighty (80) byte, fixed length records arranged in a random sequence. The output is a record sequential file with eighty (80) byte, fixed length records sorted in sequence by the last name (or surname).

Table of Contents Previous Section Next Section The JCL Members

The following describes the JCL Members used in this suite of programs.

Table of Contents Previous Section Next Section Execute, COBOL with a Called SORT

The following JCL Member (CBSORTJ1.jcl) is used to allocate the resources and execute the COBOL program that calls the SORT program. The input is an unsorted file. The output is a sorted file arranged by surname sequence.

//CBSORTJ1 JOB (SIMOTIME),'COBOL SORT',CLASS=1,MSGCLASS=0,
//             NOTIFY=CSIP1
//* *******************************************************************
//*       CBSORTJ1.JCL - a JCL Member for Batch Job Processing        *
//*       This JCL Member is provided by SimoTime Technologies        *
//*           (C) Copyright 1987-2017 All Rights Reserved             *
//*             Web Site URL:   http://www.simotime.com               *
//*                   e-mail:   helpdesk@simotime.com                 *
//* *******************************************************************
//*
//* Text   - COBOL program with called SORT
//* Author - SimoTime Technologies
//* Date   - January 24, 1996
//*
//* This job will describe and demonstrate by example how to use
//* a COBOL program to call the sort program to sort a data file.
//*
//* This set of programs will run on a mainframe under MVS or on a
//* Personal Computer with Windows and Micro Focus Mainframe Express.
//*
//*                     ************
//*                     * CBSORTJ1 *
//*                     ********jcl*
//*                          *
//*                     ************
//*                     * IEFBR14  *
//*                     ********utl*
//*                          *
//*    ************     ************     ************
//*    * SORTG080 *-----* CBSORTC1 *-----* SORTP080 *
//*    ********dat*     ********cbl*     ********dat*
//*                          *   *
//*                          *   *       ************
//*                          *   *-call--*   SORT   *
//*                          *           ********utl*
//*                          *
//*                     ************
//*                     *   EOJ    *
//*                     ************
//*
//* *******************************************************************
//* Step 1 of 2, Delete any previously created file...
//*
//GETREADY EXEC PGM=IEFBR14
//SORTP080 DD  DSN=SIMOTIME.DATA.CUSTS080,DISP=(MOD,DELETE,DELETE),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=FB,LRECL=80,BLKSIZE=800,DSORG=PS)
//*
//* *******************************************************************
//* Step 2 of 2, Right, left and center adjust a text string in a field
//*              Create a new output file...
//*
//JUSTIFY1 EXEC PGM=CBSORTC1
//STEPLIB  DD  DSN=SIMOTIME.DEMO.LOADLIB1,DISP=SHR
//SORTG080 DD  DSN=SIMOTIME.DATA.CUSTW080,DISP=SHR
//SORTP080 DD  DSN=SIMOTIME.DATA.CUSTS080,
//             DISP=(NEW,CATLG,DELETE),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=FB,LRECL=80,BLKSIZE=800,DSORG=PS)
//SYSOUT   DD  SYSOUT=*
//

Table of Contents Previous Section Next Section Create a Test Data File for SORT Input

The following JCL Member (CBSORTJ8.jcl) is used to allocate the resources and create the test files used by this suite of programs.

//CBSORTJ8 JOB SIMOTIME,CLASS=1,MSGCLASS=0,NOTIFY=CSIP1
//* *******************************************************************
//*       CBSORTJ8.JCL - a JCL Member for Batch Job Processing        *
//*       This JCL Member is provided by SimoTime Technologies        *
//*           (C) Copyright 1987-2017 All Rights Reserved             *
//*             Web Site URL:   http://www.simotime.com               *
//*                   e-mail:   helpdesk@simotime.com                 *
//* *******************************************************************
//*
//* Text   - Create a Sequential Data Set on disk using IEBGENER.
//* Author - SimoTime Technologies
//* Date   - January 24, 1996
//*
//* The first job step (QSAMDELT) will delete any previously created
//* file. The second job step (QSAMCRT1) will create a new file.
//*
//* This set of programs will run on a mainframe under MVS or on a
//* Personal Computer with Windows and Micro Focus Mainframe Express.
//*
//*                      ************
//*                      * CBSORTJ8 *
//*                      ********jcl*
//*                           *
//*                           *
//*                      ************     ************
//*                      * IEFBR14  ******* CUSTW080 *
//*                      ********utl*     ***delete***
//*                           *
//*                           *
//*     ************     ************     ************
//*     *  SYSIN   ******* IEBGENER ******* CUSTW080 *
//*     ********jcl*     ********utl*     *******rseq*
//*                           *
//*                           *
//*                      ************
//*                      *   EOJ    *
//*                      ************
//*
//* *******************************************************************
//* Step 1 of 2, Delete any previously created file...
//*
//QSAMDELT EXEC PGM=IEFBR14
//CUST0080 DD  DSN=SIMOTIME.DATA.CUSTW080,DISP=(MOD,DELETE,DELETE),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=FB,LRECL=80,BLKSIZE=800,DSORG=PS)
//*
//* *******************************************************************
//* Step 2 of 2, Create and populate a new QSAM file...
//*
//QSAMCRT1 EXEC PGM=IEBGENER
//SYSPRINT DD  SYSOUT=*
//SYSIN    DD  DUMMY
//* :....1....:....2....:....3....:....4....:....5....:....6....:....7. ..:....8
//SYSUT1   DD  *
000100 Anderson       Adrian    1113 Peachtree Plaza    Atlanta        GA 26101
000200 Brown          Billie    224 Baker Boulevard     Baltimore      MD 35702
000300 Carson         Cameron   336 Crenshaw Blvd.      Cupertino      CA 96154
000400 Davidson       Dion      448 Main Street         Wilmington     DE 27323
000500 Everest        Evan      55 5TH Avenue, Apt 105  New York       NY 10341
000600 Franklin       Francis   6612 66TH Avenue        Bedrock        NY 11903
000700 Garfunkel      Gwen      777 77TH Street         New York       NY 16539
000800 Harrison       Hilary    888 88TH Street         Pocatello      ID 79684
000900 Isley          Isabel    999 99TH Avenue         Indianapolis   IN 38762
001000 Johnson        Jamie     1010 Paradise Drive     Larkspur       CA 90504
001010 Johnson        Julie     1010 Paradise Drive     Larkspur       CA 90504
001100 Kemper         Kelly     1111 Oak Circle         Kansas City    KS 55651
001200 Lemond         Lesley    1212 Lockwood Road      Mohave Desert  AZ 80303
001300 Mitchell       Marlow    1313 Miller Creek Road  Anywhere       TX 77123
001400 Newman         Noel      1414 Park Avenue        Santa Monica   CA 90210
001500 Osborn         Owen      1515 Center Stage       Rolling Rock   PA 36613
001600 Powell         Pierce    PO Box 1616             Ventura        CA 97712
001700 Quigley        Quincy    1717 Farm Hill Road     Oshkosh        WI 43389
001800 Ripley         Ray       1818 Alien Lane         Wayout         KS 55405
001900 Smith          Sammy     1919 Carnoustie Drive   Novato         CA 94919
002000 Tucker         Taylor    2020 Sanger Lane        St. Paul       MN 43998
002100 Underwood      Ulysses   2121 Wall Street        New York       NY 17623
002200 Van Etten      Valerie   2222 Vine Street        Hollywood      CA 98775
002300 Wilson         Wiley     2323 Main Street        Boston         MA 01472
002400 Xray           Xavier    2424 24TH Street        Nashville      TN 44190
002500 Young          Yanni     2525 Yonge Street       Toronto        ON 6B74A6
002600 Zenith         Zebulon   2626 26TH Street        Dallas         TX 71922
123456 Doe            John      123 Main Street         Anywhere       OR 88156
/*
//SYSUT2   DD  DSN=SIMOTIME.DATA.CUSTW080,
//             DISP=(NEW,CATLG,DELETE),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=FB,LRECL=80,BLKSIZE=800,DSORG=PS)
//

Table of Contents Previous Section Next Section The CMD Files

The following describes the Windows Command files used in this suite of programs.

Table of Contents Previous Section Next Section Execute, COBOL with a Called SORT

The following CMD file (CBSORTW1.cmd) is used to set the environment and execute the COBOL program that calls the SORT program. The input is an unsorted file. The output is a sorted file arranged by surname sequence.

@echo OFF
rem  * *******************************************************************
rem  *               CBSORTW1.CMD - a Windows Command File               *
rem  *         This program is provided by SimoTime Technologies         *
rem  *           (C) Copyright 1987-2017 All Rights Reserved             *
rem  *             Web Site URL:   http://www.simotime.com               *
rem  *                   e-mail:   helpdesk@simotime.com                 *
rem  * *******************************************************************
rem  *
rem  * Text   - Sort a File
rem  * Author - SimoTime Technologies
rem  * Date   - January 01, 1989
rem  *
rem  * *******************************************************************
rem  * Step 1 of 1  WIP
rem  * *******************************************************************
     set CMDNAME=CBSORTW1.CMD
     call ..\Env1BASE
     if "%SYSLOG%" == "" set syslog=c:\SimoLIBR\LOGS\SimoTime.LOG
rem  *
     call SimoNOTE "*******************************************************%CMDNAME%"
     call SimoNOTE "Starting CMDNAME %CMDNAME%, User is %USERNAME%"
rem  * *******************************************************************
     set SORTG080=%BaseLib1%\DATA\Asc1\SIMOTIME.DATA.CUSTW080.DAT
     set SORTP080=%BaseLib1%\DATA\Asc1\SIMOTIME.DATA.CUST0080.DAT
     if exist %SORTP080% erase %SORTP080%
     run CBSORTC1
     if not ERRORLEVEL = 0 set JobStatus=0010
     if not "%JobStatus%" == "0000" goto :EOJNOK
rem  *
:EOJNOK
     call SimoNOTE "ABENDING JobName %CMDNAME%"
     call SimoNOTE "ABENDING Message Job Status is %JobStatus%"
     goto :EOJpause
:EOJAOK
     call SimoNOTE "Finished JobName %CMDNAME%"
:EOJpause
     call SimoNOTE "Conclude SysLog is %SYSLOG%"
     if not "%1" == "nopause" pause
:EOJ

Table of Contents Previous Section Next Section Create a Test Data File for SORT Input

The following CMD file (CBSORTW8.cmd) is used to set the environment and create the test files used by this suite of programs.

@echo OFF
rem  * ************************************************************************
rem  *                 CBSORTW8.cmd - a Windows Command File                  *
rem  *           This program is provided by SimoTime Technologies            *
rem  *              (C) Copyright 1987-2017 All Rights Reserved               *
rem  *                Web Site URL:   http://www.simotime.com                 *
rem  *                      e-mail:   helpdesk@simotime.com                   *
rem  * ************************************************************************
rem  *
rem  * Text   - Create various sequential files with 80-byte records.
rem  * Author - SimoTime Technologies
rem  * Date   - January 24, 1996
rem  *
rem  * This procedure uses the Microsoft "ECHO" command to pipe instream
rem  * data to an ASCII/Text file. The following terms are used.
rem  *
rem  * LSEQ - a Line Sequential File or ASCII/Text File
rem  * RSEQ - a Record Sequential File. This example uses a file of
rem  *        80-byte records that may be ASCII or EBCDIC encoded.
rem  *
rem  * Once the LSEQ file is created it is used as input to create an
rem  * RSEQ file of 80-byte, ASCII-encoded records.
rem  *
rem  * Next, the LSEQ file is read a second time. The record content is
rem  * converted from ASCII to EBCDIC. A new RSEQ file is created with
rem  * the EBCDIC-encodd records.
rem  *
rem  * *******************************************************************
rem  * Step 1, Delete any previously created file...
rem  *
     set CmdName=CBSORTW8
     call ..\ENV1BASE
rem  *
     call SimoNOTE "*******************************************************%CmdName%.cmd"
     call SimoNOTE "Starting JobName %CmdName%"
:DeleteLSEQ
     call SimoNOTE "Identify JobStep DeleteLSEQ"
     set LSEQ0080=%BaseLib1%\DATA\Txt1\SIMOTIME.DATA.CUSTW080.TXT
     if exist %LSEQ0080% del %LSEQ0080%
rem  *
rem  * *******************************************************************
rem  * Step 2, Create a new output file. Use the "echo" command provided
rem  *         with Microsoft Windows to pipe instream data to a new
rem  *         ASCII/Text file.
rem  *
:ExecuteCreateLSEQ
     call SimoNOTE "Identify JobStep ExecuteCreateLSEQ"
rem  ....:....1....:....2....:....3....:....4....:....5....:....6....:....7....:....8
echo 001500 Osborn         Owen      1515 Center Stage       Rolling Rock   PA 36613 >>%LSEQ0080%
echo 000200 Brown          Billie    222 Baker Boulevard     Baltimore      MD 35702 >>%LSEQ0080%
echo 000300 Carson         Cameron   333 Crenshaw Blvd.      Cupertino      CA 96154 >>%LSEQ0080%
echo 000400 Davidson       Dion      444 Main Street         Wilmington     DE 27323 >>%LSEQ0080%
echo 000500 Everest        Evan      555 5TH Avenue          New York       NY 10341 >>%LSEQ0080%
echo 000600 Franklin       Francis   666 66TH Avenue         Bedrock        NY 11903 >>%LSEQ0080%
echo 002200 Van Etten      Valerie   2222 Vine Street        Hollywood      CA 98775 >>%LSEQ0080%
echo 000700 Garfunkel      Gwen      777 77TH Street         New York       NY 16539 >>%LSEQ0080%
echo 000800 Harrison       Hilary    888 88TH Street         Pocatello      ID 79684 >>%LSEQ0080%
echo 000900 Isley          Isabel    999 99TH Avenue         Indianapolis   IN 38762 >>%LSEQ0080%
echo 001000 Johnson        Jamie     1010 Paradise Drive     Larkspur       CA 90504 >>%LSEQ0080%
echo 001100 Kemper         Kelly     1111 Oak Circle         Kansas City    KS 55651 >>%LSEQ0080%
echo 001200 Lemond         Lesley    1212 Lockwood Road      Mohave Desert  AZ 80303 >>%LSEQ0080%
echo 001300 Mitchell       Marlow    1313 Miller Creek Road  Anywhere       TX 77123 >>%LSEQ0080%
echo 001400 Newman         Noel      1414 Park Avenue        Santa Monica   CA 90210 >>%LSEQ0080%
echo 001600 Powell         Pierce    PO Box 1616             Ventura        CA 97712 >>%LSEQ0080%
echo 001700 Quigley        Quincy    1717 Farm Hill Road     Oshkosh        WI 43389 >>%LSEQ0080%
echo 001800 Ripley         Ray       1818 Alien Lane         Wayout         KS 55405 >>%LSEQ0080%
echo 001900 Smith          Sammy     1919 Carnoustie Drive   Novato         CA 94919 >>%LSEQ0080%
echo 002000 Tucker         Taylor    2020 Sanger Lane        St. Paul       MN 43998 >>%LSEQ0080%
echo 000100 Anderson       Adrian    111 Peachtree Plaza     Atlanta        GA 26101 >>%LSEQ0080%
echo 002100 Underwood      Ulysses   2121 Wall Street        New York       NY 17623 >>%LSEQ0080%
echo 002300 Wilson         Wiley     2323 Main Street        Boston         MA 01472 >>%LSEQ0080%
echo 002400 Xray           Xavier    2424 24TH Street        Nashville      TN 44190 >>%LSEQ0080%
echo 002500 Young          Yanni     2525 Yonge Street       Toronto        ON 6B74A6>>%LSEQ0080%
echo 002600 Zenith         Zebulon   2626 26TH Street        Dallas         TX 71922 >>%LSEQ0080%
echo 123456 Doe            John      123 Main Street         Anywhere       OR 88156 >>%LSEQ0080%
rem  *
     if not exist %LSEQ0080% set JobStatus=0002
     if not "%JobStatus%" == "0000" goto EojNok
     call SimoNOTE "Produced DataSet %LSEQ0080%"
rem  *
:ConvertLSEQtoRSEQasc
rem  *
rem  * *******************************************************************
rem  * Step 3, Read the previously created Line Sequential File (LSEQ)
rem  *         and write a Record Sequential File (RSEQ) with 80-byte,
rem  *         ASCII-encoded records.
rem  *
     call SimoNOTE "Identify JobStep ConvertLSEQtoRSEQasc"
     set GETLS080=%LSEQ0080%
     set PUTRS080=%BaseLib1%\DATA\Asc1\SIMOTIME.DATA.CUSTW080.DAT
     if exist %PUTRS080% del %PUTRS080%
     run CV80ALAR
     if not exist %PUTRS080% set JobStatus=0003
     if not "%JobStatus%" == "0000" goto EojNok
     call SimoNOTE "Produced DataSet %PUTRS080%"
rem  *
:ConvertLSEQtoRSEQebc
rem  *
rem  * *******************************************************************
rem  * Step 4, Read the previously created Line Sequential File (LSEQ)
rem  *         and write a Record Sequential File (RSEQ) with 80-byte,
rem  *         EBCDIC-encoded records.
rem  *
     call SimoNOTE "Identify JobStep ConvertLSEQtoRSEQebc"
     set GETLS080=%LSEQ0080%
     set PUTRS080=%BaseLib1%\DATA\Ebc1\SIMOTIME.DATA.CUSTW080.DAT
     if exist %PUTRS080% del %PUTRS080%
     run CV80ALER
     if not exist %PUTRS080% set JobStatus=0004
     if not "%JobStatus%" == "0000" goto EojNok
     call SimoNOTE "Produced DataSet %PUTRS080%"
rem  *
rem  * *******************************************************************
rem  *
:EojAok
     call SimoNOTE "Finished JobName %CmdName%, Job Status is %JobStatus%"
     goto :End
:EojNok
     call SimoNOTE "ABENDING JobName %CmdName%, Job Status is %JobStatus%"
:End
     call SimoNOTE "Conclude SysLog is %SYSLOG%"
     if not "%1" == "nopause" pause

Table of Contents Previous Section Next Section The COBOL Program

The following COBOL program (CBSORTC1.cbl) is used to call the SORT program. The input is an unsorted file. The output is a sorted file arranged by surname in ascending sequence.

       IDENTIFICATION DIVISION.
       PROGRAM-ID.    CBSORTC1.
       AUTHOR.        SIMOTIME TECHNOLOGIES.
      *****************************************************************
      * Copyright (C) 1987-2017 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: CBSORTC1.CBL
      *****************************************************************
      * CBSORTC1 - Sort a File.
      *
      * CALLING PROTOCOL
      * ----------------
      * Use standard procedure to RUN or ANIMATE.
      *
      * DESCRIPTION
      * -----------
      * This program will sort a file by Postal Code sequence.
      *
      *  ************     ************     ************
      *  * SORTG080 *-----* CBSORTC1 *-----* SORTP080 *
      *  ************     ********cbl*     ******dsply*
      *                        *
      *                        *
      *                   ************
      *                   *   EOJ    *
      *                   ************
      *
      *****************************************************************
      * MAINTENANCE
      * -----------
      * 1989/02/27 Simmons, Created program.
      * 1997/03/17 Simmons, Updated for OPEN to test existance of
      *                     the input file.
      *
      *****************************************************************
      *
       ENVIRONMENT DIVISION.
       INPUT-OUTPUT SECTION.
       FILE-CONTROL.
           SELECT SORT-WORK   ASSIGN       TO SORTWORK.
           SELECT SORT-INPUT  ASSIGN       TO SORTG080
                              ORGANIZATION IS SEQUENTIAL
                              FILE STATUS  IS SORT-INPUT-STATUS.
           SELECT SORT-OUTPUT ASSIGN       TO SORTP080
                              ORGANIZATION IS SEQUENTIAL.

      *****************************************************************
       DATA DIVISION.
       FILE SECTION.
       SD  SORT-WORK.
       01  SORT-WORK-RECORD.
           05  FILLER              pic X(7).
           05  LAST-NAME           pic X(15).
           05  FILLER              pic X(58).

       FD  SORT-INPUT.
       01  SORT-INPUT-RECORD       pic X(80).

       FD  SORT-OUTPUT.
       01  SORT-OUTPUT-RECORD      pic X(80).

      *****************************************************************
       WORKING-STORAGE SECTION.
       01  SIM-TITLE.
           05  T1 pic X(11) value '* CBSORTC1 '.
           05  T2 pic X(34) value 'How to do a COBOL Callable Sort   '.
           05  T3 pic X(10) value ' v12.01.24'.
           05  T4 pic X(24) value ' http://www.simotime.com'.
       01  SIM-COPYRIGHT.
           05  C1 pic X(11) value '* CBSORTC1 '.
           05  C2 pic X(20) value 'Copyright 1987-2017 '.
           05  C3 pic X(28) value '   SimoTime Technologies    '.
           05  C4 pic X(20) value ' All Rights Reserved'.

       01  SORT-INPUT-STATUS.
           05 SORT-INPUT-STATUS-L  pic X.
           05 SORT-INPUT-STATUS-R  pic X.

      *****************************************************************
      * The following buffers are used to create a four-byte numeric  *
      * file status code that may be displayed.                       *
      *****************************************************************
       01  IO-STATUS.
           05  IO-STAT1            pic X.
           05  IO-STAT2            pic X.
       01  TWO-BYTES-BINARY        pic 9(4) BINARY.
       01  TWO-BYTES-ALPHA         redefines TWO-BYTES-BINARY.
           05  TWO-BYTES-LEFT      pic X.
           05  TWO-BYTES-RIGHT     pic X.
       01  IO-STATUS-04.
           05  IO-STATUS-0401      pic 9   value 0.
           05  IO-STATUS-0403      pic 999 value 0.

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

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

       01  END-OF-FILE             pic X(3)    value 'NO '.

      *****************************************************************
       PROCEDURE DIVISION.
       MAINLINE.
           perform Z-POST-COPYRIGHT
           perform CHECK-SORTIN-FILE-EXIST
           perform SORT-THE-FILE
           GOBACK.

      *****************************************************************
       CHECK-SORTIN-FILE-EXIST.
           open input SORT-INPUT.
           if  SORT-INPUT-STATUS = '00'
               close SORT-INPUT
               move 'Sort-Input-File-Exist...' to MESSAGE-TEXT
               perform Z-DISPLAY-MESSAGE-TEXT
           else
               move 'SORT-INPUT-FAILURE-OPEN-!!!' to MESSAGE-TEXT
               perform Z-DISPLAY-MESSAGE-TEXT
               move SORT-INPUT-STATUS to IO-STATUS
               perform Z-DISPLAY-IO-STATUS
               perform Z-ABEND-PROGRAM
           end-if
           exit.

      *****************************************************************
       SORT-THE-FILE.
           sort SORT-WORK
           on ascending key LAST-NAME
           with DUPLICATES in ORDER
                  using SORT-INPUT
                 giving SORT-OUTPUT
           exit.

      *****************************************************************
      * The following Z-Routines perform administrative functions
      * for this program.
      *****************************************************************
       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 16 to ZERO giving RETURN-CODE
           GOBACK.
      *    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'
               move IO-STAT1 to IO-STATUS-04(1:1)
               subtract TWO-BYTES-BINARY from TWO-BYTES-BINARY
               move IO-STAT2 to TWO-BYTES-RIGHT
               add TWO-BYTES-BINARY to ZERO giving IO-STATUS-0403
               move 'File Status is: nnnn' to MESSAGE-TEXT
               move IO-STATUS-04 to MESSAGE-TEXT(17:4)
               perform Z-DISPLAY-MESSAGE-TEXT
           else
               move '0000' to IO-STATUS-04
               move IO-STATUS to IO-STATUS-04(3:2)
               move 'File Status is: nnnn' to MESSAGE-TEXT
               move IO-STATUS-04 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
               display MESSAGE-BUFFER(1:79) upon console
           else
               display MESSAGE-BUFFER upon console
           end-if
           move all SPACES to MESSAGE-TEXT
           exit.

      *****************************************************************
       Z-POST-COPYRIGHT.
           display SIM-TITLE upon console
           display SIM-COPYRIGHT upon console
           exit.
      *****************************************************************
      *      This example is provided by SimoTime Technologies        *
      *        Our e-mail address is: helpdesk@simotime.com           *
      *     Also, visit our Web Site at http://www.simotime.com       *
      *****************************************************************

Table of Contents Previous Section Next Section Summary

The purpose of this document is to describe and demonstrate how to use a COBOL program to call the SORT program. This document may serve 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 document and the links to other documents are intended to provide a greater awareness of the Data Management and Application Processing alternatives.

The 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 send an e-mail to: helpdesk@simotime.com or call 415 883-6565. We appreciate hearing from you.

Table of Contents Previous Section Next Section Software Agreement and Disclaimer

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

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

Table of Contents Previous Section Next Section Downloads and Links

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

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

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

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

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

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

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

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

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

Link to Internet   Link to Server   Explore The File Status Return Codes 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 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 Comments or Feedback

This document was created and is copyrighted and maintained by SimoTime Technologies.

If you have any questions, suggestions, comments or feedback please call or send an e-mail to: helpdesk@simotime.com

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
Callable SORT using a COBOL Program
Copyright © 1987-2017
SimoTime Technologies and Services
All Rights Reserved
When technology complements business
http://www.simotime.com