Page tree

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 16 Current »

Summary: This document provides information about the extension providing RPG support.

Extension ID


What's new?

Please see RPG 2.0 - What's new for more information.


This extension provides support for applications written using RPG languages.

Although this extension is officially supported by CAST, please note that it has been developed within the technical constraints of the CAST Universal Analyzer technology and to some extent adapted to meet specific customer needs. Therefore the extension may not address all of the coding techniques and patterns that exist for the target technology and may not produce the same level of analysis and precision regarding e.g. quality measurement and/or function point counts that are typically produced by other CAST AIP analyzers.

In what situation should you install this extension?

If your application contains source code written using RPG and you want to view these object types and their links with other objects, then you should install this extension.

Supported Versions of RPG

  • RPG III (also known as GAP 3)
  • RPG IV with traditional operation codes
  • RPG IV with alternate Calc spec and Extended Factor 2
  • RPG IV with /FREE directive

Embedded SQL support

Embedded SQL is supported, primarily to obtain Usiud links from RPG400 and CL400 objects to SQL Tables and SQL Views. The resolution of these link types requires that the database (DB2 UDB) is delivered and analyzed, however, the DB400 extractor can be used to simulate this database.

  • The following source code is considered as embedded SQL:
    • For RPG400: C/EXEC SQL … C/END-EXEC
    • For RPG Free Format: EXEC SQL … ;
    • For CL: RUNSQL(…)
  • Dynamic execution is not supported.

Function Point, Quality and Sizing support

This extension provides the following support:

  • Function Points (transactions): a green tick indicates that OMG Function Point counting and Transaction Risk Index are supported
  • Quality and Sizing: a green tick indicates that CAST can measure size and that a minimum set of Quality Rules exist
Function Points
Quality and Sizing(tick)

CAST AIP compatibility

This extension is compatible with:

CAST AIP release




Supported DBMS servers

This extension is compatible with the following DBMS servers:



(tick)An installation of any compatible release of CAST AIP (see table above)

Download and installation instructions

Please see:

CAST Transaction Configuration Center (TCC) configuration

A set of RPG Transaction Entry/End Points, Data Entities and Excluded Items for use in the CAST Transaction Configuration Center is delivered in the extension via a .TCCSetup file. Therefore if you are using:

  • CAST AIP ≥ 8.3.x, there is nothing for you to do: this configuration will be automatically imported during the extension installation and will be available in the CAST Transaction Configuration Center
  • CAST AIP ≤ 8.2.x, you can manually import the file %PROGRAMDATA%\CAST\CAST\Extensions\com.castsoftware.rpg.<version>\RPG.TCCSetup to obtain configuration (see instructions below).

Manual import action for CAST AIP ≤ 8.2.x

  • Locate the .TCCSetup file in the extension folder: %PROGRAMDATA%\CAST\CAST\Extensions\com.castsoftware.rpg.<version>\RPG.TCCSetup 

  • In the CAST Transaction Configuration Center, ensure you have selected the Templates node:

  • This .TCCSetup file is to be imported into the CAST Transaction Calibration Center using either the:

    • File > Import Configuration menu option:

    • Or right clicking on the Template node and selecting Import Configuration:

  • The import of the "RPG.TCCSetup" file will provide you with a sample configuration under Templates (click to enlarge)
  • Now right click any of the imported items and select copy
  • Paste the item into the equivalent node under the Application, for example, below we have copied it into the Application MEUDON:

  • Repeat for any additional items or generic sets that have been imported from the .TCCSetup file.

Prepare and deliver the source code

Once the extension is downloaded and installed, you can now package your source code and run an analysis. The process of preparing and delivering your source code is described below:

Source code preparation

Before the RPG source code can be delivered and then analyzed, it needs to be collected from the proper iSeries libraries and transferred to the designated location. During this operation, each artifact (program, CL, DSPF) must be put into a single file only. This will result in a single artifact per file. Furthermore, the type of source code must be expressed using the extension to the file. The appropriate files extensions are listed in the following table. 

Source code is kept in a member of a file. The file is kept in a library. Each file can have many members. Each member is the source code for a program. The source code files can have any name but conventionally the names start with Q and end with SRC, for source.

Source code type

iSeries library

Required extension

Used in MetaModel

RPG-III programs


*.rpg, *.rpg38


ILE RPG Programs




ILE RPG Programs with SQL




Copy source members




CL programs


*.cl, *.clp, *.cl38, *.clp38


ILE CL Programs




Display Files


*.dspf, *.dspf38


Printer Files


*.prtf, *.prtf38


Logical Files


*.lf, *.lf38


Physical Files


*.pf, *.pf38


Bound service programs








SQL Files

Source code preprocessing

RPG source code needs to be preprocessed so that CAST can understand it and analyze it correctly. In previous releases of the extension, this preprocessing was a manual action that needed to be completed before the code was analyzed. However, in this release and all future releases, the code preprocessing is actioned automatically when an analysis is launched or a snapshot is generated (the code is preprocessed before the analysis starts). In other words you only need to package, deliver and launch an analysis/generate a snapshot for the preprocessing to be completed.

