COBOL and DB2 API, Application Program Interface
Part Three - Challenge #09

Background:

COBOL connection and interaction with DB2 relational database table

You are NOT expected to have experience with COBOL to complete the challenge.

The COBOL code provided includes a working example of COBOL API (EXEC SQL ...) to connect to your DB2 relational database.

Challenge #09 assumes you successfully completed challenge #07 where you created and loaded a DB2 relational database table.


You will learn to:
  • Recognize COBOL code
  • Compile COBOL code using JCL
  • Execute COBOL code using JCL
  • Modify COBOL code based upon recognizable COBOL code pattern

Several obstacles and tasks will be encountered to complete the challenge:
  • View COBOL compile failure related to a misspelled internal file name
  • Modify COBOL code correcting compile failure
  • View COBOL execution issue related to no data written
  • Modify COBOL code correcting issue with no data written

Challenge:

View COBOL compile failure related to a misspelled internal file name
  1. Edit Z#####.SOURCE
  2. From the PDS command line enter s db2cbl to create new empty member
  3. From ISPF editor primary command line enter copy 'zos.mtm2018.public.source(db2cbl)'
  4. submit ; =sd ; st to:
      JCL is included in the db2cbl member that reads and compiles the COBOL source code displayed
      Pre-compile and compile the COBOL code
      Jump to SDSF status panel to review compile output
  5. Use ? to view the JCL JOBNAME DB2CBL DDNAMEs
      The compile failed with return code (RC) of 12
      DDNAME SYSPRINT from ProcStep COBOL consists of the compile details and failure message
      Compile output is long because the pre-compiler inserted code for each EXEC SQL statement
  6. Enterprise COBOL messages begin with IGY - f igy to find COBOL messages in the compile output
      The first message beginning with IGYPS2122-S is a severe message indicating the real problem
      The subsequent IGY messages ending with -W are warning messages resulting from the severe error
  7. Study the message text
      The message text identifies the code correction needed

Big hints
 Only 1 character is involved that created the problem
 Look in COBOL PROCEDURE DIVISION and examine OPEN statements
 Is the correct filename being opened?


Modify COBOL code correcting compile failure
  1. Edit Z#####.SOURCE
  2. From the PDS command line enter s db2cbl
  3. Use ISPF editor to correct the error in the COBOL source code
  4. submit ; =sd ; st to:
      Pre-compile and compile the COBOL code
      Jump to SDSF status panel to review compile output
  5. If the compile is successful, then proceed to the next twisty
      Return Code of 4 is expected and normal
  6. If the compile failed, then identify and correct COBOL code syntax error

Remember the big hint - removal of a single character in the COBOL will fix the problem

If needed you can delete all the lines of the COBOL code and copy in the original COBOL code again


View COBOL execution issue related to no data written
  1. Submit COBOL program execution
    From ISPF of SDSF command line enter tso submit 'zos.public.jcl(db2cblr)'
      The JCL executes the COBOL program which is intended to:
        - read from your DB2 relational database table
        - write selected fields to filename REPORT
      The program execution JCL REPORT DDNAME references to Z#####.P3.OUTPUT(#09)
  2. View Z#####.P3.OUTPUT member #09
      Member #09 is empty
      Unfortunetly, the JCL execution of the program completed with RC = 0 which is no help

Note: Big hint from above - read from your DB2 relational database table

What is the name of your DB2 relational database table?

Proceed to the next twisty


Modify COBOL code correcting issue with no data written
  1. Edit Z#####.SOURCE member name DB2CBL
  2. Find the SQL select statements in the COBOL source code
      What is the table name in the code?
      Study all EXEC SQL statements for table name
      What is your table name?
  3. Modify the code to read from your table name
  4. Compile the modified COBOL code
    submit ; =sd ; st to:
      Pre-compile and compile the COBOL code
      Jump to SDSF status panel to review compile output
  5. If the compile is successful, then execute program
      From ISPF or SDSF command line enter tso submit 'zos.public.jcl(db2cblr)'
      View Z#####.P3.OUTPUT(#09) upon completion of JCL JOBNAME DB2CBLR
  6. If Z#####.P3.OUTPUT(#09) has the report - you are done with the challenge - Congratulations!
  7. If Z#####.P3.OUTPUT(#09) is still empty - you need to review COBOL code again

The challenge actions are the actions of a mainframe developer. The only difference is the developer might be using a DevOps GUI instead of text based ISPF, SDSF, and DB2 Interactive facilility. Using the text based TN3270 interfaces will result in proficiency with any DevOps GUI.

Next: Challenge #10