TechTalk: Adding Fields to a Physical File

General
Typography
  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times

From: James Moore To: All

I need to add a field to our Master physical file. Can anyone give me some tips on what to watch out for? Will I have to recompile the logicals (10 of them) or will an IPL take care of that? Also, will I run into level check problems? Any help would be appreciated.

From: Pete Hall To: James Moore

Yes-on all counts. You could specify LVLCHK(*NO) on the CRTxF or CHGxF commands; but if you do that, your new field may not be properly initialized when records are added, and if the new field is not at the end of the record, you stand a very good chance of corrupting your data. Even input operations may return garbage. You will need to delete all dependent logicals before you will be able to delete the old physical file. If you leave the old physical file on disk, the logicals will remain attached to it. In general, the procedure for modifying a physical file record definition is as follows:

1. Delete all dependent logicals.

2. Rename the old physical file.

3. Create the new physical file (CRTPF).

4. Map the old data into the new file:

CPYF FROMFILE(LIB/OLDFILE) +

TOFILE(LIB/NEWFILE) +

MBROPT(*ADD) FMTOPT(*MAP *DROP)

5. Recreate all dependent logicals (CRTLF).

6. Recompile all programs which use the file or any dependent logicals. If you can't easily identify the programs, either use PDM to scan for the file name, specifying option 14 (compile), or use DSPPGMREF to build an output file for all programs in the application libraries, and write a query to list the programs that use the file(s) or the record name(s), and then manually submit the compiles working from the query report. If you want to get fancy, you can write a CL program to process the DSPPGMREF file and submit the compile commands automatically. You could even front-end the CL program with an OPNQRYF, which would allow a general purpose program to recompile all impacted programs based on a variable file name. I'll bet that would make a neat utility for MC.

7. Delete the old physical file after you are sure that the data is OK.

From: Ernie Malaga To: James Moore

Pete's advice is sound, but I want to add one more tip you may have missed. QUSRTOOL contains a command to recreate a physical file, named Rebuild Database File (RBLDBF). There's also another command to delete all dependent logicals at once (DLTDEPLGL), which is worth looking into.

In general, I don't trust QUSRTOOL much. So, though I can't really recommend that you use these utilities, they could be what the doctor ordered.

LVLCHK(*NO) should be used only temporarily, to get something urgent out the door, but never as a permanent solution. It's a sure-fire way to get into trouble, as Pete mentioned.

BLOG COMMENTS POWERED BY DISQUS

LATEST COMMENTS

Support MC Press Online

$

Book Reviews

Resource Center

  •  

  • LANSA Business users want new applications now. Market and regulatory pressures require faster application updates and delivery into production. Your IBM i developers may be approaching retirement, and you see no sure way to fill their positions with experienced developers. In addition, you may be caught between maintaining your existing applications and the uncertainty of moving to something new.

  • The MC Resource Centers bring you the widest selection of white papers, trial software, and on-demand webcasts for you to choose from. >> Review the list of White Papers, Trial Software or On-Demand Webcast at the MC Press Resource Center. >> Add the items to yru Cart and complet he checkout process and submit

  • SB Profound WC 5536Join us for this hour-long webcast that will explore:

  • Fortra IT managers hoping to find new IBM i talent are discovering that the pool of experienced RPG programmers and operators or administrators with intimate knowledge of the operating system and the applications that run on it is small. This begs the question: How will you manage the platform that supports such a big part of your business? This guide offers strategies and software suggestions to help you plan IT staffing and resources and smooth the transition after your AS/400 talent retires. Read on to learn: