46
© 2004 IBM Corporation IBM ^ z/VM Module 8: CMS Pipelines

© 2004 IBM Corporation IBM ^ z/VM Module 8: CMS Pipelines

  • View
    235

  • Download
    2

Embed Size (px)

Citation preview

Page 1: © 2004 IBM Corporation IBM ^ z/VM Module 8: CMS Pipelines

© 2004 IBM Corporation

IBM ^

z/VMModule 8: CMS Pipelines

Page 2: © 2004 IBM Corporation IBM ^ z/VM Module 8: CMS Pipelines

© 2004 IBM Corporation

IBM ^

Objectives

Describe the fundamental concepts behind CMS Pipelines Explain what device drivers are and how they work Explain the difference between running the PIPE command

from a command prompt and from a REXX EXEC Describe filters and how they are used within a CMS Pipeline

Page 3: © 2004 IBM Corporation IBM ^ z/VM Module 8: CMS Pipelines

© 2004 IBM Corporation

IBM ^

Objectives continued

Describe how to use the LOCATE and FIND commands to select records

Explain how to create your own filters using REXX Show how to use pipelines in EXECs and XEDIT macros in

different subcommand environments Describe the commands needed to create a SPOOL file to hold

information

Page 4: © 2004 IBM Corporation IBM ^ z/VM Module 8: CMS Pipelines

© 2004 IBM Corporation

IBM ^

Objectives continued

List the commands needed to read information from a SPOOL file

Describe the CP commands that control the virtual reader Describe what multistream pipelining is and how to use it

Page 5: © 2004 IBM Corporation IBM ^ z/VM Module 8: CMS Pipelines

© 2004 IBM Corporation

IBM ^

What is a Pipeline?

Page 6: © 2004 IBM Corporation IBM ^ z/VM Module 8: CMS Pipelines

© 2004 IBM Corporation

IBM ^

Device Drivers

Page 7: © 2004 IBM Corporation IBM ^ z/VM Module 8: CMS Pipelines

© 2004 IBM Corporation

IBM ^

The PIPE Command

PIPE:

Page 8: © 2004 IBM Corporation IBM ^ z/VM Module 8: CMS Pipelines

© 2004 IBM Corporation

IBM ^

Some Popular Device Drivers

The console filter reads from the terminal and types on it; for example:

Pipe console | console CONSOLE can provide two functions:

Read input, when it is first in a pipeline specification Type the input it gets, when it is not first

A device driver that writes to a device also writes the output to the pipeline.

Page 9: © 2004 IBM Corporation IBM ^ z/VM Module 8: CMS Pipelines

© 2004 IBM Corporation

IBM ^

Some Popular Device Drivers, continued

Reading and writing disk files:– ‘<‘ to read a file– ‘>’ to create or replace a file– ‘>>’ to append to or create a file

LITERAL:– A literal creates a record with the argument string and writes to a

pipeline Combining input drivers:

– This allows the programmer to create a file at one location and append, copy, or overwrite the file later in the pipeline.

Page 10: © 2004 IBM Corporation IBM ^ z/VM Module 8: CMS Pipelines

© 2004 IBM Corporation

IBM ^

Using the PIPE Command and Other Commands

The PIPE command is not part of the pipeline itself, therefore it is not considered a stage.

In the reading and writing example, the left-hand stage reads the file from disk and the right-hand stage appends to the file specified.

In the second example, we use the CONSOLE command to print the file to the screen. This is helpful when you want to see the file quickly.

Page 11: © 2004 IBM Corporation IBM ^ z/VM Module 8: CMS Pipelines

© 2004 IBM Corporation

IBM ^

Filters

A filter is an application in a pipeline that takes its input from the stage to the left and passes its output to the stage to the right.

The filters that are supplied with CMS Pipelines have many general-use functions.

A function can be anything.

Page 12: © 2004 IBM Corporation IBM ^ z/VM Module 8: CMS Pipelines

© 2004 IBM Corporation

IBM ^

Filters: XLATE - Change Characters

XLATE: This filter translates data passing through the pipeline on a

character-by-character basis.

Some sample pipes:

– Pipe literal ABCDEFG | xlate 1-* lower | console

– Pipe literal abcdefghi | xlate c-g = e e | console

This filter is also capable of altering multiple characters and character ranges in a single stage or pipe.

Page 13: © 2004 IBM Corporation IBM ^ z/VM Module 8: CMS Pipelines

© 2004 IBM Corporation

IBM ^

Filters: XLATE - Change Characters

XLATE:

/* Replace “%” with “.” and *//* Replace “!” with “0” and *//* Replace “4” with “0” and *//* Replace “+” with “-” */

“Pipe Literal Don’t forget that (2+2) / 10 = 40%! |”, ‘Xlate 1-* % . ! 0 4 0 + - |’, ‘Console’________________________________________ Don’t forget that (2-2) / 10 = 00.0

Page 14: © 2004 IBM Corporation IBM ^ z/VM Module 8: CMS Pipelines

© 2004 IBM Corporation

IBM ^

Making Records Longer or Shorter

