The original contents of this page have become obsolete, go to this page for up-to-date information.
Advice about programming, operations, communications, and anything else I can think of
The original contents of this page have become obsolete, go to this page for up-to-date information.
I recently received a message asking about subfiles:
I know this is a stupid question and I have done this a million times before, but I'm just blocked now and can't figure out what is wrong. My subfile is fully loaded, it is a few pages long. Enter was pressed on a second page, so I need the same page displayed when control is passed back to the subfile. For some reason it goes back to the first page.
The questioner must be asking about a "expanding" or a "load all" type of subfile, as this would not be an issue in the "page a time" subfile.
Fortunately there is a quick, and easy, solution for this problem by the addition of one line of code to the display file's source and a just two lines to the RPGLE/RPG IV's source.
If like me you have been patiently waiting like a child waits for Santa Claus, today is the day Technical Refresh 7 (TR7) for IBM i 7.1 officially becomes available.
You can see what is included in this Technical Refresh in an earlier post I wrote called IBM i Technical Refresh 7.
It is available as a group PTF, MF99007, you can view the PTF Cover Letter here.
In my opinion the most anticipated part of TR7 is the changes made to RPG/free. Now the Control (H), File (F), Data Definition (D), and Procedure (P) specifications are all in free format. Input (I) and Output (O) specifications remain in fixed format.
I thoroughly enjoyed yesterday's presentation by the IBM i (AS400) Virtual User Group called Modern RPG - a look at the new and improved free form and other modernization thoughts which is available for download as a PDF here.
And tomorrow is release date for IBM i 7.1 Technical Refresh 7!
Having discussed in previous posts about how to generate pseudo-random numbers using the CEERAN0 API in RPG and the SQL RAND function I received an email showing me a third way to do it, using a C function.
I would like to thank Bob Schmalandt for sending me the example program upon which this post is based upon.
There are two C functions that generate a pseudo-random number, and they both work in the same way.
In my examples below I will be using rand.
I found an interesting post written by Hans Boldt, who was part of the team that developed RPG/free at IBM in Toronto, Canada. In it he gives us a brief glimpse into some of the decisions and processes involved in creating RPG/free.
It all started more than twenty years ago, back when RPG IV was being designed. At the time, there were two distinct schools of thought. On one side, there were people who insisted RPG should have a fully free-form syntax. On the other, were those who strongly believed that RPG should remain in its traditional fixed-form layout.
He reminds us that RPG/free is no longer new as it was released 12 years ago in V5R1, and ILE RPG/RPGLE/RPG IV 18 years ago in V3R1.
You can read it here: A Short History of Free-Form RPG
In September I wrote about a problem I had encountered where I had to rename one field in a file, and not rename the other fields, in Renaming one field in a file in RPG. I achieved this using RPG's Input specification, I-spec. BlueBull posted a comment on the post explaining that I could have used the EXTFLD keyword in the Data Definition specification, D-spec, to do the same.
In this post I will show how I would use the EXTFLD to rename a field, and determine if it would fit the scenario I used in my previous post.
I have received an email asking me the following question:
How can I validate numbers in RPGLE /free without using testn?
I have spent a considerable amount of time dealing with data from Microsoft Excel spreadsheets that has been uploaded to the IBM i (AS400). It is easy to use the TESTN operation code to test ideally formatted "00123456", but what about "123456 " or "1,234.56 "?
It is always good to find others who agree with one of your opinions. This week I felt really good to find that two eminent IBM i (AS400) folks share my opinion on the importance of User Groups.
Jon Paris and Susan Gantner wrote a post on the IBMSystems Magazine blog called "Kindred Spirits in the IBM i Community".
There's a lot to be said for kindred spirits getting together. It will be no surprise to readers of our blog that we're big believers in local IBM i user groups.
I have nothing further to say except to give you the link to this post: Kindred Spirits in the IBM i Community
I received an email from Mark Watts to introduce the Metro Midrange Systems Association (MMSA) from Texas.
"The Metro Midrange Systems Association is a community of IBM midrange users serving Dallas/Ft. Worth and the surrounding North Central Texas Area," Mark explained.
You can check their website at www.metromidrange.org
I have also added this link to the IBM i user groups page. You will find a link to the user groups page at the top of every page of this website, or you can click here.
Feel free to check out which user group is closest to you.
If you know of a group which is not on the user groups page use the Contact form, on right, to send me its details.
There are times for statistical or testing reasons you need a random number. Computers have always struggled to generate truly random numbers, therefore, they use a process called psuedorandomness. Which is defined by Wikipedia as:
A pseudorandom process is a process that appears to be random but it is not. Pseudorandom sequences typically exhibit statistical randomness while being generated by an entirely deterministic causal process.
But how generate one on an IBM i (AS400)?
QCMDEXC is a useful API, that has been around since the launch of the AS400 (IBM i), that is called to execute a single command. It is one of the simpler APIs to call with just two parameters:
I have seen many examples of RPGLE/RPG IV source code that looks something like this:
01 D CmdString S 132 02 D CmdLen S 15 5 03 /free 04 CmdString = 'CLRPFM TESTFILE' ; 05 CmdLength = 15 ; 06 /end-free 07 C call(e) 'QCMDEXC' 08 C parm CmdString 09 C parm CmdLength 10 /free 11 if (%error) ; |
The programmer has gone "out" of RPG/free, line 6, to be able to CALL QCMDEXC, as the CALL operation is not supported in RPG/free.
On line 7 the programmer has used the 'E' operation extender to stop the program erroring if an error was encountered by QCMDEXC, such as TESTFILE not being in the library list or the file is in use by another job. Then they have gone back "into" RPG/free, line 10, before performing a test to see if there is an error, line 11. But what was the error?