<<

NESUG 16 Posters

PS006

Reading IBM® Standard Label tapes under

Hugh Kawabata, Bristol-Myers Squibb Evangelito Gascon, Novartis

ABSTRACT mainframe operating systems use this information when- ever files stored on tape are read; this information is One problem that many data centers that use UNIX sys- written when a is written to the tape. tems have is the handling of IBM tapes (and cartridges). While there does exist hardware that will attach to UNIX Programs that can process this information on UNIX sys- systems and physically read IBM tapes, little processing tems are relatively rare. The program described here util- is done of any 'metadata' by the UNIX commands. This izes the information stored in these header and trailers to poster shows the use of SAS® to process such informa- generate the UNIX to copy the files, converting tion. each record from EBCDIC (IBM’s character coding sys- tem) to ASCII (commonly used in UNIX). The informa- One of the advantages of IBM's standard label tapes is tion on the tape is used to construct the UNIX command that useful information (metadata) about the tape and the with the appropriate record size and block size options, files on the tape is stored in headers on the tape itself. and executes the UNIX system command. Every tape has a volume header, an 80- record that contains information about the tape. Each file also has a SAS PROGRAM header, two 80-byte records and a trailer, additional two 80-byte records. IBM mainframe operating systems use In this program, a SAS macro was written to utilize a 10- this information whenever files stored on tape are read; cartridge auto-loading cartridge reader. This macro, this information is written when a file is written to the readtape, is passed the number of cartridges to be read tape. (num_tapes).

The program described here utilizes the information in %macro readtape(num_tapes); these headers and trailers to generate the UNIX command to copy the file, passing the record and block size infor- %doi=1%to&num_tapes; mation to the UNIX command, and executes the com- mand. Using a tape autoloader, this program allows mul- A message is displayed on the UNIX console, using the tiple tapes to be read without operator intervention. SAS system call, x, and the UNIX command, .

INTRODUCTION x "echo Reading tape &i";

One problem that many data centers that use UNIX sys- Two SAS macro variables are assigned names for a log tems have is the handling of IBM tapes (and cartridges). file, to keep a log of what happened, and a label file, While there are hardware that will attach to UNIX sys- contains the contents of the IBM standard label. tems and physically read IBM tapes, and UNIX systems Note the use of the SAS automatic variables, sysdate and have commands that allow such tapes to be used, little systime, which contain the system date and , respec- processing is done of any “metadata” on the tape, such as tively. IBM’s standard labels. This short paper uses SAS to proc- %let log = readtape.&sysdate.. ess such information. &systime..log; %let lbl = readtape.&sysdate.. One of the advantages of IBM’s standard label tapes is &systime..lbl; that useful information (metadata) about the tape and the files on the tape is stored in headers on the tape itself (see The filename statement sets the handle “hdr” to a UNIX Figure 1). Every tape has a volume header, an 80-byte pipe pointing to the output of the UNIX dd command. record that contains information about the tape, the The dd command here reads from the tape an 80-byte useful being the actual volume serial number (volser). record, converts them to ASCII and passes it to SAS; the Each file also has a header, a block of two 80-byte records command results is appended to the log file. and a trailer, another block of two 80-byte records. IBM Page 1 NESUG 16 Posters

input @6 blksize $5. filename hdr pipe "dd if=/dev/rmt/0mn @11 lrecl $5. cbs=80 ibs=80 conv= 2>>&log"; ;

The options for this command that does this are typical of and the values are stored in SAS macro varibles. most UNIX systems: call symput ('blksize', if = the input file, /dev/rmt/0mn, on our server is the trim(left(blksize))); tape device call symput ('lrecl', cbs = conversion block size, in this case, 80 characters trim(left(lrecl))); ibs = input block size, in this case, 80 characters end; conv=ascii = specifies conversion to ASCII 2>>&log = redirects the output of the command to a Now the contents of the header records are stored in the file and the console label file.

