Creating a REGIONAL(1) data set is illustrated in Figure 16. The data set is a list of telephone extensions with the names of the subscribers to whom they are allocated. The telephone extensions correspond with the region numbers in the data set; the data in each occupied region being a subscriber's name.
/********************************************************************/
/* */
/* DESCRIPTION */
/* Create a REGIONAL(1) data set. */
/* */
/* USAGE */
/* The following commands are required to establish */
/* the environment variables to run this program: */
/* */
/* SET DD:SYSIN=CRG.INP,RECSIZE(30) */
/* SET DD:NOS=NOS.DAT,RECCOUNT(100) */
/* */
/********************************************************************/
CRR1: proc options(main);
dcl Nos file record output direct keyed
env(regional(1) recsize(20));
dcl Sysin file input record;
dcl 1 In_Area,
2 Name char(20),
2 Number char( 2);
dcl IoField char(20);
dcl Sysin_Eof bit (1) init('0'b);
dcl Ntemp fixed(15);
on endfile (Sysin) Sysin_Eof = '1'b;
open file(Nos);
read file(Sysin) into(In_Area);
do while(¬Sysin_Eof);
IoField = Name;
Ntemp = Number;
write file(Nos) from(IoField) keyfrom(Ntemp);
put file(sysprint) skip edit (In_Area) (a);
read file(Sysin) into(In_Area);
end;
close file(Nos);
end CRR1;
The execution time input file, CRG.INP, might look like this: ACTION,G. 12 BAKER,R. 13 BRAMLEY,O.H. 28 CHEESNAME,L. 11 CORY,G. 36 ELLIOTT,D. 85 FIGGINS,E.S. 43 HARVEY,C.D.W. 25 HASTINGS,G.M. 31 KENDALL,J.G. 24 LANCASTER,W.R. 64 MILES,R. 23 NEWMAN,M.W. 40 PITT,W.H. 55 ROLF,D.E. 14 SHEERS,C.D. 21 SURCLIFFE,M. 42 TAYLOR,G.C. 47 WILTON,L.W. 44 WINSTONE,E.M. 37