Archive

Archive for April, 2010

RPG and Programming › A Fantasy

April 15th, 2010 Comments off

In an alternative universe:
IBM Toronto
Press Release
April 1, 2010
RPG, from its very inception, has been designed to be an easy to use programming language. Since business data is stored in files, RPG was designed to make reading and writing files easy. To that end, its creators made sure that the processing of files was made easy by its READ and READE and READP operation codes, using a Pascal-like DO loop. Doing subtotals has been accomplished by the programmer storing intermediate data in temporary user-defined fields, then comparing group identifiers with the new identifiers and outputting the results before proceeding. Proper cascading logic enables the user to track multiple group changes that may need to be done at the same time. CHAIN and READ make it possible to easily link related files.

Batch file processing used to be the way to process data; but eventually the report became less important and the screen more so. Now, as SQL is used more and more, with SELECTs and the use of a cursor, pseudo-batch processing has come more into vogue.

With that in mind, we felt it was time to take a radical step to make batch processing more elegant. We have implemented in the latest release of RPGIV a new facility we have chosen to call “the RPG cycle”.

With the RPG cycle, by declaring a file (using new file descriptors in the F specifications) as “primary” or “secondary”, you no longer need to issue explicit READ instructions. The compiler assumes you want to read the file or files from beginning to end. If only one file (primary) is used, you don’t even have to tell the system what file is being referred to. If a secondary file is also used, you use numbered Boolean variables or flags to identify a calculation as being associated with a particular file.

We have also made it possible for the programmer to designate up to nine subgroups for totaling and other calculations associated with the subgroup. If a field designated as a subgroup identifier changes in value, the input data is held in buffers until calculations affecting that subgroup and all lower level subgroups have been completed in ascending level order (from 1 to 9). There is NO need to save data in “hold fields”; the system handles all of that. These field changes are known as “level breaks”, and the calculations associated with them are called “level break calculations”. The changes are referenced or indicated by Boolean variables L1 through L9 (L standing for level). “LR”, now used to designate end of file (Last record) will activate all previous calculations and output for all levels in ascending numerical order.

You can process files one after the other, or you can emulate SQL joins by associating related fields in the files with another Boolean variable called “matching record”, or MR.

You can still use READ and CHAIN to process files, without reference to the cycle; using the new features of the cycle is entirely optional. You can also, within the cycle, read other files using CHAIN and READ operations.

The beauty of the new process is that you don’t have to save the “level break” fields to process group totals. The system takes care of all the details. We have thus created a powerful, flexible system for batch file processing.

Early reports from beta testers indicate a high level of appreciation for, and excitement about, the possibilities of the new process.

Another new feature that has had programmers excited was enhancement of the printing functions of RPG. Now that PDF support has been implemented, the fact that printing is still important has been given more emphasis.

We have been rethinking the whole print process, in an attempt to make it easier. In particular, it was felt that page overflow could be handled more elegantly. With this in mind, a new concept called “fetch overflow” has been implemented.

Suppose you have heading output that depends upon your overflow indicators, defined as Boolean variables OA through OG, plus OV. With an appropriate entry in your output specifications, you no longer have to test for overflow in your calculations and write code to generate the output. The system checks whether overflow has occurred when the detail output is about to print. If it detects the overflow flag on, it outputs the heading lines designated to print at page overflow, then prints the detail line that triggered the process.

If you set on the overflow flag in your *INZSR subroutine, your first page headings will print the very first time a detail line set for “fetch overflow” is encountered. Page control then becomes almost completely automatic. You no longer have to use EXCEPT output to print headings.

Of course, you can still generate headings by testing for overflow manually, or you can count lines on the page. RPGIV retains flexibility in this area.

We are extremely proud of the innovations in this release, and we are confident that the user community will also be happy with them.

The IBM RPGIV Compiler Team

Update: April 15, 2010

Reaction to the upgrades has been enthusiastic, even exuberant. A typical response has been “We love it! It’s great! RPG READ and SQL DECLARE CURSOR are so 20th century.”


Read the original at RPG and Programming.

Categories: Blogs Tags: , ,

RPG and Programming › Who’s the Best Programmer Around? Not Me

April 12th, 2010 Comments off

My recent experience on the forum on Bob Cozzi’s RPGIV website underlined the fact that I am not in contention for the title of “World’s Best RPG Programmer”. I posed a question that involved the use of APIs and prototypes, and I submitted my sample code. I got my question answered, but not before it was made very clear to me that my abilities as to APIs and prototyping were considerably below cutting edge.

How do you get to be a good programmer? You have to be intelligent, which can mean you have to know when to be as stupid as the computer. You have to be intolerant of errors. And you have to be willing to learn from your mistakes, as you will make thousands of them.

But beyond these basic qualities and attitudes, other circumstances may determine how deeply you will get into the more arcane aspects of your chosen programming language that will allow you to be among the “best”.

For one thing, your circumstances have to be such that you are exposed to advanced programming techniques. This will likely also be a function of your intellectual curiosity. But perhaps just as importantly, your circumstances have to be such that you will actually have a need for these techniques. You may never be in a position where you will need to access user spaces. While you may see some benefit to variable length fields, you may not see any burning need to start using them. And while much of the benefit of ILE is built around things like APIs and prototypes, it may well occur that your site simply does not need a wholesale conversion of code to make use of called procedures.

As it happened, my experience above came as a result of a need for them. Two-digit years are still used on my system. In calculating the maturity date of a 30-year loan written in 2010, I bumped up against the ILE default for two-digit date fields (1940 to 2039) and got an “invalid date” error when I attempted to generate 3/15/40 to represent 2040. To get around this, I decide to use an API I was aware of, CEESCEN, which allows you to float the 100 year range you want to use for the 100-year period in question. This is used in association with APIs CEEDAYS and CEEDATE to allow you to format dates in numerous different formats. (Google the API names for details.)

However, I was not familiar with how to set up the prototypes needed, and as a result I made some stupid mistakes that leaped out at the knowledgeable participants in the forum, especially Bob. But anyway, with some help, I got the prototypes and program calls to work.

But my learning things like these are in response to a specific need. I don’t have a burning need to learn all or even a substantial portion of the APIs available. I simply don’t need them. The fact is that I am getting paid to write production code, not specifically to “learn new things” . And the fact is also that I am not in a position where I can spend a lot of time outside the workplace learning new stuff, since family and other personal needs and circumstances have first claim on my time.

Other people, by reason of education, career choices, and the employers they happened to have, may have had open to them early in their careers opportunities to work on truly advanced concepts that I never was exposed to and likely never will be. Of course, their being smarter than me, not to mention better educated early on, would also make this more likely :-) My task being to maintain and upgrade code that was from the 1980’s and 1990’s in style, if not always in vintage, I will likely be kept busy doing that for the balance of my career. I like to think I’m good, but I’ll never be the best.


Read the original at RPG and Programming.

Categories: Blogs Tags: , , ,

ile rpg programming: tips and techniques › Sample code: How to create radio buttons in display files

April 12th, 2010 Comments off
This articles shows a basic example of how to code the display file to create single or multiple choice radio buttons.  The code sample starts with the display file (RADIOFM) and is followed by...

Visit site to read full content and more



Read the original at ile rpg programming: tips and techniques.