Ted Holt
Ted Holt is the senior technical editor at The Four Hundred and editor of the former Four Hundred Guru newsletter at Guild Companies. Holt is Senior Software Developer with Profound Logic, a maker of application development tools for the IBM i platform, and contributes to the development of new and existing products with a team that includes fellow IBM i luminaries Scott Klement and Brian May. In addition to developing products, Holt supports Profound Logic with customer training and technical documentation.
-
Read a Data Area As a One-Row Table with SQL
May 19, 2004 Hey, Ted
Is it possible to treat a data area as if it were a one-record physical file in an SQL query? We currently copy the data area to a one-record file, which we use in our queries. However, occasionally the data area gets updated but the refresh lags behind.
–W.G.
I’ve never thought about it, but that’s an interesting idea. In my S/36 days, I frequently wished it were possible to treat the local data area as a one-record disk file in Query/36.
To answer your question: yes, it’s possible if you’re at V5R2. You will need to create a table
-
Writing Control Break Programs
May 12, 2004 Ted Holt
[The code for this article is available for download.]
Having worked on programs written by different programmers, I have noticed a lot of different techniques and programming styles. However, one thing is consistent: that most programmers do not design programs. When it comes time to write a program, they just sit down at their workstations and have at it. This approach to program development results in error-prone programs that are hard to modify. A saying I once read on a poster comes to mind: If builders built houses the way programmers write programs, the first woodpecker to …
Read more -
Proper CL Error-Handling
May 5, 2004 Hey, Ted
When a CL program produces an unexpected error, we find the problem, fix it, and take option “I” (ignore) or “R” (retry) in response to the error message. However, when a user runs a program and encounters an unexpected error, we run into problems. The user might call us. The user might not call us. The user may pick the wrong option and really mess things up. What can we do?
–Sandra
You can prevent the user from seeing an inquiry message when something goes wrong. The first thing you need is a global monitor message (MONMSG) command that branches
-
Closing Files in ILE Service Programs
May 5, 2004 Hey, Ted
We’re moving all our new development to RPG IV and ILE, and as part of this process we are looking at putting our commonly used processes into service programs. Many of these functions require access to database files. For example, one function would retrieve the price of an item according to the area in which it is being sold, the date for which the price is applicable, and whether any discounts have been set up. This is quite a complicated procedure, and we want a simple function we can call that will prevent us having to code it separately each
-
Keep Your Users Informed
April 28, 2004 Hey, Ted
Although we run an ERP package, we have plenty of homegrown programs that fill holes in the package. Most of them produce reports that the package doesn’t offer us. Sometimes a user keys runtime information into a prompt screen and presses a function key to submit a request to batch. However, if the results don’t come off the printer PDQ, the user may submit another request, thinking the first one was not accepted. How can we inform the user that the request was received?
–George
Your problem reminds me of something I’ve noticed: that homegrown software often does a poor
-
Find Database Records with Invalid Dates
April 28, 2004 Hey, Ted
We store dates in YYYYMMDD format in packed decimal fields in our database. This served us well when we wrote all our applications in green-screen RPG. Now that we’re using other technologies, invalid dates (like all zeros, all nines, or April 31) cause us problems. Is there a way in SQL to test the validity of a date? Something similar to RPG’s TEST op code with the D extender would be great.
–Kenny
I don’t know of an SQL function that will tell you whether a numeric field contains a valid date, so I wrote one.
Use the method of
-
Make a CL Program or Module Retrieve Its Name
April 21, 2004 Hey, Ted
As if I didn’t have enough to do, I wasted an hour on a wild goose chase. A user contacted me when a program cancelled. The message she received told her that program XYZ had ended abnormally. It took me a while to determine that program ABC had cancelled instead. It turned out that ABC was a clone of XYZ and still included the following, misleading CL command.
SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA('Program + XYZ ended abnormally') MSGTYPE(*ESCAPE)
I would like to make CL programs determine their own names, so that I can make sure each program reports the correct name
-
Using Filters in the Remote Systems LPEX Editor
April 7, 2004 Hey, Ted
I have recently started to use the WebSphere Development Studio client (WDSc) LPEX editor to maintain RPG programs, and so far I am enjoying the experience. I would like to share a tip with readers of Four Hundred Guru who, like me, are working their way through the LPEX learning curve.
–Lynn
When editing with SEU, I often use the X and XX line commands to exclude lines that I do not wish to see. After issuing these commands, I can use SEU’s Find command or the Find/Change Options menu to display selected lines. LPEX has additional filtering capabilities that
-
Determine Elapsed Days, Weekdays, and Workdays
March 31, 2004 Hey, Ted
Finding the number of days between two dates is a common requirement in IT shops. We have a method that works well for us. It lets us include or exclude holidays and weekends.
We have a calendar file that has a record for every date between January 1, 1940, and December 31, 2039. It has quite a few fields, but the three that pertain to this discussion are DATE, DAYOFWEEK, and HOLIDAY. DATE is the date itself, defined with the date data type. DAYOFWEEK is a one-digit packed decimal number in the range 1 (Sunday) to 7 (Saturday), the same
-
Why Use the Magic Number in Qshell Scripts?
March 17, 2004 Hey, Ted
I have not worked with Unix, so Qshell is a new adventure for me. I am curious about the “magic number,” the #! comment that shell scripts typically begin with. It appears to me that Qshell doesn’t care whether you include the comment. Is that true? If so, is there a reason why I should include the magic number?
–Jim
It’s true. Take a look at the process Qshell goes through to execute a script.
When you type a script name and press Enter, Qshell starts a new job and asks the system to run the script. The system reads