REXX, A Popular Mainframe Scripting Language
Part Three - Challenge #03

Background:

There are many hundreds of computer programming languages. It is important to recognize that recent "hot" languages get the most attention by the programming community due to the specific programming language characteristics that make them a best fit for developing specific emerging technology.

The following is a list of computer programming languages
Many Hundreds of Computer Programming Languages

While the mainframe is capable of compiling and running the relatively new and "hot" programming languages, such as GO, SWIFT, and SCALA, the contest challenge focus is on the time tested languages that are currently pervasive in IT enterprises. These time tested mainframe computer programming languages are COBOL, Java, C/C++, Assembler, and REXX. Knowing how to read these languages can enable you to understand large IT enterprise mainframe business application programs and systems infrastructure programs which are critical to the daily operation of the enterprise.

Many highly experienced mainframe technicians use a scripting language that is unfamiliar to most in the distributed processing world even though this language is available to the other platforms. While numerous z/OS scripting languages exist, a preferred scripting language by highly experienced z/OS technicians is REXX. REXX was designed for ease of learning and reading. The capabilities of REXX went far beyond the original intent of quickly writing prototype code to writing production permanent code. While REXX started out as a scripting language, REXX can be compiled into machine instruction programs enabling increased execution speed.

If you end up in a job as a z/OS System Programmer or System Administrator in a large enterprise, the chances of encountering REXX code is very high. It is not necessary to memorize REXX syntax. REXX syntax and coding techniques are everywhere on the internet.

The previous REXX learning URLs are easiest to read. Below are more websites with more extensive details about the REXX programming language:

Having "REXX" on your resume, similar to having "COBOL" or "JCL", can be an attention getter. An employer that observes "REXX" may immediately think this is an applicant with potential to fill future mainframe System Programmer or System Administrator openings within the organization.

Challenge:

Enter the following:
tso submit 'zos.public.jcl(p3ch3)'

Part 2 challenge 13 involved capturing system command output about network traffic and reporting on differences between two time periods. A system command syntax correction was required to complete Part 2 Challenge 13. This same challenge involved a REXX program to read the before and after command output, then report the differences.

Completion of part 3 challenge 3 is to modify the REXX program used in part 2 challenge 13 to write a report on a subset of NETSTAT STATS command output between two time periods. Therefore, the modification to the REXX program is to delete the unwanted code and retain only the REXX program code necessary to write the requested report.

The report required for successful completion must include before and after values for Packets Received, Received Address Errors, and Current Established Connections.

Packets Received and Received Address Errors are in the NETSTAT STATS output twice, once for IPv4 and again for IPv6. The report must only include the values for IP Statistics (IPv4).

An example report follows:

Enter tso netstat stats a few times and observe values for:

  IP Statistics (IPv4)
  Packets Received
  Received Address Errors
 TCP Statistics
  Current Established Connections

Edit hlq.SOURCE and select s new member name NSTATS, then copy REXX program code into the new NSTATS member name

copy 'zos.mtm2017.public.clist(ch13)'

The REXX code copied into member NSTATS is the REXX code used in part 2 challenge 13.

Note: You do not need to change the code at this time. You will be instructed to edit and the change the REXX code later in the challenge. For now, just review REXX program syntax constructs.

While several REXX programming learning URLs were provided, below is a description of a few REXX program constructs in the REXX program you will modify to complete the challenge:

call -- branch to a named label in the program and execute statements until return encountered
return -- return from the named label and execute next statement in sequence
ALLOC -- allocate a data set name to read, write, or update
EXECIO -- used to input and/or output (I/O) data records
  notice the STEM run1. on the EXECIO
run1 is a variable used to store the content of each record
do i=1 to run1.0 -- a loop reading data set records where 0 in run1.0 represents the last record
run1.i -- where value of i represents the current record - an array of records
run1.1 -- is the 1st record where i = 1
run1.2 -- is the 2nd record where i = 2
run1.n -- is the nth record where i = n
parse var -- parse current record assigning variable names to each space separated field in the record

Jump to SDSF STATUS panel from the edit session by entering =sd ; st

Observe JOB P3CH3B is in a HOLD status. Enter a to the left of P3CH3B to release the JCL JOB.

JOB P3CH3B executed the 2nd NETSTAT STATS command writing output to hlq.CH13.OUTPUT(RUN3).

Edit hlq.SOURCE to display the directory of members

Enter ex to the left of NSTATS to execute the REXX program. If you have not changed the REXX code, then you executed the same REXX code used in part 2 challenge 13. The output is written to the TN3270 display. The output is identical to the part 2 challenge 13 output.

Note: Observe the Julian date in the report may not be today. The Julian date is from output captured when you completed Part 2 Challenge 13.

Edit hlq.SOURCE member name NSTATS

Observe the "ALLOC" statements on lines 10 and 58.

  • Part 2 challenge 13 processed hlq.CH13.OUTPUT members RUN1 and RUN2
  • JCL JOBs P3CH3 and P3CH3B created members RUN3 and RUN4
  • Modify the NSTATS REXX program
      change CH13.OUTPUT(RUN1) to CH13.OUTPUT(RUN3)
      change CH13.OUTPUT(RUN2) to CH13.OUTPUT(RUN4)
    f3 to exit and return to hlq.SOURCE directory list

Enter ex to the left of NSTATS and observe report when the program input is CH13.OUTPUT(RUN3) and CH13.OUTPUT(RUN4).

Modify NSTATS REXX program to report only the following:

  • Packets Received for IP Statistics (IPv4)
  • Received Address Errors for IP Statistics (IPv4)
  • Current Established Connections
  •     Reminder: Packets Received and Received Address Errors are in the NETSTAT STATS output twice, once for IPv4 and again for IPv6.
        The report must only include the values for IP Statistics (IPv4)

Again, the objective is to delete unwanted REXX code and leave the REXX code that will write the report above.

The REXX code that writes "** No change" message when network traffic values are the same must also be deleted.

f3 to save changes and return to hlq.SOURCE directory list.

The challenge is exactly the kind of task you might be asked to complete as a new hire in a mainframe technical role.

REXX code syntax:
REXX code CANNOT have line numbers on the far right.
Caution: ISPF Edit primary command RENUM will place numbers in the far right of each line.
How to eliminate lines to the far right of each line:
  enter number off
  enter c p'='  ' ' 72 80 all to remove line numbers from columns 72 thru 80.

Execute ex NSTATS again. Repeat this process until you are satisfied the report meets the requested report criteria.

Helpful Hint:
Approximately half of the NSTATS lines will be deleted.
Do not delete lines testing for IPV6, then skipping 20 records. These lines are required.
If you need to start over, delete all NSTATS lines and copy 'zos.mtm2017.public.clist(ch13)'.

Once the report meets the requested criteria, then enter
tso submit 'zos.public.jcl(p3ch3c)'

JCL job P3CH3C writes the REXX program output to the JES2 spool

Use SDSF to review P3CH3C output. Enter ? to the left of P3CH3C and select s DDNAME SYSTSPRT with associated StepName REPORT.

Once a good report is produced, then write the report to hlq.P3.OUTPUT(#03) as follows:

  • Enter xdc to the left of DDNAME SYSTSPRT associated with StepName REPORT as follows:

  • Another panel is displayed enabling member #03 to be written to P3.OUTPUT as follows:
    BLKS in the Space units field is required

Successful completion will be a valid report in hlq.P3.OUTPUT(#03)

Next: Challenge #04