![]() |
ASCII, Text to ASCII, Indexed COBOL Source for Random Update http://www.simotime.com |
| When technology complements business | Copyright © 1987-2012 SimoTime Enterprises All Rights Reserved |
This is an example of how a COBOL program can read an ASCII/Text file and update an existing ASCII-Indexed file. The COBOL source code was generated using SimoZAPS, a product of SimoTime Enterprises. The SimoZAPS utility program also has the capability of reading, writing or converting between other file formats.
In the world of programming there are many ways to solve a problem. This program is provided as a COBOL example of one of the possible solutions to the problem of changing the contents and structure of data files.
This program will read an ASCII-Text file and update an existing ASCII-Indexed (VSAM, KSDS - Keyed Sequential Data Set) file. This example includes a procedure for converting ASCII Decimal data to EBCDIC Packed (or COMP-3) and Binary (or COMP) data.
The following is the content of the TXAKSAM1.BAT file that was used to create the COBOL source code. This process uses the SimoZAPS utility program to do the actual program generation.
@echo OFF echo * echo * This process will read the TXAKSAT2.TXT file and create the echo * TXAKSAC2.CBL file using the SYSMASK2.TXT as a mask. echo * The TXAKSAT2.TXT file is expected to contains the specifications echo * for reading a TEXT, 512-byte, variable, ASCII file and updating echo * an INDEXED, 512-byte maximum record length, variable, ASCII file echo * with the key position at 1 for a key length of 12. echo * echo * TXAKSAM2 Starting the GENERATE function of SimoZAPS set syscntl=TXAKSAT2.txt set sysmask=sysmask2.txt set syscobol=TXAKSAC2.CBL type %syscntl% simozaps GENERATE echo * TXAKSAM2 SYSCOBOL is %syscobol% echo * TXAKSAM2 SYSCNTL is %syscntl% echo * TXAKSAM2 The SYSCOBOL is displayed in a separate window, echo * TXAKSAM2 to continue... close the SYSCOBOL window. notepad %syscobol% echo * TXAKSAM2 Thank you for using the GENERATE function by SimoTime Enterprises
The TXAKSA.TXT file contains the specifications used by the preceding batch file. The content of the TXAKSAT1.TXT specifications file is as follows.
*********************************************************************** * SYSUT1 should be a Sequential, 512-byte, variable, ASCII content. * * SYSUT2 should be an INDEXED, 512-byte, variable, ASCII content * * with key position at 1 for a key length of 12. * * * * The DIALECT statement specifies the use of COBOL/2 compliant code * * for the generated conversion program. * * * * The VSAMLOAD statement specifies random processing of records to * * the indexed (i.e VSAM KSDS) file. * * ********************************************************************* /Dialect C2 /VSAMload Random /progid TXAKSAC2 /sysut1 name=TXADB512 org=ascii/crlf recfm=variable rlen=512 /sysut2 name=KSADB512 org=indexed recfm=variable rlen=512 kpos=1 klen=12 * /transmode A2A /transcopy from pos 001 len 012 to pos 001 len 012 /transcopy from pos 013 len 001 to pos 013 len 001 /transcopy from pos 014 len 012 to pos 014 len 012 /transcopy from pos 026 len 001 to pos 026 len 001 /dopackit from pos 027 len 012 to pos 027 len 007 /transcopy from pos 039 len 001 to pos 034 len 001 /transcopy from pos 040 len 012 to pos 035 len 012 /transcopy from pos 052 len 001 to pos 047 len 001 /dobinary from pos 053 len 012 to pos 048 len 004 /transcopy from pos 065 len 001 to pos 052 len 001 /transcopy from pos 066 len 012 to pos 053 len 012 /transcopy from pos 078 len 001 to pos 065 len 001 /transcopy from pos 079 len 026 to pos 066 len 026 * /END
The following is the source code for the file conversion. This program was compiled and tested on the PC using Micro Focus Net Express or Mainframe Express (with the non-mainframe dialect). Since the organization of the input file (SYSUT1) is specified as LINE SEQUENTIAL (the Micro Focus terminology for ASCII Text files) this program will not compile or execute on the mainframe.
IDENTIFICATION DIVISION.
PROGRAM-ID. TXAKSAC2.
AUTHOR. SIMOTIME ENTERPRISES.
*****************************************************************
* This program was generated by SimoZAPS *
* A product of SimoTime Enterprises *
* Our e-mail address is: helpdesk@simotime.com *
* Also, visit our Web Site at http://www.simotime.com *
* *
* Generation Date: 2002-09-22 Generation Time: 09:11:04:10 *
* *
* Function Name Organization Rec-Format R-Len K-Len K-Pos *
* INPUT TXADB512 ASCII/CRLF VARIABLE 00512 *
* OUTPUT KSADB512 INDEXED VARIABLE 00512 00012 00001 *
* *
* Translation Mode is ASCII to ASCII *
* *
*****************************************************************
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT SYSUT1-FILE ASSIGN TO TXADB512
ORGANIZATION IS LINE SEQUENTIAL
ACCESS MODE IS SEQUENTIAL
FILE STATUS IS SYSUT1-STATUS.
SELECT SYSUT2-FILE ASSIGN TO KSADB512
ORGANIZATION IS INDEXED
ACCESS MODE IS RANDOM
RECORD KEY IS SYSUT2-KEY-01
FILE STATUS IS SYSUT2-STATUS.
*
*****************************************************************
DATA DIVISION.
FILE SECTION.
FD SYSUT1-FILE
DATA RECORD IS SYSUT1-RECORD
.
01 SYSUT1-RECORD.
05 SYSUT1-DATA-01 PIC X(00512).
*
FD SYSUT2-FILE
DATA RECORD IS SYSUT2-RECORD
.
01 SYSUT2-RECORD.
05 SYSUT2-KEY-01 PIC X(00012).
05 SYSUT2-DATA-01 PIC X(00500).
*
*****************************************************************
* This program was created using the SYSMASK2.TXT file as input.*
* The SYSMASK2 provides for the sequential reading of the input *
* file (SYSUT1) and the random writing of the output file *
* (SYSUT2). If the output file (SYSUT2) is indexed then the *
* input file (SYSUT1) does not need to be in sequence by the *
* field that will be used to provide the key for the output *
* file (SYSUT2). *
* New records will be added and existing records will be *
* updated. If duplicate keys are provided from SYSUT1 then only *
* the information from the last record will be reflected in the *
* output file (SYSUT2). *
*****************************************************************
WORKING-STORAGE SECTION.
01 SIM-TITLE.
05 T1 pic X(11) value '* TXAKSAC2 '.
05 T2 pic X(34) value 'Data File Content Modification '.
05 T3 pic X(10) value ' v2.0.02 '.
05 T4 pic X(24) value ' http://www.simotime.com'.
01 SIM-COPYRIGHT.
05 C1 pic X(11) value '* TXAKSAC2 '.
05 C2 pic X(18) value '(C) Copyright 2002'.
05 C3 pic X(30) value ' SimoTime Enterprises, LLC '.
05 C4 pic X(20) value ' All Rights Reserved'.
*
01 MESSAGE-BUFFER.
05 MESSAGE-HEADER pic X(11) value '* TXAKSAC2 '.
05 MESSAGE-TEXT.
10 MESSAGE-TEXT-1 pic X(68) value SPACES.
10 MESSAGE-TEXT-2 pic X(188) value SPACES.
01 MESSAGE-CONTROL.
05 MESSAGE-CONTROL-1 pic X(32) value SPACES.
05 MESSAGE-CONTROL-2 pic X(36) value SPACES.
*
01 SYSUT1-STATUS.
05 SYSUT1-STATUS-L pic X.
05 SYSUT1-STATUS-R pic X.
01 SYSUT1-EOF pic X value 'N'.
01 SYSUT1-OPEN-FLAG pic X value 'C'.
01 SYSUT1-RECORD-FOUND pic X value 'N'.
*
01 SYSUT2-STATUS.
05 SYSUT2-STATUS-L pic X.
05 SYSUT2-STATUS-R pic X.
01 SYSUT2-EOF pic X value 'N'.
01 SYSUT2-OPEN-FLAG pic X value 'C'.
01 SYSUT2-RECORD-FOUND pic X value 'N'.
*
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 YES-BYTE pic X value 'Y'.
01 NUMERIC-CHECK-FLAG pic X value 'N'.
*
01 PACK-10 pic X(10) value SPACES.
01 UNPK-18 pic X(18) value SPACES.
*
01 WORK-S-PACK-ALPHA.
05 WORK-S-PACK-VALUE PIC S9(18) COMP-3 value 0.
01 WORK-S-UNPK-ALPHA.
05 WORK-S-UNPK-VALUE PIC S9(18) value 0.
01 WORK-U-PACK-ALPHA.
05 WORK-U-PACK-VALUE PIC 9(18) COMP-3 value 0.
01 WORK-U-UNPK-ALPHA.
05 WORK-U-UNPK-VALUE PIC 9(18) value 0.
*
01 COMP-08 pic X(8) value SPACES.
01 UNCP-18 pic X(18) value SPACES.
*
01 WORK-S-COMP-ALPHA.
05 WORK-S-COMP-VALUE PIC S9(18) COMP value 0.
01 WORK-S-UNCP-ALPHA.
05 WORK-S-UNCP-VALUE PIC S9(18) value 0.
01 WORK-U-COMP-ALPHA.
05 WORK-U-COMP-VALUE PIC 9(18) COMP value 0.
01 WORK-U-UNCP-ALPHA.
05 WORK-U-UNCP-VALUE PIC 9(18) value 0.
*
01 NON-NUMERIC-ERROR.
05 filler pic X(21) value 'Non-Numeric error is '.
05 NN-ERROR-COUNT pic 9(9) value 0.
*
01 SYSUT1-TOTAL.
05 filler pic X(21) value 'SYSUT1 records read '.
05 SYSUT1-RDR pic 9(9) value 0.
01 SYSUT2-TOTAL.
05 filler pic X(21) value 'SYSUT2 records added '.
05 SYSUT2-ADD pic 9(9) value 0.
05 filler pic X(17) value ' records updated '.
05 SYSUT2-UPD pic 9(9) value 0.
*
*****************************************************************
* The following copy file contains the translation tables for *
* the ASCII and EBCDIC conversion. Sections of the tables may *
* also be used for case conversion. *
*****************************************************************
COPY ASCEBCB1.
*
*****************************************************************
PROCEDURE DIVISION.
perform Z-POST-COPYRIGHT
perform SYSUT1-OPEN
perform SYSUT2-OPEN
*
perform UNTIL SYSUT1-EOF = 'Y'
if SYSUT1-EOF = 'N'
perform SYSUT1-READ
if SYSUT1-EOF = 'N'
add 1 to SYSUT1-RDR
move 'N' to NUMERIC-CHECK-FLAG
perform BUILD-OUTPUT-RECORD
move 'Y' to NUMERIC-CHECK-FLAG
perform SYSUT2-READ
perform BUILD-OUTPUT-RECORD
if SYSUT2-RECORD-FOUND = 'Y'
add 1 to SYSUT2-UPD
perform SYSUT2-REWRITE
else
add 1 to SYSUT2-ADD
perform SYSUT2-WRITE
end-if
end-if
end-if
end-perform.
*
move SYSUT1-TOTAL to MESSAGE-TEXT
perform Z-DISPLAY-CONSOLE-MESSAGE
*
move SYSUT2-TOTAL to MESSAGE-TEXT
perform Z-DISPLAY-CONSOLE-MESSAGE
*
if APPL-EOF
move 'is Complete...' to MESSAGE-TEXT
else
move 'is ABENDING...' to MESSAGE-TEXT
end-if
perform Z-DISPLAY-CONSOLE-MESSAGE
*
perform SYSUT2-CLOSE
perform SYSUT1-CLOSE
GOBACK.
*
*****************************************************************
* The following routines are in alphabetical sequence.. *
*****************************************************************
*
*****************************************************************
BUILD-OUTPUT-RECORD.
*> TransMODE is A2A...
*> TransINIT process...
move ALL SPACES to SYSUT2-RECORD
*> TransCOPY...
move SYSUT1-RECORD(00001:00012) to SYSUT2-RECORD(00001:00012)
*> TransCOPY...
move SYSUT1-RECORD(00013:00001) to SYSUT2-RECORD(00013:00001)
*> TransCOPY...
move SYSUT1-RECORD(00014:00012) to SYSUT2-RECORD(00014:00012)
*> TransCOPY...
move SYSUT1-RECORD(00026:00001) to SYSUT2-RECORD(00026:00001)
*> /DOPACKIT Convert from PIC9 to PACKED...
move ALL ZEROES to UNPK-18
move SYSUT1-RECORD(00027:00012) to UNPK-18(07:12)
perform BUILD-OUTPUT-RECORD-DOPACKIT
move PACK-10(04:07) to SYSUT2-RECORD(00027:00007)
*> TransCOPY...
move SYSUT1-RECORD(00039:00001) to SYSUT2-RECORD(00034:00001)
*> TransCOPY...
move SYSUT1-RECORD(00040:00012) to SYSUT2-RECORD(00035:00012)
*> TransCOPY...
move SYSUT1-RECORD(00052:00001) to SYSUT2-RECORD(00047:00001)
*> /DOBINARY Convert from PIC9 to BINARY...
move ALL ZEROES to UNCP-18
move SYSUT1-RECORD(00053:00012) to UNCP-18(07:12)
perform BUILD-OUTPUT-RECORD-DOBINARY
move COMP-08(05:04) to SYSUT2-RECORD(00048:00004)
*> TransCOPY...
move SYSUT1-RECORD(00065:00001) to SYSUT2-RECORD(00052:00001)
*> TransCOPY...
move SYSUT1-RECORD(00066:00012) to SYSUT2-RECORD(00053:00012)
*> TransCOPY...
move SYSUT1-RECORD(00078:00001) to SYSUT2-RECORD(00065:00001)
*> TransCOPY...
move SYSUT1-RECORD(00079:00026) to SYSUT2-RECORD(00066:00026)
exit.
*
*****************************************************************
* This is a general purpose routine that will convert an
* existing TEXT input field to a new PACKED output field.
*
BUILD-OUTPUT-RECORD-DOPACKIT.
move UNPK-18 to WORK-S-UNPK-ALPHA
if WORK-S-UNPK-VALUE NUMERIC
ADD WORK-S-UNPK-VALUE to ZERO giving WORK-S-PACK-VALUE
move WORK-S-PACK-ALPHA to PACK-10
else
subtract ZERO from ZERO giving WORK-S-UNPK-VALUE
add WORK-S-UNPK-VALUE to ZERO giving WORK-S-PACK-VALUE
move WORK-S-PACK-ALPHA to PACK-10
if NUMERIC-CHECK-FLAG = YES-BYTE
add SYSUT1-RDR to ZERO giving NN-ERROR-COUNT
move NON-NUMERIC-ERROR to MESSAGE-TEXT
perform Z-DISPLAY-CONSOLE-MESSAGE
end-if
end-if
exit.
*
*****************************************************************
* This is a general purpose routine that will convert an
* existing TEXT input field to a new BINARY output field.
*
BUILD-OUTPUT-RECORD-DOBINARY.
move UNCP-18 to WORK-S-UNCP-ALPHA
if WORK-S-UNCP-VALUE NUMERIC
add WORK-S-UNCP-VALUE to ZERO giving WORK-S-COMP-VALUE
move WORK-S-COMP-ALPHA to COMP-08
else
subtract ZERO from ZERO giving WORK-S-UNCP-VALUE
add WORK-S-UNCP-VALUE to ZERO giving WORK-S-COMP-VALUE
move WORK-S-COMP-ALPHA to COMP-08
if NUMERIC-CHECK-FLAG = YES-BYTE
add SYSUT1-RDR to ZERO giving NN-ERROR-COUNT
move NON-NUMERIC-ERROR to MESSAGE-TEXT
perform Z-DISPLAY-CONSOLE-MESSAGE
end-if
end-if
exit.
*
*****************************************************************
* I/O ROUTINES FOR SYSUT1... *
*****************************************************************
SYSUT1-CLOSE.
add 8 to ZERO giving APPL-RESULT.
close SYSUT1-FILE
if SYSUT1-STATUS = '00'
subtract APPL-RESULT from APPL-RESULT
else
add 12 to ZERO giving APPL-RESULT
end-if
if APPL-AOK
CONTINUE
else
move 'SYSUT1-Failure-CLOSE...' to MESSAGE-TEXT
perform Z-DISPLAY-CONSOLE-MESSAGE
move SYSUT1-STATUS to IO-STATUS
perform Z-DISPLAY-IO-STATUS
perform Z-ABEND-PROGRAM
end-if
exit.
*---------------------------------------------------------------*
SYSUT1-READ.
read SYSUT1-FILE
if SYSUT1-STATUS = '00'
subtract APPL-RESULT from APPL-RESULT
else
if SYSUT1-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 SYSUT1-EOF
else
move 'SYSUT1-Failure-GET...' to MESSAGE-TEXT
perform Z-DISPLAY-CONSOLE-MESSAGE
move SYSUT1-STATUS to IO-STATUS
perform Z-DISPLAY-IO-STATUS
perform Z-ABEND-PROGRAM
end-if
end-if
exit.
*---------------------------------------------------------------*
SYSUT1-OPEN.
add 8 to ZERO giving APPL-RESULT.
open input SYSUT1-FILE
if SYSUT1-STATUS = '00'
subtract APPL-RESULT from APPL-RESULT
move 'O' to SYSUT1-OPEN-FLAG
else
add 12 to ZERO giving APPL-RESULT
end-if
if APPL-AOK
CONTINUE
else
move 'SYSUT1-Failure-OPEN...' to MESSAGE-TEXT
perform Z-DISPLAY-CONSOLE-MESSAGE
move SYSUT1-STATUS to IO-STATUS
perform Z-DISPLAY-IO-STATUS
perform Z-ABEND-PROGRAM
end-if
exit.
*
*****************************************************************
* I/O ROUTINES FOR SYSUT2... *
*****************************************************************
SYSUT2-WRITE.
if SYSUT2-OPEN-FLAG = 'C'
perform SYSUT2-OPEN
end-if
write SYSUT2-RECORD
if SYSUT2-STATUS = '00'
subtract APPL-RESULT from APPL-RESULT
else
if SYSUT2-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 'SYSUT2-Failure-WRITE...' to MESSAGE-TEXT
perform Z-DISPLAY-CONSOLE-MESSAGE
move SYSUT2-STATUS to IO-STATUS
perform Z-DISPLAY-IO-STATUS
perform Z-ABEND-PROGRAM
end-if
exit.
*---------------------------------------------------------------*
SYSUT2-REWRITE.
if SYSUT2-OPEN-FLAG = 'C'
perform SYSUT2-OPEN
end-if
rewrite SYSUT2-RECORD
if SYSUT2-STATUS = '00'
subtract APPL-RESULT from APPL-RESULT
else
if SYSUT2-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 'SYSUT2-Failure-WRITE...' to MESSAGE-TEXT
perform Z-DISPLAY-CONSOLE-MESSAGE
move SYSUT2-STATUS to IO-STATUS
perform Z-DISPLAY-IO-STATUS
perform Z-ABEND-PROGRAM
end-if
exit.
*---------------------------------------------------------------*
SYSUT2-OPEN.
add 8 to ZERO giving APPL-RESULT.
open I-O SYSUT2-FILE
if SYSUT2-STATUS = '00'
subtract APPL-RESULT from APPL-RESULT
move 'O' to SYSUT2-OPEN-FLAG
else
add 12 to ZERO giving APPL-RESULT
end-if
if APPL-AOK
CONTINUE
else
move 'SYSUT2-Failure-OPEN...' to MESSAGE-TEXT
perform Z-DISPLAY-CONSOLE-MESSAGE
move SYSUT2-STATUS to IO-STATUS
perform Z-DISPLAY-IO-STATUS
perform Z-ABEND-PROGRAM
end-if
exit.
*---------------------------------------------------------------*
SYSUT2-READ.
move 'N' to SYSUT2-RECORD-FOUND
move 'N' to SYSUT2-EOF
add 12 to ZERO giving APPL-RESULT
read SYSUT2-FILE
evaluate SYSUT2-STATUS
when '00' move 'Y' to SYSUT2-RECORD-FOUND
subtract APPL-RESULT from APPL-RESULT
when '23' move 'N' to SYSUT2-RECORD-FOUND
subtract APPL-RESULT from APPL-RESULT
when '10' move 'N' to SYSUT2-RECORD-FOUND
move 'Y' to SYSUT2-EOF
subtract APPL-RESULT from APPL-RESULT
end-evaluate.
if APPL-AOK
CONTINUE
else
move 'SYSUT2-Failure-GET...' to MESSAGE-TEXT
perform Z-DISPLAY-CONSOLE-MESSAGE
move SYSUT2-STATUS to IO-STATUS
perform Z-DISPLAY-IO-STATUS
perform Z-ABEND-PROGRAM
end-if
exit.
*---------------------------------------------------------------*
SYSUT2-CLOSE.
add 8 to ZERO giving APPL-RESULT.
close SYSUT2-FILE
if SYSUT2-STATUS = '00'
subtract APPL-RESULT from APPL-RESULT
move 'C' to SYSUT2-OPEN-FLAG
else
add 12 to ZERO giving APPL-RESULT
end-if
if APPL-AOK
CONTINUE
else
move 'SYSUT2-Failure-CLOSE...' to MESSAGE-TEXT
perform Z-DISPLAY-CONSOLE-MESSAGE
move SYSUT2-STATUS to IO-STATUS
perform Z-DISPLAY-IO-STATUS
perform Z-ABEND-PROGRAM
end-if
exit.
*
*****************************************************************
* The following Z-ROUTINES provide administrative functions *
* 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 '* TXAKSAC2 File-Status-' IO-STAT1 '/'
TWO-BYTES-BINARY upon console
else
display '* TXAKSAC2 File-Status-' IO-STATUS upon console
end-if
exit.
*
*****************************************************************
Z-POST-COPYRIGHT.
display SIM-TITLE upon console
display SIM-COPYRIGHT upon console
exit.
*****************************************************************
* This program was generated by SimoZAPS *
* A product of SimoTime Enterprises *
* Our e-mail address is: helpdesk@simotime.com *
* Also, visit our Web Site at http://www.simotime.com *
* *
* Generation Date: 2002-09-22 Generation Time: 09:11:04:10 *
*****************************************************************
The following COBOL copy file contains the ASCII and EBCDIC tables. The tables may also be used to do case conversion.
*
*****************************************************************
* Provided by SimoTime Enterprises *
* Our e-mail address is: helpdesk@simotime.com *
* Also, visit our Web Site at http://www.simotime.com *
*****************************************************************
* The following tables are used by the INSPECT statement to do *
* the conversion betweeen EBCDIC and ASCII. *
* inspect FIELD-NAME converting EBCDIC-INFO to ASCII-INFO *
* inspect FIELD-NAME converting ASCII-INFO to EBCDIC-INFO *
* *
* The tables may also be used to convert between lower and *
* upper case. * *
* inspect FIELD-NAME converting EBCDIC-LOWER to EBCDIC-UPPER *
* inspect FIELD-NAME converting ASCII-LOWER to ASCII-UPPER *
*****************************************************************
*
*> ------------------------------------------------------------
*> ** The EBCDIC Table ...
*> ** 01 A B C D E F G H I
*> ** 02 J K L M N O P Q R
*> ** 03 S T U V W X Y Z
*> ** 04 a b c d e f g h i
*> ** 05 j k l m n o p q r
*> ** 06 s t u v w x y z
*> ** 07 0 1 2 3 4 5 6 7 8 9
*> ** 08 space . < ( + | & ! $ *
*> ** 09 ) ; - / , % _ > ? `
*> ** 10 7D/7F Single/Double quote : # @7D =7F [ ] { }
*> ** 11 \ ~ ^
01 EBCDIC-DATA.
05 EBCDIC-UPPER-CASE-DATA.
10 filler pic X(9) value X'C1C2C3C4C5C6C7C8C9'.
10 filler pic X(9) value X'D1D2D3D4D5D6D7D8D9'.
10 filler pic X(8) value X'E2E3E4E5E6E7E8E9'.
05 EBCDIC-UPPER redefines EBCDIC-UPPER-CASE-DATA
pic X(26).
05 EBCDIC-LOWER-CASE-DATA.
10 filler pic X(9) value X'818283848586878889'.
10 filler pic X(9) value X'919293949596979899'.
10 filler pic X(8) value X'A2A3A4A5A6A7A8A9'.
05 EBCDIC-LOWER redefines EBCDIC-LOWER-CASE-DATA
pic X(26).
05 EBCDIC-DIGITS.
10 filler pic X(10) value X'F0F1F2F3F4F5F6F7F8F9'.
05 EBCDIC-SPECIAL.
10 filler pic X(10) value X'404B4C4D4E4F505A5B5C'.
10 filler pic X(10) value X'5D5E60616B6C6D6E6F79'.
10 filler pic X(10) value X'7A7B7C7D7E7FADBDC0D0'.
10 filler pic X(3) value X'E0A1B0'.
01 EBCDIC-INFO redefines EBCDIC-DATA pic X(95).
01 EBCDIC-TABLE redefines EBCDIC-DATA.
05 EBCDIC-BYTE pic X occurs 95 times.
*
*> ------------------------------------------------------------
*> ** The ASCII Table ...
*> ** 01 A B C D E F G H I
*> ** 02 J K L M N O P Q R
*> ** 03 S T U V W X Y Z
*> ** 04 a b c d e f g h i
*> ** 05 j k l m n o p q r
*> ** 06 s t u v w x y z
*> ** 07 0 1 2 3 4 5 6 7 8 9
*> ** 08 space . < ( + | & ! $ *
*> ** 09 ) ; - / , % _ > ? `
*> ** 10 27/22 Single/Double quote : # @27 =22 [ ] { }
*> ** 11 \ ~ ^
01 ASCII-DATA.
05 ASCII-UPPER-CASE-DATA.
10 filler pic X(9) value X'414243444546474849'.
10 filler pic X(9) value X'4A4B4C4D4E4F505152'.
10 filler pic X(8) value X'535455565758595A'.
05 ASCII-UPPER redefines ASCII-UPPER-CASE-DATA
pic X(26).
05 ASCII-LOWER-CASE-DATA.
10 filler pic X(9) value X'616263646566676869'.
10 filler pic X(9) value X'6A6B6C6D6E6F707172'.
10 filler pic X(8) value X'737475767778797A'.
05 ASCII-LOWER redefines ASCII-LOWER-CASE-DATA
pic X(26).
05 ASCII-DIGITS.
10 filler pic X(10) value X'30313233343536373839'.
05 ASCII-SPECIAL.
10 filler pic X(10) value X'202E3C282B7C2621242A'.
10 filler pic X(10) value X'293B2D2F2C255F3E3F79'.
10 filler pic X(10) value X'3A2340273D225B5D7B7D'.
10 filler pic X(3) value X'5C7E5E'.
01 ASCII-INFO redefines ASCII-DATA pic X(95).
01 ASCII-TABLE redefines ASCII-DATA.
05 ASCII-BYTE pic X occurs 95 times.
The purpose of this document is to assist as a tutorial for new programmers or as a quick reference for experienced programmers. These sample programs are made available on an "as-is" basis and may be downloaded, copied and modified for specific situations as long as the copyright information is not removed or changed. As always, it is the programmer's responsibility to thoroughly test all programs.
Permission to use, copy, modify and distribute this software for any non-commercial purpose and without fee is hereby granted, provided the SimoTime copyright notice appear on all copies of the software. The SimoTime name or Logo may not be used in any advertising or publicity pertaining to the use of the software.
SimoTime Enterprises makes no warranty or representations about the suitability of the software for any purpose. It is provided "AS IS" without any express or implied warranty, including the implied warranties of merchantability, fitness for a particular purpose and non-infringement. SimoTime Enterprises shall not be liable for any direct, indirect, special or consequential damages resulting from the loss of use, data or projects, whether in an action of contract or tort, arising out of or in connection with the use or performance of this software.
Take a look at the Table of ASCII and EBCDIC values.
The SimoZAPS Utility Program runs on a Windows platform and has the capability of generating a COBOL program that will do the conversion of sequential and VSAM (KSDS) files between EBCDIC and ASCII. SimoZAPS can also read a sequential file in EBCDIC format and create an ASCII/CRLF file or VSAM Keyed Sequential Data Set in ASCII format. The conversion tables may be viewed or modified to meet unique requirements. The Hexcess/2 function of SimoZAPS provides the capability of viewing, finding or patching the contents of a file in hexadecimal.
Check out The COBOL Connection for more examples of mainframe COBOL coding techniques and sample code.
Check out The VSAM-QSAM Connection in the SimoTime Library for more examples of mainframe COBOL techniques and sample code.
This document provides a quick summary of the File Status Key for VSAM data sets and QSAM files. The File Status Key is a two character data item. The first character of the status key is known as status key 1. The second character is known as status key 2.
If you have any questions, suggestions or comments please call or send an e-mail to: helpdesk@simotime.com
Founded in 1987, SimoTime Enterprises is a privately owned company. We specialize in the creation and deployment of business applications using new or existing technologies and services. We have a team of individuals that understand the broad range of technologies being used in today's environments. This includes the smallest thin client using the Internet and the very large mainframe systems. There is more to making the Internet work for your company's business than just having a nice looking WEB site. It is about combining the latest technologies and existing technologies with practical business experience. It's about the business of doing business and looking good in the process. Quite often, to reach larger markets or provide a higher level of service to existing customers it requires the newer Internet technologies to work in a complementary manner with existing corporate mainframe systems. Whether you want to use the Internet to expand into new market segments or as a delivery vehicle for existing business functions simply give us a call or check the web site at http://www.simotime.com
| Return-to-Top |
| Copyright © 1987-2012 SimoTime Enterprises All Rights Reserved |
| When technology complements business |