RPG, RPGLE, RPG 400

AWS Transform for mainframe refactor supports RPG (Report Program Generator) dependencies analysis in the mainframe group. It detects dependencies among programs (e.g. RPG, RPGLE) as well as other file types (e.g. CL, PF, LF…).

Properties attached to RPG dependencies (procedureName on "Call procedure", RPG.fileUsage, RPG.fileAddition and RPG.fileDelete on file declarations) are described in the Dependency properties page.

Traditional Statements

Direct dependency

Logical dependencies

CALL

The CALL statement implies a dependency on a CL or an RPG file.

  • CALL PROGRAM in .RPG and .RPGLE files
  • CALL(EXTENDERS) PROGRAM in .RPG and .RPGLE files. There can be one or several extenders among A, H, N, P, D, T, Z, M, R, E.

Where PROGRAM can be a raw string or a prototype declared with EXTPGM or EXTPROC, either in the same file or in a copybook included with /COPY or /INCLUDE.

CALLB

The CALLB statement implies a dependency on a CL or an RPG file.

  • CALLB PROGRAM in .RPG and .RPGLE files
  • CALLB(EXTENDERS) PROGRAM in .RPG and .RPGLE files. There can be one or several extenders among A, H, N, P, D, T, Z, M, R, E.

Where PROGRAM can be a raw string or a prototype declared with EXTPGM or EXTPROC, either in the same file or in a copybook included with /COPY or /INCLUDE.

CALLP

The CALLP statement implies a dependency on a CL or an RPG file.

  • CALLP PROCEDURE in .RPG and .RPGLE files
  • CALLP(EXTENDERS) PROCEDURE in .RPG and .RPGLE files. There can be one or several extenders among A, H, N, P, D, T, Z, M, R, E.

Where PROCEDURE can be a raw string or a prototype declared with EXTPGM or EXTPROC, either in the same file or in a copybook included with /COPY or /INCLUDE.

Procedures can be declared in RPG files:

  • Global: P PROCEDURE B EXPORT
  • Local: P PROCEDURE B
  • An implicit procedure is declared for each .RPG or .RPGLE file
IF / EVAL / EVALR / DOU / DOW / WHEN

The IF, EVAL, EVALR, DOU, DOW and WHEN statements imply a dependency on an RPG file when a procedure is called inside their expression.

  • IF PROCEDURE(arg) in .RPG and .RPGLE files
  • EVAL result = PROCEDURE(arg) in .RPG and .RPGLE files

Where PROCEDURE is a procedure declared in an RPG file, as for CALLP.

EXTPGM

The EXTPGM statement defines a variable but also implies a dependency on the EXTPGM part.

  • D myVar PR EXTPGM(PROGRAM)

Where myVar is the name of the declared variable and PROGRAM is the name of a file in the project.

Inclusion dependencies

COPY
  • COPY FILE
  • COPY LIBRARY,FILE

Where LIBRARY is the name of a library and FILE is the name of a file in the project.

INCLUDE
  • INCLUDE FILE
  • INCLUDE LIBRARY,FILE

Where LIBRARY is the name of a library and FILE is the name of a file in the project.

Resource dependencies

CHKMSGID / MSGID

The call on CHKMSGID or MSGID in a DSPF file implies a dependency on a .MSGF file.

  • CHKMSGID(ERR0001 MESSAGEFILE)
  • CHKMSGID(ERR0001 LIB/MESSAGEFILE)
  • MSGID(ERR0001 MESSAGEFILE)
  • MSGID(ERR0001 LIB/MESSAGEFILE)

Where MESSAGEFILE is the name of a MSGF file in the project.

DTAARA

The call on DTAARA implies a definition of a Data Area object.

  • DTAARA(DATAOBJECT)
  • DTAARA('DATAOBJECT')
  • DTAARA("DATAOBJECT")
  • DTAARA(path/to/DATAOBJECT)
  • DTAARA DEFINE DATAOBJECT
  • DTAARA DEFN DATAOBJECT

Where DATAOBJECT is the name of the defined object.

EXTNAME

The call on EXTNAME implies a dependency on any other file.

  • EXTNAME(filename)

Where filename is the name of a file in the project.

FLINE
  • Ffilename (C|I|O|U)

Where filename is the name of a file in the project.

The call on FLINE can imply a dependency on a PRTF, PRT, LF or PF file if the file definitions are not included in the RPG program by I/O lines.

  • Ifilename are for input files defined with a C, I or U flag
  • Ofilename are for output files defined with a C or O flag

