Site hosted by Angelfire.com: Build your free website today!
RPG/400 for the AS/400. Help for your homework. Screenprints of RPG programs and physical files. Links to other RPG sites, and RPG books.

Intro to RPG (Report Generator Program)

Sage Enterprises RPG TUTORIAL

In this programming instruction course you will learn the fundamentals for using the programming language RPG to describe data processing problems. Before we begin, let us look at RPG a little closer.

In April of 1964, International Business Machines introduced the System/360 family of computer systems. That announcement included not only the introduction of the third generation of computer hardware, but included a series of significant software nnouncements as well. During that period of time the modern version of RPG (REPORT PROGRAM GENERATOR) was announced. RPG was a programmming language initially designed to provide the user of computer systems with an efficient, easy to use technique for developing computer programs for the solution of business oriented problems. To program in RPG the user was required to complete a series of entries on predefined specification forms that basically defined the input, processing, and output to be produced. The need for writing extensive instructions that directed the computer in each logical step was not necessary.

As with all programming languages, RPG has experienced an evolutionary growth. As the needs of the users became known, additional features and more powerful capabilities were added to the original RPG language until, in 1970, RPG II was announced. RPG II is a new and more powerful version of the original RPG and included within the language is the ability to control when input and output take place, more flexibility in controlling report formatting, array processing capability, simplification of coding, and numerous other features providing for more sophisticated processing techniques.

From this inception in 1964, RPG has been widely used as the language of choice on several of I.B.M.'s systems which include the System 3, 34, 36, 38, and most recently the AS/400. Other computer manufacturers over the years have also offered on their equipment this high level language compiler.

With the advent of the ever changing micro computer industry and its ability to process more and faster computers, RPG is now available on such systems. Though not widely accepted yet, we do find its ever increasing use as RPG mini computer shops down size or find advantages for their programmers to use RPG on their personal computers.

LITTLE KNOWLEDGE OF PROGRAMMING

The tutorial on RPG is designed with the assumption you have little computer knowledge. Therefore, even thought we will not bore you by dwelling on the rudimentary computer concepts, we will touch upon some basic elements.

HOW TO USE THIS TUTORIAL
This tutorial is written in such a way that the student should sit before his/her computer and study each unit or chapter by displaying it on the monitor or reading the text which corresponds to it. Each chapter is presented in sets of instructions, question, and answers. (Refer to ANSWER.TXT for each chapters answers.)

HOW RPG WORKS

Each object program that the RPG compiler generates goes through the same general cycle of operations. The phrase 'program cycle' refers to the operations that are performed for each record read.

RPG PROGRAM CYCLE

The program cycle involves three basic logic steps:

Within each program cycle, these basic logic steps can be divided into numerous substeps in which you as the programmer can assign indicators to control when calculation and output operations occur.

According to RPG program logic, calculation and output operations are performed at two different times in a cycle: total time and detail time. First, the program performs total calculation operations (those conditioned by a control level indicator in columns 7 and 8 of the calculation specifications) and total output operations (those specified by a T in column 15 of the output specifications). Second, the program performs all detail calculation operations (those not conditioned by a control level indicator in columns 7 and 8 of the calculation specifications) and all detail output operations (those specified by a D or H in column 15 of the output specifications).

Total calculation and total output operations are generally performed on data accumulated for a group of related records that form a control group. A control group is a set of records all having the same information in a control field. Each time a record is read, the program checks the information in th control field to determine whether it differs from the control field information on the previous record. When the information differs from the previous record's control field, a control break occurs, indication that all records from a particular group have been read and a new group is starting. When all records from a control group have been read, the program performs total calculation and output operations using the information accumulated from all records in that group. Information contained in the record that starts the new control group is not used in the total operations.

Detail calculation and detail output operations are generally performed for each record read if all conditioning indicators are satisfied. If either of the following conditions is met, detail calculation and output operations are performed:

A program cycle begins with step 1 and continues through step 11, then begins again with step 1. Steps 7 and 8 are known as total time, and steps 1 and 11 are known as detail time. The following statements describe the steps.

STEP 1.
If the conditioning indicators are satisfied, RPG performs the heading or detail output (those lines having an H or D in column 15 of the output specifications).

STEP 2.
RPG turns off all control level and record identifying indicators.

STEP 3.
RPG reads a record and turns on the appropriate record identifying indicator.

STEP 4.
RPG determines whether a control break occurred. (A control break occurs when the control field of the record just read differs from the control field of the previous record.)

STEP 5.
If a control break has occurred, RPG turns on the proper control level indicator and all lower control level indicators except L0, which is always on.

STEP 6.
If this is the first cycle, RPG goes to step 9.

STEP 7.
RPG performs total calculation operations (those conditioned by control level indicators in columns 7 and 8 of the calculation specifications) if the appropriate control level indicators are on.

STEP 8.
RPG performs total output operations (those lines having a T in column 15 of the output specifications) according to output specifications.

STEP 9.
RPG determines whether the LR indicator is on. If it is, all records have been processed, and the program ends.

STEP 10.
RPG makes data from the record read at the beginning of the cycle (step 3) available for use in detail calculation and output operations.

STEP 11.
RPG performs all detail calculation operations (those not conditioned by control level indicators in columns 7 and 8 of the calculation specifications) on the data from the record read at the beginning of the cycle.

The first and last cycles of a program differ somewhat from the other cycles. Before the first record is read in the first cycle, the program prints lines conditioned by the 1P (first page) indicator and also performs any heading or detail output operations having no conditioning indicators or all negative conditioning indicators. Heading lines printed before the first record is read might consist of constant or page heading information or fields for reserved words, such as PAGE and UDATE. In addition, the program bypasses total calculations and total output steps.

During the last program cycle, when no more records are available, the LR (last record) indicator turns on, automatically causing all control level indicators to turn on. The program performs the total calculations and total output, and the program ends.

Where to Next?

RPG Home
Recommended RPG Books
RPG Links Pge
Back to the PowerPoint Page

Email: csadewater@excite.com

This Page Brought to you by Randy's Guitar Clinic
Click Here To Learn to play guitar!


Shawn Colvin - One of my favorite singer-songwriters. Check her out if you haven't!


Jackson Browne - My other favorite singer-songwriter.
He inspired me to be a musician. Thank you Jackson!



Jimmy Buffett - Get me a Corona and a Cheeseburger!


An Epic Adventure told entirely in verse


Find out where I'm playing next


Click here for My Tribute to Calvin and Hobbes!



Who wrote The Big Sleep? Click here and find out!


Who wrote The Maltese Falcon? Click here and find out!


Angelfire - Free Home Pages