I was wondering why IBM did not provide a command to display logical files similar to the one for physical files. Sometimes there is the need to actually see your data in its arrival sequence, and optionally to include and/or omit the data that you have described for the logical file. So I have written Display Logical File Member (DSPLFM).
The command structure (4a) requires three parameters: the file name, the library in which the file resides, and the member of that file. Usually, when I use this command, the file is somewhere in my library list, so I have caused the default library name to be *LIBL, substituting the library list. Also, I have caused the default for the member to be *ALL. Later, I will explain why.
The command structure (Figure 4a) requires three parameters: the file name, the library in which the file resides, and the member of that file. Usually, when I use this command, the file is somewhere in my library list, so I have caused the default library name to be *LIBL, substituting the library list. Also, I have caused the default for the member to be *ALL. Later, I will explain why.
The CPP (LFM001CL, 4b) describes five input variables; &QUALFILE, &FILE, &LIB, &MBR, and &MSG. &QUALFILE contains the file and library names. &FILE and &LIB are broken out of the &QUALFILE variable by the substring function. &MBR will be the member of that file. The last, &MSG, is for sending error messages in the event of file not found, library not found, or member not found.
The CPP (LFM001CL, Figure 4b) describes five input variables; &QUALFILE, &FILE, &LIB, &MBR, and &MSG. &QUALFILE contains the file and library names. &FILE and &LIB are broken out of the &QUALFILE variable by the substring function. &MBR will be the member of that file. The last, &MSG, is for sending error messages in the event of file not found, library not found, or member not found.
The CPP first checks for the existence of the object. Message CPF9801 is given if the file itself is not found, and CPF9810 for a library not found. Then, if the file member parameter is not *ALL, the CPP checks for the existence for the actual member by monitoring for CPF9815. If any error situation is reached, a message is sent, and the CL program is exited.
I decided that it would be best for my own use to use one file name in QTEMP. That way, if I wanted to look at it again, all I had to do was remember one file name. Anyone who wants to change that logic need only replace the file name DSPLFMPF (DSPLFM physical file) with &FILE. The physical file DSPLFMPF (or &FILE, if you choose) is deleted each time the command is executed, and message ID CPF2105 is checked in case the file to be deleted does not exist. The reasoning behind this is: if a file has record format "A," and we try to copy record format "B," the vast majority of the time, the formats are incompatible. Also, by copying the file to QTEMP, we do not have to do our own housekeeping. When a user signs off, all objects for that user in QTEMP will automatically be deleted. Lastly, it uses the Display Physical File Member (DSPPFM) command. Since DSPPFM defaults to *FIRST for the member, if the member selected is *ALL, DSPPFM will only show the first member. If a particular file member is selected, that member will be displayed.
As stated before, the member parameter of the command defaults to *ALL. Since the member will reside in QTEMP until changed or until the user signs off, the user can use the DSPPFM command to display the particular member if it isn't the *FIRST one.
TechTalk: Peek Into Logical Files
Figure 4A Command DSPLFM
DSPLFM: CMD PROMPT('Display Logical File Member') PARM KWD(FILE) TYPE(Q1) MIN(1) PROMPT('Logical + file name') PARM KWD(MBR) TYPE(*NAME) LEN(10) DFT(*ALL) + SPCVAL((*ALL)) PROMPT('Member') Q1: QUAL TYPE(*NAME) LEN(10) MIN(1) QUAL TYPE(*NAME) LEN(10) DFT(*LIBL) + SPCVAL((*LIBL)) PROMPT('Library')
TechTalk: Peek Into Logical Files
Figure 4B CL program LFM001CL
LFM001CL: + PGM PARM(&QUALFILE &MBR) DCL VAR(&QUALFILE) TYPE(*CHAR) LEN(20) DCL VAR(&MBR) TYPE(*CHAR) LEN(10) DCL VAR(&FILE) TYPE(*CHAR) LEN(10) DCL VAR(&LIB) TYPE(*CHAR) LEN(10) DCL VAR(&MSG) TYPE(*CHAR) LEN(60) /* Break qualified name */ CHGVAR VAR(&FILE) VALUE(%SST(&QUALFILE 1 10)) CHGVAR VAR(&LIB) VALUE(%SST(&QUALFILE 11 10)) /* Check for existence of logical file */ CHKOBJ OBJ(&LIB/&FILE) OBJTYPE(*FILE) MONMSG MSGID(CPF9801) EXEC(DO) CHGVAR VAR(&MSG) VALUE('File' *BCAT &LIB *TCAT '/' *CAT &FILE + *BCAT 'not found') GOTO CMDLBL(ERRMSG) ENDDO MONMSG MSGID(CPF9810) EXEC(DO) CHGVAR VAR(&MSG) VALUE('Library' *BCAT &LIB *BCAT 'not found') GOTO CMDLBL(ERRMSG) ENDDO /* Validate member name if not *ALL */ IF COND(&MBR *NE '*ALL') THEN(DO) CHKOBJ OBJ(&LIB/&FILE) OBJTYPE(*FILE) MBR(&MBR) MONMSG MSGID(CPF9815) EXEC(DO) CHGVAR VAR(&MSG) VALUE('Member' *BCAT &MBR *BCAT 'in' + *BCAT &LIB *TCAT '/' *CAT &FILE *BCAT 'not found') GOTO CMDLBL(ERRMSG) ENDDO ENDDO /* Copy logical file to QTEMP/DSPLFMPF */ CHKOBJ OBJ(QTEMP/DSPLFMPF) OBJTYPE(*FILE) MONMSG MSGID(CPF9801) EXEC(DO) CPYF FROMFILE(&LIB/&FILE) TOFILE(QTEMP/DSPLFMPF) + FROMMBR(&MBR) TOMBR(*FROMMBR) MBROPT(*ADD) CRTFILE(*YES) GOTO CMDLBL(DSPFILE) ENDDO CPYF FROMFILE(&LIB/&FILE) TOFILE(QTEMP/DSPLFMPF) FROMMBR(&MBR) + TOMBR(*FROMMBR) MBROPT(*REPLACE) CRTFILE(*NO) /* Display logical file member */ DSPFILE: + IF COND(&MBR *EQ '*ALL') THEN(DO) DSPPFM FILE(QTEMP/DSPLFMPF) ENDDO ELSE CMD(DO) DSPPFM FILE(QTEMP/DSPLFMPF) MBR(&MBR) ENDDO GOTO CMDLBL(ENDPGM) /* Send error messages */ ERRMSG: + SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA(&MSG) MSGTYPE(*DIAG) SNDPGMMSG MSGID(CPF0002) MSGF(QCPFMSG) MSGTYPE(*ESCAPE) ENDPGM: + ENDPGM
LATEST COMMENTS
MC Press Online