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