Use Windows Help Files for Documentation
I collect various RPG IV procedures and functions and have found that it can be hard to remember what some of them do and with what service program or binding directory each is associated, so I created a Microsoft HTML help file to keep all this straight. Anytime I write or find a new procedure, I just add it to the help file, add any index keywords I might use to search for it, and recompile the help file.
Compiled help, or CHM, files are like selfcontained mini Web sites because they are HTML-driven. Almost anything that you can do within a Web site—such as JavaScript, style sheets, images, image maps, and hyperlinks—can be done within the help file. I use style sheets to help maintain font and layout consistency, and I use very simple JavaScript to call the Windows help API to create pop-ups and Related Topics buttons. HTML Help also has a full-text search option that can be activated without any coding on your part; you need only select it during the setup.
I have placed a sample help file called Procedures.CHM on the Midrange Computing Web site at www.midrangecomputing. com/mc. You can download it, place it on a PC, and launch it by clicking the file name from Windows Explorer. This gives you an idea of how you can use Windows help in your environment.
My real documentation is contained in several help files, not just one. I take advantage of a feature of the help compiler by linking multiple help files into one. For example, I have a driver help file, called as400.chm, linked to additional help files, such as ftp.chm, uim.chm, and ILE.chm. Each file can be used independently or from the driver as400.chm.
To create the help files, I use Microsoft’s HTML Help compiler. It’s free, and there’s not much of a learning curve if you have basic knowledge of HTML. To learn more about the HTML Help compiler and download it, you can visit http://msdn.microsoft. com/library/default.asp?URL=/library/tools/htmlhelp/chm/hh1start.htm&RLD=77 or http://msdn.microsoft.com/library/periodic/period98/htmlhelp.htm. I also recommend that you check out Official Microsoft HTML Help Authoring Kit by Steve Wexler and Building Enhanced HTML Help with DHTML and CSS by Jeannine Klein.
We have not yet used this technique for user documentation, but there’s no reason why it shouldn’t work. HTML Help is easy to maintain and provides an easy way to group information by topic. Once the file is updated, you can put it on a server and give everyone a shortcut to it. I think this is a good vehicle to use for, say, a department standards manual. Because of its ability to display images, it’s also good for program documentation. Just get a screen capture and insert it into the help file.
— Jeff Kinzer
Track the Growth of Physical Files
IBM has provided a number of commands for looking at the size of objects, but no way to track an object’s size over time, so I wrote a utility that uses the Display Object Description (DSPOBJD), Display File Description (DSPFD), and Open Query File (OPNQRYF) OS/400 commands, along with some homegrown CL and RPG programs for tracking the growth of physical files.
CL Program CHK001CL uses DSPOBJD to build a database file of all the files on your system; OPNQRYF selects physical files and sorts the file in descending order by size. RPG IV program CHK001R reads the sorted list of physical files and loads information about the 200 largest files into a database file called FILSTAT. Then, program CHK003R runs three times, producing a report of disk file usage in three different sequences. Figure 1 shows what the report looks like.
To load and run this utility, follow these steps:
• Download the source code from the Midrange Computing Web site at www. midrangecomputing.com/mc.
• Place the source members into one source physical file. (I call mine QDASDSRC.)
Figure 2 lists the source members.
• Edit the CHKINSTALL member. Change the values of the first three DCL commands: variables &SRCLIB, &OBJLIB, and &SRCF. Use the names of the source library, the object library (where the compiled code will go), and the source physical file.
• Compile and call OPM CL program CHKINSTALL. If all goes well, you will see a completion message telling you that the utility has been installed.
• Use your job-scheduling software to run the utility once a week. In our shop, it runs on Sunday afternoons. The CL command that it should execute is SBMJOB ... CMD (CALLCHK001CL).
— Bill Barnes
12/11/2000 Object Size Change Report CHK003R
9:56:47 By Size CHK003RP
Obj Name Library Owner Cur 1 Wk Nbr Nbr
Size Ago Ago Ago Ago Ago Ago Records Deleted Mbrs
12/03/00 11/26/00 11/19/00 11/12/00 11/05/00 10/29/00 10/22/00
TLTRAN00 PKMANH18 QPGMR 3,381 3,315 3,270 3,225 3,181 3,142 3,106 6,508,822 283 1
JPWKHST JPTSFIL JPTS 3,360 3,344 3,324 3,303 3,286 3,267 3,251 29,411,986 1
TLTRAN30 PENANHTS QPGMR 3,248 3,248 3,248 6,255,932 278 1
JPWKHST NONELIB JPTS 3,230 3,230 3,230 3,230 3,230 3,230 3,230 28,075,986 1
PDPICK PENANH18 QPGMR 2,510 2,466 2,432 2,401 2,371 2,341 2,310 3,149,580 46 1
X.SHIP QS36F QDFTOWN 76 76 76 76 76 76 76 164,797 1
QRPGSRC JPT QSECOFR 76 76 76 76 76 76 76 674,420 1,030
REPORT TOTALS 68,368 70,541 69,819 55,431 54,903 54,506 53,917 285,835,878 5,436
CHANGE AMOUNT -3.18% 1.02% 20.61% .95% .72% 1.08%
SYSTEM ASP 403.7GB PERCENT USED 36.2620% TOP 200 PERCENTAGE OF TOTAL USED 46.7026%
Page 4
Figure 1: CHK001CL tracks database growth over time.
Member Type Description
CHKINSTALL CLP Creates DASD utilization objects CHK001CL CLLE Loads FILSTAT with current file statistics and prints reports CHK001R RPGLE Loads FILSTAT with current file statistics
CHK002CL CLLE Obtains members to determine deleted record ratio CHK003CL CLLE Prints file size change report
CHK003R RPGLE Prints file size change report
CHK003RP PRTF File size change report
FILSTAT PF Archive of file statistics
NUM002RG RPGLE Extracts a number from a string
Figure 2: CHKINSTALL creates the other objects.
SBMJOB Parameter Length Limitation
Q: I have an application in which one program calls another program, passing it 10,000 bytes of data, and I need to change the application so the first program submits the CALL to batch. However, the Submit Job (SBMJOB) command can’t pass that much data. Is there any other way to accomplish this?
A: Upgrade to V4R5. In V4R5, the size of the SBMJOB command string is increased from 3,000 bytes to 20,000 bytes.
— Bruce Vining
More Cool Query Techniques
I searched high and low for a method of developing cross-tab queries, queries that would turn single sales records into meaningful monthly buckets, but to no avail. A recent article about the power of Query/400, Bob Ellsworth’s “The Hidden Power of Query, Part 1” in the October 2000 issue of MC, ignited my interest again after it had waned for many months. The article showed me how to use an array of 1s and 0s, indexed by a month number, to perform the cross-tab calculation.
Figure 3 shows how I use this technique. First, I pull out the month by doing the proper division and subtraction on the invoice date. Then, I set up 12 arrays of 12 multipliers in which only one of the 12 is 1 and the rest are 0, depending on the month they represent. The microsecond function turns the alpha 1 or 0 into a numeric multiplication factor for the period. Presto! The amount is multiplied into the proper bucket. The microsecond function was what I needed all this time, and it was right under my nose!
As a bonus to this newfound friend, I could determine debit or credit entries based on a credit memo code that our software uses. Amounts are kept as positive numbers in the sales file. The credit memo code can be 0, 1, 2, or 3. Values 0 and 3 represent debits (positive numbers), whereas values 1 and 2 represent customer credits and returns (negative numbers). Figure 4 shows how I convert a positive number into either a positive or a negative number, depending on the credit memo code field IHCRMM. Using the CC array in the query and subtracting the converted value from 1 gives me +1 or -1 as my multiplication factor, which I multiply by the positive amount. Once you know how to do this, it works very well.
Thanks again for that query article. If anybody has any solutions to “IF” functions on strings or calculations at the subtotal level, I would love to see them.
— Michael Calderon
Field Definition Length Decimals
YEAR (ihivdt/10000) 4 0 YR YEAR+1900
MONTH (ihivdt-(year*10000))/100 4 0 P1 ‘100000000000’
P2 ‘010000000000’ P3 ‘001000000000’
(Fields P4 through P11 defined in a similar manner.) P12 ‘000000000001’
PER1 microsecond(‘1988-12-25-17.30.00.00000’|| substr(p1,month,1))*IVSALT”
PER2 microsecond(‘1988-12-25-17.30.00.00000’|| substr(p2,month,1))*IVSALT”
PER3 microsecond(‘1988-12-25-17.30.00.00000’|| substr(p3,month,1))*IVSALT” (Fields PER4 through PER11 defined in a similar manner.) PER12 microsecond(‘1988-12-25-17.30.00.00000’|| substr(p12,month,1))*IVSALT
Figure 3: Query moves field IVSALT into one of 12 monthly buckets.
Field Definition
CC ‘0220’ AMT (1-(microsecond(
‘1988-12-25-17.30.00.00000’|| substr(cc,ihcrmm+1,1))))*TAMT
Figure 4: Query converts a positive number into either a debit or a credit.
LATEST COMMENTS
MC Press Online