Keeping up to date
By Pascal Jacquemain, Search400.com expert
By submitting your personal information, you agree that TechTarget and its partners may contact you regarding relevant content, products and special offers.
A thread about RPG cycle on a well-known AS/400-dedicated Web site grew out of proportion recently. Some messages even involved verbal violence. One programmer had asked what this strange P on F specification was. Another programmer explained the specification and said it was best to stay away from this old technology -- the RPG cycle. I innocently asked why one should keep away from the RPG cycle, and the debate started.
With a headline such as "Keeping up to date," you might expect me to tell you to dump this odd cycle and use more modern programming techniques that can be easily understood by all programmers. Well, that isn't the case. I do use the cycle from time to time, and I think it still has a lot to offer. But you can modernize other aspects of your programming.
Seeing that IBM recommended the use of new variable types such as signed integers (type I) and unsigned integers (type U), I quickly made them features of programs I write or revise. They are supposed to give you better performance than the usual packed fields. Signed and unsigned integers are similar to binary format fields, but they have shed some of the range limits imposed on binary fields. And that makes them better-suited to be used as parameters or fields to retrieve file information data structure. Another nice enhancement IBM provided is the introduction of the good old FOR loops that Basic programmers have used for a long time. Instead of using the DO loop, you can now use a FOR loop, which has the added advantage of working up and down.
An example with DO:
C Start Do End Occur . . processing . C Enddo Step
An example with FOR:
C For Occur = Start to End Step Step . . processing . C Endfor
In both examples, the start and step are optional. Both have a default value of 1.
In this situation, at least, I have kept up to date with my programming techniques. However, by using a For loop with the Occur field defined as an unsigned integer while the End field was packed, I came across a slight problem. The program did not work properly. I checked everything and could not find any fault. I decided to debug, and the first thing I realized was that the loop ran only once. I then checked the Occur value and was surprised to see that after going through the loop once, the value changed to 47 after the Endfor.
I may have been up to date on my coding, but someone else was not up to date with his. My next step then was to find a PTF (program temporary fix). A visit to http://as400serivice.ibm.com revealed that a PTF (SF62366 for version V4R4M0 now updated by PTF SF63038) corrects the problem. It also showed that I had two choices: install this PTF or change my program. In this case, the change was either to use a good old DO loop instead of FOR or make sure all variables in the FOR loop were all integer or all packed. I decided to go for DO loops.
This isn't the first such problem I have encountered. It just goes to show that to ensure your AS/400 is in good shape, you need to from time to time check whether a new cumulative is available and install it. One should also be on the lookout for HIPER PTFs that correct problems that, according to IBM, should not wait for the next cumulative to be fixed.
And if you aren't responsible for PTF maintenance, check with the appropriate team and make sure it is done properly. It may save you from some bad headaches.
Pascal Jacquemain is an analyst/programmer at Gulliver Travel in London. In addition, he has worked as an AS/400 instructor.