RPG Analyzer provides specific pre-processors for each language embedded in this extension: the preprocessor per language only considers the files with the expected extensions. 

Note that the CAST Management Studio will use the LISA folder to analyze the preprocessed files.

Deliver the source code

Using AIP Console

RPG is supported in AIP Console ≥ 1.22.

AIP Console expects either a ZIP/archive file or source code located in a folder configured in AIP Console. You should include in the ZIP/source code folder all RPG source code. CAST highly recommends placing the files in a folder dedicated to RPG. If you are using a ZIP/archive file, zip the folders in the "temp" folder - but do not zip the "temp" folder itself, nor create any intermediary folders:


The following file extensions will trigger the extractor to process the IBM Db2 for i related files correctly - so ensure that at least one of these is delivered if you have IBM Db2 for i definitions (DDS and/or DDL):

  • .lf
  • .pf
  • .sql
  • .sqli
  • .sqlt
  • .sqlv
  • .sqlu
  • .sqlp

When the source code has been delivered, AIP Console will create:

  • One RPG package with the provided source code. The associated Analysis Unit will end with a suffix as shown below:

  • One RPG DB400 package containing source code with the specific IBM Db2 for i file extensions listed above. The associated Analysis Unit will have a name depending on what has been discovered and will be extracted into a subfolder named as below:

Using the CAST Delivery Manager Tool

  • create a new Version
  • create a new Package for your RPG source code using the Files on your file system option and choose the location of your source code:

Click to enlarge

  • create an additional new package for your Tables and Views using the DB400 extraction option:

Click to enlarge

  • Run the Package action.
  • Before delivering the source code, check the packaging results.

Dependency configuration in the CAST Management Studio

In the Application editor > Dependencies tab, add a dependency between the Universal Analysis Unit as Source and LIB (UDB DB2 schema) as the target

Configuring Technical Size measures for RPG in the CAST Health Dashboard

Technical Size measures can be displayed for RPG analysis results in the CAST Health Dashboard by manually editing the following file:

1.x WAR file: %CATALINA_HOME%\webapps\<dashboard>\portal\resources\app.json
2.x WAR file: %CATALINA_HOME%\webapps\<dashboard>\WEB-INF\classes\config\hd\app.json
2.x ZIP file: com.castsoftware.aip.dashboard.2.0.0\config\hd\app.json

Add the following entries into the existing section "TechnicalSizeMeasures":

