|
|
Alphabetic
Conversion Upper and Lower Case http://www.simotime.com |
| When technology complements business | Copyright © 1987-2010 SimoTime Enterprises All Rights Reserved |
This is an example of how COBOL can do case conversion of alpha-numeric data within a field (or text string). The four basic functions provided are as follows.
| 0. | Convert a text string to lower case. | |
| 1. | Convert a text string to upper case. | |
| 2. | Capitalize each word in a text string. | |
| 3. | Edit specific words in a text string using pre-defined table values. |
This is an example of how COBOL programs do case conversion. The example shows simple conversion between upper and lower case plus capitalization and editing of specific words within a text string. Both COBOL programs were written and tested using the VS COBOL II dialect. Also, both COBOL programs will 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 (refer to http://www.microfocus.com ). Also, a CMD member is provided to run the job with Micro Focus Net Express (MFE) running on a PC with Windows.
In the world of programming there are many ways to solve a problem. This suite of programs is provided as a COBOL programming example of one of the possible solutions for doing case conversion of alpha-numeric text strings. This example may serve as a tutorial for new programmers and as a reference for experienced programmers. Additional information is provided in the Downloads and Links to Similar Pages section of this document.
Note: The source code for this example is available from the SimoTime Library under Download Directory at www.simotime.com
The callable interface requires a data structure to be defined. A copy file (PASSCASE.CPY) is provided with the following source code.
*****************************************************************
* Data Structure or Pass Area used for calling SIMOCASE. *
*****************************************************************
* Copyright (C) 1987-2010 SimoTime Enterprises *
* All Rights Reserved *
*****************************************************************
* Provided by SimoTime Enterprises *
* Our e-mail address is: helpdesk@simotime.com *
* Also, visit our Web Site at http://www.simotime.com *
*****************************************************************
*
* When CASE-PASS-REQUEST is '1' then
* Do Upper to Lower case conversion
* When CASE-PASS-REQUEST is '2' then
* Do Lower to Upper case conversion
* When CASE-PASS-REQUEST is '3' then
* Do capitalization of each word
* When CASE-PASS-REQUEST is '4' then
* Edit key words from a table
*
01 CASE-PASS-AREA.
05 CASE-PASS-REQUEST PIC X.
05 CASE-PASS-RESULT PIC 9(4).
05 CASE-PASS-STRING-SIZE PIC 9(4).
05 CASE-PASS-BUFFER PIC X(256).
*! PASSCASE - End-of-Copy File...
The input text string is moved to CASE-PASS-BUFFER before the call to SIMOCASE. After returning from the call with the CASE-PASS-REQUEST set to a value of '0' or ZERO a lower case text string will be returned in CASE-PASS-BUFFER.
| Input | THE QUICK BROWN FOX JUMPED OVER THE LAZY DOG'S BACK | |
| Output | the quick brown fox jumped over the lazy dog's back | |
Example |
move '0' to CASE-PASS-REQUEST call 'SIMOCASE' using CASE-PASS-AREA |
|
The input text string is moved to CASE-PASS-BUFFER before the call to SIMOCASE. After returning from the call with the CASE-PASS-REQUEST set to a value of '2' a lower case text string with each word capitalized will be returned in CASE-PASS-BUFFER.
| Input | the quick brown fox jumped over the lazy dog's back | |
| Output | The Quick Brown Fox Jumped Over The Lazy Dog's Back | |
Example |
move '2' to CASE-PASS-REQUEST call 'SIMOCASE' using CASE-PASS-AREA |
|
The input text string is moved to CASE-PASS-BUFFER before the call to SIMOCASE. After returning from the call with the CASE-PASS-REQUEST set to a value of '3' a lower case text string with each word capitalized and specific words modified based on an internal table will be returned in CASE-PASS-BUFFER. Notice in the following example the second occurence of "the" is not capitalized.
| Input | The Quick Brown Fox Jumped Over The Lazy Dog's Back | |
| Output | The Quick Brown Fox Jumped Over the Lazy Dog's Back | |
Example |
move '3' to CASE-PASS-REQUEST call 'SIMOCASE' using CASE-PASS-AREA |
|
There are two (2) Windows Command files provided with this suite of sample programs. The first Command file will execute the sampe programs that do the actual case conversions.
The second Command file is used to create a file that contains records with text strings that will be converted by the case conversion sample programs. This Command file should be executed at least once prior to attempting to execute the sample programs.
The following is the Windows Command file (CASECRE1.CMD) that is required to run as a job on a PC using Micro Focus Net Express.
@echo OFF
rem * *******************************************************************
rem * This program is provided by: *
rem * SimoTime Enterprises, LLC *
rem * (C) Copyright 1987-2010 All Rights Reserved *
rem * Web Site URL: http://www.simotime.com *
rem * e-mail: helpdesk@simotime.com *
rem * *******************************************************************
rem *
rem * Text - Read a file of text info, do case convert, write output.
rem * Author - SimoTime Enterprises
rem * Date - January 24, 1996
rem *
rem * The job will read an 80-byte file that contains text string
rem * information. The job will also write a file containing the results
rem * of the case conversion requests.
rem *
rem * This set of programs will run on a mainframe under MVS or on a
rem * Personal Computer with Windows and Micro Focus Net Express.
rem *
rem * ************
rem * * CaseCrE1 *
rem * ********cmd*
rem * *
rem * *
rem * ************
rem * * run ****
rem * ********utl* *
rem * * *
rem * * **************************
rem * * *
rem * * ************ ************ ************
rem * * * CASEGET1 ******* CaseCrC1 ******* CASEPUT1 *
rem * * *******rseq* ********cbl* *******rseq*
rem * * *
rem * * ************
rem * * * SIMOCASE *
rem * * ********cbl*
rem * *
rem * ************
rem * * EOJ *
rem * ************
rem *
rem * *******************************************************************
rem * Step 1 Delete any previously created file...
rem *
set CmdName=CaseCrE1
call Env1PROD %CmdName%
if "%SYSLOG%" == "" set syslog=c:\SimoLIBR\LOGS\SimoTime.LOG
rem *
call SimoNOTE "*******************************************************%CmdName%"
call SimoNOTE "Starting CmdName %CmdName%"
:DeleteQSAM
call SimoNOTE "StepInfo Delete previously created file"
set CASEGET1=%BaseLib1%\DataLibA\Asc1\CASERS80.DAT
set CASEPUT1=%BaseLib1%\DataLibA\Wrk1\CASEPUT1.DAT
if exist %CASEPUT1% del %CASEPUT1%
rem *
rem * *******************************************************************
rem * Step 2 Edit input, create a new output file...
rem *
:ExecuteCASEifyRoutine
call SimoNOTE "StepInfo Execute the CASEify Program"
call ezEXEC CaseCrC1
if not ERRORLEVEL = 0 set JobStatus=0010
if not %JobStatus% == 0000 goto :EojNok
call SimoNOTE "DataTake %CASEGet1%"
call SimoNOTE "DataMake %CASEPUT1%"
rem *
if exist %CASEPUT1% goto :EojAok
set JobStatus=0020
goto :EojNok
:EojAok
call SimoNOTE "Finished JobName %CmdName%, Job Status is %JobStatus%"
goto :End
:EojNok
call SimoNOTE "ABENDING JobName %CmdName%, Job Status is %JobStatus%"
:End
if not "%1" == "nopause" pause
The following is the Windows Command file (CASECRE2.CMD) that will create a file of records with text strings that may be used by the case conversion sample programs.
@echo OFF
rem * *******************************************************************
rem * This program is provided by: *
rem * SimoTime Enterprises, LLC *
rem * (C) Copyright 1987-2010 All Rights Reserved *
rem * Web Site URL: http://www.simotime.com *
rem * e-mail: helpdesk@simotime.com *
rem * *******************************************************************
rem *
rem * Text - Create a Sequential Data Set on disk using IEBGENER.
rem * Author - SimoTime Enterprises
rem * Date = January 24, 1996
rem *
rem * The first job step (DeleteTEXT) will delete any previously created
rem * files.
rem * The second job step (CreateTEXT) will create a new ASCII/Text file.
rem * The third step will convert the Line Sequential file to a Record
rem * Sequential file.
rem *
rem * This set of programs will run on a Personal Computer with Windows
rem * and Micro Focus Net Express.
rem *
set CmdName=CASECRE2
call Env1PROD %CmdName%
if "%SYSLOG%" == "" set syslog=c:\SimoLIBR\LOGS\SimoTime.LOG
rem *
call SimoNOTE "*******************************************************%CmdName%"
call SimoNOTE "Starting CmdName %CmdName%, User is %USERNAME%"
call SimoNOTE "StepInfo Delete previously created files"
set CASETXT1=%BaseLib1%\DataLibA\Asc1\CASETXT1.TXT
rem *
rem * *******************************************************************
rem * Step 1 of 2 Create and populate a new ASCII/TEXT file...
rem *
call SimoNOTE "StepInfo Create an ASCII/Text File"
if exist %CASETXT1% del %CASETXT1%
rem * ..1....:....2....:....3....:....4....:....5....:....6....:....7.
echo THE QUICK BROWN FOX JUMPED OVER THE LAZY DOG'S BACK >>%CASETXT1%
echo john q adams >>%CASETXT1%
echo 123 main street >>%CASETXT1%
echo dick aND jane >>%CASETXT1%
echo hElLo wOrlD >>%CASETXT1%
if exist %CASETXT1% call SimoNOTE "DataMake %CASETXT1%"
if not exist %CASETXT1% set JobStatus=9001
if not %JobStatus% == 0000 goto :EojNok
rem *
rem * *******************************************************************
rem * Step 2 of 2 ConvertASCII/TEXT file to Record Sequential File...
rem *
call SimoNOTE "StepInfo Convert Line Sequential to Record Sequential"
set GETLS080=%BaseLib1%\DataLibA\Asc1\CASETXT1.TXT
set PUTRS080=%BaseLib1%\DataLibA\Asc1\CASERS80.DAT
if exist %PUTRS080% del %PUTRS080%
run ALAR80C1
if not ERRORLEVEL = 0 set JobStatus=0030
if not %JobStatus% == 0000 goto :EojNok
call SimoNOTE "DataTake %GETLS080%"
call SimoNOTE "DataMake %PUTRS080%"
rem *
:EojAok
call SimoNOTE "Finished CmdName %CmdName%, Job Status is %JobStatus% "
goto :End
:EojNok
call SimoNOTE "NOTE ABENDING CmdName %CmdName%, Job Status is %JobStatus% "
:End
if not "%1" == "nopause" pause
There are two (2) JCL members provided with this suite of sample programs. The first JCL member will execute the sampe programs that do the actual case conversions.
The second JCL member is used to create a file that contains records with text strings that will be converted by the case conversion sample programs. This JCL member should be executed at least once prior to attempting to execute the sample programs.
The following is the JCL Member (CASECRJ1.JCL) that is required to run as a job on a Mainframe System or on a Windows System with Micro Focus Mainframe Express.
//CASECRJ1 JOB SIMOTIME,CLASS=1,MSGCLASS=0,NOTIFY=CSIP1 //* ******************************************************************* //* This program is provided by: * //* SimoTime Enterprises, LLC * //* (C) Copyright 1987-2010 All Rights Reserved * //* Web Site URL: http://www.simotime.com * //* e-mail: helpdesk@simotime.com * //* ******************************************************************* //* //* Text - Read file of text strings, do case convert, write output. //* Author - SimoTime Enterprises //* Date - January 24, 1996 //* //* The job will read an 80-byte file that contains Text Strings //* The job will also write a file containing the results //* of the case conversion request. //* //* This set of programs will run on a mainframe under MVS or on a //* Personal Computer with Windows and Micro Focus Mainframe Express. //* //* ************ //* * CASECRJ1 * //* ********jcl* //* * //* ************ //* * IEFBR14 * //* ********utl* //* * //* ************ ************ ************ //* * CASEGET1 *-----* CASECRIO *-----* CASEPUT1 * //* *******rseq* ********cbl* *******rseq* //* * * //* * * ************ //* * *-call--* SIMOCASE * //* * ********cbl* //* * //* ************ //* * EOJ * //* ************ //* //* ******************************************************************* //* Step 1 Delete any previously created file... //* //CLEANUP1 EXEC PGM=IEFBR14 //CASEPUT1 DD DSN=SIMOTIME.DATA.CASEPUT1,DISP=(MOD,DELETE,DELETE), // STORCLAS=MFI, // SPACE=(TRK,5), // DCB=(RECFM=FB,LRECL=80,DSORG=PS) //* //* ******************************************************************* //* Step 2 Test the Callable Case Conversion Routine... //* //CASEEDIT EXEC PGM=CASECRIO //STEPLIB DD DSN=SIMOTIME.DEMO.LOADLIB1,DISP=SHR //CASEGET1 DD DSN=SIMOTIME.DATA.CASEGET1,DISP=SHR //CASEPUT1 DD DSN=SIMOTIME.DATA.CASEPUT1, // DISP=(NEW,CATLG,DELETE), // STORCLAS=MFI, // SPACE=(TRK,5), // DCB=(RECFM=FB,LRECL=80,DSORG=PS) //SYSOUT DD SYSOUT=* //
The following is the mainframe JCL member (CASECRJ2.JCL) that will create a file of records with text strings that may be used by the case conversion sample programs.
//CASECRJ2 JOB SIMOTIME,CLASS=1,MSGCLASS=0,NOTIFY=CSIP1 //* ******************************************************************* //* This program is provided by: * //* SimoTime Enterprises, LLC * //* (C) Copyright 1987-2010 All Rights Reserved * //* Web Site URL: http://www.simotime.com * //* e-mail: helpdesk@simotime.com * //* ******************************************************************* //* //* Text - Create a Sequential Data Set on disk using IEBGENER. //* Author - SimoTime Enterprises //* Date - January 24, 1996 //* //* The first job step (QSAMDELT) will delete any previously created //* file. The second job step (QCRTDIN1) will create a new file. //* //* This set of programs will run on a mainframe under MVS or on a //* Personal Computer with Windows and Micro Focus Mainframe Express. //* //* ******************************************************************* //* Step 1 Delete any previously created file... //* //QSAMDELT EXEC PGM=IEFBR14 //SYSUT2 DD DSN=SIMOTIME.DATA.CASEGET1,DISP=(MOD,DELETE,DELETE), // STORCLAS=MFI, // SPACE=(TRK,5), // DCB=(RECFM=FB,LRECL=80,DSORG=PS) //* //* ******************************************************************* //* Step 2 Create and populate a new QSAM file... //* //QCRTDIN1 EXEC PGM=IEBGENER //SYSPRINT DD SYSOUT=* //SYSIN DD DUMMY //* :....1....:....2....:....3....:....4....:....5....:....6....:....7. //SYSUT1 DD * THE QUICK BROWN FOX JUMPED OVER THE LAZY DOG'S BACK john q adams 123 main street dick aND jane hElLo wOrlD /* //SYSUT2 DD DSN=SIMOTIME.DATA.CASEGET1, // DISP=(NEW,CATLG,DELETE), // STORCLAS=MFI, // SPACE=(TRK,5), // DCB=(RECFM=FB,LRECL=80,DSORG=PS) //
This program (CASECRIO.CBL) was written to test the callable COBOL program (SIMOCASE.CBL) that does the case conversion between upper and lower case for alphameric text strings.
IDENTIFICATION DIVISION.
PROGRAM-ID. CASECRIO.
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: 2008-06-14 Generation Time: 18:21:27:26 *
* *
* Record Record Key *
* Function Name Organization Format Max-Min Pos-Len *
* INPUT CASEGET1 SEQUENTIAL FIXED 00080 *
* *
* OUTPUT CASEPUT1 SEQUENTIAL FIXED 00080 *
* *
*****************************************************************
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT CASEGET1-FILE ASSIGN TO CASEGET1
ORGANIZATION IS SEQUENTIAL
ACCESS MODE IS SEQUENTIAL
FILE STATUS IS CASEGET1-STATUS.
SELECT CASEPUT1-FILE ASSIGN TO CASEPUT1
ORGANIZATION IS SEQUENTIAL
ACCESS MODE IS SEQUENTIAL
FILE STATUS IS CASEPUT1-STATUS.
*****************************************************************
DATA DIVISION.
FILE SECTION.
FD CASEGET1-FILE
DATA RECORD IS CASEGET1-REC
.
01 CASEGET1-REC.
05 CASEGET1-DATA-01 PIC X(00080).
FD CASEPUT1-FILE
DATA RECORD IS CASEPUT1-REC
.
01 CASEPUT1-REC.
05 CASEPUT1-DATA-01 PIC X(00080).
*****************************************************************
* This program was created using the SYSMASK3.TXT file as the *
* template for the File I/O. It is intended for use with the *
* TransCALL facility that makes a call to a routine that does *
* the actual conversion between EBCDIC and ASCII. For more *
* information or questions contact SimoTime Enterprises. *
* *
* Our e-mail address is: helpdesk@simotime.com *
* Also, visit our Web Site at http://www.simotime.com *
* *
* The SYSMASK3 provides for the sequential reading of the input *
* file and the sequential writing of the output file. *
* If the output file is indexed then the input file must be in *
* sequence by the field that will be used to provide the key *
* for the output file. *
* *
* If the key field is not in sequence then refer to SYSMASK4 *
* to provide for a random add or update of the indexed file. *
*****************************************************************
WORKING-STORAGE SECTION.
01 SIM-TITLE.
05 T1 pic X(11) value '* CASECRIO '.
05 T2 pic X(34) value 'Example of Case Conversion & COBOL'.
05 T3 pic X(10) value ' v08.02.16'.
05 T4 pic X(24) value ' http://www.simotime.com'.
01 SIM-COPYRIGHT.
05 C1 pic X(11) value '* CASECRIO '.
05 C2 pic X(20) value 'Created by SimoZAPS,'.
05 C3 pic X(20) value ' a utility package '.
05 C4 pic X(28) value 'of SimoTime Enterprises, LLC'.
01 CASEGET1-STATUS.
05 CASEGET1-STATUS-L pic X.
05 CASEGET1-STATUS-R pic X.
01 CASEGET1-EOF pic X value 'N'.
01 CASEGET1-OPEN-FLAG pic X value 'C'.
01 CASEPUT1-STATUS.
05 CASEPUT1-STATUS-L pic X.
05 CASEPUT1-STATUS-R pic X.
01 CASEPUT1-EOF pic X value 'N'.
01 CASEPUT1-OPEN-FLAG pic X value 'C'.
01 CASEGET1-LRECL pic 9(5) value 00080.
01 CASEPUT1-LRECL pic 9(5) value 00080.
*****************************************************************
* The following buffers are used to create a four-byte status *
* code that may be displayed. *
*****************************************************************
01 IO-STATUS.
05 IO-STAT1 pic X.
05 IO-STAT2 pic X.
01 IO-STATUS-04.
05 IO-STATUS-0401 pic 9 value 0.
05 IO-STATUS-0403 pic 999 value 0.
01 TWO-BYTES-BINARY pic 9(4) BINARY.
01 TWO-BYTES-ALPHA redefines TWO-BYTES-BINARY.
05 TWO-BYTES-LEFT pic X.
05 TWO-BYTES-RIGHT pic X.
*****************************************************************
* Message Buffer used by the Z-DISPLAY-MESSAGE-TEXT routine. *
*****************************************************************
01 MESSAGE-BUFFER.
05 MESSAGE-HEADER pic X(11) value '* CASECRIO '.
05 MESSAGE-TEXT.
10 MESSAGE-TEXT-1 pic X(68) value SPACES.
10 MESSAGE-TEXT-2 pic X(188) value SPACES.
*****************************************************************
01 PROGRAM-NAME pic X(8) value 'CASECRIO'.
01 APPL-RESULT pic S9(9) comp.
88 APPL-AOK value 0.
88 APPL-EOF value 16.
01 CASEGET1-TOTAL.
05 CASEGET1-RDR pic 9(9) value 0.
05 filler pic X(3) value ' - '.
05 filler pic X(23) value 'Line count for CASEGET1'.
01 CASEPUT1-TOTAL.
05 CASEPUT1-ADD pic 9(9) value 0.
05 filler pic X(3) value ' - '.
05 filler pic X(23) value 'Line count for CASEPUT1'.
COPY PASSCASE.
*****************************************************************
PROCEDURE DIVISION.
perform Z-POST-COPYRIGHT
perform CASEGET1-OPEN
perform CASEPUT1-OPEN
add 80 to ZERO giving CASE-PASS-STRING-SIZE
perform until CASEGET1-STATUS not = '00'
perform CASEGET1-READ
if CASEGET1-STATUS = '00'
add 1 to CASEGET1-RDR
perform BUILD-OUTPUT-RECORD
perform CASEPUT1-WRITE
if CASEPUT1-STATUS = '00'
add 1 to CASEPUT1-ADD
end-if
end-if
end-perform
move CASEGET1-TOTAL to MESSAGE-TEXT
perform Z-DISPLAY-MESSAGE-TEXT
move CASEPUT1-TOTAL to MESSAGE-TEXT
perform Z-DISPLAY-MESSAGE-TEXT
if APPL-EOF
move 'is Complete...' to MESSAGE-TEXT
else
move 'is ABENDING...' to MESSAGE-TEXT
end-if
perform Z-DISPLAY-MESSAGE-TEXT
perform CASEPUT1-CLOSE
perform CASEGET1-CLOSE
GOBACK.
*****************************************************************
BUILD-OUTPUT-RECORD.
*> TransCALL process...
move SPACES to CASE-PASS-BUFFER
move CASEGET1-REC(1:80) to CASE-PASS-BUFFER
move 'Input Record ..... ' to CASEPUT1-REC
move CASE-PASS-BUFFER(1:80) to CASEPUT1-REC(20:61)
perform CASEPUT1-WRITE
move '0' to CASE-PASS-REQUEST
call 'SIMOCASE' using CASE-PASS-AREA
move 'Convert Lower .... ' to CASEPUT1-REC
move CASE-PASS-BUFFER(1:80) to CASEPUT1-REC(20:61)
perform CASEPUT1-WRITE
move '2' to CASE-PASS-REQUEST
call 'SIMOCASE' using CASE-PASS-AREA
move 'Capitalization ... ' to CASEPUT1-REC
move CASE-PASS-BUFFER(1:80) to CASEPUT1-REC(20:61)
perform CASEPUT1-WRITE
move '3' to CASE-PASS-REQUEST
call 'SIMOCASE' using CASE-PASS-AREA
move 'Edited Words ..... ' to CASEPUT1-REC
move CASE-PASS-BUFFER(1:80) to CASEPUT1-REC(20:61)
exit.
*****************************************************************
* I/O Routines for the INPUT File... *
*****************************************************************
CASEGET1-CLOSE.
add 8 to ZERO giving APPL-RESULT.
close CASEGET1-FILE
if CASEGET1-STATUS = '00'
subtract APPL-RESULT from APPL-RESULT
else
add 12 to ZERO giving APPL-RESULT
end-if
if APPL-AOK
CONTINUE
else
move 'CLOSE Failure with CASEGET1' to MESSAGE-TEXT
perform Z-DISPLAY-MESSAGE-TEXT
move CASEGET1-STATUS to IO-STATUS
perform Z-DISPLAY-IO-STATUS
perform Z-ABEND-PROGRAM
end-if
exit.
*---------------------------------------------------------------*
CASEGET1-READ.
read CASEGET1-FILE
if CASEGET1-STATUS = '00'
subtract APPL-RESULT from APPL-RESULT
else
if CASEGET1-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 CASEGET1-EOF
else
move 'READ Failure with CASEGET1' to MESSAGE-TEXT
perform Z-DISPLAY-MESSAGE-TEXT
move CASEGET1-STATUS to IO-STATUS
perform Z-DISPLAY-IO-STATUS
perform Z-ABEND-PROGRAM
end-if
end-if
exit.
*---------------------------------------------------------------*
CASEGET1-OPEN.
add 8 to ZERO giving APPL-RESULT.
open input CASEGET1-FILE
if CASEGET1-STATUS = '00'
subtract APPL-RESULT from APPL-RESULT
move 'O' to CASEGET1-OPEN-FLAG
else
add 12 to ZERO giving APPL-RESULT
end-if
if APPL-AOK
CONTINUE
else
move 'OPEN Failure with CASEGET1' to MESSAGE-TEXT
perform Z-DISPLAY-MESSAGE-TEXT
move CASEGET1-STATUS to IO-STATUS
perform Z-DISPLAY-IO-STATUS
perform Z-ABEND-PROGRAM
end-if
exit.
*****************************************************************
* I/O Routines for the OUTPUT File... *
*****************************************************************
CASEPUT1-WRITE.
if CASEPUT1-OPEN-FLAG = 'C'
perform CASEPUT1-OPEN
end-if
write CASEPUT1-REC
if CASEPUT1-STATUS = '00'
subtract APPL-RESULT from APPL-RESULT
else
if CASEPUT1-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 'WRITE Failure with CASEPUT1' to MESSAGE-TEXT
perform Z-DISPLAY-MESSAGE-TEXT
move CASEPUT1-STATUS to IO-STATUS
perform Z-DISPLAY-IO-STATUS
perform Z-ABEND-PROGRAM
end-if
exit.
*---------------------------------------------------------------*
CASEPUT1-OPEN.
add 8 to ZERO giving APPL-RESULT.
open OUTPUT CASEPUT1-FILE
if CASEPUT1-STATUS = '00'
subtract APPL-RESULT from APPL-RESULT
move 'O' to CASEPUT1-OPEN-FLAG
else
add 12 to ZERO giving APPL-RESULT
end-if
if APPL-AOK
CONTINUE
else
move 'OPEN Failure with CASEPUT1' to MESSAGE-TEXT
perform Z-DISPLAY-MESSAGE-TEXT
move CASEPUT1-STATUS to IO-STATUS
perform Z-DISPLAY-IO-STATUS
perform Z-ABEND-PROGRAM
end-if
exit.
*---------------------------------------------------------------*
CASEPUT1-CLOSE.
add 8 to ZERO giving APPL-RESULT.
close CASEPUT1-FILE
if CASEPUT1-STATUS = '00'
subtract APPL-RESULT from APPL-RESULT
move 'C' to CASEPUT1-OPEN-FLAG
else
add 12 to ZERO giving APPL-RESULT
end-if
if APPL-AOK
CONTINUE
else
move 'CLOSE Failure with CASEPUT1' to MESSAGE-TEXT
perform Z-DISPLAY-MESSAGE-TEXT
move CASEPUT1-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-MESSAGE-TEXT
end-if
move 'PROGRAM-IS-ABENDING...' to MESSAGE-TEXT
perform Z-DISPLAY-MESSAGE-TEXT
add 12 to ZERO giving RETURN-CODE
STOP RUN.
* exit.
*****************************************************************
* Display CONSOLE messages... *
*****************************************************************
Z-DISPLAY-MESSAGE-TEXT.
if MESSAGE-TEXT-2 = SPACES
display MESSAGE-BUFFER(1:79)
else
display MESSAGE-BUFFER
end-if
move all SPACES to MESSAGE-TEXT
exit.
*****************************************************************
* Display the file status bytes. This routine will display as *
* four digits. If the full two byte file status is numeric it *
* will display as 00nn. If the 1st byte is a numeric nine (9) *
* the second byte will be treated as a binary number and will *
* display as 9nnn. *
*****************************************************************
Z-DISPLAY-IO-STATUS.
if IO-STATUS not NUMERIC
or IO-STAT1 = '9'
move IO-STAT1 to IO-STATUS-04(1:1)
subtract TWO-BYTES-BINARY from TWO-BYTES-BINARY
move IO-STAT2 to TWO-BYTES-RIGHT
add TWO-BYTES-BINARY to ZERO giving IO-STATUS-0403
move 'File Status is: nnnn' to MESSAGE-TEXT
move IO-STATUS-04 to MESSAGE-TEXT(17:4)
perform Z-DISPLAY-MESSAGE-TEXT
else
move '0000' to IO-STATUS-04
move IO-STATUS to IO-STATUS-04(3:2)
move 'File Status is: nnnn' to MESSAGE-TEXT
move IO-STATUS-04 to MESSAGE-TEXT(17:4)
perform Z-DISPLAY-MESSAGE-TEXT
end-if
exit.
*****************************************************************
Z-POST-COPYRIGHT.
display SIM-TITLE
display SIM-COPYRIGHT
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: 2008-06-14 Generation Time: 18:21:27:28 *
*****************************************************************
This program (SIMOCASE.CBL) was originally written to be used as a teaching and learning aid. It was first used in a production environment to replace a callable 370 assembler routine. Today, this program (or a modified version) is used in a number of mainframe shops and it is the program of choice used by SimoTime. Also, the program has been tested and deployed on the PC with Mainframe Express or Net Express from Micro Focus. The source code for the SIMOCASE callable program. is part of the SimoMODS package of callable routines.
This copy file (PASSCASE.CPY) provides a convenient method for defining the data areas (or fields) that are used to pass information between the demo program and the case conversion routine.
*****************************************************************
* Data Structure or Pass Area used for calling SIMOCASE. *
*****************************************************************
* Copyright (C) 1987-2010 SimoTime Enterprises *
* All Rights Reserved *
*****************************************************************
* Provided by SimoTime Enterprises *
* Our e-mail address is: helpdesk@simotime.com *
* Also, visit our Web Site at http://www.simotime.com *
*****************************************************************
*
* When CASE-PASS-REQUEST is '1' then
* Do Upper to Lower case conversion
* When CASE-PASS-REQUEST is '2' then
* Do Lower to Upper case conversion
* When CASE-PASS-REQUEST is '3' then
* Do capitalization of each word
* When CASE-PASS-REQUEST is '4' then
* Edit key words from a table
*
01 CASE-PASS-AREA.
05 CASE-PASS-REQUEST PIC X.
05 CASE-PASS-RESULT PIC 9(4).
05 CASE-PASS-STRING-SIZE PIC 9(4).
05 CASE-PASS-BUFFER PIC X(256).
*! PASSCASE - End-of-Copy File...
The purpose of this document is 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 suite of programs is provided as a COBOL programming example of one of the possible solutions to the case conversion requirements.
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 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, documentation or training material.
If you have any questions, suggestions or comments please call or send an e-mail to: helpdesk@simotime.com
You may download this example at http://www.simotime.com/sim4dzip.htm#COBOLCaseConvert as a Z-Pack. The Z-Packs provide individual programming examples, documentation and test data files in a single package. The Z-Packs are usually in zip format to reduce the amount of time to download.
Please view the complete list of SimoTime Z-Pack Examples at http://www.simotime.com/sim4dzip.htm .
Note: You must be attached to the Internet to download a Z-Pack or view the list.
The SimoZAPS Utility Program 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 KSDS file in ASCII format. The conversion tables may be viewed or modified to meet unique requirements. The Hexcess/2 function 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 SimoTime Library for a wide range of topics for Programmers, Project Managers and Software Developers.
To review all the information available on this site start at The SimoTime Home Page .
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-2010 SimoTime Enterprises All Rights Reserved |
| When technology complements business |
| http://www.simotime.com |
| Version 06.11.08 |