A popular development guru, Jon is an IBM Champion and a frequent author, forum contributor, and speaker at User Group meetings and technical conferences around the world, holding a number of speaker excellence awards from COMMON. He is a partner at Partner400 and System i Developer, the organizers of the RPG & DB2 Summit conference. Paris cut his teeth on the System/38 way back when, and in 1987 he joined IBM's Toronto software lab to work on the COBOL compilers for the System/38 and System/36. He also worked on the creation of the COBOL/400 compilers for the original AS/400s back in 1988 and was one of the key developers behind RPG IV and the CODE/400 development tool. In 1998, he left IBM to develop and deliver education focused on enhancing IBM i application development skills with wife Susan Gantner, also an expert in IBM i programming.
March 6, 2019 Jon Paris
Author’s Note: I’m revisiting this classic tip since the original was written back in 2009, long before the introduction of free-form data declarations. In addition, I’ve updated this tip to point to the new %SCANRPL BIF, which impacts this scenario. And, of course, I still regularly encounter RPGers who are confused by the differences between the %XLATE and %REPLACE built-in functions (BIFs). Part of that confusion of course is the result of wishful thinking on the part of those frustrated by the limitations of %XLATE!
The first thing to remember when deciding which function to use is that %XLATE operates …Read more
February 13, 2019 Jon Paris
Author’s Note: The reason I chose this particular tip to revisit was that a similar question came up on one of the RPG web forums the other day. The questioner was looking for an easy way to edit a numeric field to include the use of colons as separators. Because the answer involves the use of %EditW I have added a simple example of its use at the end of this tip.
“I need to convert a numeric value into a character string. How do I . . . ?” This question is often asked by RPGers as they face …Read more
February 11, 2019 Jon Paris
Recently I came upon a couple of questions on internet lists asking for an easy method to create flat files in the IFS. Not CSV files, but rather simple text files where individual data items are in fixed character positions. Various somewhat convoluted solutions were offered to the requestors, but to me this problem shouted “Open Access!”
So, I set about quickly building an Open Access (OA) handler to perform the task. I find OA really useful for this kind of job because, once the handler is written, creating these kinds of files in the future become a trivial task, …Read more
January 16, 2019 Jon Paris
Many RPG programmers seem to get confused about the usage and operation of a number of built-in functions (BIFs). In particular the BIFs %XLATE, %REPLACE, %SCAN, and %CHECK seem to cause a lot of confusion. In this tip, I focus on %CHECK and %SCAN. I decided to re-visit this particular tip because of the recent introduction of %SCAN’s companion BIF %SCANR and a related enhancement to %SCAN itself. More on this later.
The %SCAN BIF has been with us since V3R7, when it was introduced along with %EDITC and %EDITW, to improve string handling. %CHECK, on the other hand, is …Read more
November 26, 2018 Jon Paris
When is an error not an error? When it is expected! In this article I want to discuss the use of RPG’s MONITOR op-code and discuss ways in which it might change the way you code RPG. I was prompted to write up my thoughts on this subject as a result of being quizzed by students at a recent RPG & DB2 Summit as to why I was using Monitor blocks rather than more conventional RPG techniques in my examples.
So what do I mean by expected? Basically I mean those errors that you know are going to happen …Read more
September 5, 2018 Jon Paris
Author’s Note: In part 1 and part 2 of this XML series, I introduced you to the basics of using RPG’s XML support. In this tip we begin to explore some of the challenges that you may face when processing commercial XML documents, and the support XML-INTO offers to handle them. In particular we will be reviewing how to ignore parts of the document through the use of the path= %XML option. We will also review how to handle XML documents that make use of namespaces and how to handle XML element names that include characters that are not valid …Read more
August 29, 2018 Jon Paris
In the first part of this series for Guru Classic, I introduced you to the basics of using RPG’s XML-INTO op-code. In that tip I showed how the provision of a count provided by RPG in the PSDS can be used to determine how many of a repeating element were processed.
However, as I noted at the time, this can only be used when handling a repeating outer element. But what if there is a repeating element within each of those outer elements? In this second part of the series we will be studying how to handle those situations. …Read more
August 1, 2018 Jon Paris
Author’s Note: The original version of this article was written in the V6 timeframe and included references to V5R4. References to the V5R4 limitations have been removed from this updated version. I have also updated the data definitions to take into account RPG’s ability for the direct coding of nested data structures rather than having to use LikeDS as before.
RPG IV’s built-in XML support has been available for some time now, having been originally introduced with V5R4 back in 2006. However, it wasn’t until the advent of V6 with its removal of many of RPG’s size limits that it …Read more
June 18, 2018 Jon Paris
In this tip I’m going to give a brief introduction to the latest addition to the RPG language. The new DATA-INTO op-code. DATA-INTO is IBM’s response to the oft-asked question: “When is IBM going to introduce JSON-INTO so we can process JSON as easily as XML?”
DATA-INTO provides this capability, but IBM has very cleverly given it functionality that goes way beyond what a simple JSON-INTO op-code could ever have done. DATA-INTO is effectively a cross between XML-INTO and Open Access. Like XML-INTO it uses the names of items and their hierarchy to unpack the document into RPG variables. Like …Read more
April 9, 2018 Jon Paris
From time to time, many of us have to find solutions for handling our old non-normalized tables in an efficient manner. It would be nice to have the luxury of redesigning and normalizing these databases, but real life is not like that. This is particularly true when the tables in question are part of an application package where you have no control over the file layout.
I should point out that by “efficient” in this context I don’t necessarily mean processing speed, but rather in terms of the number of lines of code needed to perform the necessary manipulations and/or …Read more