TechTalk: Creating Logical Files

General
Typography
  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times

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 
BLOG COMMENTS POWERED BY DISQUS

LATEST COMMENTS

Support MC Press Online

$

Book Reviews

Resource Center

  •  

  • LANSA Business users want new applications now. Market and regulatory pressures require faster application updates and delivery into production. Your IBM i developers may be approaching retirement, and you see no sure way to fill their positions with experienced developers. In addition, you may be caught between maintaining your existing applications and the uncertainty of moving to something new.

  • The MC Resource Centers bring you the widest selection of white papers, trial software, and on-demand webcasts for you to choose from. >> Review the list of White Papers, Trial Software or On-Demand Webcast at the MC Press Resource Center. >> Add the items to yru Cart and complet he checkout process and submit

  • SB Profound WC 5536Join us for this hour-long webcast that will explore:

  • Fortra IT managers hoping to find new IBM i talent are discovering that the pool of experienced RPG programmers and operators or administrators with intimate knowledge of the operating system and the applications that run on it is small. This begs the question: How will you manage the platform that supports such a big part of your business? This guide offers strategies and software suggestions to help you plan IT staffing and resources and smooth the transition after your AS/400 talent retires. Read on to learn: