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-ds | Declaration of a data-structure |
dcl-ds Person; |
dcl-f | Declaration of a file for native access |