Now the tape header can be read in a SAS data step. And, file "&lbl" mod; since the UNIX dd command had already converted the put _infile_; data into ASCII, no conversion is necessary in the SAS run; input statement. The information that was read is now used to copy the file There are three types of header records, each of which onto the UNIX disk, using the UNIX dd command. The contain different information. The two that are of interest UNIX file will have a name consisting of the original here are the “header 1” record, which contain the dataset dsname, plus the volume serial number (volser) of the name, volume serial number and volume sequence num- tape. ber (and other information that is not used here). The sec- ond record is the “header 2” record, which contain the x "dd if=/dev/rmt/0mn ibs=&blksize block size and the record length of the dataset. cbs=&lrecl conv=ascii of=&dsname..&vol..raw 2>>&log"; In this program, the first four characters are read and the input line is held. If the dataset was large enough to span several tape vol- umes, the volume sequence number should also be used in data _null_; the dataset name, like this: infile hdr pad lrecl=80; input @1 hr $4. @; x "dd if=/dev/rmt/0mn ibs=&blksize cbs=&lrecl conv=ascii If a header 1 record is found (the record begins with the of=&dsname..&vol..&volseq..raw characters, “HDR1”), the information needed are read. 2>>&log";

if hr = 'HDR1' then do; If the data contains binary information, the ASCII conver- input @5 dsn $17. sion option should be removed and SAS informats used to @22 volser $6. convert selected fields as appropriate. The dd command @28 volseq $4. should then look like this: ; x "dd if=/dev/rmt/0mn bs=&blksize Now the values read are stored in SAS macro variables. of=&dsname..&vol..raw 2>>&log";

call symput ('dsname', The following data step reads the trailer record and ap- trim(left(dsname)) ); pends the trailer (EOF) records to the label file for docu- call symput ('vol', mentation purposes. trim(left(volser)) || trim(left(volseq)) ); filename eof pipe "dd end; if=/dev/rmt/0m cbs=80 ibs=80 conv=ascii 2>>&log"; If a header 2 record is found, the information from this record is read, data _null_; infile eof lrecl=80 pad; else if hr='HDR2' input; then do; file "&lbl" mod; put _infile_; Page 2 NESUG 16 Posters

run; REFERENCES A message is then written to the UNIX console. Figure 1 is adapted from Gary DeWard Brown, System x "echo Finished tape &i"; 390 JCL, Fourth Edition, New York: Wiley, 1998.

In our environment, the 10-cartridge auto-loader can be The use of pipes under UNIX in the filename statement is instructed to unload the cartridge and load the subsequent documented in SAS Companion for UNIX Environments: cartridge, with the following UNIX command: Language.

x "mt -t /dev/rmt/0m offl"; ACKNOWLEDGEMENTS

The do loop is now ended, and the macro is complete. SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS %end; Institute in the USA and other countries. ® indicates USA registration. %mend; IBM is a registered trademark of the International Busi- With a 10-cartridge auto loader, this macro (with 10 as an ness Machines Corporation of Armonk, New York. argument) can read 10 tapes without operator interven- tion, except for the loading and unloading of the tape CONTACT INFORMATION magazine and the initial load of the first tape.

%readtape(10); Comments and questions are welcomed, : Hugh Kawabata CONCLUSION Pharmaceutical Research Institute Bristol-Myers Squibb This SAS program illustrates the flexibility of the SAS P.O. Box 4500 system in interacting with the computer . Princeton, NJ 08543 We were able to process batches of cartridges from IBM 609-897-3695 (voice) facilities with significantly labor. Using the same [email protected] techniques illustrated in this example, the data on the tapes could be read directly into SAS datasets.

Page 3 NESUG 16 Posters

Figure 1: Tape layouts for IBM standard labeled and unlabeled tapes

IBM STANDARD LABELS

HDR1/ EOF1/ VOL HDR2 DATA EOF2

LOAD TAPE MARKS POINT

NO LABELS

DATA

Page 4