Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Introduction How to create multiboot configuration with XP\Vista and Windows 7 on it? And most important question - how to do this correctly so not to have any kind of nightmares we get when system gets screwed? First of all one should realize t…
As the title indicates, I have done this before. It chills me everytime I update the OS on my phone, ( because one time I did this and I essentially had a bricked …
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.

670 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