28.11.2012 Views

IBM Tivoli NetView for z/OS Programming: Pipes - IBM notice

IBM Tivoli NetView for z/OS Programming: Pipes - IBM notice

IBM Tivoli NetView for z/OS Programming: Pipes - IBM notice

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Introduction and Concepts<br />

Stages<br />

10 <strong>Programming</strong>: <strong>Pipes</strong><br />

It is possible <strong>for</strong> a connector to be neither first nor last, in which case, the<br />

connector defines both an input and an output <strong>for</strong> the labeled stage. It is also<br />

possible to use two connectors in a row. This usage connects the output of one<br />

labeled stage to the input of another.<br />

In the following example, the secondary output of LOCATE is connected to the<br />

secondary input of FANIN:<br />

PIPE (END ¬)<br />

| < SOMEMEM<br />

| COLOR YELLOW<br />

| RD: LOCATE /GREEN/<br />

| COLOR GREEN<br />

| BK: FANIN<br />

| CONSOLE ONLY<br />

¬ RD:<br />

| BK:<br />

The PIPE stages in this example are explained in detail in Chapter 2, “Pipeline<br />

Stages and Syntax,” on page 19. For now, understand that < reads data from a data<br />

set member called SOMEMEM, the COLOR stage changes the color of text<br />

presented on the CONSOLE, and FANIN collects data from multiple input streams<br />

and passes the data to a single output stream.<br />

In this pipeline, all the records in the member SOMEMEM are read and given the<br />

color attribute YELLOW. Then, all records containing the word GREEN are colored<br />

green. Records containing the word GREEN flow through the pipeline directly to<br />

the FANIN stage and then to the console. Records that do not contain the word<br />

GREEN flow to the RD: connector from the LOCATE/GREEN/ stage, which<br />

defines the RD: label. Because the BK: connector follows the RD: label, the data<br />

flows from the BK: connector as input to the stage defining it (BK: FANIN).<br />

Stages that Disconnect Streams be<strong>for</strong>e Termination<br />

Some stages can disconnect a stream be<strong>for</strong>e terminating. An example is the TAKE<br />

stage. The TAKE stage disconnects its primary output as soon as the specified<br />

count is reached. However, if a secondary output stream is defined, the TAKE<br />

stage is not terminated. It continues to pass messages to its secondary output<br />

stream.<br />

The processing of the TAKE stage is important to the following REXX pipeline,<br />

because FANIN will not begin to read its secondary input until its primary input<br />

has disconnected:<br />

’PIPE (NAME REDNAME END ¬)’,<br />

’| < NAMELIST’, /* Read list of names */<br />

’|C: TAKE 12’, /* Hope to get 12 or fewer names */<br />

’|R: FANIN’, /* Bringing names together */<br />

’| $STEM NAMEVAR.’, /* Save names in order FANIN reads */<br />

’| CONSOLE’, /* and display them */<br />

’¬ C:’, /* Pick up excess names from TAKE */<br />

’| COLOR RED’, /* Names past twelfth should be red */<br />

’| R:’ /* give these to FANIN’s secondary */<br />

The first 12 names are displayed on the console in the default color. The remaining<br />

names are displayed in red.<br />

Depending on their function, stages can be grouped into two categories: device<br />

drivers and filters.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!