Sort Program
 Simple Examples
http://www.simotime.com
When technology complements business    Copyright © 1987-2010  SimoTime Enterprises  All Rights Reserved
  Table of Contents Version 10.03.20 
  Introduction
  Mainframe JCL for ZOS SORT
 
  JCL, Sort Record Sequential to Record Sequential File
  JCL, Case Insensitive SORT for EBCDIC-Encoded, Record Sequential File
  JCL, Case Insensitive SORT for ASCII-Encoded, Record Sequential File
  Windows CMD Files for Micro Focus SORT
 
  Windows CMD, Sort ASCII/Text to ASCII/Text File
  Windows CMD, Sort ASCII/Text to ASCII-encoded, Sequential File
  Windows CMD, Sort ASCII/Text to EBCDIC-encoded, Sequential File
  Special Handling, Advanced or Shared Functions
 
  Special Handling, Setting the Environment
  Special Handling, Displaying and Logging Messages
  Summary
 
  Software Agreement and Disclaimer
  Downloads and Links to Similar Pages
  Glossary of Terms
  Comments or Suggestions
  About SimoTime

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

This suite of programs will describe how to do use the Micro Focus SORT program with a Windows command line or Mainframe JCL. The Mainframe JCL will execute on a Mainframe System with ZOS. A small sequential file is created and then sorted.

The source code, data sets and documentation are provided in a single zipped file called SORTUT01.ZIP. This zipped file may be downloaded from the SimoTime Web site. In the Windows environment the file names have file extensions. When the JCL member is uploaded to a ZOS Mainframe from the Windows and Micro Focus environment the file extension is dropped.

Mainframe JCL for ZOS SORT
(Next) (Previous) (Table-of-Contents)

This section describes the various JCL members that are used to create and sort files in a mainframe-oriented environment. The term "Mainframe-Oriented" is used to refer to the following.

1. An IBM Mainframe System running the ZOS Operating System
2. Micro Focus Mainframe Express running in a Windows Environment
3. Micro Focus Studio or Server for Mainframe Migration running in a Windows, UNIX or Linux environment.

JCL, Sort Record Sequential to Record Sequential File
(Next) (Previous) (Table-of-Contents)

The following JCL member (SORTX5J1.JCL) is used to create a record sequential file with eighty (80) byte fixed length records. The next job step will then sort the file based on the character in position five (5). The Sort will create a new record sequential file with eighty (80) byte fixed length records.