The "F line" dependency also carries the file's usage as edge properties, from the fixed-format F specification:

RPG.fileUsage the access mode from column 17: Input (I), Output (O), Update (U) or Combined (C).     
RPG.fileAddition set to Add when the File Addition flag (position 20) is A on an input/update file (records can also be added). RPG IV only; RPG III / RPG 400 uses a different F-spec layout and is not read for this flag.     
RPG.fileDelete set to Delete for an Update file, which is implicitly delete-capable in fixed format.

Example:

FCDACTU01  UF A E           K Disk

Output:

{
 "dependencyType": "F line",
 "name": "CDACTU01",
 "path": null,
 "type": "Missing DDS",
 "properties": {
     "RPG.fileUsage": "Update",
     "RPG.fileAddition": "Add",
     "RPG.fileDelete": "Delete"
 }
}
FORMAT

The call on FORMAT implies a dependency on a PRTF, PRT, LF or PF file.

  • FORMAT(ddsFile)

Where ddsFile is the name of a file in the project.

HLPPNLGRP

The call on HLPPNLGRP implies a dependency on a PNLGRP file.

  • HLPPNLGRP('DETAIL' pnlgrpFile)
  • HLPPNLGRP("DETAIL" pnlgrpFile)
  • HLPPNLGRP('DETAIL' path/to/pnlgrpFile)
  • HLPPNLGRP(TITLE pnlgrpFile) with TITLE a variable containing the title of the panel.

Where pnlgrpFile is the name of a file in the project.

HLPRCD

The call on HLPRCD implies a dependency on a record file.

  • HLPRCD('DETAIL' recordFile)
  • HLPRCD("DETAIL" recordFile)
  • HLPRCD('DETAIL' path/to/recordFile)
  • HLPRCD(TITLE recordFile) with TITLE a variable containing the title of the panel.

Where recordFile is the name of a file in the project.

JFILE / PFILE

The call on JFILE or PFILE implies a dependency on a PRTF, PRT, LF, PF or DDS file, an SQL table or an SQL view.

  • JFILE(ddsFile)
  • JFILE(*LIBL/ddsFile)
  • JFILE(*CURLIB/ddsFile)
  • JFILE(LIBNAME/ddsFile)
  • PFILE(ddsFile)
  • PFILE(*LIBL/ddsFile)
  • PFILE(*CURLIB/ddsFile)
  • PFILE(LIBNAME/ddsFile)
  • JFILE(ddsFile1 ddsFile2 ...)
  • JFILE(path1 path2 ...)
  • PFILE(ddsFile1 ddsFile2 ...)
  • PFILE(path1 path2 ...)

Where ddsFile is the name of a file in the project.         
*LIBL – Search for the target file name in all libraries and establish the dependency with all matches         
*CURLIB – Search for the target file name from the root of the source file path; a dependency link is created for the matched target         
LIBNAME – Search for the folder named LIBNAME from the root of the source file path and get the list of matched target files         
If LIBNAME is not found during the analysis, a Missing library node named LIBNAME is created.

It’s possible to have several arguments in the JFILE or PFILE statement separated by space.         
path1 and path2 refer to any combination of the library path.         
Example:         
PFILE(*CURLIB/ddsFile1 LIBNAME/ddsFile2)         
PFILE(LIBNAME1/ddsFile1 LIBNAME2/ddsFile2 LIBNAME3/ddsFile3)

REF

The call on REF in a DDS source (PF, DSPF, PRTF) implies a "REF" dependency on the referenced file.

REF(ddsFile)
REF(LIBNAME/ddsFile)
REF(ddsFile recordFormat)
REF(LIBNAME/ddsFile recordFormat)

Where ddsFile is the name of a PF, LF, PRTF, DSPF or DDS file in the project. LIBNAME (*LIBL, *CURLIB or a library name) and recordFormat (a record format inside the referenced file) are accepted and do not imply any dependency: only the file is resolved. A file that is not in the project is reported as "Missing DDS".

Example: REF(*LIBL/PF_FILE1 PFREC1)

Creates:

{
    "dependencyType": "REF",
    "name": "PF_FILE1.PF",
    "path": "pf/PF_FILE1.PF",
    "type": "PF"
}
REFFLD

The call on REFFLD implies a dependency on a PRTF, LF, PF or DDS file.

  • REFFLD([recName/]refName [libName/]ddsFile)

