Skip to content

Commit cdd2fbf

Browse files
committed
Updated Mainframe script
Signed-off-by: Ali <65877768+alim395@users.noreply.github.com>
1 parent 2a2050d commit cdd2fbf

File tree

1 file changed

+45
-36
lines changed

1 file changed

+45
-36
lines changed

COBOL Programming Course #4 - Testing/COBOL Programming Course #4 - Testing.md

Lines changed: 45 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -449,51 +449,60 @@ By the end of this lab, you'll have practical experience in setting up an automa
449449
# Check Java availability
450450
java -version
451451
452-
# Change to the appropriate directory
453-
cd /z/$ZOWE_USERNAME/cobolcheck || { echo "Directory not found"; exit 1; }
454-
ls -al
452+
# Set ZOWE_USERNAME
453+
ZOWE_USERNAME="Z36963" # Replace with the actual username or dataset prefix
455454
456-
# Check if cobolcheck exists and make it executable
457-
if [ -f cobolcheck ]; then
458-
chmod +x cobolcheck
459-
ls -al
460-
else
461-
echo "cobolcheck file not found"
462-
exit 1
463-
fi
455+
# Change to the cobolcheck directory
456+
cd cobolcheck
457+
echo "Changed to $(pwd)"
458+
ls -al
464459
465-
# Check and make linux_gnucobol_run_tests executable
466-
if [ -d scripts ] && [ -f scripts/linux_gnucobol_run_tests ]; then
467-
cd scripts
468-
chmod +x linux_gnucobol_run_tests
469-
cd ..
460+
# Make cobolcheck executable
461+
chmod +x cobolcheck
462+
echo "Made cobolcheck executable"
463+
464+
# Make script in scripts directory executable
465+
cd scripts
466+
chmod +x linux_gnucobol_run_tests
467+
echo "Made linux_gnucobol_run_tests executable"
468+
cd ..
469+
470+
# Function to run cobolcheck and copy files
471+
run_cobolcheck() {
472+
program=$1
473+
echo "Running cobolcheck for $program"
474+
475+
# Run cobolcheck, but don't exit if it fails
476+
./cobolcheck -p $program
477+
echo "Cobolcheck execution completed for $program (exceptions may have occurred)"
478+
479+
# Check if CC##99.CBL was created, regardless of cobolcheck exit status
480+
if [ -f "CC##99.CBL" ]; then
481+
# Copy to the MVS dataset
482+
if cp CC##99.CBL "//'${ZOWE_USERNAME}.CBL($program)'"; then
483+
echo "Copied CC##99.CBL to ${ZOWE_USERNAME}.CBL($program)"
484+
else
485+
echo "Failed to copy CC##99.CBL to ${ZOWE_USERNAME}.CBL($program)"
486+
fi
470487
else
471-
echo "scripts directory or linux_gnucobol_run_tests not found"
472-
exit 1
488+
echo "CC##99.CBL not found for $program"
473489
fi
474-
475-
pwd
476-
477-
# Function to run COBOL check and copy files
478-
run_cobol_check() {
479-
local program=$1
480-
if [ -f "${program}.CBL" ] && [ -f "${program}.JCL" ]; then
481-
./cobolcheck -p "$program"
482-
if [ -f CC##99.CBL ]; then
483-
cp CC##99.CBL "//'${ZOWE_USERNAME}.CBL(${program})'"
484-
cp "${program}.JCL" "//'${ZOWE_USERNAME}.JCL(${program})'"
485-
echo "${program} processed successfully"
486-
else
487-
echo "CC##99.CBL not generated for ${program}"
488-
fi
490+
491+
# Copy the JCL file if it exists
492+
if [ -f "${program}.JCL" ]; then
493+
if cp ${program}.JCL "//'${ZOWE_USERNAME}.JCL($program)'"; then
494+
echo "Copied ${program}.JCL to ${ZOWE_USERNAME}.JCL($program)"
489495
else
490-
echo "${program}.CBL or ${program}.JCL not found"
496+
echo "Failed to copy ${program}.JCL to ${ZOWE_USERNAME}.JCL($program)"
491497
fi
498+
else
499+
echo "${program}.JCL not found"
500+
fi
492501
}
493502
494-
# Run COBOL check on NUMBERS, EMPPAY, and DEPTPAY
503+
# Run for each program
495504
for program in NUMBERS EMPPAY DEPTPAY; do
496-
run_cobol_check "$program"
505+
run_cobolcheck $program
497506
done
498507
499508
echo "Mainframe operations completed"

0 commit comments

Comments
 (0)