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.
-
Encouraging Mere Mortals
December 16, 2009 Hey, Ted
You’ve got to be kidding, right? I’ve generally thought you were trying to show better approaches for coding issues. Are you advocating falling back to bad fixed-format techniques? The only conclusion that makes sense is that you’re testing the waters to see if anyone’s paying attention. Or just trying to drum up traffic to your site.
What about a data structure that would have performed the split? Or an EVAL operation using built-in functions to convert to character format, substring it, then convert it back to the decimal fields? Both of those wouldn’t rely on the “magic smoke” multiply and
-
Ken Likes FMTDATE
December 2, 2009 Hey, Ted
I immediately loaded and tested your FMTDATE function when I saw it in Four Hundred Guru. I just wanted to say “Thank You!” The tool is fantastic! We have mostly ISO and LONGJUL dates in our files and it is always a pain when converting or throwing math at them. No more!
Here is an example of some date math I tried on a LONGJUL order date and an ISO invoice date to calculate “Days-To-Ship” using your function:
SELECT fmtdate(OrderDate, 'LONGJUL', 'ISO-') Ordered, fmtdate(InvDate, 'ISO', 'ISO-') Invoiced, Date(fmtdate(InvDate, 'ISO', 'ISO-'))- Date(fmtdate(OrderDate, 'LONGJUL', 'ISO-')) FROM ORDERS
–Ken
I got a
-
Message Received, But Not Understood
November 18, 2009 Hey, Ted
I had a problem last week. I was monitoring for error messages after an Add Physical File Member (ADDPFM) command in a CL program. Well, OS/400 sent two CPF messages when ADDPFM failed. MONMSG would only trap the second message, but I wanted to trap the first one because that’s the one that tells me what went wrong. What do I need to do?
–Chris
This seems like a good time to review some messaging fundamentals. Chris is not a newbie programmer, so if he doesn’t understand, there are probably others who don’t understand either.
When a CL command fails,
-
The Case of the Used Unused Object: A Mystery
November 11, 2009 Hey, Ted
Put on your deerstalker hat. I’ve got a mystery for you. We are cleaning up disk and stumbled upon something that has us puzzled. The system tells us that a logical file in a test library has been used many times, and according to the object description, was recently used. None of our programs use the file, and no one has used the test library for a long time. Why does the system tell us we’re using a file that we don’t use?
–Rick
Rick and I solved his mystery with a little effort. There’s something to be learned in
-
Distinguish between Record Types without Indicators
October 28, 2009 Hey, Ted
I have an RPG question. Now that indicators are verboten, how does an RPG program distinguish between record types when reading a multi-format logical file? That is, what do I use instead of record identifying indicators?
–Tricia
Define a file information data structure for the logical file. The system will place the record format name in positions 261-270. Here’s some sample source code to get you started.
CODE1
–Ted
Post this story to del.icio.us
Post this story to Digg
Post this story to Slashdot -
How Do I Find What’s Not There?
October 14, 2009 Hey, Ted
Our inventory items are assigned seven-digit numbers. When we accept an order for a custom product, we assign it a number, build the product, ship it, and retire the number. After a few years, the system automatically purges these numbers, which means we are free to reuse these numbers. Is there a way to make an SQL query find the numbers within a range that are not assigned to items?
–Tim
I’ll give you a method that works at V5R4 or above, Tim.
Let’s say your database file is IBM‘s famous QIWS/QCUSTCDT, and that you want to find available
-
Mass Rename of IFS Files
September 30, 2009 Hey, Ted
I find Qshell a powerful tool for manipulating IFS files, but some Qshell features make me long for my MS DOS batch file programming days. A case in point is the ability to rename files in mass. Let me show you what I mean.
I want to rename the files with a .txt extension so that they have a .csv extension instead. I only want to rename .txt files, and I only want to rename the files in a certain directory. In MS DOS, I would have used a rename command with wildcards in both arguments.
ren *.txt *.csv
Try
-
Let’s Start Over from the Beginning
September 23, 2009 Hey, Ted
We have RPG programs that use SQL cursors to sequentially retrieve data. If a program cancels and I call it again, the program resumes processing a cursor where it left off. I have to sign off and back on in order to restart from the top. Why doesn’t the program start over from the beginning of the returned data set?
–Lynne
The behavior you’re witnessing comes from three contributing factors, Lynne. First, your program was compiled to close the cursor when the activation group is destroyed. Second, your program is running in the default activation group. Third, you are not
-
Use the Dup Key in Subfiles
September 2, 2009 Hey, Ted
I hope you don’t mind another question about the “old” stuff. How do I program for the Dup key in a data entry subfile?
–David
This is a good technique to know, David, and it’s not hard to do.
Let’s start with a simple subfile of 10 records per page. There are three input fields: a date; a customer number; and an amount. Here’s the DDS:
A DSPSIZ(24 80 *DS3) A INDARA A R SFL SFL A SDATE 6S 0I 8 6DUP(31) A SCUST 8A I 8 16DUP(32) A SAMOUNT 7Y 3I 8 30DUP(33) A R CTL SFLCTL(SFL) A SFLSIZ(12)
-
Using Free-Format Calcs with Cycle Programs
August 5, 2009 Hey, Ted
I use free-format calculations for new development and for existing cycle-less RPG programs. However, I have responsibility for some old programs that use the RPG cycle. Is it possible for me to use free-format calcs in those programs?
–Bill
Yes, Bill. In the detail calculations (calcs with no level indicator in columns 7 and 8), use the /FREE and /END-FREE directives as you normally would. In the following example, I have added free-format calcs that are to be executed at L1 detail time (before a new control group) and at detail time (for each input record).
C L1 MOVE *ZERO