15 pts.
 cpyf on multiple files
i need to copy all of the records from all of the files in one libray to a diff libray (add the records - joning two lib's into one - how can I do this with out running the job 3000+ times

Software/Hardware used:
as400 r5v4
ASKED: February 22, 2010  9:16 PM
UPDATED: February 23, 2010  6:30 PM

Answer Wiki:
Hi, You may try using the CRTDUPOBJ command specifying *ALL for OBJ and and *YES for DATA parameters. Eg: CRTDUPOBJ OBJ(*ALL) FROMLIB(fromlib) OBJTYPE(*FILE) TOLIB(tolib) DATA(*YES) Also you might wish to submit the job instead of calling it interactively as there are too many files. It could take a while. Cheers!
Last Wiki Answer Submitted:  February 22, 2010  11:51 pm  by  tjgm88   980 pts.
All Answer Wiki Contributors:  tjgm88   980 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

1. Use the dspfd to create an outfile listing all the physical files in the library .. if you use the mbrlist option I think it will list the number of records .. so you can determine which need to be copied
2. Write a short CL to read each record in the outfile and if the number of records is greater than 1 then copy it to the file in the final library with add option.

Good luck
Phil

 44,630 pts.

 

I have an old web site that could be helpful. See the ‘List Processing’ functions from my on-lines Files page. Some of the stuff there is almost 20 years old, but the list processors are still very useful. A lot of the rest is just stuff I needed to learn what HTML and web sites were years ago.

Download and compile the list set. Use the BLDFLST command to build a list of files. Then process that list with PRCFLST, using BLDMBRLST as the command to run against the file list and build a list of members, adding each file’s members to the list being built. Then process the member list with PRCMBRLST; set CPYF as the command to run against the member list.

A basic CL sequence with the list processing functions would look something like:

BLDFLST FILE( MyLib/*ALL ) FILEATR(*PF)
PRCFLST CMD( BLDMBRLST FILE( @@L/@@F ) LSTOPT(*FILE *ADD))
PRCMBRLST CMD( CPYF FROMFILE( @@L/@@F ) TOFILE( ToLib/@@F ) FROMMBR( @@M )
               TOMBR(*FROMMBR) MBROPT(*ADD) ERRLVL(*NOMAX) )

Once the commands and their underlying programs are uploaded and compiled, that would copy every member of every physical file in library MyLib to the matching members in library ToLib. The intermediate file and member lists could be editted with SQL, or DFU, or however you chose, to do whatever cleanup you needed after each of the first two steps.

CL is a powerful scripting language that is nicely extensible.

Tom

 110,105 pts.

 

In a CL, DSPOBJD of the FromLib to an out file. Read the outfile. Do a CHKOBJ on the the ToLib. If the object exists, CPYF MBROPT(*ADD), if it doesn’t CPYF CRTFILE(*YES) MBROPT(*REPLACE)

 40 pts.