Вы находитесь на странице: 1из 4

ILE RPG, RPG IV Specifications (H, F, D, I, C and P)

Specifications in RPGLE
The first thing you should know in RPG IV is that RPG IV is a positional language. This means that we
are allowed to write code at specific columns only. In RPGLE every line of code begins with the
declaration of specifications. Actually in RPG IV all types of statements have been categorized. The
specification tells the compiler which category the coming statement falls into. Thats the RPGLE
compiler interprets a specific line of code on the basis of the specification. In RPG IV we have the
following main specifications. All these specifications begin on the 6th column.
There are the following specifications in RPG IV (ILE RPG) .
The H Specification
This specification is used to give the instructions to compiler. For example the data format to be used
within the program. Whether source debugging is allowed or not etc. Now-a-days most of these
compiler instructions are given while compiling the program only. However, the most frequently used
compiler instruction in RPGLE is NOMAIN.
The F Specification
This specification is also known as the File specification. Here we declare all the files which we will be
using in the program. The files might be any of the physical file, logical file, display file or the printer
file. Message files are not declared in the F specification.
The D Specification
We declare all the variables to be used in the program in the D specs. Though we can also declare
the variables on the ad-hoc basis, this is strongly discouraged for it makes the maintenance of huge
programs a miserable task.
The I Specification
I specifications are used to rename some fields or record format names. Now a days renaming of
record formats is done in F-Specs only. To rename a record format in F-Spec we use the keyword
(Rename) as explained in the F Specification section of this tutorial.
The C Specification
This is the most widely used specification. All the calculations take place here. All the file operations,
calculations, Calls to other programs, calls to procedures etc. are done in this specification only. A
typical C-Specification statement looks as below.

The P Specification
These statements mark the boundary of the Procedure. We will learn more about procedures in the
Modules and Procedures and Sub procedures sections. Now that we have had a little idea of an RPGLE
specification we can proceed to our first RPGLE program.






















How to create an RPGLE program
You can create an RPGLE program in any of the following ways.

Method 1: Direct Program Creation
Do a WRKMBRPDM and find the member to be copiled.
Enter the option 14 againt the member and press enter.
Thats It. This is the simplest program compilation method. When you compile with option 14, the
system determines which command it should use to compile the program.
Method 2:Create Program From Modules

We can create a modular program in two steps.
Create RPGLE Modules:- Compile the program to create an RPGLE module. You can compile a
source member into an RPGLE module by entering the option 15 against it.
Alternatively you can create an RPGLE module using the command CRTRPGMOD. To learn the
attributes of CRTRPGMOD take an F4 after writing the command on command line. This will list all
the parameters which this command takes. After this you can press F1 on each of the parameters to
learn what it means.
Create Program from Modules:- Once you have created the rpgle module, you need to create the
program. To create the RPGLE program use the command CRTPGM. This command creates any
program in AS400. You can use this command to create programs from RPGLE, SQLRPGLE, CLLE or
any other type of modules. To create the program you specify the modules which you have created
for this program (Currently only one). Here again you can take F4 and then F1.
Once your program is created successfully, you can run the program using the CALL command. This
command takes the program name and optional entry parameters as input. The syntax of this
command is something like CALL programName.


First RPGLE Program
Create a member "helloworld" in your working source physical file. Give the type of this member as
"RPGLE". Now type the following code in the source member.
C 'Hello World' Dsply
C Return
Now compile the module. Create the program and call it as described in the section how to compile
and create an RPGLE Program. It Will display the phrase Hello World. like this.
DSPLY Hello World
That is a basic RPGLE program but you learn several things as discussed below.
The C specs is mentioned on the 6th place. Other specifications are also specified at this place only.
Other specifications are H, F,D, I and P. (Specifications O and E are RPG specifications)

The text Hello world is written at Factor one position. i.e at the 12th place. At this place we specify
the factor one of any operation code in RPGLE. You will use this factor frequently for declaring
keylists of file and defining parameter list.
The Op codes in RPGLE. The opcodes are placed at the position starting from 26. In the example
above we have used two opcodes dsply and Return.
Dsply This opcode is used to display any text as the output. The program does not stop execution
but halts for a small time. When you press the return key. The subsequent statements are executed.
This opcode can be used to display a text of maximum 52 length.
Return This opcode is a required keyword. When the program runs this statement, it terminates its
execution and returns to the calling program immediately. In the example above the caller is the
system as we have called this program from command line, hence the program will end when it
executes the return statement.

Вам также может понравиться