Application Development - Procedural Programming Languages
Part Three - Challenge #04

Background:

Computer Programming Languages

All programming languages have the same purpose - control the behavior of the machine or computer. Thousands of programming languages exist and new ones are created every year. All programming languages have strengths and weaknesses. A 'popular' programming language can be the wrong programming language for specific requirements.

z/OS supports and hosts many popular languages in addition to the time tested, trusted, and high performing languages.

Part 3 exposes you to several widely used z/OS programming languages. The objective is not to make you proficient in any specific programming language, but to have you recognize syntax structure of various programming languages, how to compile, and how to execute those programming languages.


What does C and COBOL programming languages have in common?
Both programming languages are:
  1. 50+ years old
  2. not typically listed as the "most popular" languages
  3. used to maintain many important computer applications still running today
  4. procedural languages - orderly flow control
    Based upon structure programming aimed at improving the clarity, quality, and development time of a computer program by making extensive use of the structured control flow constructs of selection (if/then/else)
    See Diagram under headings Elements (Control Structures)

Bottom line: These procedural languages are important now and will be far into the forseeable future.


COBOL - wrongly maligned with an under estimated learning value

COBOL, Common Business-Oriented Language, manages some of the most critical data and business logic in the world's economy. Many reasons exist for why COBOL is a computer language with incredible longevity.

COBOL is absent from nearly all the lists of 'popular' programming languages. COBOL is too verbish for the likes of some programmers. However, COBOL is respective and trusted by those that have many years in the industy. And COBOL can be easier to maintain than other languages as a result of being verbish.

COBOL programming language benefits from over 50 years of advancements, such as, COBOL compiler optimization, and COBOL runtime performance.

The core business logic of many large enterprises has decades of business process improvements embedded in COBOL programs.

The point is - whatever you read or hear about COBOL, be very skeptical. The opportunity to work directly with someone involved in writing or maintaining critical business logic using COBOL is an opportunity to learn about the operation of the core business. Business managers, business analysts, and decision makers come and go. The sum of all good business decisions can frequently be found in COBOL programs. The answer to "How does this business actually work?" can be found in COBOL programs.

COBOL is incredibly easy to learn and understand. Auditors are not programmers. However, auditors are responsible for insuring the business financial statements are presented fairly. COBOL processing frequently results in business ledger updates and subsequent financial statements requiring code review by auditors.

A comment recently made in a well known business journal by someone with a suspect agenda was quoted as saying, "COBOL is a computing language used in business and finance. It was first designed in 1959 and is pretty old and slow." A highly experienced business technology person knows the only true part of that last sentence was that COBOL was first designed in 1959. "Slow" is absolutely incorrect. The opposite is true.

It's no secret many banks have millions of lines of COBOL on mainframes. COBOL is at the core of how many banks handle the daily money transactions totally transparent to the smart phones involved with initiating those banking transactions.

COBOL is an attention getter on resumes. Hiring authorities and hiring influencers in large organizations running mission critical applications written in COBOL are more likely to spend more time reading a resume after spotting COBOL.

That is real world!

COBOL that runs in the z/OS Environment is called Enterprise COBOL.


You will learn to recognize C and COBOL source code

You can complete this challenge without any experience with C or COBOL.

C and COBOL source code is provided. The C and COBOL source code is compiled into an executable modules, then executed.


Optional: C and COBOL for Beginners

Below are a few recommended references for those with a desire to advance their skill level with C and COBOL.


Practice Preparation

Assumption moving forward is that you know how to locate and edit your various data sets for the purpose of copying in text from another data set.

Assumption moving forward is that you know how submit JCL providing a unique character for the generated JCL JOB statement, then locate and review JCL job output using SDSF.

  1. Copy 'zos.mtm2019.public.p3.source(cblhello)' into your SOURCE data set as new member name cblhello
  2. Observe the simple COBOL source syntax
  3. Copy 'zos.mtm2019.public.p3.source(chello)' into your SOURCE data set as new member name chello
  4. Observe the simple C source syntax
  5. Copy 'zos.mtm2019.public.p3.jcl(hello)' into your JCL data set as new member name hello
  6. Description of the JCL:
     Line 1
     Executes a JCL procedure reading CBLHELLO source to create an executable module
     Line 3
     Executes the CBLHELLO executable module
     Line 4
     Instructs the system where to find CBLHELLO executable module
     Line 6
     Executes a JCL procedure reading CHELLO source to create an executable module
     Line 8
     Executes the CHELLO executable module
     Line 9
     Instructs the system where to find CHELLO executable module
  7. Enter sub ; =sd ; st to submit the JCL and review the output
     Output has 2 Hello! messages, 1 from COBOL execution and 1 from C execution

