.st0{fill:#FFFFFF;}

RPG Code Specifications 

 October 10, 2004

By  NickLitten

EDIT: 2014: NOTE- this is an OLD blog from over ten years ago. Most of it is complete Guff now that we live in the world filled with freeformat RPG code πŸ™‚

The first thing you should know in RPG3 or RPG400 is that it 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 RPG400 all types of statements have been categorized. The specification tells the compiler which category the coming statement falls into. That’s 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.

NickLitten


IBM i Software Developer, Digital Dad, AS400 Anarchist, RPG Modernizer, Shameless Trekkie, Belligerent Nerd, Englishman Abroad and Passionate Eater of Cheese and Biscuits. Nick Litten Dot Com is a mixture of blog posts that can be sometimes serious, frequently playful and probably down-right pointless all in the space of a day. Enjoy your stay, feel free to comment and remember: If at first you don't succeed then skydiving probably isn't a hobby you should look into.

Nick Litten

related posts:

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}
__CONFIG_colors_palette__{"active_palette":0,"config":{"colors":{"cff50":{"name":"Main Accent","parent":-1},"a344d":{"name":"Accent Transparent","parent":"cff50"}},"gradients":[]},"palettes":[{"name":"Default","value":{"colors":{"cff50":{"val":"var(--tcb-skin-color-0)"},"a344d":{"val":"rgba(46, 138, 229, 0.85)","hsl_parent_dependency":{"h":210,"l":0.54,"s":0.78}}},"gradients":[]},"original":{"colors":{"cff50":{"val":"rgb(0, 178, 255)","hsl":{"h":198,"s":1,"l":0.5}},"a344d":{"val":"rgba(0, 178, 255, 0.85)","hsl_parent_dependency":{"h":198,"s":1,"l":0.5}}},"gradients":[]}}]}__CONFIG_colors_palette__

Get In Touch

I’m always looking for awesome input, feedback and critique!

>