RPG flow charts

Visustin generates flow charts from RPG I, RPG II, RPG II and RPG IV source code. It supports both legacy and modern RPG (Report Program Generator).

Support was built using the following documents as main sources:

Understanding RPG formats

If you are not familiar with RPG, here is how you determine which format the code is in. RPG I, II and III are always fixed-format. RPG IV can be one of the following:

Supported RPG code

Visustin flowcharts the following code in an RPG file:

Other specifications and data lines appear in the charts "as is".

The following operation codes have a visible effect in the charts generated:

Operation typeRPG III (I/II)RPG IV fixedRPG IV free
Conditional statementIFxx, ELSEIF, IFxx, ELSEIF, ELSEIF, ELSEIF, ELSE
Conditional operatorANDxx, ORxxANDxx, ORxx
Conditional branchCABxxCABxx
Conditional invokeCASxxCASxx
Looping, conditionalDOUxx, DOWxDOU, DOUxx, DOW, DOWxxDOU, DOW
Loop iterationITERITERITER
SubproceduresP specificationsDCL-PROC
Comments* Comment* Comment// Comment

Most other operation codes are handled as regular statements.

The fixed-format fields Control Level, Indicators, Resulting Indicators and Comment are also visualized. They are described below.

Column format

Fully free format code can appear in any column. On the contrary, fixed-format and free-format code must conform to a specific column format. Otherwise they will not visualize correctly.

In modes accepting fixed-format source, a ruler appears above the source code in the main window. The ruler shows the expected column format. The ruler shows the positions of important fields for "C" lines: ":" for Factor 1, Operation Code, Factor 2 and Result, and ">><<==" for Resulting Indicators. Fields for other specifications are not marked.

The following tables describe the column format that Visustin expects. The formats are as per IBM documentation. Many details have been left out. These tables are intended for users who are not experienced with RPG, and users who need to understand how Visustin creates flow charts. They are not comprehensive documentation of RPG columns.

RPG III columns
General line format 1-567-(80)
Comment line 1-5678-
"C" line 1-56 789-12-15-18-2728-3233-4243-525354-56-58- 60-
line#CCtrl LvlIndicators (3) Factor1 Operation Factor2 Result Ext Resulting Indicators Comment

RPG IV columns
General line format 1-567-(100)
Comment line 1-5678-
"C" line 1-56 789-1112-2526-3536-4950-7071-73-75- 77-80 81-
line#CCtrl LvlIndicator Factor1 Operation Factor2 Result etc. Resulting Indicators ignored Comment
line#CCtrl LvlIndicator blank Operation Extended Factor2 Comment
/free format 1-56-78-8081-
line#blankCode in free format Comment
**FREE format 1-
Code in fully free format

The line# columns are ignored by Visustin. This area was originally reserved for punched card number and line number.

The Type column indicates specification type. Visustin recognizes all types but processes only "C" and "P" types.

An asterisk * in column 7 indicates a comment line. Comments may also exist in the Comment field at the end of each "C" line.

The Control Level (7-8) field contains L0-L9 or LR if the line executes at total calculation time (before other lines) if condition L0-L9 or LR is set. This field appears on the flow chart as if it was an additional IF statement for the line.

The Indicator fields can specify "IF" conditions on when the line executes and when not. The Indicator fields appear on the flow chart as if they were additional IF statements for the line.

The Operation fields contains an operation code, which is the actual command to execute. The other columns are for operands and various flags. Flowcharting is based on the contents of the Operation field.

In RPG IV, the fields to the right of Operation depend on the contents of Operation. Most operations expect the first format with Factor2 and the other fields. Certain operations use the longer field "Extended Factor2", which may span one or multiple lines.

The Resulting Indicators fields can be used to set indicators. Indicators are special variables (flags) whose value depends on the result of the operation. Indicators can be used in the Indicators columns to control the execution of subsequent lines. Resulting Indicators, when found, are displayed on the flow chart with a symbol immediately preceding the command that sets them. The symbols are as follows:

+>Resulting Indicator is set for condition Plus, 1>2, High
-<Resulting Indicator is set for condition Minus, 1<2, Low
Z/EQ Resulting Indicator is set for condition Zero, 1=2, Equal


If your RPG code doesn't seem to create a meaningful flow chart, check the following:


The RPG cycle does not appear in the chart. It is implied. Calls to subroutines and subprocedures do not appear as a link. Embedded SQL is supported but its internal structure is not visualized.

When dealing with fixed-format code, a fixed-width font is recommended, yet optional. In order to preserve column format, word wrapping does not occur when the source contains any fixed-format code. In RPG III mode, the Wrap lines option is permanently disabled; in RPG IV it is enabled but wrapping does not occur if some of the code is in fixed-format.

©Aivosto OyVisustin Help