The COBOL and C executable modules are in your LOAD partitioned data set.

From the ISPF command line enter tso call load(cblhello)

From the ISPF command line enter tso call load(chello)

Executable modules, regardless of the programming language, can be executed using JCL in the background or executed interactively in the foreground.


Challenge:

Get and review COBOL program source code.
  1. Copy 'zos.mtm2019.public.p3.source(zcobol)' into your SOURCE partitioned data set as member zcobol
  2. COBOL programming language includes:
      4 Divisions
        1 - Identification
        2 - Environment
        3 - Data
        4 - Procedure
      > COBOL verbs are English like
      > Asterisk in column 7 results in the line treated as a comment
      > Procedure Division is the execution logic
  3. Find the RECIN and RECOUT file names in the source code
  4. Enter F3 or save;return to save and return

Get and review C program source code
  1. Copy 'zos.mtm2019.public.p3.source(zc)' into your SOURCE partitioned data set as member zc
  2. C programming language includes:
    #include directive imports various functions with associated variables
    int main() where int will return an integer number and main is the program logic
    { } Braces ("curly braces") are used to group statements and declarations
      Class content or interface are enclosed in braces
      Method bodies and constructor bodies are enclosed in braces
      Braces are used to group the statements in an
      if statement, a loop, or other control structures
    [ ] Brackets ("square brackets") are used to index into an array
    ( ) Parentheses are used to:
      control the order of operations in an expression
      supply parameters to a constructor or method
  3. Find the RECIN and RECOUT file names in the source code
  4. Enter F3 or save;return to save and return

Get and review program compile and execution JCL
  1. Copy 'zos.mtm2019.public.p3.jcl(rwrecord)' into your JCL partitioned data set as member rwrecord
  2. Description of the JCL:
     Line 1
     Executes a JCL procedure reading ZC source to create an executable module
     Line 5
     Executes the ZC executable module
     Line 6
     Instructs the system where to find ZC executable module
     Line 7
     ZC file name RECIN input
     Line 8
     ZC program file name RECOUT output
     Line 12
     Executes a JCL procedure reading ZCOBOL source to create an executable module
     Line 16
     Executes the ZCOBOL executable module
     Line 17
     Instructs the system where to find ZCOBOL executable module
     Line 18 and 19
     ZCOBOL file name RECIN input
     Line 20
     ZCOBOL program file name RECOUT output

Program inputs and outputs

C program input (RECIN) is ZOS.MTM2019.PUBLIC.SHARED.DATA(MSG1)

ZOS.MTM2019.PUBLIC.SHARED.DATA(MSG1) has a single record with text:
 Replace ### farms with ??? ? and save a fortune in data center costs.

C program output (RECOUT) is P3.OUTPUT(#04)

P3.OUTPUT(#04) has as single record with text:
 Replace x86 farms with ??? ? and save a fortune in data center costs.

The C program changed string ### to x86.

COBOL program input (RECIN) reads 2 data sets:
ZOS.MTM2019.PUBLIC.SHARED.DATA(MSG2)
P3.OUTPUT(#04) the single record previously written by the C program

ZOS.MTM2019.PUBLIC.SHARED.DATA(MSG2) has 2 records with text:
 A single ??? ? can host thousands of operating systems resulting
 in massive reduction in power cost and floor space.

P3.OUTPUT(#04) has a single record with text:
 Replace x86 farms with ??? ? and save a fortune in data center costs.

Result will be P3.OUTPUT(#04) with 3 records:
 A single ??? ? can host thousands of operating systems resulting
 in massive reduction in power cost and floor space.
 Replace x86 farms with ??? ? and save a fortune in data center costs.


Execute C and COBOL programs
  1. Submit JCL to compile and execute C and COBOL source code, then review the output
    tso submit jcl(rwrecord)
  2. dslist p3.output and view member #04

Result is P3.OUTPUT(#04) with 3 records:
 A single ??? ? can host thousands of operating systems resulting
 in massive reduction in power cost and floor space.
 Replace x86 farms with ??? ? and save a fortune in data center costs.


The message needs a correction to complete the challenge

The COBOL program (ZCOBOL) needs to be modified to inspect the RECIN input records, replacing any occurrence of ??? ? with IBM Z before the RECOUT output records are written.

Modify ZCOBOL to replace all occurrences of ??? ? with IBM Z, and re-run JCL(rwrecord).

Edit p3.output(#04)

If C and COBOL programs produced the 3 records with the requested string modifications, then copy source(zcobol) after a line 3.

The final p3.output(#04) should contain the 3 records followed by the COBOL source code used to modify the records.


If you are new to C and COBOL, you can now at least recognize the C and COBOL program language syntax.

Next: Challenge #05