//SORTX5J1 JOB SIMOTIME,CLASS=1,MSGCLASS=0,NOTIFY=CSIP1
//* *******************************************************************
//*                   This program is provided by:                    *
//*                    SimoTime Enterprises, LLC                      *
//*           (C) Copyright 1987-2010 All Rights Reserved             *
//*             Web Site URL:   http://www.simotime.com               *
//*                   e-mail:   helpdesk@simotime.com                 *
//* *******************************************************************
//*
//* Text   - Create a Sequential Data Set using IEBGENER and Sort.
//* Author - SimoTime Enterprises
//* Date   - January 24, 1996
//*
//* Step 1, DELSEQS1 will delete any previously created file.
//* Step 2, CRTSEQS2 will create a new file.
//* Step 3, SRTSEQS3 will sort the file.
//* Step 4, EXTENDS4 will add a record to the input file.
//*
//* This job uses instream sorting specifications.
//*
//* This set of programs will run on a mainframe under MVS or on a
//* Personal Computer with Windows and Micro Focus Mainframe Express.
//*
//* *******************************************************************
//* Step   1 of 4, Delete any previously created file...
//*
//DELSEQS1 EXEC PGM=IEFBR14
//SEQBFORE DD  DSN=SIMOTIME.DATA.SEQBFORE,DISP=(MOD,DELETE,DELETE),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=FB,LRECL=80,BLKSIZE=800,DSORG=PS)
//SEQAFTER DD  DSN=SIMOTIME.DATA.SEQAFTER,DISP=(MOD,DELETE,DELETE),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=FB,LRECL=80,BLKSIZE=800,DSORG=PS)
//*
//* *******************************************************************
//* Step   2 of 4, Create and populate a new QSAM file...
//*
//CRTSEQS2 EXEC PGM=IEBGENER
//SYSPRINT DD  SYSOUT=*
//SYSIN    DD  DUMMY
//* :....1....:....2....:....3....:....4....:....5....:....6....:....7.
//SYSUT1   DD  *
001 A C1 1100 0001 41 0100 0001
002 B C2 1100 0010 42 0100 0010
003 0 F0 1111 0000 30 0011 0000
004 C C3 1100 0011 43 0100 0011
/*
//SYSUT2   DD  DSN=SIMOTIME.DATA.SEQBFORE,
//             DISP=(NEW,CATLG,DELETE),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=FB,LRECL=80,BLKSIZE=800,DSORG=PS)
//*
//* *******************************************************************
//* Step   3 of 4, Sort the file...
//*
//SRTSEQS3 EXEC PGM=SORT,
//             REGION=1024K
//SYSIN    DD  *
* ..:....1....:....2....:....3....:....4....:....5....:....6....:....7.
         SORT  FIELDS=(5,1,CH,A)
/*
//SORTIN   DD  DSN=SIMOTIME.DATA.SEQBFORE,DISP=SHR
//SORTOUT  DD  DSN=SIMOTIME.DATA.SEQAFTER,DISP=(NEW,CATLG,DELETE),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=FB,LRECL=80,BLKSIZE=800,DSORG=PS)
//SYSOUT   DD  SYSOUT=*
//*
//* *******************************************************************
//* Step   4 of 4, Create and populate a new QSAM file...
//*
//EXTENDS4 EXEC PGM=IEBGENER
//SYSPRINT DD  SYSOUT=*
//SYSIN    DD  DUMMY
//* :....1....:....2....:....3....:....4....:....5....:....6....:....7.
//SYSUT1   DD  *
005 1 F1 1111 0001 31 0011 0001
/*
//SYSUT2   DD  DSN=SIMOTIME.DATA.SEQBFORE,
//             DISP=(MOD,KEEP,KEEP),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=FB,LRECL=80,BLKSIZE=800,DSORG=PS)

The preceding job may be executed on the mainframe as an MVS batch job. The JOB and DD statements will require modification prior to execution in different mainframe environments. It may also be executed on the PC running the Micro Focus Mainframe Express product.

JCL, Case Insensitive SORT for EBCDIC-Encoded, Record Sequential File
(Next) (Previous) (Table-of-Contents)

The following JCL member (SORTCEJ1.JCL) will create an input file that is out-of-sequence based on the character in positio five (5) of a record. Subsequent job steps will sort the file. The last job step will do a case insensitive sort with the upper nad lower case letters grouped together. Since the ALTSEQ function of the sort requires a table to be defined in hexadecimal notation this job will only work with EBCDIC encoded files.

The Sort steps will create new, sorted record sequential files with eighty (80) byte fixed length records.

//SORTCEJ1 JOB SIMOTIME,CLASS=1,MSGCLASS=0,NOTIFY=CSIP1
//* *******************************************************************
//*                   This program is provided by:                    *
//*                    SimoTime Enterprises, LLC                      *
//*           (C) Copyright 1987-2010 All Rights Reserved             *
//*             Web Site URL:   http://www.simotime.com               *
//*                   e-mail:   helpdesk@simotime.com                 *
//* *******************************************************************
//*
//* Text   - Create a Sequential Data Set using IEBGENER and Sort.
//* Author - SimoTime Enterprises
//* Date   - January 24, 1996
//*
//* Step 1, DELSEQS1 will delete any previously created file.
//* Step 2, CRTSEQS2 will create a new file.
//* Step 3, SRTSEQS3 will sort the file.
//* Step 4, EXTENDS4 will add a record to the input file.
//* Step 5, SRTSEQS5 will do a case insensitive sort of the file .
//*
//* CAUTION! Since the ALTSEQ is defined at the binary (or hexadecimal)
//*          level step 5 will only work for EBCDIC-encoded files.
//*
//* Refer to SORTCAJ1.JCL for a case insensitive sort for the ASCII
//* encoded environment.
//*
//* This job uses instream sorting specifications.
//*
//* This set of programs will run on a mainframe under MVS or on a
//* Personal Computer with Windows and Micro Focus Mainframe Express.
//*
//* 1. Demonstrate how to use IEFBR14 with DD statements to delete
//*    files that have been created by a previous execution of this
//*    job.
//* 2. Demonstrate how to use IEBGENER to create and populate a new
//*    record sequential file with eighty (80) byte fixed length
//*    records.
//* 3. Demonstrate how to use the SORT program to sort a file based
//*    on the value in position five (5) of each record.
//* 4. Demonstrate how to do a case insensitive sort. A normal sort
//*    sequence will sort all the uppercase together and then all the
//*    lower case together in a group, for example ABCDEabcde.
//*    Sometimes it is desirable to sort the upper and lower case
//*    together, for example AaBbCcDdEe. This is referred to as a
//*    case insensitive sort.
//*
//* *******************************************************************
//* Step   1 of 5, Delete any previously created file...
//*
//DELSEQS1 EXEC PGM=IEFBR14
//SEQBFORE DD  DSN=SIMOTIME.DATA.SEQBE4D1,DISP=(MOD,DELETE,DELETE),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=FB,LRECL=80,BLKSIZE=800,DSORG=PS)
//SEQAFTD1 DD  DSN=SIMOTIME.DATA.SEQAFTD1,DISP=(MOD,DELETE,DELETE),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=FB,LRECL=80,BLKSIZE=800,DSORG=PS)
//SEQAFTD2 DD  DSN=SIMOTIME.DATA.SEQAFTD2,DISP=(MOD,DELETE,DELETE),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=FB,LRECL=80,BLKSIZE=800,DSORG=PS)
//*
//* *******************************************************************
//* Step   2 of 5, Create and populate a new QSAM file...
//*
//CRTSEQS2 EXEC PGM=IEBGENER
//SYSPRINT DD  SYSOUT=*
//SYSIN    DD  DUMMY
//* :....1....:....2....:....3....:....4....:....5....:....6....:....7.
//SYSUT1   DD  *
001 A C1 1100 0001 41 0100 0001
002 B C2 1100 0010 42 0100 0010
003 0 F0 1111 0000 30 0011 0000
004 C C3 1100 0011 43 0100 0011
005 a 81 1000 0001 61 0110 0001
006 b 82 1000 0010 62 0110 0010
007 1 F1 1111 0001 31 0011 0001
/*
//SYSUT2   DD  DSN=SIMOTIME.DATA.SEQBE4D1,
//             DISP=(NEW,CATLG,DELETE),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=FB,LRECL=80,BLKSIZE=800,DSORG=PS)
//*
//* *******************************************************************
//* Step   3 of 5, Sort the file...
//*
//SRTSEQS3 EXEC PGM=SORT,
//             REGION=1024K
//SYSIN    DD  *
* ..:....1....:....2....:....3....:....4....:....5....:....6....:....7.
         SORT  FIELDS=(5,1,CH,A)
/*
//SORTIN   DD  DSN=SIMOTIME.DATA.SEQBE4D1,DISP=SHR
//SORTOUT  DD  DSN=SIMOTIME.DATA.SEQAFTD1,DISP=(NEW,CATLG,DELETE),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=FB,LRECL=80,BLKSIZE=800,DSORG=PS)
//SYSOUT   DD  SYSOUT=*
//*
//* *******************************************************************
//* Step   4 of 5, Extend or add records to an existing QSAM file...
//*
//EXTENDS4 EXEC PGM=IEBGENER
//SYSPRINT DD  SYSOUT=*
//SYSIN    DD  DUMMY
//* :....1....:....2....:....3....:....4....:....5....:....6....:....7.
//SYSUT1   DD  *
999 9 F9 1111 1001 39 0011 1001
/*
//SYSUT2   DD  DSN=SIMOTIME.DATA.SEQBE4D1,
//             DISP=(MOD,KEEP,KEEP),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=FB,LRECL=80,BLKSIZE=800,DSORG=PS)
//*
//* *******************************************************************
//* Step   5 of 5, Do a Case Insensitive Sort of the file...
//*
//* CAUTION! Since the ALTSEQ is defined at the binary (or hexadecimal)
//*          level step 5 will only work for EBCDIC-encoded files.
//*
//SRTSEQS5 EXEC PGM=SORT,
//             REGION=1024K
//SYSIN    DD  *
* ..:....1....:....2....:....3....:....4....:....5....:....6....:....7.
  SORT FIELDS=(5,1,AQ,A)
  ALTSEQ CODE=(81C1,82C2,83C3,84C4,85C5,86C6,87C7,88C8,89C9,
               91D1,92D2,93D3,94D4,95D5,96D6,97D7,98D8,99D9,
               A2E2,A3E3,A4E4,A5E5,A6E6,A7E7,A8E8,A9E9)
/*
//SORTIN   DD  DSN=SIMOTIME.DATA.SEQBE4D1,DISP=SHR
//SORTOUT  DD  DSN=SIMOTIME.DATA.SEQAFTD2,DISP=(NEW,CATLG,DELETE),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=FB,LRECL=80,BLKSIZE=800,DSORG=PS)
//SYSOUT   DD  SYSOUT=*

JCL, Case Insensitive SORT for ASCII-Encoded, Record Sequential File
(Next) (Previous) (Table-of-Contents)

The following JCL member (SORTCAJ1.JCL) will create an input file that is out-of-sequence based on the character in positio five (5) of a record. Subsequent job steps will sort the file. The last job step will do a case insensitive sort with the upper nad lower case letters grouped together. Since the ALTSEQ function of the sort requires a table to be defined in hexadecimal notation this job will only work with ASCII encoded files in the Micro Focus environment.

The Sort steps will create new, sorted record sequential files with eighty (80) byte fixed length records.

//SORTCAJ1 JOB SIMOTIME,CLASS=1,MSGCLASS=0,NOTIFY=CSIP1
//* *******************************************************************
//*                   This program is provided by:                    *
//*                    SimoTime Enterprises, LLC                      *
//*           (C) Copyright 1987-2010 All Rights Reserved             *
//*             Web Site URL:   http://www.simotime.com               *
//*                   e-mail:   helpdesk@simotime.com                 *
//* *******************************************************************
//*
//* Text   - Create a Sequential Data Set using IEBGENER and Sort.
//* Author - SimoTime Enterprises
//* Date   - January 24, 1996
//*
//* Step 1, DELSEQS1 will delete any previously created file.
//* Step 2, CRTSEQS2 will create a new file.
//* Step 3, SRTSEQS3 will sort the file.
//* Step 4, EXTENDS4 will add a record to the input file.
//* Step 5, SRTSEQS5 will do a case insensitive sort of the file .
//*
//* CAUTION! Since the ALTSEQ is defined at the binary (or hexadecimal)
//*          level step 5 will only work for ASCII-encoded files.
//*
//* Refer to SORTCEJ1.JCL for a case insensitive sort for the EBCDIC
//* encoded environment.
//*
//* This job uses instream sorting specifications.
//*
//* This set of programs will run on a mainframe under MVS or on a
//* Personal Computer with Windows and Micro Focus Mainframe Express.
//*
//* 1. Demonstrate how to use IEFBR14 with DD statements to delete
//*    files that have been created by a previous execution of this
//*    job.
//* 2. Demonstrate how to use IEBGENER to create and populate a new
//*    record sequential file with eighty (80) byte fixed length
//*    records.
//* 3. Demonstrate how to use the SORT program to sort a file based
//*    on the value in position five (5) of each record.
//* 4. Demonstrate how to do a case insensitive sort. A normal sort
//*    sequence will sort all the uppercase together and then all the
//*    lower case together in a group, for example ABCDEabcde.
//*    Sometimes it is desirable to sort the upper and lower case
//*    together, for example AaBbCcDdEe. This is referred to as a
//*    case insensitive sort.
//*
//* *******************************************************************
//* Step   1 of 5, Delete any previously created file...
//*
//DELSEQS1 EXEC PGM=IEFBR14
//SEQBFORE DD  DSN=SIMOTIME.DATA.SEQBE4D1,DISP=(MOD,DELETE,DELETE),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=FB,LRECL=80,BLKSIZE=800,DSORG=PS)
//SEQAFTD1 DD  DSN=SIMOTIME.DATA.SEQAFTD1,DISP=(MOD,DELETE,DELETE),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=FB,LRECL=80,BLKSIZE=800,DSORG=PS)
//SEQAFTD2 DD  DSN=SIMOTIME.DATA.SEQAFTD2,DISP=(MOD,DELETE,DELETE),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=FB,LRECL=80,BLKSIZE=800,DSORG=PS)
//*
//* *******************************************************************
//* Step   2 of 5, Create and populate a new QSAM file...
//*
//CRTSEQS2 EXEC PGM=IEBGENER
//SYSPRINT DD  SYSOUT=*
//SYSIN    DD  DUMMY
//* :....1....:....2....:....3....:....4....:....5....:....6....:....7.
//SYSUT1   DD  *
001 A C1 1100 0001 41 0100 0001
002 B C2 1100 0010 42 0100 0010
003 0 F0 1111 0000 30 0011 0000
004 C C3 1100 0011 43 0100 0011
005 a 81 1000 0001 61 0110 0001
006 b 82 1000 0010 62 0110 0010
007 1 F1 1111 0001 31 0011 0001
/*
//SYSUT2   DD  DSN=SIMOTIME.DATA.SEQBE4D1,
//             DISP=(NEW,CATLG,DELETE),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=FB,LRECL=80,BLKSIZE=800,DSORG=PS)
//*
//* *******************************************************************
//* Step   3 of 5, Sort the file...
//*
//SRTSEQS3 EXEC PGM=SORT,
//             REGION=1024K
//SYSIN    DD  *
* ..:....1....:....2....:....3....:....4....:....5....:....6....:....7.
         SORT  FIELDS=(5,1,CH,A)
/*
//SORTIN   DD  DSN=SIMOTIME.DATA.SEQBE4D1,DISP=SHR
//SORTOUT  DD  DSN=SIMOTIME.DATA.SEQAFTD1,DISP=(NEW,CATLG,DELETE),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=FB,LRECL=80,BLKSIZE=800,DSORG=PS)
//SYSOUT   DD  SYSOUT=*
//*
//* *******************************************************************
//* Step   4 of 5, Extend or add records to an existing QSAM file...
//*
//EXTENDS4 EXEC PGM=IEBGENER
//SYSPRINT DD  SYSOUT=*
//SYSIN    DD  DUMMY
//* :....1....:....2....:....3....:....4....:....5....:....6....:....7.
//SYSUT1   DD  *
999 9 F9 1111 1001 39 0011 1001
/*
//SYSUT2   DD  DSN=SIMOTIME.DATA.SEQBE4D1,
//             DISP=(MOD,KEEP,KEEP),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=FB,LRECL=80,BLKSIZE=800,DSORG=PS)
//*
//* *******************************************************************
//* Step   5 of 5, Do a Case Insensitive Sort of the file...
//*
//* CAUTION! Since the ALTSEQ is defined at the binary (or hexadecimal)
//*          level step 5 will only work for ASCII-encoded files.
//*
//SRTSEQS5 EXEC PGM=SORT,
//             REGION=1024K
//SYSIN    DD  *
* ..:....1....:....2....:....3....:....4....:....5....:....6....:....7.
  SORT FIELDS=(5,1,AQ,A)
  ALTSEQ CODE=(6141,6242,6343,6444,6545,6646,6747,6848,6949,
               6A4A,6B4B,6C4C,6D4D,6E4E,6F4F,7050,7151,7252,
               7353,7454,7555,7656,7757,7858,7959,7A5A)
/*
//SORTIN   DD  DSN=SIMOTIME.DATA.SEQBE4D1,DISP=SHR
//SORTOUT  DD  DSN=SIMOTIME.DATA.SEQAFTD2,DISP=(NEW,CATLG,DELETE),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=FB,LRECL=80,BLKSIZE=800,DSORG=PS)
//SYSOUT   DD  SYSOUT=*

Windows CMD Files for Micro Focus SORT
(Next) (Previous) (Table-of-Contents)

This section provides a suite of Windows Command Files that may be used to execute the Micro Focus SORT program in a WIndows environment.

Windows CMD, Sort ASCII/Text to ASCII/Text File
(Next) (Previous) (Table-of-Contents)

The following Windows Command FIle (SORTTXE1.CMD) is used to create an ASCII/Text file and then sort the file based on the character in position five (5). The Sort will create a new ASCII/Text file.

@echo OFF
echo ******************************************************************
echo *                  This program is provided by:                  *
echo *                   SimoTime Enterprises, LLC                    *
echo *          (C) Copyright 1987-2010 All Rights Reserved           *
echo *            Web Site URL:   http://www.simotime.com             *
echo *                  e-mail:   helpdesk@simotime.com               *
echo ******************************************************************
rem  * Step 1, Set environment and delete any previously created files.
rem  * Step 2, Create an ASCII/Text (or Line Sequential) file using the
rem  *         Windows echo command and piping the output to SORTIN.
rem  * Step 3, Sort the SORTIN file and create SORTOUT. The sorting
rem  *         specifications are included as a command line parameter.
rem  *         The SORTIN file is an ASCII/Text file.
rem  *         The SORTOUT file is an ASCII/Text file.
rem  ******************************************************************
rem  * Set Environment Variables, Delete previously created files
:STEP01
     echo Set the environment, delete previously created files...
rem  * The Env1PROD is a Windows Command file that sets environment
rem  * variables that are common to a variety of sam[le applications
rem  * provided in the SimoTime collection.
     call Env1PROD
     call SimoNOTE "SORTTXE1.CMD is STARTING..."
rem  * Set environment variables that are unique to this job...
     set SORTIN=%BaseLib1%\DataLibA\Wrk1\SRTBFORE.TXT
     set SORTOUT=%BaseLib1%\DataLibA\Wrk1\SRTATEXT.TXT
rem  * Delete previously created files...
     if exist %SORTIN%  erase %SORTIN%
     if exist %SORTOUT% erase %SORTOUT%
rem  *
rem  ******************************************************************
rem  * Create a test file to be sorted
:STEP02
     echo Create the SORTIN file...
rem  *    ....:....1....:....2....:....3....:....4....:....5....:....6
     echo 001 A C1 1100 0001 41 0100 0001>  %SORTIN%
     echo 002 B C2 1100 0010 42 0100 0010>> %SORTIN%
     echo 003 0 F0 1111 0000 30 0011 0000>> %SORTIN%
     echo 004 C C3 1100 0011 43 0100 0013>> %SORTIN%
rem  *
rem  ******************************************************************
rem  * Sort the test file to be sorted
:STEP03
     echo Start the SORT . . .
     MFSORT SORT FIELDS=(5,1,CH,A) use %SORTIN% ORG LS give %SORTOUT%
     if errorlevel = 1 set JobStatus=0016
     echo Job Status after the SORT is = %JobStatus%
     if not "%JobStatus%" == "0000" goto :EOJNOK
rem  *
rem  ******************************************************************
rem  * Normal EOJ, Display the sorted test file
:EOJAOK
     call SimoNOTE "SORTXTE1.CMD is FINISHED..."
echo ....:....1....:....2....:....3....:....4....:....5....:....6
     type %SORTOUT%
     echo SortOut=%SORTOUT%
     goto :EOJ
rem  *
rem  ******************************************************************
rem  * ABENDING, display a message and pause
:EOJNOK
     call SimoNOTE "SORTTXE1.CMD is ABENDING..."
rem  *
rem  ******************************************************************
rem  * ABENDING, display a message and pause
:EOJ
     pause
     exit /B %JobStatus%

Windows CMD, Sort ASCII/Text to ASCII-encoded, Sequential File
(Next) (Previous) (Table-of-Contents)

The following Windows Command FIle (SORTA5E1.CMD) is used to create an ASCII/Text file and then sort the file based on the character in position five (5). The Sort will create a new ASCII-encoded, record sequential file with fixed-length, eighty (80) byte records.

@echo OFF
echo ******************************************************************
echo *                  This program is provided by:                  *
echo *                   SimoTime Enterprises, LLC                    *
echo *          (C) Copyright 1987-2010 All Rights Reserved           *
echo *            Web Site URL:   http://www.simotime.com             *
echo *                  e-mail:   helpdesk@simotime.com               *
echo ******************************************************************
rem  * Step 1, Set environment and delete any previously created files.
rem  * Step 2, Create an ASCII/Text (or Line Sequential) file using the
rem  *         Windows echo command and piping the output to SORTIN.
rem  * Step 3, Sort the SORTIN file and create SORTOUT. The sorting
rem  *         specifications are included as a command line parameter.
rem  *         The SORTIN file is an ASCII/Text file.
rem  *         The SORTOUT file is an ASCII-encoded, record sequential
rem  *         file with eighty (80) byte, fixed length records.
rem  ******************************************************************
rem  * Set Environment Variables, Delete previously created files
:STEP01
     echo Set the environment, delete previously created files...
rem  * The Env1PROD is a Windows Command file that sets environment
rem  * variables that are common to a variety of sam[le applications
rem  * provided in the SimoTime collection.
     call Env1PROD
     call SimoNOTE "SORTA5E1.CMD is STARTING..."
rem  * Set environment variables that are unique to this job...
     set SORTIN=%BaseLib1%\DataLibA\Wrk1\SRTBFORE.TXT
     set SORTOUT=%BaseLib1%\DataLibA\Wrk1\SRTARSEQ.DAT
rem  * Delete previously created files...
     if exist %SORTIN%  erase %SORTIN%
     if exist %SORTOUT% erase %SORTOUT%
rem  *
rem  ******************************************************************
rem  * Create a test file to be sorted
:STEP02
     echo Create the SORTIN file...
rem  *    ....:....1....:....2....:....3....:....4....:....5....:....6
     echo 001 A C1 1100 0001 41 0100 0001>  %SORTIN%
     echo 002 B C2 1100 0010 42 0100 0010>> %SORTIN%
     echo 003 0 F0 1111 0000 30 0011 0000>> %SORTIN%
     echo 004 C C3 1100 0013 43 0100 0013>> %SORTIN%
rem  *
rem  ******************************************************************
rem  * Sort the test file to be sorted
:STEP03
     echo Start the SORT . . .
     MFSORT SORT FIELDS=(5,1,CH,A) use %SORTIN% ORG LS give %SORTOUT% RECORD F,80 ORG SQ
     if errorlevel = 1 set JobStatus=0016
     echo Job Status after the SORT is = %JobStatus%
     if not "%JobStatus%" == "0000" goto :EOJNOK
rem  *
rem  ******************************************************************
rem  * Normal EOJ, Display the sorted test file
:EOJAOK
     call SimoNOTE "SORTA5E1.CMD is FINISHED..."
     echo SortOut=%SORTOUT%
     goto :EOJ
rem  *
rem  ******************************************************************
rem  * ABENDING, display a message and pause
:EOJNOK
     call SimoNOTE "SORTA5E1.CMD is ABENDING..."
rem  *
rem  ******************************************************************
rem  * ABENDING, display a message and pause
:EOJ
     pause
     exit /B %JobStatus%

Windows CMD, Sort ASCII/Text to EBCDIC-encoded, Sequential File
(Next) (Previous) (Table-of-Contents)

The following Windows Command FIle (SORTE5E1.CMD) is used to create an ASCII/Text file and then sort the file based on the character in position five (5). The Sort will create a new EBCDIC-encoded, record sequential file with fixed-length, eighty (80) byte records.

@echo OFF
echo ******************************************************************
echo *                  This program is provided by:                  *
echo *                   SimoTime Enterprises, LLC                    *
echo *          (C) Copyright 1987-2010 All Rights Reserved           *
echo *            Web Site URL:   http://www.simotime.com             *
echo *                  e-mail:   helpdesk@simotime.com               *
echo ******************************************************************
rem  * Step 1, Set environment and delete any previously created files.
rem  * Step 2, Create an ASCII/Text (or Line Sequential) file using the
rem  *         Windows echo command and piping the output to SORTIN.
rem  * Step 3, Sort the SORTIN file and create SORTOUT. The sorting
rem  *         specifications are included as a command line parameter.
rem  *         The SORTIN file is an ASCII/Text file.
rem  *         The SORTOUT file is an EBCDIC-encoded, record sequential
rem  *         file with eighty (80) byte, fixed length records.
rem  ******************************************************************
rem  * Set Environment Variables, Delete previously created files
:STEP01
     echo Set the environment, delete previously created files...
rem  * The Env1PROD is a Windows Command file that sets environment
rem  * variables that are common to a variety of sam[le applications
rem  * provided in the SimoTime collection.
     call Env1PROD
     call SimoNOTE "SORTE5E1.CMD is STARTING..."
rem  * Set environment variables that are unique to this job...
     set SORTIN=%BaseLib1%\DataLibA\Wrk1\SRTBFORE.TXT
     set SORTOUT=%BaseLib1%\DataLibA\Wrk1\SRTERSEQ.DAT
rem  * Delete previously created files...
     if exist %SORTIN%  erase %SORTIN%
     if exist %SORTOUT% erase %SORTOUT%
rem  *
rem  ******************************************************************
rem  * Create a test file to be sorted
:STEP02
     echo Create the SORTIN file...
rem  *    ....:....1....:....2....:....3....:....4....:....5....:....6
     echo 001 A C1 1100 0001 41 0100 0001>  %SORTIN%
     echo 002 B C2 1100 0010 42 0100 0010>> %SORTIN%
     echo 003 0 F0 1111 0000 30 0011 0000>> %SORTIN%
     echo 004 C C3 1100 0011 43 0100 0011>> %SORTIN%
rem  *
rem  ******************************************************************
rem  * Sort the test file to be sorted
:STEP03
     echo Start the SORT . . .
     MFSORT CHAR-EBCDIC SORT FIELDS=(5,1,CH,A,1,3,CH,A) use %SORTIN% ORG LS give %SORTOUT% RECORD F,80 ORG SQ
     if errorlevel = 1 set JobStatus=0016
     echo Job Status after the SORT is = %JobStatus%
     if not "%JobStatus%" == "0000" goto :EOJNOK
rem  *
rem  ******************************************************************
rem  * Normal EOJ, Display the sorted test file
:EOJAOK
     call SimoNOTE "SORTE5E1.CMD is FINISHED..."
     echo SORTOUT=%SORTOUT%
     goto :EOJ
rem  *
rem  ******************************************************************
rem  * ABENDING, display a message and pause
:EOJNOK
     call SimoNOTE "SORTE5E1.CMD is ABENDING..."
rem  *
rem  ******************************************************************
rem  * ABENDING, display a message and pause
:EOJ
     pause
     exit /B %JobStatus%

Special Handling
(Next) (Previous) (Table-of-Contents)

This section provides additional detail about the commonly used or shared routines that set the environment and log job messages.

Special Handling, Setting the Environment
(Next) (Previous) (Table-of-Contents)

A command file (Env1PROD.CMD) is called from other command files to set commonly used environment variables. This provides a single point of definition. The following is a listing of the contents of the command file.

rem  * *******************************************************************
rem  * Set the commonly used environment variables. This is used to
rem  * provide a single point for managing the commonly used environment
rem  * variables.
rem  *
     set BaseLib1=c:\SimoSAM1
     set SYSLOG=%BaseLib1%\LOGS\SYSLOG_USER.TXT
     set SimoNOTE=%BaseLib1%\LOGS\SIMONOTE_USER.TXT
     call SimoNOTE "*"
rem  *
     set SYSOUT=%BaseLib1%\LOGS\SYSOUT_USER.TXT
     set LRSTOKEN=%BaseLib1%\DataLibA\Txt1\LRSTOKEN.TXT
     set CobCpy=%BaseLib1%\CobCpy1;c:\SimoLIBR
rem  *
rem  * set MFTRACE_CONFIG=%BaseLib1%\LOGS\TRACE001\ctfrtsfs.cfg
rem  * set MFTRACE_LOGS=%BaseLib1%\LOGS\TRACE001
rem  *
rem  * The following SORTSPACE of 1 gigabyte is used when sorting very
rem  * large files. The value is the digit one (1) followed by nine (9)
rem  * zeroes. To allocate this amount of memory for sorting requires a
rem  * minimum of two (2) gigabytes of RAM.
rem  set SORTSPACE=1000000000
rem  *
rem  * For large file support and record locking control of File Handler
     set EXTFH=%BaseLib1%\SysLibA1\EXTFH4AE.CFG
rem  * Set environment for MFBSI (Micro Focus Batch Scheduling Interface)
     set ES_EMP_EXIT_1=mfbsiemx
     set MFBSI_DIR=%BaseLib1%\BSIA\%ezServerName%
     set MFBSIEOP_CMD=ENABLE
     set MFBSIEOP_CSV=ENABLE
rem  *
rem  * The following is used to map the location of files that are to be
rem  * allocated using JCL with ES/MTO.
     set ES_ALLOC_OVERRIDE=%BaseLib1%\SysLibA1\CatMapA1.cfg
rem  *
rem  * Set the environment for Core Dump on System error, CBLCORE file
rem  set COBCONFIG_=%BaseLib1%\SysLibA1\Diagnose.CFG
     set COBCONFIG_=
rem  *
rem  * Specify the location of the IDY files when animating
     set COBIDY=%BaseLib1%\COBOL
rem  *
rem  * The following may need to be adjusted based on individual systems
rem  * and the various versions of the Operating System, Sub-Systems and
rem  * other software.
     if "%ENV1PROD%" == "Y" goto :NOPATH
     set iexplore=C:\Program Files\Internet Explorer
     set path="C:\Program Files\Micro Focus\Net Express 5.0\Base\";"C:\Program Files\Micro Focus\Net Express 5.0\Base\bin";%PATH%;
rem  set path="C:\Program Files\Micro Focus\Server 5.0\Base\";"C:\Program Files\Micro Focus\Server 5.0\Base\bin";%PATH%;
:NOPATH
     set cobpath=%BaseLib1%\ProdLibA;%BaseLib1%\ProdLibA\UTIL;c:\SimoLIBR
     set JobStatus=0000
     set StepStatus=0000
     set ENV1PROD=Y
     call SimoNOTE "BaseLib1 is %BaseLib1%"

Special Handling, Displaying and Logging Messages
(Next) (Previous) (Table-of-Contents)

The following is a listing of the contents of the (SimoNOTE.CMD) command file.

@echo OFF
rem  * *******************************************************************
rem  *                   This program is provided by:                    *
rem  *                    SimoTime Enterprises, LLC                      *
rem  *           (C) Copyright 1987-2010 All Rights Reserved             *
rem  *             Web Site URL:   http://www.simotime.com               *
rem  *                   e-mail:   helpdesk@simotime.com                 *
rem  * *******************************************************************
rem  *
rem  * Text    - Display message on screen and write to a log file.
rem  * Author  - SimoTime Enterprises
rem  *
rem  * This script may be called from other scripts and expects a
rem  * single parameter enclosed in double quotes. The double quotes
rem  * will be removed. Before writing to the log file a date and time
rem  * stamp will be inserted in front of the message text.
rem  *
rem  * Note: The tilde (~) removes leading/trailing double-quotes.
rem  *
if "%SimoNOTE%" == "" set SimoNOTE=c:\SimoLIBR\LOGS\SimoTime.LOG
echo %date% %time% %~1>> %SimoNOTE%
echo %~1

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

The purpose of this suite of programs is to provide examples for sorting files in a Mainframe environment or a Windows environment using Micro Focus technologies.

Software Agreement and Disclaimer
(Next) (Previous) (Table-of-Contents)

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.

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

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

You may download an evaluation copy of this example at  http://www.simotime.com/sim4dzip.htm#ZipTagXsortut01  or view the complete list of SimoTime Examples at  http://www.simotime.com/sim4dzip.htm .

Note: You must be attached to the Internet to download a Z-Pack or view the list.

Check out  The JCL Connection  for more mainframe JCL examples.

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

To review all the information available on this site start at  The SimoTime Home Page .

Glossary of Terms
(Next) (Previous) (Table-of-Contents)

Check out  The SimoTime Glossary  for a list of terms and definitions used in the documents provided by SimoTime.

Comments or Suggestions
(Next) (Previous) (Table-of-Contents)

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

About SimoTime Enterprises
(Next) (Previous) (Table-of-Contents)

Founded in 1987, SimoTime Enterprises is a privately owned company. We specialize in the creation and deployment of business applications using new or existing technologies and services. We have a team of individuals that understand the broad range of technologies being used in today's environments. This includes the smallest thin client using the Internet and the very large mainframe systems. There is more to making the Internet work for your company's business than just having a nice looking WEB site. It is about combining the latest technologies and existing technologies with practical business experience. It's about the business of doing business and looking good in the process. Quite often, to reach larger markets or provide a higher level of service to existing customers it requires the newer Internet technologies to work in a complementary manner with existing corporate mainframe systems. Whether you want to use the Internet to expand into new market segments or as a delivery vehicle for existing business functions simply give us a call or check the web site at http://www.simotime.com


Return-to-Top
Copyright © 1987-2010  SimoTime Enterprises  All Rights Reserved
When technology complements business