Rational Developer for System z
PL/I for Windows, Version 8.0, Programming Guide

Example

Figure 8 shows the use of stream-oriented data transmission to create a consecutive data set. The data is first read from the data set bday.inp that contains a list of names and birthdays of several people. Then a consecutive data set bday.oct is written that contains the names and birthdays of people whose birthdays are in October.

The command SET DD:SYSIN=BDAY.INP should be used to associate the disk file bday.inp with the input data set. If this file was not created by a PL/I program, the RECSIZE option must also be specified.

The command SET DD:WORK=BDAY.OCT should be used to associate the consecutive output file WORK with the disk data set bday.oct.

Figure 8. Creating a data set with stream-oriented data transmission
 /********************************************************************/
 /*                                                                  */
 /*  DESCRIPTION                                                     */
 /*    Create a CONSECUTIVE data set with 30-byte records containing */
 /*    names and birthdays of people whose birthdays are in October. */
 /*                                                                  */
 /*  USAGE                                                           */
 /*    The following  commands are required to establish   */
 /*    the environment variables to run this program:                */
 /*                                                                  */
 /*      SET DD:WORK=BDAY.OCT                                        */
 /*      SET DD:SYSIN=BDAY.INP,RECSIZE(80)                           */ 
 /********************************************************************/

 BDAY: proc options(main);
   
   put skip list('BDAY TEST HAS STARTED'); 
   
   dcl Work file stream output,
       1 Rec,
           3 Name char(19),
           3 BMonth char(3),
           3 Pad1 char(1),
           3 BDate char(2),
           3 Pad2 char(1),
           3 BYear char(4);

    dcl Eof bit(1) init('0'b);
    dcl In char(30) def Rec;

    on endfile(sysin) Eof='1'b;

    open file(Work) linesize(400);
    get file(sysin) edit(In)(a(30));
    do while (¬Eof);
     if BMonth = 'OCT'
        then put file(Work) edit(In)(a(30));
        else;
     get file(sysin) edit(In)(a(30));
    end;
    close file(Work);
	
	put skip list('BDAY TEST HAS ENDED');
	
 end BDAY;


bday.inp contains the input data used at execution time:

LUCY   D.          MAR 15 1950
REGINA W.          OCT 09 1971
GARY   M.          DEC 01 1964
PETER  T.          MAY 03 1948
JANE   K.          OCT 24 1939
Rational Developer for System z
PL/I for Windows, Version 8.0, Programming Guide