The SORT Program
 Simple Examples
When technology complements business    Copyright © 1987-2012  SimoTime Enterprises  All Rights Reserved
  Table of Contents Version 10.11.01 
  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
  Special Handling, Setting the Environment
  Special Handling, Displaying and Logging Messages
  Summary
  Software Agreement and Disclaimer
  Downloads and Links to Similar Pages
  Downloads and Links, Internet Access Required
  Downloads and Links, Local Access
  Glossary of Terms
  Comments, Suggestions or Feedback
  Company Overview
The SimoTime Home Page

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
  Create and Sort Files in a Mainframe-Oriented 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          *
//*           (C) Copyright 1987-2012 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 sort the 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.
//*
//* 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.
//*
//* *******************************************************************
//* 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
/*
//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  *
005 1 F1 1111 0001 31 0011 0001
/*
//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, Sort the file...
//*
//SRTSEQS5 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.SEQAFTD2,DISP=(NEW,CATLG,DELETE),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=FB,LRECL=80,BLKSIZE=800,DSORG=PS)
//SYSOUT   DD  SYSOUT=*

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          *
//*           (C) Copyright 1987-2012 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          *
//*           (C) Copyright 1987-2012 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
rem  * *******************************************************************
rem  *               SORTTXE1.CMD - a Windows Command File               *
rem  *         This program is provided by SimoTime Enterprises          *
rem  *           (C) Copyright 1987-2012 All Rights Reserved             *
rem  *             Web Site URL:   http://www.simotime.com               *
rem  *                   e-mail:   helpdesk@simotime.com                 *
rem  * *******************************************************************
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 ezSetEnv 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 ..\Env1BASE
     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
rem  * *******************************************************************
rem  *               SORTA5E1.CMD - a Windows Command File               *
rem  *         This program is provided by SimoTime Enterprises          *
rem  *           (C) Copyright 1987-2012 All Rights Reserved             *
rem  *             Web Site URL:   http://www.simotime.com               *
rem  *                   e-mail:   helpdesk@simotime.com                 *
rem  * *******************************************************************
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 ezSetEnv 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 ..\Env1BASE
     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
rem  * *******************************************************************
rem  *               SORTE5E1.CMD - a Windows Command File               *
rem  *         This program is provided by SimoTime Enterprises          *
rem  *           (C) Copyright 1987-2012 All Rights Reserved             *
rem  *             Web Site URL:   http://www.simotime.com               *
rem  *                   e-mail:   helpdesk@simotime.com                 *
rem  * *******************************************************************
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 ezSetEnv 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 ..\Env1BASE
     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 (Env1BASE.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.

@echo OFF
rem  * *******************************************************************
rem  *               ENV1BASE.CMD - a Windows Command File               *
rem  *        This program is provided by SimoTime Enterprises           *
rem  *           (C) Copyright 1987-2012 All Rights Reserved             *
rem  *             Web Site URL:   http://www.simotime.com               *
rem  *                   e-mail:   helpdesk@simotime.com                 *
rem  * *******************************************************************
rem  *
rem  * Text   - Provide a single point to set common environment variables.
rem  * Author - SimoTime Enterprises
rem  * Date   - January 24, 1996
rem  *
rem  * Set the commonly used environment variables. This is used to provide
rem  * a single point for managing the commonly used environment variables.
rem  *
     set BaseLib1=c:\SimoSAM1\DEVL
     set BaseLib8=c:\SimoSAM8
     set SAM1ANIM=C:\SIMOSAM1\DEVL\SAM1SOL1\SAMBATG1\bin\x86\Debug
     set BASEAPP=%BaseLib1%
     set BASESYS=%BaseLib1%\SYS1
     set BASECAT=%BaseLib1%\DATA
     set SYSLOG=%BASESYS%\LOGS\SYSLOG_USER.DAT
     set SYSOUT=%BASEAPP%\LOGS\SYSOUT_SIMSAM01.TXT
     set SLZMSG=%BASEAPP%\LOGS\SLZMSG_USER.TXT
     set PostNOTE=%BASEAPP%\LOGS\SYSOUT_SIMONOTE.TXT
     set SimoNOTE=%BASEAPP%\LOGS\SYSOUT_SIMONOTE.TXT
     set MIFOBASE="C:\Program Files (x86)\Micro Focus\Studio Enterprise Edition 6.0\Base"
     set MIFOBIN=%MIFOBASE%\bin
rem  *
     set SimoLIBR=c:\SimoLIBR
     set JESSERVERNAME=SIMOBATA
rem  *     set SIMOMODE=PAUSE
rem  *
     set MAINFRAME_FLOATING_POINT=true
     set CobCpy=%BASEAPP%\CobCpy1;%BASEAPP%\CobCpy6;c:\SimoLIBR;%MIFOBASE%\SOURCE
     set COBIDY=%BASEAPP%\COBIDY
rem  * For large file support and record locking control of File Handler
     set EXTFH=%BASESYS%\CONFIG\EXTFHBIG.CFG
rem  * For Sort Resource Allocation and Performance
     set SORTSPACE=1000000
     set ES_ALLOC_OVERRIDE=%BASESYS%\CONFIG\CATMAPA1.cfg
     set COBCONFIG_=%BASESYS%\CONFIG\diagnose.cfg
rem  * Set environment for MFBSI (Micro Focus Batch Scheduling Interface)
     set ES_EMP_EXIT_1=mfbsiemx
     set MFBSI_DIR=%BASESYS%\LOGS\%ezServerName%
     set MFBSIEOP_CMD=ENABLE
     set MFBSIEOP_CSV=ENABLE
     set MFBSIEOP_HTM=ENABLE
     set MFBSIEOP_XML=ENABLE
rem  * Set Behavior and Trace Flags for GETJOBDD
     set JDDFLAGS=nnnWnnnn/nnnnnnnn
rem  *
     if "%SIMOPATH%" == "Y" goto JUMPPATH
     set path=%MIFOBASE%;%MIFOBIN%;%PATH%;
     set COBPATH=.;%BASEAPP%\LOADLIB;%BASESYS%\LOADLIB;C:\SimoLIBR
     set LIBPATH=.;%BASEAPP%\LOADLIB;%BASESYS%\LOADLIB;C:\SimoLIBR
     set TXDIR=%BASESYS%\LOADLIB;%MIFOBASE%
:JUMPPATH
     set SIMOPATH=Y
     set JobStatus=0000
     call SimoNOTE "* Settings CmdName Env1BASE.CMD, Version 10.04.19"
     call SimoNOTE "* BaseAPP is %BASEAPP%"

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 SimoTime Enterprises          *
rem  *            (C) Copyright 1987-2012 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 single
rem  * parameter enclosed in double quotes. The double quotes will be
rem  * removed. Before writing to the log file a date and time stamp
rem  * 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. This document may be used to assist as a tutorial for new programmers or as a quick reference for experienced programmers. In the world of programming there are many ways to solve a problem. This documents and the links to other documents are intended to provide a choice of alternatives.

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

Permission to use, copy, modify and distribute this software, documentation or training material for any purpose requires a fee to be paid to SimoTime Enterprises. 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 Enterprises.

SimoTime Enterprises 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 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, documentation or training material.

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

This section includes links to documents with additional information that is beyond the scope and purpose of this document. The first sub-section requires an internet connection, the second sub-section references locally available documents.

Downloads and Links, Internet Access Required
(Next) (Previous) (Table-of-Contents)

The following links will require an internet connect.

A good place to start is The SimoTime Home Page for access to white papers, program examples and product information.

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.

Explore The File Status Return Codes to interpret the results of accessing VSAM data sets and QSAM files.

Explore The Micro Focus Web Site for more information about products and services available from Micro Focus.

Downloads and Links, Local Access
(Next) (Previous) (Table-of-Contents)

The following links should be accessible without an internet connection.

Explore The File Status Return Codes to interpret the results of accessing VSAM data sets and QSAM files.

Check out The JCL Connection for more mainframe JCL examples.

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, Suggestions or Feedback
(Next) (Previous) (Table-of-Contents)

This document was created and is maintained by SimoTime Enterprises.

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.

Company Overview
(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
The SORT Program, Simple Examples
Copyright © 1987-2012 SimoTime Enterprises  All Rights Reserved
When technology complements business
http://www.simotime.com