OS/400 helps you keep information well organized by allowing physical files to have multiple members. This support is great, but creating a logical file over each and every member of the physical file can be a chore. Specifying DTAMBRS(*ALL) in the CRTLF command causes an access path to be built over all members, but, there is no easy way to create a multi-member logical file with one-to-one correspondence to each member of the physical file.
If you ever had to create a logical file over a multi-member physical file you have two options:
1. Specify each member on the DTAMBRS parameter, which is a tedious task.
2. Perform a CRTLF with no members and run the ADDLFM command for each member, w hich again is a tedious task.
Therefore, I created command ADDLFMALL (1a) and its processing program LFM002CL (1b) for the programmers. The only requirement is that the logical file must be created with MBR(*NONE) and MAXMBRS(*NOMAX) for this to operate correctly. If a member already exists, it just proceeds to the next one. In addition, RCVMSGs are used to send the user every message that is encountered.
Therefore, I created command ADDLFMALL (Figure 1a) and its processing program LFM002CL (Figure 1b) for the programmers. The only requirement is that the logical file must be created with MBR(*NONE) and MAXMBRS(*NOMAX) for this to operate correctly. If a member already exists, it just proceeds to the next one. In addition, RCVMSGs are used to send the user every message that is encountered.
TechTalk: Creating Logical Files
Figure 1A Command ADDLFMALL
ADDLFMALL: CMD PROMPT('Add All Logical File Members') PARM KWD(LF) TYPE(Q1) MIN(1) PROMPT('Logical file') PARM KWD(PF) TYPE(Q1) MIN(1) PROMPT('Physical file') Q1: QUAL TYPE(*SNAME) LEN(10) MIN(1) QUAL TYPE(*SNAME) LEN(10) DFT(*LIBL) + SPCVAL((*LIBL)) PROMPT('Library')
TechTalk: Creating Logical Files
Figure 1B CL program LFM002CL
LFM002CL: + PGM PARM(&QUALLF &QUALPF) DCL VAR(&LF) TYPE(*CHAR) LEN(10) DCL VAR(&LFLIB) TYPE(*CHAR) LEN(10) DCL VAR(&MSG) TYPE(*CHAR) LEN(132) DCL VAR(&MSGID) TYPE(*CHAR) LEN(7) DCL VAR(&OK) TYPE(*LGL) LEN(1) VALUE('0') DCL VAR(&PF) TYPE(*CHAR) LEN(10) DCL VAR(&PFLIB) TYPE(*CHAR) LEN(10) DCL VAR(&QUALLF) TYPE(*CHAR) LEN(20) DCL VAR(&QUALPF) TYPE(*CHAR) LEN(20) DCLF FILE(QAFDMBRL) CHGVAR VAR(&PF) VALUE(%SST(&QUALPF 1 10)) CHGVAR VAR(&PFLIB) VALUE(%SST(&QUALPF 11 10)) CHGVAR VAR(&LF) VALUE(%SST(&QUALLF 1 10)) CHGVAR VAR(&LFLIB) VALUE(%SST(&QUALLF 11 10)) DSPFD FILE(&PFLIB/&PF) TYPE(*MBRLIST) OUTPUT(*OUTFILE) + OUTFILE(QTEMP/MBRS) MONMSG MSGID(CPF0000) EXEC(GOTO CMDLBL(SNDMSG)) OVRDBF FILE(QAFDMBRL) TOFILE(QTEMP/MBRS) CHGVAR VAR(&OK) VALUE('1') READ: + RCVF MONMSG MSGID(CPF0864) EXEC(GOTO CMDLBL(END)) ADDLFM FILE(&LFLIB/&LF) MBR(&MLNAME) DTAMBRS((&PFLIB/&PF + (&MLNAME))) TEXT('Logical - ' *CAT &MLMTXT) MONMSG MSGID(CPF0000) SNDMSG: + RCVMSG MSG(&MSG) MSGID(&MSGID) IF COND(&MSGID *NE ' ') THEN(DO) SNDPGMMSG MSG(&MSG) TOPGMQ(*PRV) MSGTYPE(*INFO) GOTO CMDLBL(SNDMSG) ENDDO IF COND(&OK) THEN(GOTO CMDLBL(READ)) END: + ENDPGM
LATEST COMMENTS
MC Press Online