Cannot copy file on AS/400 due to members error

Trying to use CPYF to copy a file from one library to another.  The code we are using changes the member of the file so it becomes a date identifier.  The command string looks like this:



When the command executes, I get:

Members for file FILE more than maximum allowed
Member X063009X01 not added to file because of error

I thought that CLRPFM clears the file and member, but apparently that is not the case.  I also thought that the *REPLACE would let me overwrite the member.   The MAXMBRS on the file is set to 1.  

Any  help would be appreciated!


Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Gary PattersonVP Technology / Senior Consultant Commented:
Clearing a member does not remove it, just makes it empty.  My guess is that you are clearing member "A", and then trying to add member "B".  If the name of the existing member (DSPFD *MBRLIST) is different from the name of the new member, remove the member first (RMVM) or make sure and specify the same name on the CPYF command.

The error "Member ... NOT ADDED to the file because of error" is the giveaway - the system is trying to add a member to the file, and it is already at it's limit of one member.

BTW, there is not need to CLRPFM a member if you are going to CPYF *REPLACE that same member.  that is what *REPLACE does - automatically clear before copying.  Also no need to CPRPFM before RMVM.

Hope that helps.

- Gary Patterson
netwrkedAuthor Commented:
OK,  I tried the RMVM command on the file and it successfully removed the member, verified using DSPFD.  I tried my exact same copy command, this time I get:

Member X063009X01 added to file FILE in TOLIB
Empty member FILE in file FILE in library FROMLIB is not copied
Copy command ended because of an error

But, when I do the DSPFD (*MBRLIST), it shows the member as X063009X01 which is what I wanted.  Is there any way to get this command to work without erroring out?  It is bart of a batch of jobs that run and it keeps hanging up waiting for input (C I R D)


Gary PattersonVP Technology / Senior Consultant Commented:
Well, just like the error says, your From Member "FILE" in your From File "FROMFILE/FILE" is empty.  Personally, I think this behavior (CPYF fails on empty from member when *REPLACE is specified) sucks, and that the command should not fail, but hey, they didn't ask me.
Is this a mistake or a  bug in an earlier step, or is it normal to have an empty member here?

Lost of things you can do:  

You can modify your CL to ignore the "Copy commanded ended because of error (CPF2817)" message using a MONMSG statement right after the CPYF command, but this has the unfortunate consequence of causing your program to ignore all copy failures.  That might be bad.

You could clear the target member first, and then use the CPYF *ADD option - I don't think it will fail on an empty member in that case.  (This is probably the easiest thing to do if it is OK for the member to be empty).

You could, check to make sure that there are records in the From member before attempting to copy (RTVMBRD NBRCURRCD parameter).

You could perform the copy, and if it fails, check through diagnostic messages (RCVMSG) to see if it failed due to the "Empty member" message (CPF2869).  This process is a little tricky, since there can be a lot of messages on the message queue, and it can be a little tricky to know which go with that command.

- Gary Patterson


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
netwrkedAuthor Commented:
Good information, thanks!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Operating Systems

From novice to tech pro — start learning today.