Sunday, October 21, 2012

Getting a better knowledge of ILE RPG

I'm willing to answer questions occasionally. The question today is "How can I develop my programming skills and get a better knowledge of RPG IV?"


First, get and read "The Modern RPG IV Language" by Robert Cozzi, Jr. (the link takes you Barnes & Noble; the Nook version is less expensive). A confession: I haven't read this book but I like what I've heard about it.

Second, download the "WDS RPG Language Reference" (SC09-2508) and "WDS RPG Programmer's Guide" (SC09-2507) from IBM (select the appropriate version based on the version of IBM i you're using). I'm going to post a guide to IBM manuals soon but, until then, start with the IBM i and System i Information Center and you should be able to find them. (Note that the current country is at the top and you can change it if you wish.) The Language Reference is the authoritative manual for everything you want to know about RPG IV (also know as ILE RPG) but it doesn't try to tell you how to do something. The Programmer's Guide is more of guide of how to do things. Update Oct. 23, 2012: I have written a blog entry on the programming manuals you need for version 7.1.

Third, you should use an interactive (non-green-screen) editor for your programming. The choices are too complicated to go into here. In addition, I recommend that all new programs be written in free format.

Fourth, understand that writing code is not all there is to programming. You must understand file operations against the database and how locking works (both of records and objects). And you will need to be able to figure out how best to write the code for each specific project.

Finally, there are some things you should not learn about. The RPG Cycle is one of these. Originally, back in 1965, you needed to know the cycle. Today, not at all. If you have to maintain a program using the cycle, track down a old timer like me with a good memory and I will help you (at the standard billing rate, of course).

Another thing is rather important to me. In college, I was taught structured programming (also known as GOTO-less programming), as advocated by Edsger Dijkstra, and have not written an RPG program with a single GOTO in it since 1976. But IBM, not caring what one of the greatest computer scientists advocated, added additional non-structured operation codes to RPG. The basic concept of structured programming is that every section of code should have one but only one entry point and one but only one exit point. If you write an RPG program for me, you will not use these operation codes:

CABxx   (Compare and branch)
GOTO    (Go to)
ITER    (Iterate)
LEAVE   (Leave a do/for group)
LEAVESR (Leave a subroutine — Allowed only if just before an End Subroutine)
RETURN  (Return — Allowed but only once per program or procedure and used carefully with *INLR or *INRT)
TAG     (Tag)

After reading the book, manuals and this information, you should be able to develop your programming skills. After writing 100 programs, you might get fairly good at this!



No comments:

Post a Comment

Well-thought-out comments by intelligent people are encouraged. Other comments will be deleted or not approved. Note that anonymous comments are allowed; feel free to include your handle in your comment.