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:

CLRPFM FILE

CPYF FROMFILE(FROMLIB/FILE) TOFILE(TOLIB/FILE) FROMMBR(FILE) TOMBR(X063009X01) MBROPT(*REPLACE) FMTOPT(*NOCHK)

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!

Thanks,

Joe
netwrkedAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Gary PattersonConnect With a Mentor VP 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

0
 
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
0
 
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)

Thanks,

Joe
0
 
netwrkedAuthor Commented:
Good information, thanks!
0
All Courses

From novice to tech pro — start learning today.