All OS/400 commands that support tape devices offer the ENDOPT parameter, which can have the values *LEAVE, *REWIND or *UNLOAD. When the same tape has to be processed repeatedly, one usually selects the *LEAVE option, either manually or in a CL program. This saves time, wear and tear and since the tape does not rewind after each use.
Once in awhile, however, the tape is left in the middle with the next operation expecting it to be rewound. For example, you could have a loop in a CL program that saves a number of objects to a tape using ENDOPT(*LEAVE) for an unknown number of objects. After the last object is saved, you need to display the contents of the tape to a printer--which expects the tape to be rewound.
The Rewind Tape command (RWDTAP) solves this problem. It only needs to know the name of the tape device and whether you want to rewind or unload. It accomplishes its objective by using the CHKTAP command with no special parameters except ENDOPT. See the command and program in Figures 5a and 5b.
TechTalk: Rewind by Remote Control
Figure 5A Command RWDTAP
RWDTAP: CMD PROMPT('Rewind Tape') PARM KWD(DEV) TYPE(*NAME) LEN(10) MIN(1) + PROMPT('Device name') PARM KWD(UNLOAD) TYPE(*CHAR) LEN(4) RSTD(*YES) + DFT(*NO) VALUES(*YES *NO) PROMPT('Unload + tape after rewinding')
TechTalk: Rewind by Remote Control
Figure 5B CL program TAP002CL
TAP002CL: + PGM PARM(&DEV &UNLOAD) DCL VAR(&DEV) TYPE(*CHAR) LEN(10) DCL VAR(&ENDOPT) TYPE(*CHAR) LEN(7) DCL VAR(&MSGDTA) TYPE(*CHAR) LEN(80) DCL VAR(&MSGF) TYPE(*CHAR) LEN(10) DCL VAR(&MSGFLIB) TYPE(*CHAR) LEN(10) DCL VAR(&MSGID) TYPE(*CHAR) LEN(7) DCL VAR(&UNLOAD) TYPE(*CHAR) LEN(4) IF COND(&UNLOAD *EQ '*YES') THEN(CHGVAR VAR(&ENDOPT) + VALUE(*UNLOAD)) ELSE CMD(CHGVAR VAR(&ENDOPT) VALUE(*REWIND)) CHKTAP DEV(&DEV) ENDOPT(&ENDOPT) MONMSG MSGID(CPF0000) EXEC(DO) RCVMSG MSGTYPE(*EXCP) RMV(*NO) MSGDTA(&MSGDTA) MSGID(&MSGID) + MSGF(&MSGF) MSGFLIB(&MSGFLIB) SNDPGMMSG MSGID(&MSGID) MSGF(&MSGFLIB/&MSGF) MSGDTA(&MSGDTA) + MSGTYPE(*DIAG) SNDPGMMSG MSGID(CPF0002) MSGF(QCPFMSG) MSGTYPE(*ESCAPE) ENDDO ENDPGM
LATEST COMMENTS
MC Press Online