Now, Get RPG Codes in all three formats only on this website on every RPGLE related programming article.

Fixed, /Free and Fully Free RPG


Multimember physical file in AS400

Multimember physical file in AS400
Multimember physical file in AS400, ADDPFM,DSPPFM,RMVM,CLRPFM,CPYF, OVRDBF,CRTPF, DSPFD, CHGPF, as400,ibmi
Multimember physical file in AS400

Introduction

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, ADDPFM, multimember physical file in as400
MAXMBRS parameter on CRTPF command

MAXMBRS parameter on CRTPF command Help,ADDPFM,Multimember pf in as400.ibmi,iseries,systemi
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 in AS400, CRPF in IBMi, mutimember physical file in AS400
CRTPF object created

DSPFD (Display File Description)

Perform DSPFD EASYCLASS1/WEB_3 from the command line

DSPFD, multimember physical file in as400,ibmi
DSPFD

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, DSPFD, multimember physical file in as400
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)
ADDPFM, add physical file member,  multimember physical file in as400
ADDPFM

Member got added in PF

addpfm, add physical file member, multimember physical file in as400
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.

DSPFD, multimember physical file in as400
DSPFD

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.

Member list, DSPFD type *MBLIST, multimember physical file in as400
Member List

Error in Adding new member than the specified limit on MAXMBRS parameter

Warning!
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.

CPF3213,Members for file <FILE> more than maximum allowed. ,ADDPFM, Multimember pf in as400
CPF3213

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)
CHGPF, ADDPFM, Multimember physical file in AS400 MAXMBRS parameter on CHGPF command
CHGPF

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.

DSPFD, addpfm, multimember physical file in as400,ibmi
DSPFD

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 members to PF in AS400,CPYF,multimember physical file in AS400
CPYF command to add a member to PF

member MBR3 added to PF WEB_3 using CPYF command.

Member added using CPYF command,CPYF, multimember physical file in as400
Member added using CPYF command

DSPFD with *MBRLIST option after adding member MBR3

DSPFD TYPE(*MBRLIST), dspfd, addpfm, multimember physical file in as400, add physical file member, ibmi
DSPFD TYPE(*MBRLIST)

Related Post

Post a Comment

© AS400 and SQL Tricks. All rights reserved. Developed by Jago Desain