Skip to main content

Advantages of using Free-format RPGLE

Advantages of Using Free-Format RPGLE

IBM has always been focusing on making the RPG easy for Non-RPG Programmers. One such Important move is introducing the Free-Format into RPG for C-Spec. 

Introducing Eclipse based RDi is another biggest move. This encourages young developers in learning RPG like any other web based languages. RDi has an addition to convert your Fixed Format code to Free-Format. 

Almost after a Decade of Introducing Free-Format, IBM took major Step to Convert RPG into Full-Free format.

As a Core RPG Developer, I can say this as 'Really Huge' change to the way how RPG was being coded and how the RPG has become now. This has changed its way from RPG II, RPG III and to Full-Free Format.

We will have a quick look at the Major advantages of Using Free-Format RPGLE in this article.

  • Readability
  • Efficient use of Space
  • New Features Specific to Free Format
  • Easy to Understand/Maintain


  • No need to stick to specific columns and thinking about the limitations of Factor or Extended Factor for writing any calculations.
  • Maintaining Proper Indentation makes easy for Analyzing the code.
  • Declaring Variables with Proper Meaning. E.g.: 'IsPurchaseOrderFulfilled' makes more Sense than 'IsPOfulfld'.  This helps understanding the Purpose of Variable and Logic.

Efficient Use of Space:

  • Biggest Advantage of Full-Free format RPGLE is making efficient use of Space instead of Restricting to work from 6th Position to 80th Position. Code can be written Starting from 1st Position.
  • Free Format Declarations allows to Declaring the large variable names in a single line by avoiding ellipsis (...) in D-Spec.
  • Business Logic will appear clean in Free Format and can save the number of lines coded compared to Fixed Format.

New Features to Free Format:

  • Defining Keys directly in Chain/Setll instead of maintaining the KLIST. This helps eliminating multiple KLIST entries and Code looks cleaner for Modification/Analysis.
  • EXCEPT keyword can be avoided with Free-Format Specific %Fields(). This eliminates the O-Spec and Fields can be mentioned directly with UPDATE Keyword.

Easy to Understand/Maintain:

  • Free-Format File declarations has changed the way of File Declarations in F-Specs. You no longer need to remember the Position & Possible Values. This can be as simple as your Variables Declaration.
  • No need to follow the sequence. Variables can be declared in middle of File Declarations. This helps declaring the Stand alone fields used for file processing to be defined immediately after File Declaration.
Not to Miss, It helps young developer to understand RPG quickly and learn.


Popular posts from this blog

All about READ in RPGLE & Why we use it with SETLL/SETGT?

READ READ is one of the most used Opcodes in RPGLE. As the name suggests main purpose of this Opcode is to read a record from Database file. What are the different READ Opcodes? To list, Below are the five Opcodes.  READ - Read a Record READC - Read Next Changed Record READE - Read Equal Key Record READP - Read Prior Record READPE - Read Prior Equal Record We will see more about each of these later in this article. Before that, We will see a bit about SETLL/SETGT .  SETLL (Set Lower Limit) SETLL accepts Key Fields or Relative Record Number (RRN) as Search Arguments and positions the file at the Corresponding Record (or Next Record if exact match isn't found).  SETGT (Set Greater Than) SETGT accepts Key Fields or Relative Record Number (RRN) as Search Arguments and positions the file at the Next Record (Greater Than the Key value). Syntax: SETLL SEARCH-ARGUMENTS/KEYFIELDS FILENAME SETGT  SEARCH-ARGUMENTS/KEYFIELDS FILENAME One of the below can be passed as Search Arguments. Key Fiel

What we need to know about CHAIN (RPGLE) & How is it different from READ?

CHAIN READ & CHAIN, These are one of the most used (& useful) Opcodes by any RPG developer. These Opcodes are used to read a record from file. So, What's the difference between CHAIN & READ?   CHAIN operation retrieves a record based on the Key specified. It's more like Retrieving Random record from a Database file based on the Key fields.  READ operation reads the record currently pointed to from a Database file. There are multiple Opcodes that start with READ and all are used to read a record but with slight difference. We will see more about different Opcodes and How they are different from each other (and CHAIN) in another article. Few differences to note.  CHAIN requires Key fields to read a record where as READ would read the record currently pointed to (SETLL or SETGT are used to point a Record).  If there are multiple records with the same Key data, CHAIN would return the same record every time. READE can be used to read all the records with the specified Ke

Extract a portion of a Date/Time/Timestamp in RPGLE - IBM i

%SUBDT Extracting Year, Month, Day, Hour, Minutes, Seconds or Milli seconds of a given Date/Time/Timestamp is required most of the times.  This can be extracted easily by using %SUBDT. BIF name looks more similar to %SUBST which is used to extract a portion of string by passing from and two positions of the original string. Instead, We would need to pass a value (i.e., Date, Time or Timestamp ) and Unit (i.e., *YEARS, *MONTHS, *DAYS, *HOURS, *MINUTES, *SECONDS or *MSECONDS) to %SUBDT.  Valid unit should be passed for the type of the value passed. Below are the valid values for each type. Date - *DAYS, *MONTHS, *YEARS Time - *HOURS, *MINUTES, *SECONDS Timestamp - *DAYS, *MONTHS, *YEARS, *HOURS, *MINUTES, *SECONDS, *MSECONDS Syntax: %SUBDT(value : unit { : digits { : decpos} }) Value and Unit are the mandatory arguments.  Digits and Decimal positions are optional and can only be used with *SECONDS for Timestamp. We can either pass the full form for the unit or use the short form. Below i