CHOP truncates each record after a column. PAD fills each record to the specified length with a pad character (the

default is a blank). Example:

– Pipe disk Unknown Data | pad 256 | chop 256 | > Demo output A You can combine chop and pad to create fixed format records. Strip removes blanks from both the beginning and the end of records.

Page 15: © 2004 IBM Corporation IBM ^ z/VM Module 8: CMS Pipelines

© 2004 IBM Corporation

IBM ^

Reformat Records

SPLIT creates an output record for each blank-delimited word in its input record.

JOIN creates a single record from one or more input records.

FBLOCK reformats the input stream to fixed length records.

Page 16: © 2004 IBM Corporation IBM ^ z/VM Module 8: CMS Pipelines

© 2004 IBM Corporation

IBM ^

Edit and Rearrange Contents of Records

Page 17: © 2004 IBM Corporation IBM ^ z/VM Module 8: CMS Pipelines

© 2004 IBM Corporation

IBM ^

Buffer Filters

A filter that buffers a file reads all input records before writing output records.

The SORT filter must buffer the file by the nature of its processing.

Use BUFFER when a file must be buffered but not reordered. Examples:

Pipe Disk INPUT FILE | Split | Sort unique | Console Pipe console | buffer | stack

Page 18: © 2004 IBM Corporation IBM ^ z/VM Module 8: CMS Pipelines

© 2004 IBM Corporation

IBM ^

Selecting Records

Page 19: © 2004 IBM Corporation IBM ^ z/VM Module 8: CMS Pipelines

© 2004 IBM Corporation

IBM ^

Looking for Labels - FIND and NFIND

Page 20: © 2004 IBM Corporation IBM ^ z/VM Module 8: CMS Pipelines

© 2004 IBM Corporation

IBM ^

Discarding and Keeping Records

Use TAKE and DROP to retain or discard a specified number of records from the beginning or end of the file.

TAKE and DROP make it easy to select records based on their position in the file.

The DROP filter is the converse of TAKE, which allows you to delete the first or last n lines.

Page 21: © 2004 IBM Corporation IBM ^ z/VM Module 8: CMS Pipelines

© 2004 IBM Corporation

IBM ^

Writing REXX Filters

There are two types of REXX programs you can write to run in a pipeline:

One reads input records and writes output records, just like all other programs

The other kind is a subroutine pipeline The REXX program ‘COPY REXX’

copies its input to the output. It can be used as a prototype for more complex filters.

Page 22: © 2004 IBM Corporation IBM ^ z/VM Module 8: CMS Pipelines

© 2004 IBM Corporation

IBM ^

Pipeline Input and Output in a REXX Program

Two of the most important REXX interface commands are READ and WRITE.

The READTO command has a single argument: the name of the variable you wish to be set to the contents of the next input record.

The OUTPUT command is followed by the data you wish to write; you can compute the output data as a REXX expression or you can write a literal.

Page 23: © 2004 IBM Corporation IBM ^ z/VM Module 8: CMS Pipelines

© 2004 IBM Corporation

IBM ^

How to Use Filters

Page 24: © 2004 IBM Corporation IBM ^ z/VM Module 8: CMS Pipelines

© 2004 IBM Corporation

IBM ^

How to Use Filters, continued

Page 25: © 2004 IBM Corporation IBM ^ z/VM Module 8: CMS Pipelines

© 2004 IBM Corporation

IBM ^

Using Pipelines in EXECs

and XEDIT Macros

Page 26: © 2004 IBM Corporation IBM ^ z/VM Module 8: CMS Pipelines

© 2004 IBM Corporation

IBM ^

Using Pipelines in EXECs and XEDIT Macros continued

VAR handles the special case where you want to read and write a single record with the contents of a REXX variable.

When you run the pipeline shown in the notes, the SCRIPT macro reads a line from the stack and inserts it in the document.

Page 27: © 2004 IBM Corporation IBM ^ z/VM Module 8: CMS Pipelines

© 2004 IBM Corporation

IBM ^

Getting Information about Files

STATE and STATEW provide information about selected files. STATEW only searches minidisks that are accessed in write mode. The underlying CMS commands allow asterisks for components of a file name, so you

can find the first occurrence of a certain type of file.

Page 28: © 2004 IBM Corporation IBM ^ z/VM Module 8: CMS Pipelines

© 2004 IBM Corporation

IBM ^

Subcommand Environments

There can be several subcommand environments active in your session, such as XEDIT, CMS, and ISPF.

The SUBCOM device driver takes as an argument the name of a subcommand environment, which is used for execution and displaying output.

Page 29: © 2004 IBM Corporation IBM ^ z/VM Module 8: CMS Pipelines

© 2004 IBM Corporation

IBM ^

Accessing Files in XEDIT

Page 30: © 2004 IBM Corporation IBM ^ z/VM Module 8: CMS Pipelines

© 2004 IBM Corporation

IBM ^

More REXX Interface Commands

Page 31: © 2004 IBM Corporation IBM ^ z/VM Module 8: CMS Pipelines

© 2004 IBM Corporation

IBM ^

More REXX Interface Commands

