RPG Declarations

To use variables and constants in RPG they needs to be declared before used. This can be done internally in each program but can also be done by referring to external definitions such as tables, prototypes and copy sources.

To declare in modern free format RPG this is done with the keyword DCL.

Declaration Description Example
dcl-s Declaration of a variable dcl-s   x int(5);
dcl-c Declaration of a constant

dcl-c  cTrue ‘1’;
dcl-c  cFalse’0′;

dcl-ds Declaration of a data-structure

dcl-ds  Person;
     FirstName varchar(128);
     LastName varchar(128);

dcl-f Declaration of a file for native access