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:
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:
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 type||RPG III (I/II)||RPG IV fixed||RPG IV free|
|Conditional statement||IFxx, ELSE||IF, IFxx, ELSEIF, ELSE||IF, ELSEIF, ELSE|
|Conditional operator||ANDxx, ORxx||ANDxx, ORxx|
|Selection||SELEC, WHxx, OTHER||SELECT, WHEN, WHENxx, OTHER||SELECT, WHEN, OTHER|
|Looping, conditional||DOUxx, DOWx||DOU, DOUxx, DOW, DOWxx||DOU, DOW|
|Exit||RETRN||RETURN, LEAVESR||RETURN, LEAVESR|
|Line labels||TAG (ENDSR)||TAG (ENDSR)|
|Error handling||MONITOR, ON-ERROR||MONITOR, ON-ERROR|
|Subroutines||BEGSR, ENDSR||BEGSR, ENDSR, BEGACT, ENDACT||BEGSR, ENDSR, BEGACT, ENDACT|
|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.
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.
|General line format||1-5||6||7-(80)|
|line#||C||Ctrl Lvl||Indicators (3)||Factor1||Operation||Factor2||Result||Ext||Resulting Indicators||Comment|
|General line format||1-5||6||7-(100)|
|line#||C||Ctrl Lvl||Indicator||Factor1||Operation||Factor2||Result etc.||Resulting Indicators||ignored||Comment|
|line#||C||Ctrl Lvl||Indicator||blank||Operation||Extended Factor2||Comment|
|line#||blank||Code in free format||Comment|
|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 Oy – Visustin Help