Go Premium for a chance to win a PS4. Enter to Win


Cannot copy file on AS/400 due to members error

Posted on 2009-07-02
Medium Priority
Last Modified: 2013-12-06
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!


Question by:netwrked
  • 2
  • 2
LVL 35

Expert Comment

by:Gary Patterson
ID: 24765878
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

Author Comment

ID: 24767175
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)


LVL 35

Accepted Solution

Gary Patterson earned 2000 total points
ID: 24776137
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


Author Closing Comment

ID: 31599246
Good information, thanks!

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello I read in a discussion about a person who configured a very simple mirror RAID with two hard drives; the system and data were on the same partition. He asked how to repair the system as it was not booting up anymore. In his case running …
In a recent article here at Experts Exchange (http://www.experts-exchange.com/articles/18880/PaperPort-14-in-Windows-10-A-First-Look.html), I discussed my nine-month sandbox testing of the Windows 10 Technical Preview, specifically with respect to r…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question