|Multimember physical file in AS400|
A multimember physical file is having more than one member associated with it. Normally when we create the Physical file using CRTPF command a default member with the same name as PF gets added to the physical file so that's called the single-member physical file.
But when we add another member or a set of members to that physical file using CL command ADDPFM(Add physical file member) then we actually make that file multimember file.
There is one important parameter MAXMBRS(Maximum members) which actually decided whether the file can be multiple member files or not at the time of file creation.
The default value is set as 1 for the MAXMBRS parameter on the CRTPF command.
You need to set this MAXMBRS parameter to some value of more than 1 to make that file capable of becoming the multimember PF in the future.
You can provide MAXMBRS value from 1 to 32767 maximum or the *NOMAX value i.e. the number of members that can be in a PF is the system maximum value of 32767 members.
|MAXMBRS parameter on CRTPF command|
|MAXMBRS parameter on CRTPF command Help|
In case if we used the default provided value as 1 for parameter MAXMBRS on the CRTPF command still we can change the MAXMBRS value using CHGPF(Change physical file) command.
Let's create Multimember PF to better understand the concept
Following is the DDS source for the PF named WEB_3 in library EASYCLASS1 which is going to be a multimember PF and MAXMBRS value will be set to 2 on the CRTPF command.
CRTPF(Create Physical File) with MAXMBRS parameter
WEB_3 DDS PF
A R RCDFMT1 A CHAR1 10A
Create the Physical file object and set the MAXMBRS parameter as 2
CRTPF FILE(EASYCLASS1/WEB_3) SRCFILE(EASYCLASS1/WEBSITE) SRCMBR(WEB_3) MAXMBRS(2)
|CRTPF object created|
DSPFD (Display File Description)
Perform DSPFD EASYCLASS1/WEB_3 from the command line
In the above DSPFD screenshot for the file WEB_3, It is clearly mentioned that there can be a maximum of 2 members added to the PF WEB_3 and the current number of members are 1.
|Members in PF|
We have seen in the above screenshots that the member name is the default the same as the file name. Here in our case file name is WEB_3 and the member name is WEB_3
ADDPFM(Add Physical File Member) to add members
Let's add the second member named MBR2 using command ADDPFM to the PF named WEB_3.
ADDPFM FILE(EASYCLASS1/WEB_3) MBR(MBR2)
Member got added in PF
|Member added in PF|
DSPFD after adding a member to PF
Attached is the DSPFD information of file WEB_3 in library EASYCLASS1 after adding a second member.
Display PF member list
You can view the physical file member list using the DSPFD command as follows.
DSPFD FILE(WEB_3) TYPE(*MBRLIST)
Member list of the physical file WEB_3.
Error in Adding new member than the specified limit on MAXMBRS parameter
You cannot add members more than the number specified on the MAXMBRS parameter.
If you try to add new member MBR3 to the PF WEB_3 in library EASYCLASS1, you will be going to get the Error Members for file WEB_3 more than the maximum allowed.
CHGPF(Change Physical File) command to increase the number on MAXMBRS parameter for PF to add new members
To add a new member now you need to use the CHGPF command to change the values specified on the MAXMBRS parameter for the physical file at the time of creating the file
CHGPF FILE(EASYCLASS1/WEB_3) MAXMBRS(3)
If you run the DSPFD command again on file WEB_3, you will see max members are now 3 and the current number of members is 2.
CPYF (Copy File) command to add member
Now You can add a new member again using either the ADDPFM command or the CPYF command. So let's now add a new member using the CPYF command.
CPYF FROMFILE(EASYCLASS1/WEB_3) TOFILE(EASYCLASS1/WEB_3) FROMMBR(MBR2) TOMBR(MBR3) MBROPT(*REPLACE)
|CPYF command to add a member to PF|
member MBR3 added to PF WEB_3 using CPYF command.
|Member added using CPYF command|
DSPFD with *MBRLIST option after adding member MBR3