Collating Sequence
When technology complements business   EBCDIC & ASCII Environments
Copyright © 1987-2008  SimoTime Enterprises, LLC  All Rights Reserved http://www.simotime.com

 
Introduction Version 05.04.14
 
  Programming Objectives
  Programming Input and Output
 
  Printable Character Set
  EBCDIC and ASCII, Side-by-Side Comparison
  Programming Requirements
  Programming Overview
  Possibilities & Considerations
 
  Possibilities & Considerations, EBCDIC & ASCII, List of Possible Exposures
  Possibilities & Considerations, EBCDIC & ASCII, IF Logic Failure, Sample & Correction
  Possibilities & Considerations, EBCDIC & ASCII, Tables & Binary Search
  Sample CMD Member for Net Express
 
  CMD to Run the Demonstration Program
  Sample JCL Member for OS/390 or Mainframe Express
 
  JCL to Run the Demonstration Program
  The Demonstration Program
  The Sort Program
  The File Create Program
  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)

The sorting or collating sequence for an EBCDIC environment is not the same as the sorting or collating sequence for an ASCII environment. The hexadecimal values used to represent the character sets that may be printed or displayed are different. When creating reports that are sorted by an alpha-numeric field (with or without special characters) the sequence of the presentation of information will be different. The major difference is the numbers (or digits) are sorted after the alphabet (with lower case being sorted before upper case) for the EBCDIC environment. The numbers (or digits) are sorted before the alphabet (with upper case being sorted before lower case) for the ASCII environment. The special characters will also be sorted differently as shown later in this document. This problem can usually be resolved by explaining the difference to the business users before an application is migrated between the two environments.

A bigger problem is the potential exposure for a failure in the logic of a program because of the differences in the collating sequence. For example the following logic will work fine in an EBCDIC environment but will fail in an ASCII environment.

If BYTE-ONE is less than a SPACE-CHARACTER or Greater than DIGIT-NINE then BYTE-ONE is non-printable

For more informationj about the potential for logic failures refer to the Possibilities and Considerations section of this document.

This suite of programs will show the differences between the EBCDIC and ASCII collating sequences. It also provides an example of possible logic failures in COBOL source code. This example is in COBOL but the failure would occur with other languages.

The COBOL programs are written using the VS COBOL II dialect and also work with COBOL for MVS and COBOL/370. A JCL member is provided to run the job as an MVS batch job on an IBM mainframe or as a project with Micro Focus Mainframe Express (MFE) running on a PC with Windows. A Windows Command (.CMD) file is provided to run the job on a PC with Micro Focus Net Express. This program may serve as a tutorial for new programmers and as a reference for experienced programmers. Additional information about data migration or data file conversion s provided in the Downloads and Links to Similar Pages section of this document. Our thanks to Larry Simmons of Micro Focus for providing us with much of the information in this document.

Programming Objectives
(Next) (Previous) (Table-of-Contents)

The following is a list of the functions provided in this example.

1. Show the sequencing for EBCDIC and ASCII environments.
2. Show how to create a file for the full, printable character set.
3. Show an example of source code that will produce different results between the EBCDIC and ASCII environments.
4. Show how to run the application on a mainframe using JCL.
5. Show how to run the application on a Windows platform using a .CMD file.

Programming Input and Output
(Next) (Previous) (Table-of-Contents)

A JCL member (CBLCLTJ1.JCL) for the mainframe or a CMD file for the Windows environment (CBLCLTE1.CMD) defines and executes a five step procedure. The first step will delete any files created in a previous run. The second step will create a sequential file consisting of eighty-byte records with the first position containing a printable character. The third step will read the file, test the character in the first position of a record for being a valid printable character and write the results to an output file (Note: this step will work correctly in an EBCDIC environment but fail in an ASCII environment). The fourth step will sort the file (Note: this step will produce different sequencing for an EBCDIC or ASCII environment). The fifth step will read the sorted file, test the first position for a valid printable character and write the results to an output file (Note: this step will work properly in an EBCDIC environment but fail in an ASCII environment. Also, the sequence of the presentation of the data will be different between the two environments).

Sample Printable Character Set
(Next) (Previous) (Table-of-Contents)

The following is an example of the sequential file that is created (COLLATE1.DAT for EBCDIC and COLLATE1.TXT for ASCII) that shows numbers, the alphabet in upper case, the alphabet in lower case and the special characters.

0 e=F0 a=30, Digit
1 e=F1 a=31, Digit
2 e=F2 a=32, Digit
3 e=F3 a=33, Digit
4 e=F4 a=34, Digit
5 e=F5 a=35, Digit
6 e=F6 a=36, Digit
7 e=F7 a=37, Digit
8 e=F8 a=38, Digit
9 e=F9 a=39, Digit
A e=C1 a=41, Upper-Case
B e=C2 a=42, Upper-Case
C e=C3 a=43, Upper-Case
D e=C4 a=44, Upper-Case
E e=C5 a=45, Upper-Case
F e=C6 a=46, Upper-Case
G e=C7 a=47, Upper-Case
H e=C8 a=48, Upper-Case
I e=C9 a=49, Upper-Case
J e=D1 a=4A, Upper-Case
K e=D2 a=4B, Upper-Case
L e=D3 a=4C, Upper-Case
M e=D4 a=4D, Upper-Case
N e=D5 a=4E, Upper-Case
O e=D6 a=4F, Upper-Case
P e=D7 a=50, Upper-Case
Q e=D8 a=51, Upper-Case
R e=D9 a=52, Upper-Case
S e=E2 a=53, Upper-Case
T e=E3 a=54, Upper-Case
U e=E4 a=55, Upper-Case
V e=E5 a=56, Upper-Case
W e=E6 a=57, Upper-Case
X e=E7 a=58, Upper-Case
Y e=E8 a=59, Upper-Case
Z e=E9 a=6A, Upper-Case
a e=81 a=61, Lower-Case
b e=82 a=62, Lower-Case
c e=83 a=63, Lower-Case
d e=84 a=64, Lower-Case
e e=85 a=65, Lower-Case
f e=86 a=66, Lower-Case
g e=87 a=67, Lower-Case
h e=88 a=68, Lower-Case
i e=89 a=69, Lower-Case
j e=91 a=6A, Lower-Case
k e=92 a=6B, Lower-Case
l e=93 a=6C, Lower-Case
m e=94 a=6D, Lower-Case
n e=95 a=6E, Lower-Case
o e=96 a=6F, Lower-Case
p e=97 a=70, Lower-Case
q e=98 a=71, Lower-Case
r e=99 a=72, Lower-Case
s e=A2 a=73, Lower-Case
t e=A3 a=74, Lower-Case
u e=A4 a=75, Lower-Case
v e=A5 a=76, Lower-Case
w e=A6 a=77, Lower-Case
x e=A7 a=78, Lower-Case
y e=A8 a=79, Lower-Case
z e=A9 a=7A, Lower-Case
  e=40 a=20, Space Character
