Purging Deleted Records
Deleted records take up alot of room and you usually don't even know which files have them. You may want to consider this simple solution. Create an outfile using the following command.
DSPFD FILE(library_name/*ALL) TYPE(*MBRLIST) + OUTPUT(*OUTFILE) OUTFILE(file_name)
If you want to reorganize more than one library, you can use *ALL, *ALLUSR, *USRLIBL or *LIBL for the library name.
After the information has been placed in the OUTFILE, you can use either a query or one of the copy commands to select all files which contain deleted record (MLNDTR>0). Once you have found the current files, executing a Reorganize Physical File Member (RGZPFM) command on these files will free up disk space.
The File Reference File
The AS/400 keeps a reference file with an entry for each file on the system. The file is called QADBXREF and is found in QSYS. Each record contains the following fields:
DBXFIL File name DBXLIB Library name DBXDIC Dictionary name DBXOWN Owner Name DBXTXT Text DBXATR Attribute (PF, LF, TB, VW, IX) DBXLNK "E" if externally described "P" if program described DBXSQL "I" if IDDU "S" if SQL "C" if CRTDTADCT "X" if Migrated Blank = no link DBXTYP "D" if Data, "S" if Source DBXNFL Number of fields DBXNKF Number of key fields DBXRDL Maximum record length DBXIDV Internal file definition for ID dictionary
As you can see, this file can be useful in listing files by many different types of information. For example, you could list all files or groups of files by file name, library, owner or type. You can create a multitude of useful reports from this file.
Redefining Records Without Changing File
I recently had to read a file in a CL program that wasn't defined in a very user-friendly manner. It was a packaged software file that was converted to the AS/400 from a S/36. Therefore, the file's DDS described the file as follows:
... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 A KEYDTA 8A A CNTDTA 54A
The packaged software used a data structure to redefine the CNTDTA field. This data contained character, zoned and packed data. I couldn't figure out how to read the file using the CNTDTA field since it contained hexadecimal data (my CL program kept giving various error messages). So, this is the solution that I arrived at, and it worked!
I created a physical file format for use in my CL program. I gave it a unique name (different than the file's name) and defined the data that I needed as follows:
... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 A KEYDTA 8A A DTEDTA 4P 0 A JNKDTA 50A In my CL program, I used the following commands: DCLF FILE(my_new_file_name) OVRDBF FILE(my_new_field_name) + TOFILE(existing_file_name) LVLCHK(*NO) RCVF
I had a numeric CL variable declared for the DTEDTA field. I was then able to manipulate the packed data as I needed. It worked great!
Copy Logical to Physical
If you need a logical file for testing purposes, but you don't want to update the physical file, you can create a copy of the logical file to be in a physical file. Your program won't know the difference between accessing the test physical file directly or accessing the production physical file via the logical file. Just use the Copy File (CPYF) command to make a physical file copy of the logical file like this:
CPYF FROMFILE(production/logical_file) + TOFILE(testlib/physical_file) CRTFILE(*YES)
Before you run your test, make sure the test library is ahead of the production library in your library list or perform an override against the file.
LATEST COMMENTS
MC Press Online