"TechnicalSizeMeasures": {
        "id": 1008000,
        "label": "Number of RPG400 Program(RPG400)"
        "id": 1008001,
        "label": "Number of RPG400 Subroutine(RPG400)"
        "id": 1008002,
        "label": "Number of RPG400 Procedure(RPG400)"
        "id": 1008003,
        "label": "Number of RPG400 Copy Member(RPG400)"
        "id": 1009000,
        "label": "Number of RPG300 Program(RPG300)"
        "id": 1009001,
        "label": "Number of RPG300 Subroutine(RPG300)"
        "id": 1009003,
        "label": "Number of RPG300 Copy Member(RPG300)"

Following any changes you make, save the app.json file and then restart your application server so that the changes are taken into account.

Logging mechanism

During the analysis, the Universal Analyzer may throw errors or warnings. The table below lists the most significant errors/warnings and lists a suggested remediation action:

ToolsError/Warning MessageAction
PreprocessorFile 'FileName' is emptyThis is caused by source code that is referring file is empty. You can safely ignore this warning.
PreprocessorUnable to open file 'FullFileName'This is caused by source code that is referring file that cannot be found in the preprocessed code. You can safely ignore this warning.

PF corresponding to the table 'tableName' was not found

This is caused by source code that is referring the Table that cannot be found in the preprocessed code. You can safely ignore this warning.
PreprocessorFile Disk 'FDescName' not found : missing recordThe record will not be created. This is caused by source code that is referring the FDescName that cannot be found in the preprocessed code. You can safely ignore this warning.
PreprocessorFile Disk 'FDescName' not found : renamed record 'RecordName'The record will not be created. This is caused by source code that is referring the FDescName that cannot be found in the preprocessed code. You can safely ignore this warning.
PreprocessorFile Disk 'FDescName: renamed record 'RecordName' doesn't match the DDS record 'RecordName'This is caused by source code that is referring the FDescName that cannot be found in the preprocessed code
PreprocessorError NOMAIN in a PROGRAMThe program will not be preprocessed. Program will not be created
PreprocessorCopy not found 'CopyName'This is caused by source code that is referring the called Copy that cannot be found in the preprocessed code. You can safely ignore this warning.
PreprocessorMissing called program='PgmName'This is caused by source code that is referring the called program that cannot be found in the preprocessed code. You can safely ignore this warning.
PreprocessorError on match if/endif at line 'LineNumber'Object will not be created.
PreprocessorFile does not match RPG III format (RPG IV) This means file is not RPG III and probably is RPG IV.
PreprocessorFile does not match RPG IV format (RPG III) This means file is not RPG IV and probably is RPG III.
AnalyzerUnable to find the object end for type 'RPG400Subroutine' This is caused by source code that is referring to a SubRoutine that cannot be found. You can safely ignore this warning.
AnalyzerUnable to find the regexp for the link 'accessLink'   The link will not be created -
AnalyzerAn unnamed object of type 'RPG400SQLStructure' has been detectedThis is because RPG400SQLStructures have no specific name, as such, the CAST framework will give them the name "unnamed". You can safely ignore this warning.
 AnalyzerDuplicate object of type 'RPG400SQLStructure' has been detected: '<unnamed>'As mentioned above, structures have no specific name and are automatically given the name "unnamed" by CAST - as such multiple objects with the name "unnamed" will exist and will cause this error. You can safely ignore this warning.
 AnalyzerUnable to find the object end for type 'RPG400Rule'This is caused by source code that is referring to a Rule cannot be found. You can safely ignore this warning.
 AnalyzerDuplicate object of type 'MENUItem' has been detected: 'XXXXXX'This is due to a duplicate Menu name in the original Menu file. You can safely ignore this warning.
 AnalyzerWarning after preprocessing the source code- Unknown format for ' A XA3439 R REFFLD(DATM FRFGFDI4)'

Follow Sample Reference Function Specifications

00010A                                      REF(FILE1)    (1)
00020A          R RECORD1
00030A            FIELD1    R                             (1)
00040A            FIELD2    R                             (1)
00050A            FIELD3    R               REFFLD(FLD3)  (2)
00060A            FIELD4    R               REFFLD(FLD4 FILE2)  (3)
00070A            FIELD5    R               REFFLD(FLD5 LIB1/FILE3)  (4)
00080A            FIELD6    R               REFFLD(RECORDB/FLD6 LIB1/FILE4)  (5)
00090A            FIELD7    R               REFFLD(FIELD6 *SRC)  (6)
00100A            FIELD8    R               REFFLD(FLD6)  (7)
00110A          R RECORD2
00120A            FIELD1        20  (8)
00140A          R RECORD3
00150A            FIELD1    R               REFFLD(RECORD2/FIELD1 *SRC)  (9)
00170A          R RECORD4
00180A            FIELD1    R               REFFLD(FIELD1 *SRC)  (10)

Note:For line 00010, you can also specify library name and record format
name. See the REF keyword example/

You must specify R in position 29 for each field that refers to another field that was previously defined.

RPG preprocessor supports only the cases (2) and (7) : Only one parameter for the REFFLD function.

For XXL applications, if any performance issue is experienced during the "Run Extensions at application level" step of the analysis, please contact CAST Support.

What results can you expect?

RPG MetaModel

Below you can find a description of the RPG MetaModel, please click the image to download a full scale PDF version:


The following objects are displayed in CAST Enlighten:


IconObject Name
 MENU Item
MENU Project


IconObject Name
CL400 Program
CL400 Project
CL400 Subroutine


IconObject Name
DB400 Project
DB400 Table
DB400 View

DB400 Library
DB400 Index

DB400 Record


IconObject Name
 DDS400 Project
DDS400 Section
DDS400 PRTF File
DDS400 DSPF File
DDS400 Physical File
DDS400 Logical File
DDS400 RecordstructureLF
DDS400 RecordstructurePF
DDS400 Joinstructure

RPG 300

IconObject Name
RPG300 Project
RPG300 Program
RPG300 MainSubroutine
RPG300 Subroutine
RPG300 File Printer
RPG300 File Disk
RPG300 File Workstn
RPG300 File Special
RPG300 File Seq
RPG300 Rule
RPG300 Copy Member
RPG300 File Disk Record
RPG300 SQL Statement/Structure
RPG300 Data Structure
RPG300 Procedure
RPG300 Local Record Structure

RPG 400

IconObject Name
RPG400 Project
RPG400 Program
RPG400 MainSubroutine
RPG400 Subroutine
RPG400 Subroutine FreeFormat
RPG400 File Printer
RPG400 File Disk
RPG400 File Workstn
RPG400 File Special
RPG400 File Seq
RPG400 Procedure
RPG400 Procedure FreeFormat
RPG400 Procedure Prototype
RPG400 Bound Service Program
RPG400 Copy Member
RPG400 Data Structure
RPG400 File Disk Record

Structural Rules

The following structural rules are provided:

You can also find a global list here:||


False violations reported for the Quality Rule 7388: Avoid artifacts having recursive calls

To cover the dynamic call of programs in CL, for any program name referenced in a variable, a link is created. It also generates a link with the current CL program when the name of the CL program is used in a variable which is used as a parameter in a program call. These types of links are required to reduce the amount of dead code reported by the analyzer and for improved transactions (the recursive call does not affect the transaction graph). 

 However, these links can cause false violations of the Quality Rule "Avoid artifacts having recursive calls - 7388".

This limitation has been removed in RPG 2.0.3

  • No labels