" e=7F a=22, Double Quote
' e=7D a=27, Apostrophe
~ e=A1 a=7E, Tilde
! e=5A a=21, Exclamation Point
@ e=7C a=40, At Sign
# e=7B a=23, Square Symbol
$ e=5B a=24, Dollar Sign
% e=6C a=25, Per Cent Sign
^ e=B0 a=5E, Carat Symbol
& e=50 a=26, Ampersand
* e=5C a=2A, Asterisk
( e=4D a=2A, Left Parenthesis
) e=5D a=29, Right Parenthesis
_ e=6D a=5F, Underscore
+ e=4E a=2B, Plus Sign
{ e=C0 a=7B, Left Brace
} e=D0 a=7D, Right Brace
| e=4F a=7C, Vertical Bar
: e=7A a=3A, Colon
< e=4C a=3C, Less Than
> e=6E a=3E, Greater Than
? e=6F a=3F, Question Mark
` e=79 a=60, Back Apostrophe
- e=60 a=2D, Minus Sign
= e=7E a=3D, Equal Sign
[ e=AD a=5B, Left Bracket
] e=BD a=5D, Right Bracket
\ e=E0 a=5C, Back Slash
; e=5E a=3B, Semicolon
, e=6B a=2C, Comma
. e=4B a=2E, Period Full Stop
/ e=61 a=2F, Forward Slash

The preceding table is then sorted by position one (1) and produces a different sorting sequence for the EBCDIC-encoded and ASCII-encoded environments.

EBCDIC and ASCII, Side-by-Side Comparison
(Next) (Previous) (Table-of-Contents)

The following shows the programming logic that works in an EBCDIC-encoded environment and fails in an ASCII-encoded environment.

      *            The following logic will produce different results
      *            when in an EBCDIC or ASCII environment.
      *            This is because of the difference in the collating
      *            sequences of the two environments.
                   if  COLLATE1-FIRST-BYTE < SPACE
                   or  COLLATE1-FIRST-BYTE > 9
                       move 'NOT Printable'  to COLLATE2-RECORD(16:13)
                   else
                       move 'Printable AOK'  to COLLATE2-RECORD(16:13)
                   end-if
      *            End of example for logic differences

The following shows a side-by-side comparison of the results of the sorting and the programming logic that works in an EBCDIC environment and fails in an ASCII environment.

Sorted Output for EBCDIC Environment Sorted Output for ASCII Environment
Character is   Printable AOK e=40 a=20, Space Character 
Character is . Printable AOK e=4B a=2E, Period Full Stop
Character is < Printable AOK e=4C a=3C, Less Than
Character is ( Printable AOK e=4D a=2A, Left Parenthesis
Character is + Printable AOK e=4E a=2B, Plus Sign
Character is | Printable AOK e=4F a=7C, Vertical Bar
Character is & Printable AOK e=50 a=26, Ampersand
Character is ! Printable AOK e=5A a=21, Exclamation Point 
Character is $ Printable AOK e=5B a=24, Dollar Sign
Character is * Printable AOK e=5C a=2A, Asterisk
Character is ) Printable AOK e=5D a=29, Right Parenthesis 
Character is ; Printable AOK e=5E a=3B, Semicolon
Character is - Printable AOK e=60 a=2D, Minus Sign
Character is / Printable AOK e=61 a=2F, Forward Slash
Character is , Printable AOK e=6B a=2C, Comma
Character is % Printable AOK e=6C a=25, Per Cent Sign
Character is _ Printable AOK e=6D a=5F, Underscore
Character is > Printable AOK e=6E a=3E, Greater Than
Character is ? Printable AOK e=6F a=3F, Question Mark
Character is ` Printable AOK e=79 a=60, Back Apostrophe
Character is : Printable AOK e=7A a=3A, Colon
Character is # Printable AOK e=7B a=23, Square Symbol
Character is @ Printable AOK e=7C a=40, At Sign
Character is ' Printable AOK e=7D a=27, Apostrophe
Character is = Printable AOK e=7E a=3D, Equal Sign
Character is " Printable AOK e=7F a=22, Double Quote
Character is a Printable AOK e=81 a=61, Lower-Case
Character is b Printable AOK e=82 a=62, Lower-Case
Character is c Printable AOK e=83 a=63, Lower-Case
Character is d Printable AOK e=84 a=64, Lower-Case
Character is e Printable AOK e=85 a=65, Lower-Case
Character is f Printable AOK e=86 a=66, Lower-Case
Character is g Printable AOK e=87 a=67, Lower-Case
Character is h Printable AOK e=88 a=68, Lower-Case
Character is i Printable AOK e=89 a=69, Lower-Case
Character is j Printable AOK e=91 a=6A, Lower-Case
Character is k Printable AOK e=92 a=6B, Lower-Case
Character is l Printable AOK e=93 a=6C, Lower-Case
Character is m Printable AOK e=94 a=6D, Lower-Case
Character is n Printable AOK e=95 a=6E, Lower-Case
Character is o Printable AOK e=96 a=6F, Lower-Case
Character is p Printable AOK e=97 a=70, Lower-Case
Character is q Printable AOK e=98 a=71, Lower-Case
Character is r Printable AOK e=99 a=72, Lower-Case
Character is ~ Printable AOK e=A1 a=7E, Tilde
Character is s Printable AOK e=A2 a=73, Lower-Case
Character is t Printable AOK e=A3 a=74, Lower-Case
Character is u Printable AOK e=A4 a=75, Lower-Case
Character is v Printable AOK e=A5 a=76, Lower-Case
Character is w Printable AOK e=A6 a=77, Lower-Case
Character is x Printable AOK e=A7 a=78, Lower-Case
Character is y Printable AOK e=A8 a=79, Lower-Case
Character is z Printable AOK e=A9 a=7A, Lower-Case
Character is ^ Printable AOK e=B0 a=5E, Carat Symbol
Character is [ Printable AOK e=AD a=5B, Left Bracket
Character is ] Printable AOK e=BD a=5D, Right Bracket
Character is { Printable AOK e=C0 a=7B, Left Brace
Character is A Printable AOK e=C1 a=41, Upper-Case
Character is B Printable AOK e=C2 a=42, Upper-Case
Character is C Printable AOK e=C3 a=43, Upper-Case
Character is D Printable AOK e=C4 a=44, Upper-Case
Character is E Printable AOK e=C5 a=45, Upper-Case
Character is F Printable AOK e=C6 a=46, Upper-Case
Character is G Printable AOK e=C7 a=47, Upper-Case
Character is H Printable AOK e=C8 a=48, Upper-Case
Character is I Printable AOK e=C9 a=49, Upper-Case
Character is } Printable AOK e=D0 a=7D, Right Brace
Character is J Printable AOK e=D1 a=4A, Upper-Case
Character is K Printable AOK e=D2 a=4B, Upper-Case
Character is L Printable AOK e=D3 a=4C, Upper-Case
Character is M Printable AOK e=D4 a=4D, Upper-Case
Character is N Printable AOK e=D5 a=4E, Upper-Case
Character is O Printable AOK e=D6 a=4F, Upper-Case
Character is P Printable AOK e=D7 a=50, Upper-Case
Character is Q Printable AOK e=D8 a=51, Upper-Case
Character is R Printable AOK e=D9 a=52, Upper-Case
Character is \ Printable AOK e=E0 a=5C, Back Slash
Character is S Printable AOK e=E2 a=53, Upper-Case
Character is T Printable AOK e=E3 a=54, Upper-Case
Character is U Printable AOK e=E4 a=55, Upper-Case
Character is V Printable AOK e=E5 a=56, Upper-Case
Character is W Printable AOK e=E6 a=57, Upper-Case
Character is X Printable AOK e=E7 a=58, Upper-Case
Character is Y Printable AOK e=E8 a=59, Upper-Case
Character is Z Printable AOK e=E9 a=6A, Upper-Case
Character is 0 Printable AOK e=F0 a=30, Digit
Character is 1 Printable AOK e=F1 a=31, Digit
Character is 2 Printable AOK e=F2 a=32, Digit
Character is 3 Printable AOK e=F3 a=33, Digit
Character is 4 Printable AOK e=F4 a=34, Digit
Character is 5 Printable AOK e=F5 a=35, Digit
Character is 6 Printable AOK e=F6 a=36, Digit
Character is 7 Printable AOK e=F7 a=37, Digit
Character is 8 Printable AOK e=F8 a=38, Digit
Character is 9 Printable AOK e=F9 a=39, Digit
Character is   Printable AOK e=40 a=20, Space Character
Character is ! Printable AOK e=5A a=21, Exclamation Point
Character is " Printable AOK e=7F a=22, Double Quote
Character is # Printable AOK e=7B a=23, Square Symbol
Character is $ Printable AOK e=5B a=24, Dollar Sign
Character is % Printable AOK e=6C a=25, Per Cent Sign
Character is & Printable AOK e=50 a=26, Ampersand
Character is ' Printable AOK e=7D a=27, Apostrophe
Character is ( Printable AOK e=4D a=28, Left Parenthesis
Character is ) Printable AOK e=5D a=29, Right Parenthesis
Character is * Printable AOK e=5C a=2A, Asterisk
Character is + Printable AOK e=4E a=2B, Plus Sign
Character is , Printable AOK e=6B a=2C, Comma
Character is - Printable AOK e=60 a=2D, Minus Sign
Character is . Printable AOK e=4B a=2E, Period Full Stop
Character is / Printable AOK e=61 a=2F, Forward Slash
Character is 0 Printable AOK e=F0 a=30, Digit
Character is 1 Printable AOK e=F1 a=31, Digit
Character is 2 Printable AOK e=F2 a=32, Digit
Character is 3 Printable AOK e=F3 a=33, Digit
Character is 4 Printable AOK e=F4 a=34, Digit
Character is 5 Printable AOK e=F5 a=35, Digit
Character is 6 Printable AOK e=F6 a=36, Digit
Character is 7 Printable AOK e=F7 a=37, Digit
Character is 8 Printable AOK e=F8 a=38, Digit
Character is 9 Printable AOK e=F9 a=39, Digit
Character is : NOT Printable e=7A a=3A, Colon
Character is ; NOT Printable e=5E a=3B, Semicolon
Character is < NOT Printable e=4C a=3C, Less Than
Character is = NOT Printable e=7E a=3D, Equal Sign
Character is > NOT Printable e=6E a=3E, Greater Than
Character is ? NOT Printable e=6F a=3F, Question Mark
Character is @ NOT Printable e=7C a=40, At Sign
Character is A NOT Printable e=C1 a=41, Upper-Case
Character is B NOT Printable e=C2 a=42, Upper-Case
Character is C NOT Printable e=C3 a=43, Upper-Case
Character is D NOT Printable e=C4 a=44, Upper-Case
Character is E NOT Printable e=C5 a=45, Upper-Case
Character is F NOT Printable e=C6 a=46, Upper-Case
Character is G NOT Printable e=C7 a=47, Upper-Case
Character is H NOT Printable e=C8 a=48, Upper-Case
Character is I NOT Printable e=C9 a=49, Upper-Case
Character is J NOT Printable e=D1 a=4A, Upper-Case
Character is K NOT Printable e=D2 a=4B, Upper-Case
Character is L NOT Printable e=D3 a=4C, Upper-Case
Character is M NOT Printable e=D4 a=4D, Upper-Case
Character is N NOT Printable e=D5 a=4E, Upper-Case
Character is O NOT Printable e=D6 a=4F, Upper-Case
Character is P NOT Printable e=D7 a=50, Upper-Case
Character is Q NOT Printable e=D8 a=51, Upper-Case
Character is R NOT Printable e=D9 a=52, Upper-Case
Character is S NOT Printable e=E2 a=53, Upper-Case
Character is T NOT Printable e=E3 a=54, Upper-Case
Character is U NOT Printable e=E4 a=55, Upper-Case
Character is V NOT Printable e=E5 a=56, Upper-Case
Character is W NOT Printable e=E6 a=57, Upper-Case
Character is X NOT Printable e=E7 a=58, Upper-Case
Character is Y NOT Printable e=E8 a=59, Upper-Case
Character is Z NOT Printable e=E9 a=6A, Upper-Case
Character is [ NOT Printable e=AD a=5B, Left Bracket
Character is \ NOT Printable e=E0 a=5C, Back Slash
Character is ] NOT Printable e=BD a=5D, Right Bracket
Character is ^ NOT Printable e=B0 a=5E, Carat Symbol
Character is _ NOT Printable e=6D a=5F, Underscore
Character is ` NOT Printable e=79 a=60, Back Apostrophe
Character is a NOT Printable e=81 a=61, Lower-Case
Character is b NOT Printable e=82 a=62, Lower-Case
Character is c NOT Printable e=83 a=63, Lower-Case
Character is d NOT Printable e=84 a=64, Lower-Case
Character is e NOT Printable e=85 a=65, Lower-Case
Character is f NOT Printable e=86 a=66, Lower-Case
Character is g NOT Printable e=87 a=67, Lower-Case
Character is h NOT Printable e=88 a=68, Lower-Case
Character is i NOT Printable e=89 a=69, Lower-Case
Character is j NOT Printable e=91 a=6A, Lower-Case
Character is k NOT Printable e=92 a=6B, Lower-Case
Character is l NOT Printable e=93 a=6C, Lower-Case
Character is m NOT Printable e=94 a=6D, Lower-Case
Character is n NOT Printable e=95 a=6E, Lower-Case
Character is o NOT Printable e=96 a=6F, Lower-Case
Character is p NOT Printable e=97 a=70, Lower-Case
Character is q NOT Printable e=98 a=71, Lower-Case
Character is r NOT Printable e=99 a=72, Lower-Case
Character is s NOT Printable e=A2 a=73, Lower-Case
Character is t NOT Printable e=A3 a=74, Lower-Case
Character is u NOT Printable e=A4 a=75, Lower-Case
Character is v NOT Printable e=A5 a=76, Lower-Case
Character is w NOT Printable e=A6 a=77, Lower-Case
Character is x NOT Printable e=A7 a=78, Lower-Case
Character is y NOT Printable e=A8 a=79, Lower-Case
Character is z NOT Printable e=A9 a=7A, Lower-Case
Character is { NOT Printable e=C0 a=7B, Left Brace
Character is | NOT Printable e=4F a=7C, Vertical Bar
Character is } NOT Printable e=D0 a=7D, Right Brace
Character is ~ NOT Printable e=A1 a=7E, Tilde

Refer to the Possibilities and Considerations section of this document for more inofrmation about the impact of this collating sequence difference.

Programming Requirements
(Next) (Previous) (Table-of-Contents)

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

1. Executes on Windows/2000, Windows/NT and Windows/XP using Micro Focus Net Express and the CMD file provided.
2. May be ported to run on the UNIX platforms supported by Micro Focus COBOL.
3. Executes on a mainframe with MVS or Windows/2000, Windows/NT and Windows/XP using Micro Focus Mainframe Express and the JCL file provided.

Programming Overview
(Next) (Previous) (Table-of-Contents)

The following diagram is an overview of how the demonstration program fits into the example. The BLUE boxes are unique to the mainframe and Micro Focus Mainframe Express. The RED boxes are unique to the PC with Windows and Micro Focus Net Express. The GREEN boxes are platform independent and will execute on the mainframe or a PC with Windows. Also, the GREEN boxes may be ported to a UNIX platform that is supported by Micro Focus COBOL.

               
Entry Point
z/OS or MFE
     
Entry Point
Net Express
  Entry Points  
 
     
 
     
CBLCLTJ1
jcl
     
CBLCLTE1
cmd
  Start the collating sequence example  
 
     
 
     
IEFBR14
cmd
     
If Exist
stmt
  Delete previously created output file  
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
   
CBLCLTC2
cobol
     
     
     
COLLATE1
qsam
  Job Step is MAKEFILE, create a file containing the printable character set (COLLATE1).  
   
 
         
COLLATE1
qsam
     
     
     
CBLCLTC1
cobol
     
     
     
COLLATE2
qsam
  Read the input file (COLLATE1), and write the results to the output file (COLLATE2).  
   
 
         
COLLATE1
qsam
     
     
     
CBLS80C1
cobol
     
     
     
COLLATE3
qsam
  Sort the file. This step produces different sequencing for the EBCDIC and ASCII environments.  
   
 
         
COLLATE3
qsam
     
     
     
CBLCLTC1
cobol
     
     
     
COLLATE4
qsam
  This step works on the EBCDIC environment and fails in the ASCII environment.  
   
 
         
   
EOJ
      End-of-Job  
               

Possibilities & Considerations
(Next) (Previous) (Table-of-Contents)

This section describes some of the possible problems that may occur when moving from an EBCDIC-encoded environment to an ASCII environment. Some coding changes may be required to get an application to produce the same results in both environments (reports and other output will most likely be in a different sequence when the fields that deternine the sort sequence is alpha-numeric).

Possibilities & Considerations, EBCDIC & ASCII, List of Possible Exposures
(Next) (Previous) (Table-of-Contents)

The section will list of some of the items to look for during an EBCDIC to ASCII conversion. The list uses the term "half-a-range" check and is used to describe the following comparison logic.

The following will require extra time in the conversion process.

1. Logic that processes alpha-numeric values and does half-a-range check using the “IF” or “EVALUATE” capabilities of COBOL may work in an EBCDIC-encoded environment and fail in an ASCII-encoded environment.
2. The INCLUDE or OMIT statements in the SORT utility program that do half-a-range check for alpha-numeric values may work in an EBCDIC-encoded environment and fail in an ASCII-encoded environment.
3. Tables that are hard-coded in COBOL and are accessed using a binary search (i.e. SEARCH ALL) and the search argument is alpha-numeric may work in an EBCDIC-encoded environment and fail in an ASCII-encoded environment.
4. Items that are alpha-numeric and use the technique of comparing for 999999 to indicate end of table or last record in a file will work in EBCDIC-encoded environments but fail in ASCII-encoded environments.
5. When working with international character sets (i.e. accented characters such as the umlat and tilde) be aware the upper case “Y” with the umlat is x’FF’ in EBCDIC and this will get converted to x’9F’ which is the ASCII equivalent. This could cause a conflict if the actual value is used as a high-value and should not be converted.
6. The use of hexadecimal coding techniques (i.e. x’C1’). This is sometimes used in COBOL and is required with the ALTSEQ statement in the SORT utility. Note: The ALTSEQ is frequently used on the mainframe to do a case-insensitive sort.
7. During the data file transfer process if MFA is not used (i.e. FTP is used) the following will require extra consideration.
7.1. A VSAM KSDS has an alpha-numeric key and IDCAMS is used to REPRO the file to a sequential file
7.2. The sequential file is downloaded using FTP.
7.3. The sequential file is read, the data is converted from EBCDIC to ASCII, a record is written to a new Key-Sequenced file. Since the key is alpha-numeric the sequencing will be different in ASCII and an ordered (or sequential) load of the new key-sequenced file will fail with a sequencing (or collating) error. There are two possible solutions to this problem.
7.3.1. Do an unordered load of the new key-sequenced file.
7.3.2. Convert the downloaded sequential file to ASCII and then sort the file. Use the sorted, ASCII-encoded, sequential file to do an ordered load of the new key-sequenced file.
8. Data that is sequenced by an alpha-numeric key or sorted based on the content of an alpha-numeric field may be presented in a different sequence.
9. Data that is sequenced using an alphabetic upper and lower case key or sorted based on the content of an alphabetic upper and lower case field may be presented in a different sequence.
Note: it is possible to do a case insensitve sort using the ALTSEQ statement of the sort program on the mainframe or with Micro Focus. Refer to the sample sort program provided on the SimoTime Web site.
10. The technique of comparing the units position of signed, zoned-decimal numbers for an "A-I" for positive values, a "J-R" for negative values and the right and left curly brace for zero that works in an EBCDIC environment may fail in an ASCII environment.
Note: Signed, zoned-decimal format may present some challenges depending on the coding techniques to prepare for printing or exporting. Refer to the zoned-decimal numeric format provided on the SimoTime Web site.

The preceding is a quick summary of some of the items that are encountered when changing from an EBCDIC-encoded environment to an ASCII encoded environment.

Doing this level of conversion will require the standard unit testing, application testing and system testing before deploying to a production environment. It is important to note that when doing data file compares to validate the results between a Mainframe (EBCDIC) process and a Window, Micro Focus (ASCII) process extra consideration will be required for both the differences in the encoding formats and collating sequences.

Possibilities & Considerations, EBCDIC & ASCII, IF Logic Failure, Sample & Correction
(Next) (Previous) (Table-of-Contents)

Think about this senario. A customer master file contains a twelve (12) byte key. If the first byte of the key is a number then it is an indivudual account. If the first byte of the key is a letter then it is a commercial account. If a program does a test as follows then the logic will work in an EBCDIC-encoded environment but fail in an ASCII-encoded environment.

If  CUSTOMER-KEY(1:1) is equal to or greater than 0 
ACCOUNT-TYPE = INDIVIDUAL
else
ACCOUNT-TYPE = COMERCIAL
end-if

For the ASCII-encoded environment the preceding code example would conclude that all the accounts are individual accounts. The code would need to be changed to the following.

If  CUSTOMER-KEY(1:1) is equal to or greater than 0 
and CUSTOMER-KEY(1:1) is equal to or less than 9
ACCOUNT-TYPE = INDIVIDUAL
else
ACCOUNT-TYPE = COMERCIAL
end-if PRE>

The preceding code example would work in both the EBCDIC-encoded and ASCII-encoded environments.

Possibilities & Considerations, EBCDIC & ASCII, Tables & Binary Search
(Next) (Previous) (Table-of-Contents)

Think about the following senario. A sequential file contains records that will be loaded into a table. The records are in sequence based on the content of an alpha-numeric field. The records in the file are used to load a table in a COBOL (or other language) program. The table is then accessed using a binary search routine. On the new platform we are now working in an ASCII-encoded environment. The original file was EBCDIC-encoded and in sequence by the EBCDIC collating sequence. If we simple convert the file to ASCII-encoded format it will still be in sequence by EBCDIC (or out of sequence in the ASCII-encoded environment). This will cause the binary search to fail. The file must be sorted after the EBCDIC to ASCII conversion (especially since the information in the records is aplha-numeric).

Note: Remember, a SEARCH ALL of a table in COBOL does a binary search and will most likely fail when accessing an ASCII-encoded table that is in EBCDIC collating sequence and contains alpha-numeric data. A SEARCH does a scan of the table starting at the first element and will work but will be much slower for large tables.

Sample CMD File
(Next) (Previous) (Table-of-Contents)

This sample suite of programs has one CMD member that executes multiple job steps to sort and present data in the ASCII collating sequence. A subsequent step will then test the characters to determine if they are valid, printable characters. The CMD member will execute a COBOL program that will produce correct results in an EBCDIC environment but will fail in the ASCII environment.

Sample CMD, Run the Demonstration Program
(Next) (Previous) (Table-of-Contents)

The following is the CMD required to run the demonstration program on a Personal Computer with Micro Focus Net Express.

@echo OFF
rem * *******************************************************************
rem *                   This program is provided by:                    *
rem *                    SimoTime Enterprises, LLC                      *
rem *           (C) Copyright 1987-2006 All Rights Reserved             *
rem *             Web Site URL:   http://www.simotime.com               *
rem *                   e-mail:   helpdesk@simotime.com                 *
rem * *******************************************************************
rem *
rem * Text   - Create, Sort and Process a Sequential file using
rem *          a COBOL program.
rem * Author - SimoTime Enterprises
rem * Date   - January 24, 1996
rem *
rem * The 1st step (QSAMDELT) will delete any previously created file.
rem *
rem * The 2nd step (MAKEFILE) will create a new file. The first
rem * position in each record will contain a printable character.
rem *
rem * The 3rd step will show a program that works properly in an
rem * EBCDIC environment but fails in an ASCII environment.
rem *
rem * The 4th step will SORT the file. This step will produce different
rem * results when executing on an EBCDIC or ASCII environment.
rem *
rem * The 5th step shows the sequencing for the two environments and
rem * will worked properly in an EBCDIC environment but fail in an
rem * ASCII environment.
rem *
rem * This set of programs will run on a mainframe under MVS or on a
rem * Personal Computer with Windows and Micro Focus Mainframe Express.
rem *
rem * *******************************************************************
rem * Step 1 Delete any previously created file...
rem *
     set JobStatus=0000
     if "%SYSLOG%" == "" set syslog=c:\SimoLIBR\LOGS\SimoTime.LOG
rem  *
     SimoEXEC NOTE  *******************************************************CblCltE1
     SimoEXEC NOTE  Starting JobName CblCltE1, V04.08.13, User is %USERNAME%
:DeleteQSAM
     SimoEXEC NOTE  Identify JobStep DeleteQSAM
     set COLLATE1=c:\SimoNXE4\AN01\DataAsc1\COLLATE1.TXT
     set COLLATE2=c:\SimoNXE4\AN01\DataAsc1\COLLATE2.TXT
     set COLLATE3=c:\SimoNXE4\AN01\DataAsc1\COLLATE3.TXT
     set COLLATE4=c:\SimoNXE4\AN01\DataAsc1\COLLATE4.TXT
     if exist %COLLATE1% del %COLLATE1%
     if exist %COLLATE2% del %COLLATE2%
     if exist %COLLATE3% del %COLLATE3%
     if exist %COLLATE4% del %COLLATE4%
rem *
rem * *******************************************************************
rem * Step 2 Create and populate a new QSAM file...
rem *
:MakeFile
     SimoEXEC NOTE  Identify JobStep MakeFile
     set COLLATE1=c:\SimoNXE4\AN01\DataAsc1\COLLATE1.TXT
     set COLLATE2=c:\SimoNXE4\AN01\DataAsc1\COLLATE2.TXT
     SimoEXEC EXEC CBLCLTC2
     if ERRORLEVEL = 1 set JobStatus=0020
     if not "%JobStatus%" == "0000" goto :EojNok
rem *
rem * *******************************************************************
rem * Step 3 Test for printable character, create a new output file.
rem *        the program used in this step will perform correctly
rem *        in an EBCDIC environment but fail in an ASCII environment
rem *
:Test0001
     SimoEXEC NOTE  Identify JobStep Test0001
     set COLLATE1=c:\SimoNXE4\AN01\DataAsc1\COLLATE1.TXT
     set COLLATE2=c:\SimoNXE4\AN01\DataAsc1\COLLATE2.TXT
     SimoEXEC EXEC CBLCLTC1
     if ERRORLEVEL = 1 set JobStatus=0030
     if not "%JobStatus%" == "0000" goto :EojNok
rem * *******************************************************************
rem * Step 4 Sort by character set using a cobol program. This step will
rem *        produce different sequencing results when running in an
rem *        EBCDIC or ASCII environment.
rem *
:SortFile
     SimoEXEC NOTE  Identify JobStep SortFile
     set SORTGET1=c:\SimoNXE4\AN01\DataAsc1\COLLATE1.TXT
     set SORTPUT1=c:\SimoNXE4\AN01\DataAsc1\COLLATE3.TXT
     SimoEXEC  EXEC CBLS80C1
     if ERRORLEVEL = 1 set JobStatus=0040
     if not "%JobStatus%" == "0000" goto :EojNok
rem *
rem * *******************************************************************
rem * Step 5 Test for printable character, create a new output file.
rem *        the program used in this step will perform correctly
rem *        in an EBCDIC environment but fail in an ASCII environment.
rem *        This step uses the sorted file and shows the sequencing
rem *        that will be different when running in an EBCDIC or ASCII
rem *        environment.
rem *
:Test0002
     set COLLATE1=c:\SimoNXE4\AN01\DataAsc1\COLLATE3.TXT
     set COLLATE2=c:\SimoNXE4\AN01\DataAsc1\COLLATE4.TXT
     SimoEXEC EXEC CBLCLTC1
     if ERRORLEVEL = 1 set JobStatus=0050
     if not "%JobStatus%" == "0000" goto :EojNok
     goto :EojAok
rem  *
:EojNok
     SimoEXEC NOTE ABENDING JobName CblCltE1, JobStatus %JobStatus%
     SimoEXEC NOTE ABENDING Message JobStatus %JobStatus%
     pause
     goto :End
:EojAok
     SimoEXEC NOTE Finished JobName CblCltE1, JobStatus %JobStatus%
:End
     SimoEXEC NOTE Conclude SysLog is %SYSLOG%
     if not "%1" == "nopause" pause

Sample JCL
(Next) (Previous) (Table-of-Contents)

This sample suite of programs has one JCL member that executes multiple job steps to sort and present data in the EBCDIC collating sequence. A subsequent step will then test the characters to determine if they are valid, printable characters. The JCL member will execute a COBOL program that will produce correct results in an EBCDIC environment but will fail in the ASCII environment.

Sample JCL, Run the Demonstration Program
(Next) (Previous) (Table-of-Contents)

The following is the JCL required to run the demonstration program on the mainframe or with Micro Focus Mainframe Express.

//CBLCLTJ1 JOB SIMOTIME,CLASS=1,MSGCLASS=0,NOTIFY=CSIP1
//* *******************************************************************
//*                   This program is provided by:                    *
//*                    SimoTime Enterprises, LLC                      *
//*           (C) Copyright 1987-2006 All Rights Reserved             *
//*             Web Site URL:   http://www.simotime.com               *
//*                   e-mail:   helpdesk@simotime.com                 *
//* *******************************************************************
//*
//* Text   - Create, Sort and Process a Sequential file
//*          using a COBOL program.
//* Author - SimoTime Enterprises
//* Date   - January 24, 1991
//*
//* The 1st step (QSAMDELT) will delete any previously created file.
//*
//* The 2nd step (MAKEFILE) will create a new file. The first
//* position in each record will contain a printable character.
//*
//* The 3rd step will show a program that works properly in an
//* EBCDIC environment but fails in an ASCII environment.
//*
//* The 4th step will SORT the file. This step will produce different
//* results when executing on an EBCDIC or ASCII environment.
//*
//* The 5th step shows the sequencing for the two environments and
//* will worked properly in an EBCDIC environment but fail in an
//* ASCII environment.
//*
//* 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 Delete any previously created file...
//*
//QSAMDELT EXEC PGM=IEFBR14
//COLLATE1 DD  DSN=SIMOTIME.DATA.COLLATE1,DISP=(MOD,DELETE,DELETE),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=FB,LRECL=80,BLKSIZE=800,DSORG=PS)
//COLLATE2 DD  DSN=SIMOTIME.DATA.COLLATE2,DISP=(MOD,DELETE,DELETE),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=FB,LRECL=80,BLKSIZE=8000,DSORG=PS)
//COLLATE3 DD  DSN=SIMOTIME.DATA.COLLATE3,DISP=(MOD,DELETE,DELETE),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=FB,LRECL=80,BLKSIZE=8000,DSORG=PS)
//COLLATE4  DD  DSN=SIMOTIME.DATA.COLLATE4,DISP=(MOD,DELETE,DELETE),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=FB,LRECL=80,BLKSIZE=8000,DSORG=PS)
//*
//* *******************************************************************
//* Step 2 Create and populate a new QSAM file...
//*
//MAKEFILE EXEC PGM=CBLCLTC2
//COLLATE1 DD  DSN=SIMOTIME.DATA.COLLATE1,
//             DISP=(NEW,CATLG,DELETE),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=FB,LRECL=80,BLKSIZE=800,DSORG=PS)
//*
//* *******************************************************************
//* Step 3 Test for printable character, create a new output file.
//*        the program used in this step will perform correctly
//*        in an EBCDIC environment but fail in an ASCII environment
//*
//TEST0001 EXEC PGM=CBLCLTC1
//STEPLIB  DD  DSN=SIMOTIME.DEMO.LOADLIB1,DISP=SHR
//COLLATE1 DD  DSN=SIMOTIME.DATA.COLLATE1,DISP=SHR
//COLLATE2 DD  DSN=SIMOTIME.DATA.COLLATE2,
//             DISP=(NEW,CATLG,DELETE),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=FB,LRECL=80,BLKSIZE=800,DSORG=PS)
//SYSOUT   DD  SYSOUT=*
//* *******************************************************************
//* Step 4 Sort by character set using a cobol program. This step will
//*        produce different sequencing results when running in an
//*        EBCDIC or ASCII environment.
//*        The major difference is the numbers are sorted after the
//*        alphabetic characters for the EBCDIC environment and the
//*        numbers are sorted before the alhpabetic characters for
//*        the ASCII environment.
//*
//SORTFILE EXEC PGM=CBLS80C1
//STEPLIB  DD  DSN=SIMOTIME.DEMO.LOADLIB1,DISP=SHR
//SORTGET1 DD  DSN=SIMOTIME.DATA.COLLATE1,DISP=SHR
//SORTPUT1 DD  DSN=SIMOTIME.DATA.COLLATE3,DISP=(NEW,CATLG,DELETE),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=FB,LRECL=80,BLKSIZE=8000,DSORG=PS)
//SYSOUT   DD  SYSOUT=*
//*
//* *******************************************************************
//* Step 5 Test for printable character, create a new output file.
//*        the program used in this step will perform correctly
//*        in an EBCDIC environment but fail in an ASCII environment.
//*        This step uses the sorted file and shows the sequencing
//*        that will be different when running in an EBCDIC or ASCII
//*        environment.
//*
//TEST0002 EXEC PGM=CBLCLTC1
//STEPLIB  DD  DSN=SIMOTIME.DEMO.LOADLIB1,DISP=SHR
//COLLATE1 DD  DSN=SIMOTIME.DATA.COLLATE3,DISP=SHR
//COLLATE2 DD  DSN=SIMOTIME.DATA.COLLATE4,
//             DISP=(NEW,CATLG,DELETE),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=FB,LRECL=80,BLKSIZE=800,DSORG=PS)
//SYSOUT   DD  SYSOUT=*
//

The Demonstration Program
(Next) (Previous) (Table-of-Contents)

The following is the source code listing for the demonstration program that shows the type of programming logic that will work in an EBCDIC environment and fail in an ASCII environment.

       IDENTIFICATION DIVISION.
       PROGRAM-ID.    CBLCLTC1.
       AUTHOR.        SIMOTIME ENTERPRISES.
      *****************************************************************
      * Copyright (C) 1987-2006 SimoTime Enterprises, LLC.            *
      *                                                               *
      * 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 commercial purpose requires a fee to be paid to       *
      * SimoTime Enterprises. 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           *
      * Enterprises.                                                  *
      *                                                               *
      * Permission to use, copy and modify 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           *
      * Enterprises.                                                  *
      *                                                               *
      * 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                                  *
      *                                                               *
      * SimoTime Enterprises                                          *
      * 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 Enterprises,  *
      * 15 Carnoustie Drive, Novato, CA 94949-5849.                   *
      *                                                               *
      *****************************************************************
      *      This program is provided by SimoTime Enterprises         *
      *        Our e-mail address is: helpdesk@simotime.com           *
      *     Also, visit our Web Site at http://www.simotime.com       *
      *****************************************************************
      * Source Member: CBLCLTC1.CBL
      * Copy Files:    PASSRA12.CPY
      * Calls to:      SIMORA12
      *****************************************************************
      *
      *                   ************
      *                   * CBLCLTJ1 *
      *                   ********jcl*
      *                        *
      *                   ************
      *                   * IEFBR14  *
      *                   ********utl*
      *                        *
      *  ************     ************     ************
      *  * COLLATE1 *-----* CBLCLTC1 *-----* COLLATE2 *
      *  ********dat*     ********cbl*     ********dat*
      *                        *
      *                        *
      *                   ************
      *                   *   EOJ    *
      *                   ************
      *
      * The purpose of this program is to shaow an example of code
      * that will execute correctly in an EBCDIC environment but
      * fail in an ASCII environment.
      *
      *****************************************************************

       ENVIRONMENT DIVISION.
       INPUT-OUTPUT SECTION.
       FILE-CONTROL.
           SELECT COLLATE1-FILE  ASSIGN to     COLLATE1
                  ORGANIZATION is SEQUENTIAL
                  ACCESS MODE  is SEQUENTIAL
                  FILE STATUS  is COLLATE1-STATUS.
           SELECT COLLATE2-FILE  ASSIGN to     COLLATE2
                  ORGANIZATION is SEQUENTIAL
                  ACCESS MODE  is SEQUENTIAL
                  FILE STATUS  is COLLATE2-STATUS.

      *****************************************************************
       DATA DIVISION.
       FILE SECTION.
       FD  COLLATE1-FILE
           BLOCK CONTAINS 00800 CHARACTERS
           DATA RECORD    is COLLATE1-RECORD
           .
       01  COLLATE1-RECORD.
           05  COLLATE1-DATA-01.
               10  COLLATE1-FIRST-BYTE pic X.
               10  COLLATE1-2-80       pic X(79).

       FD  COLLATE2-FILE
           BLOCK CONTAINS 00800 CHARACTERS
           DATA RECORD    is COLLATE2-RECORD
           .
       01  COLLATE2-RECORD.
           05  COLLATE2-DATA-01  pic X(00080).

       WORKING-STORAGE SECTION.
       01  SIM-TITLE.
           05  T1 pic X(11) value '* CBLCLTC1 '.
           05  T2 pic X(34) value 'Test for ASCII/EBCDIC collating   '.
           05  T3 pic X(10) value ' v04.08.23'.
           05  T4 pic X(24) value ' http://www.simotime.com'.
       01  SIM-COPYRIGHT.
           05  C1 pic X(11) value '* CBLCLTC1 '.
           05  C2 pic X(20) value 'Copyright 1987-2006 '.
           05  C3 pic X(28) value '  SimoTime Enterprises, LLC '.
           05  C4 pic X(20) value ' All Rights Reserved'.

       01  SIM-THANKS-01.
           05  C1 pic X(11) value '* CBLCLTC1 '.
           05  C2 pic X(32) value 'Thank you for using this sample '.
           05  C3 pic X(32) value 'by SimoTime Enterprises, LLC    '.
           05  C4 pic X(04) value '    '.

       01  SIM-THANKS-02.
           05  C1 pic X(11) value '* CBLCLTC1 '.
           05  C2 pic X(32) value 'Please send comments or suggesti'.
           05  C3 pic X(32) value 'ons to helpdesk@simotime.com    '.
           05  C4 pic X(04) value '    '.

       01  MESSAGE-BUFFER.
           05  MESSAGE-HEADER      pic X(11)   value '* CBLCLTC1 '.
           05  MESSAGE-TEXT.
               10  MESSAGE-TEXT-1  pic X(68)   value SPACES.
               10  MESSAGE-TEXT-2  pic X(188)  value SPACES.

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

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

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

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

       01  ONE-BYTE                pic X.

       01  COLLATE1-TOTAL.
           05  filler       pic X(23)  value 'COLLATE1 line count is '.
           05  COLLATE1-LOC pic 9(7) value 0.

      *****************************************************************
       PROCEDURE DIVISION.
           perform Z-POST-COPYRIGHT
           perform COLLATE1-OPEN
           perform COLLATE2-OPEN

           perform until COLLATE1-STATUS not = '00'
               perform COLLATE1-READ
               if  COLLATE1-STATUS = '00'
                   add 1 to COLLATE1-LOC
                   move SPACES to COLLATE2-RECORD
                   move 'Character is ' to COLLATE2-RECORD
                   move COLLATE1-FIRST-BYTE to COLLATE2-RECORD(14:1)

      *            The following logic will produce different results
      *            when in an EBCDIC or ASCII environment.
      *            This is because of the difference in the collating
      *            sequences of the two environemnts.
                   if  COLLATE1-FIRST-BYTE < SPACE
                   or  COLLATE1-FIRST-BYTE > 9
                       move 'NOT Printable'  to COLLATE2-RECORD(16:13)
                   else
                       move 'Printable AOK'  to COLLATE2-RECORD(16:13)
                   end-if
                   move COLLATE1-2-80(1:40) to COLLATE2-RECORD(29:40)
                   if  COLLATE2-RECORD not = SPACES
                       move COLLATE2-RECORD to MESSAGE-TEXT
                       perform Z-DISPLAY-CONSOLE-MESSAGE
                       perform COLLATE2-WRITE
                   end-if
      *            End of example for logic differences

               end-if
           end-perform

           move COLLATE1-TOTAL to MESSAGE-TEXT
           perform Z-DISPLAY-CONSOLE-MESSAGE

           if  COLLATE1-EOF = 'Y'
               move 'is Finished...' to MESSAGE-TEXT
           else
               move 'is ABENDING...' to MESSAGE-TEXT
           end-if
           perform Z-DISPLAY-CONSOLE-MESSAGE

           perform COLLATE2-CLOSE
           perform COLLATE1-CLOSE
           perform Z-THANK-YOU.
           GOBACK.

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

      *****************************************************************
      * I/O ROUTINES FOR COLLATE2...                                  *
      *****************************************************************
       COLLATE2-WRITE.
           if  COLLATE2-OPEN-FLAG = 'C'
               perform COLLATE2-OPEN
           end-if
           write COLLATE2-RECORD
           if  COLLATE2-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
           else
               if  COLLATE2-STATUS = '10'
                   add 16 to ZERO giving APPL-RESULT
               else
                   add 12 to ZERO giving APPL-RESULT
               end-if
           end-if.
           if  APPL-AOK
               CONTINUE
           else
               move 'COLLATE2-Failure-WRITE...' to MESSAGE-TEXT
               perform Z-DISPLAY-CONSOLE-MESSAGE
               move COLLATE2-STATUS to IO-STATUS
               perform Z-DISPLAY-IO-STATUS
               perform Z-ABEND-PROGRAM
           end-if
           exit.
      *---------------------------------------------------------------*
       COLLATE2-OPEN.
           add 8 to ZERO giving APPL-RESULT.
           open output COLLATE2-FILE
           if  COLLATE2-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
               move 'O' to COLLATE2-OPEN-FLAG
           else
               add 12 to ZERO giving APPL-RESULT
           end-if
           if  APPL-AOK
               CONTINUE
           else
               move 'COLLATE2-Failure-OPEN...' to MESSAGE-TEXT
               perform Z-DISPLAY-CONSOLE-MESSAGE
               move COLLATE2-STATUS to IO-STATUS
               perform Z-DISPLAY-IO-STATUS
               perform Z-ABEND-PROGRAM
           end-if
           exit.
      *---------------------------------------------------------------*
       COLLATE2-CLOSE.
           add 8 to ZERO giving APPL-RESULT.
           close COLLATE2-FILE
           if  COLLATE2-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
               move 'C' to COLLATE2-OPEN-FLAG
           else
               add 12 to ZERO giving APPL-RESULT
           end-if
           if  APPL-AOK
               CONTINUE
           else
               move 'COLLATE2-Failure-CLOSE...' to MESSAGE-TEXT
               perform Z-DISPLAY-CONSOLE-MESSAGE
               move COLLATE2-STATUS to IO-STATUS
               perform Z-DISPLAY-IO-STATUS
               perform Z-ABEND-PROGRAM
           end-if
           exit.

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

      *****************************************************************
      * Display CONSOLE messages...                                   *
      *****************************************************************
       Z-DISPLAY-CONSOLE-MESSAGE.
           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.

      *****************************************************************
      * Display the file status bytes. This routine will display as   *
      * two digits if the full two byte file status is numeric. If    *
      * second byte is non-numeric then it will be treated as a       *
      * binary number.                                                *
      *****************************************************************
       Z-DISPLAY-IO-STATUS.
           if  IO-STATUS not NUMERIC
           or  IO-STAT1    = '9'
               subtract TWO-BYTES-BINARY from TWO-BYTES-BINARY
               move IO-STAT2 to TWO-BYTES-RIGHT
               display '* CBLCLTC1 File-Status-' IO-STAT1 '/'
                       TWO-BYTES-BINARY upon console
           else
               display '* CBLCLTC1 File-Status-' IO-STATUS upon console
           end-if
           exit.

      *****************************************************************
       Z-POST-COPYRIGHT.
           display SIM-TITLE     upon console
           display SIM-COPYRIGHT upon console
           exit.

      *****************************************************************
       Z-THANK-YOU.
           display SIM-THANKS-01 upon console
           display SIM-THANKS-02 upon console
           exit.
      *****************************************************************
      *      This example is provided by SimoTime Enterprises         *
      *        Our e-mail address is: helpdesk@simotime.com           *
      *     Also, visit our Web Site at http://www.simotime.com       *
      *****************************************************************

The Sort Program
(Next) (Previous) (Table-of-Contents)

The following is the source code listing for the sorting program. This program will produce a different sorting sequence for the EBCDIC and ASCII environments.

       IDENTIFICATION DIVISION.
       PROGRAM-ID.    CBLS80C1.
       AUTHOR.        SIMOTIME ENTERPRISES.
      *****************************************************************
      * Copyright (C) 1987-2006 SimoTime Enterprises, LLC.            *
      *                                                               *
      * 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 commercial purpose requires a fee to be paid to       *
      * SimoTime Enterprises. 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           *
      * Enterprises.                                                  *
      *                                                               *
      * Permission to use, copy and modify 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           *
      * Enterprises.                                                  *
      *                                                               *
      * 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                                  *
      *                                                               *
      * SimoTime Enterprises                                          *
      * 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 Enterprises,  *
      * 15 Carnoustie Drive, Novato, CA 94949-5849.                   *
      *                                                               *
      *****************************************************************
      *      This program is provided by SimoTime Enterprises         *
      *        Our e-mail address is: helpdesk@simotime.com           *
      *     Also, visit our Web Site at http://www.simotime.com       *
      *                                                               *
      *****************************************************************
      *
      *****************************************************************
      * Source Member: CBLS80C1.CBL
      *****************************************************************
      * CBLS80C1 - Sort a File.
      *
      * CALLING PROTOCOL
      * ----------------
      * Use standard procedure to RUN or ANIMATE.
      *
      * DESCRIPTION
      * -----------
      * This program will sort a file by Postal Code sequence.
      *
      *  ************     ************     ************
      *  * SORTGET1 *-----* CBLS80C1 *-----* SORTPUT1 *
      *  ************     ********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 SORTGET1
                              ORGANIZATION IS SEQUENTIAL
                              FILE STATUS  IS SORT-INPUT-STATUS.
           SELECT SORT-OUTPUT ASSIGN       TO SORTPUT1
                              ORGANIZATION IS SEQUENTIAL.

      *****************************************************************
       DATA DIVISION.
       FILE SECTION.
       SD  SORT-WORK.
       01  SORT-WORK-RECORD.
           05  COLLATE-CHARACTER       pic X.
           05  FILLER                  pic X.
           05  CHARACTER-DESCRIPTION   pic X(78).
       FD  SORT-INPUT.
       01  SORT-INPUT-RECORD.
           05  COLLATE-CHARACTER       pic X.
           05  FILLER                  pic X.
           05  CHARACTER-DESCRIPTION   pic X(78).
       FD  SORT-OUTPUT.
       01  SORT-OUTPUT-RECORD.
           05  COLLATE-CHARACTER       pic X.
           05  FILLER                  pic X.
           05  CHARACTER-DESCRIPTION   pic X(78).

      *****************************************************************
       WORKING-STORAGE SECTION.
       01  SIM-TITLE.
           05  T1 pic X(11) value '* CBLS80C1 '.
           05  T2 pic X(34) value 'Sort a File with 80-Byte Records  '.
           05  T3 pic X(10) value ' v04.08.23'.
           05  T4 pic X(24) value ' http://www.simotime.com'.
       01  SIM-COPYRIGHT.
           05  C1 pic X(11) value '* CBLS80C1 '.
           05  C2 pic X(20) value 'Copyright 1987-2006 '.
           05  C3 pic X(28) value '  SimoTime Enterprises, LLC '.
           05  C4 pic X(20) value ' All Rights Reserved'.

       01  SORT-INPUT-STATUS.