CALLPIPE replaces a stage with a pipeline. The asterisk followed by a colon, which seems to be a stage by itself,

is called a connector. Connectors are the magic that tells CALLPIPE to take the input and

output for the stage issuing the command and connect it to a new pipeline.

CALLPIPE returns when all stages of the new pipeline have completed.

Page 32: © 2004 IBM Corporation IBM ^ z/VM Module 8: CMS Pipelines

© 2004 IBM Corporation

IBM ^

Output Device Driver - Creating a SPOOL File

Three device drivers write lines on unit record devices. Some output device drivers include:

Printmc For a virtual printer Punch For a virtual punch Uro Can write to either device

For complete control, you must issue SPOOL, TAG, and CLOSE commands as required.

Page 33: © 2004 IBM Corporation IBM ^ z/VM Module 8: CMS Pipelines

© 2004 IBM Corporation

IBM ^

Unit Record Input - Reader SPOOL Files

SPOOL files in your virtual reader can come from several sources that have different formats; for example:

virtual card punch

virtual printer

CP-generated SPOOL files, such as a VMDUMP

read from a real card reader A reader reads a file and writes a line to the pipeline for each CCW in

the SPOOL file.

Page 34: © 2004 IBM Corporation IBM ^ z/VM Module 8: CMS Pipelines

© 2004 IBM Corporation

IBM ^

CP Commands to Control the Virtual Reader

The characteristics of a virtual reader can be set by the CP command SPOOL, which can control:

CLASS NOCOUNT & CONT NOHOLD & HOLD

A printer file is probably easier to handle than a punch file because you often want to retain the carriage control provided by the printer.

Punch files are more complicated because a punch file usually has more than plain data records.

Page 35: © 2004 IBM Corporation IBM ^ z/VM Module 8: CMS Pipelines

© 2004 IBM Corporation

IBM ^

Example: Process Reader Files

Page 36: © 2004 IBM Corporation IBM ^ z/VM Module 8: CMS Pipelines

© 2004 IBM Corporation

IBM ^

Multistream Pipelines

Page 37: © 2004 IBM Corporation IBM ^ z/VM Module 8: CMS Pipelines

© 2004 IBM Corporation

IBM ^

Examples of Multistream Pipelines

Page 38: © 2004 IBM Corporation IBM ^ z/VM Module 8: CMS Pipelines

© 2004 IBM Corporation

IBM ^

Specifying Multistream Pipelines

Page 39: © 2004 IBM Corporation IBM ^ z/VM Module 8: CMS Pipelines

© 2004 IBM Corporation

IBM ^

Combining Streams

Page 40: © 2004 IBM Corporation IBM ^ z/VM Module 8: CMS Pipelines

© 2004 IBM Corporation

IBM ^

Combining Streams continued

Page 41: © 2004 IBM Corporation IBM ^ z/VM Module 8: CMS Pipelines

© 2004 IBM Corporation

IBM ^

Pipeline Stalls

Page 42: © 2004 IBM Corporation IBM ^ z/VM Module 8: CMS Pipelines

© 2004 IBM Corporation

IBM ^

Conclusion

Each section of this module deals with an aspect of CMS Pipelines. The pipeline concepts discussed were:

Device drivers Filters Selecting records Writing REXX filters Using pipeline macros Unit record input and output

These topics help students learn the necessary elements for creating their own pipelines.

Page 43: © 2004 IBM Corporation IBM ^ z/VM Module 8: CMS Pipelines

© 2004 IBM Corporation

IBM ^

Glossary

CHOP: – truncates each record after a columnFBLOCK: – reformats the input stream to fixed length recordsFilter: – a stage in a pipeline that takes its input from the stage to the

left of it and passes its output to the stage to the right of itJOIN: – creates a single record from one or more input records

Page 44: © 2004 IBM Corporation IBM ^ z/VM Module 8: CMS Pipelines

© 2004 IBM Corporation

IBM ^

Glossary

LOCATE: – writes only the records that contain a specific stringNLOCATE: – writes all records that do not contain the string specified

as the argumentPAD: – fills each record to the specified length with a pad characterPipeline: – a series of programs that data passes through. SPLIT: – creates an output record for each blank-delimited word in its

input records

Page 45: © 2004 IBM Corporation IBM ^ z/VM Module 8: CMS Pipelines

© 2004 IBM Corporation

IBM ^

Glossary

SORT: – orders the input in ascending or descending orderUNPACK: – converts a file from the packed format supported by

COPYFILE and XEDIT to plain recordsVAR: – handles the special case where you want to read and write a

single record with the contents of a REXX variableXLATE: – translates data passing through the pipeline on a character

by character basis

Page 46: © 2004 IBM Corporation IBM ^ z/VM Module 8: CMS Pipelines

© 2004 IBM Corporation

IBM ^

References

Hartmann, J., L. Kraines, and J. Lynn. CMS Pipelines Tutorial. GG66-3158-00, February 1990.

IBM. z/VM: CMS Pipelines User’s Guide. SC24-5970-00, February 2001.

IBM. z/VM: CMS Command and Utility Reference. SC24-6010-02, May 2002.