Where ddsFile is the name of a file in the project, refName is mandatory and doesn’t apply any dependency, recName and libName are optional and don’t apply any dependency.

External Data Structure

The call on E DS implies a dependency on a PRTF, LF, PF or DDS file.

  • Ifilename  E DSddsFile

Where ddsFile is the name of a file in the project and filename doesn’t apply any dependency.

QDDS and QDDSI files

A physical file named filename.pf will be linked to a file named prefix.filename.qdds if it exists.

A logical file named filename.lf will be linked to a file named prefix.filename.qddsi if it exists.

Dynamic dependencies

In RPG, it is possible to store an entity name in a constant and use it in any type of dependency.

Constant definition

D CONST_NAME C CONST('PROG_TO_CALL')

This constant named CONST_NAME can be used to call PROG_TO_CALL.

Transparent constant

I 'PROG_TO_CALL' C CONST_NAME

This constant named CONST_NAME can be used to call PROG_TO_CALL.

Eval statement

Variable definitions can be reassigned with the EVAL statement as:

C EVAL MY_VAR = 'PROG_TO_CALL'

This new value of MY_VAR can be used to call PROG_TO_CALL.

SQL statement

Computation line

In RPG computation lines (C) a SQL query starts with Exec SQL and ends with End-Exec. All lines starting with + are continuations.         
00000C/Exec SQL Update USER         
00000C+ Set LAST-NAME = "DOE"         
00000C+ Where NAME = "JANE"         
00000C/End-Exec

Refer to the SQL dependencies documentation for further information.

RPG Free form

There are three ways to write Freeform statements in RPG:

  • Put a space in columns 6 and 7 for a one line Freeform statement
  • Use /free and /end-free markers to surround several Freeform statements
  • Start the source file with **free to have a full Freeform source file

COPY/INCLUDE

COPY and INCLUDE statements have the same behavior as in traditional RPG.

Prototype declaration statement

Usage of dcl-pr implies a dependency on any other file.

  • dcl-pr external-program
  • dcl-pr prototype-name EXTNAME('external-program')

Where external-program is the name of a file in the project. Calls made through prototype-name resolve to external-program.

File declaration statement

Usage of dcl-f implies a dependency on a PRTF, LF, PF or DDS file.

  • dcl-f dds-file
  • dcl-f printer-file printer

Where dds-file is the name of a LF, PF or DDS file in the project, and printer-file is the name of a PRTF file in the project.

A free-form dcl-f declaration also carries the file usage as edge properties, from its usage(...) keyword:

  • RPG.fileUsage: Input (*INPUT), Output (*OUTPUT), Update (*UPDATE), or Combined. usage(*input:*output) is device-aware: Combined on a WORKSTN device, otherwise Input (with addition).  
  • RPG.fileAddition: Add when the usage allows adding records (*UPDATE or *INPUT with *OUTPUT on a non-WORKSTN device). 
  • RPG.fileDelete: Delete when *DELETE is listed (in free form *DELETE must be explicit; *UPDATE alone does not imply delete).

When usage(...) is omitted, the device default applies: DISK/SEQ/SPECIAL → Input, PRINTER → Output, WORKSTN → Combined.

Example:

dcl-f UPDDELF usage(*update:*delete);

Output:

{
 "dependencyType": "Declare file",
 "name": "UPDDELF",
 "path": null,
 "type": "Missing DDS",
 "properties": {
     "RPG.fileUsage": "Update",
     "RPG.fileDelete": "Delete"
 }
}

Data structure declaration statement

Usage of the dcl-ds statement implies a dependency on a LF, PF or DDS file.

  • dcl-ds dds-file EXT
  • dcl-ds local-alias extname('dds-file')

Where dds-file is the name of a LF, PF or DDS file in the project.

Procedure declaration statement

Usage of the dcl-proc statement implies a dependency on a procedure declared internal or external (global).

  • dcl-proc procedure-name
  • dcl-proc procedure-name export

Where the export clause refers to the procedure declared external, with a global scope.

Calling Procedure

Calling the procedure (internal or external) in free form differs from traditional RPG:

  • procedure_name();
  • procedure_name(some_data);

procedure_name is defined either in a traditional or in a free-form statement. Refer to the procedure declaration statement.

SQL statement

In a Free Form section, a SQL query starts with Exec SQL and ends with ;.         
/Free         
Exec SQL Update USER         
Set LAST-NAME = "DOE"         
Where NAME = "JANE";         
/End-Free

Refer to the SQL dependencies documentation for further information.