COBOL in PeopleSoft has long been one of my frustrations. I have had trouble with change assistant not getting the right version of the files in the correct directories. The compiler is an extra set of steps for installing and getting the system working. The license has to be installed in addition to the compiler, and most likely several run time environments. Typically, you would have to ship the COBOL programs between servers assuming you only have one server that is licensed to compile.
I can understand paying money for a program that you use, but COBOL doesn’t fit that description in my mind. Every client that I have worked at won’t touch a COBOL program: every customization must be outside the COBOL programs. So, why then should I have to pay thousands of dollars for a COBOL compiler?
So, I thought I would play with an open source compiler. I thought it would do two things:
- Maybe in some small way influence toward Open COBOL as an official certified alternative
- Help me better learn how the COBOL system works
So, here’s what I learned:
Installing Open COBOL on Oracle Linux
The hardest part about installing Open COBOL was getting the dependencies. Thankfully, I finally found someone who mentioned this command that would install all the needed dependencies:
yum install gmp-devel libtool db4 db4-devel
Then, I downloaded the 1.0 version from Source Forge:
These are the commands that I used to compile and install the package:
tar -xzvf open-cobol-1.0.tar.gz cd open-cobol-1.0 ./configure make sudo make install
So, this is the version that I ended up with
$ cobc -V cobc (OpenCOBOL) 1.0.0 Copyright (C) 2001-2007 Keisuke Nishida Copyright (C) 2007 Roger While
My first challenge regarding compiling was trying to figure out if I should try to modify the delivered pscbl.mak, pscbl_mf.mak, and psrun.mak scripts or create my own from scratch. I decided to go with my own script.
For options, this is what I used:
- –std=mf: use the Microfocus dialect
- -o: output to a different file/directory; allowed me to mimic the way PeopleSoft places the compiled files in a separate directory
- -t: create a listing for debugging purposes
Note that I let it create the default dynamically loadable module rather than specifying the -x option to compile to an executable. I did this with the intention to take advantage of the cobcrun program. Also, I didn’t have t0 figure out which files were main programs and which were just libraries.
I created this script in the PeopleSoft home setup directory to do the compile:
#!/bin/sh if [ ! -e "$PS_HOME" ]; then BASEDIR=$(dirname "$0") PSCONFIG="$BASEDIR/../psconfig.sh" if [ -e "$PSCONFIG" ]; then . $PSCONFIG fi fi if [ -e "$PS_HOME" ]; then echo "PS_HOME = $PS_HOME" else echo "Error -- PS_HOME not set or does not exist" fi LOGDIR=$PS_HOME/cblout OUTDIR=$PS_HOME/cblopen if [ ! -e "$LOGDIR" ]; then mkdir "$LOGDIR" fi if [ ! -e "$OUTDIR" ]; then mkdir "$OUTDIR" fi cd $PS_HOME/src/cbl rm $LOGDIR/success.txt rm $LOGDIR/fail.txt for cbl in $(ls *.cbl); do echo "Compiling $cbl..." BASENAME=$(echo "$cbl" | sed 's/\..*$//') cobc -std=mf $cbl -o "$OUTDIR/$BASENAME.so" -t "$LOGDIR/$BASENAME.lis" > $LOGDIR/$BASENAME.out 2>&1 if [ "$?" == 0 ]; then echo "$cbl" >> $LOGDIR/success.txt echo " success" else echo "$cbl" >> $LOGDIR/fail.txt echo " fail" fi done
Trying to Run a program
PTPDBTST is the natural choice for the first test. It’s just a quick program to make sure that COBOL programs can talk to the database.
[PS@HCM92 cblopen]$ cobcrun PTPDBTST libcob: Cannot find module 'CBL_GET_OS_INFO'
Unfortunately, the program didn’t work, and it seemed that every program I tried failed with the same error. If I understood it correctly, this CBL_GET_OS_INFO module is a MicroFocus specific module.
Microfocus Compiler Flags
As I was going through trying to figure out how to compile, I did a little poking into the compile options that PeopleSoft’s script uses. First, the PSCBL_MF.MAK script has two different compiles:
cob $PSCOBOPT $PS_IGNORE -C ‘MAKESYN “COMP-5″ == “COMP”‘ -C ‘OVERRIDE “TIME-OUT” == “TIME-OUT-MF”‘ -C ‘ANS85 “SYNTAX”‘ -W e -P $cblfile.cbl
- PSCOBOPT = -C CHECKDIV”OSVS” -C ERRLIST -C WARNING=1 -C IBMCOMP -C NOALTER -C NOFORM -C NOQUERY -C NOOSVS -C BOUND -C VSC2 -C INTLEVEL”4″
- PS_IGNORE = -C REMOVE”INSTANCE” -C REMOVE”INTERFACE-ID” -C REMOVE”PARSE”
- -C: pass compiler directive to the compiler
- CHECKDIV: allow dividing by zero
- ERRLIST: Print messages only
- WARNING: Level of message to output
- IBMCOMP: Word storage mode
- NOALTER: ???
- NOQUERY: Don’t pause if a copy file is missing; just print as an error
- NOOSVS: OS/VS reserved words are not to be treated as reserved words
- BOUND: Bound-check
- VSC2: Truncate according to the rules of VS COBOL II and COBOL/370.
- INTLEVEL: Portability Level
- REMOVE”INSTANCE” De-reserve Instance keyword
- REMOVE”INTERFACE-ID”: De-reserve Interface-ID keyword
- REMOVE”PARSE”: De-reservce Parse keyword
- MAKESYN: Make COMP-5 the same as COMP
- OVERRIDE: Change the meaning of TIME-OUT to TIME-OUT-MF
- ANS85: Use the ANS85 Keywords
- -W e: set the warning level to “error”
- -P: create a listing file
cob $PSCOBOPT $PS_IGNORE -C ‘MAKESYN “COMP-5″ == “COMP”‘ -C ‘OVERRIDE “TIME-OUT” == “TIME-OUT-MF”‘ -C ‘ANS85 “SYNTAX”‘ -u -W e -P $cblfile.cbl
The one different that I notice in this second option is:
- -u: compile to generated code for an unlinked environment
Creating PSRUN —
$PS_COB $PS_COBFLAGS -W e -e “” -x -o $PS_PSRUN $PS_OSLIBS_DIR $PS_OSLIBS -L$PS_HOME/bin $PS_CLIBS_DEFAULT 2> $PS_ERRFILE
- PS_COB = cob: the Microfocus compiler
- PS_COBFLAGS = blank: option arguments, set for AIX and HP Unix environments
- -W e: set the warning level to “error”
- -e “”: means that the “entry point” should be passed on the command-line to the program
- -x: tells it to compile to a system executable
- PS_PSRUN = “PSRUN”: the actual executable file to create
PeopleTools COBOL Programs
- PTPUSTAT: Updates the status for the process scheduler
- PSPCLBLD.cbl calls PTPUSTAT in the DB000-SET-RUN-STAT-PROCESSING section.
- SQLRT storage comes from: PTCSQLRT.cbl
- USTAT (PROCESS SCHEDULER REQUEST STATUS INTERFACE) comes from: PTCUSTAT.
COBOL Programs that I usually use
- PSPPYBLD: Create Paysheets
- PSPPYRUN: Payroll Calculation
- PSPCNFRM: Payroll Confirmation
- PTPDBTST: Simple COBOL Test Program
- PTPDTTST: COBOL Database Test Program
- Microfocus Compiler Flags
- Open COBOL: Compiling Reference
- Open COBOL Compiler Options
- Open COBOL Forum: centos 5.3 install/compile error
- What is COBCRUN?
- CBL_GET_OS_INFO Reference