Wednesday, December 2, 2015

Trying fully free RPG

fully free rpg

Thanks to the guys at RZKH.DE I was able to try the new fully free RPG this weekend. The latest Technology Refreshes to IBM i 7.2, TR3, and 7.1, TR11, finally brought what can only be described a completely free RPG. Even though "all free" RPG that came in IBM i 7.1 TR7, it was still restricted to be used between the eighth and 80th columns. With these TRs it is no limited by any column restrictions, and I can use any position from the first to the last of the source member.

I thought it would be a good idea for me to share my first impressions of what I have found using "fully free" RPG, covering what I think is good and not so good.

The RZKH.DE informed me that the PTFs necessary for "fully free" was not part of the PTFs they downloaded for the TR3 upgrade to the IBM i 7.2 server.

You will need to have the following PTFs applied on your server to be able to use this:

PTF number Description
7.2 SI58137 RPG compiler, current target release
SI58110 RPG compiler, previous target release
Group SF99702 level 9 SQL precompiler
7.1 SI58136 RPG compiler, current target release
Group SF99701 level 38 SQL precompiler

There is no previous release support for 7.1

You can check the status of these PTFs on your server using the SQL View PTF_LOD. If I wanted to check if the RPG PTFs have been loaded to an IBM i 7.2 server I could use the following SQL statement:

         WHERE PTFID IN ('SI58137','SI58110')

For more information on this View see the post Quick way to find if PTF present and applied.

When coding "fully free" RPG I need to start with the compiler directive **FREE, starting in the first position of the source member. The code of all subsequent lines can start anywhere on the source member's line. See the example below:

     ...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7
01  **FREE
02  dcl-s Message char(30) inz('This is great!') ;
03  dsply Message ;
04  Message =                                'Now I can really be FREE!' ;
05  dsply Message ;

06  *inlr = *on ;

The **FREE compiler directive does not have to be upper case, I can use **free too.

What happens when I mix free format RPG with fixed format? For example:

     ...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+...
01  **FREE
02  dcl-s Incoming char(30) ;
03       C     *entry        plist
04       C                   parm                    InComing
05  dsply Incoming ;

06  *inlr = *on ;

This code does not compile, giving me the message below for line 3, as fixed format code cannot be entered after the **FREE.

RNF5347 30  An assignment operator is expected with the EVAL operation.

But fixed format can be used before the **FREE, see below. But any free format code before the **FREE is restricted to the range of the eighth to the 80th column, see line 1.

     ...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6
01         dcl-s Incoming char(30) ;
02       C     *entry        plist
03       C                   parm                    InComing
04  **FREE
05  dsply Incoming ;

06  *inlr = *on ;

With "fully free" RPG I am no longer restricted to use a source file a record length of 112. I can create the largest source file possible, record length of 240, and use that:


In the example below line 5 starts are the 205 position of the source member. I would not recommend making source files with such large record lengths, I just wanted to show what was possible.

     ...+... 1 ...+... 2 ...   //   200 ...+... 1 ...+... 2 ...+...
01  **free
02  dcl-s Message char(30) ;
03  Message = 'First line' ;
04  dsply Message ;
05                                        Message = 'Second line' ;
06  dsply Message ;
07  *inlr = *on ;

I did find documented a way to get around not being able to use fixed format code after the **FREE. It described you would have to use external members containing the fixed format code, what would be copied into a "fully free" member using either /COPY or /INCLUDE. For example:

01  **free
02  dcl-s Incoming char(30) ;

03  /copy mylib/devsrc,rpgcpy1

04  dsply Incoming ;

05  *inlr = *on ;

When compiled the external member is copied into my member. If I look at compile listing I see:

dcl-s Incoming char(30) ;

/copy mylib/devsrc,rpgcpy1
<--------------- Source Specifications ----------------->
 * RPG member name  . . . . . :  RPGCPY1                *
 * External name  . . . . . . :  MYLIB/DEVSRC(RPGCPY1)  *
 * Last change  . . . . . . . :  DD/DD/DD  TT:TT:TT     *
C     *entry        plist
C                   parm                    Incoming

dsply Incoming ;

*inlr = *on ; 

This is another reminder from IBM that it is time to let go of fixed format code, and embrace the free format equivalents.

I think this move to finally free RPG is a big step forward for the language, finally removing it from the restrictions imposed by punch cards all those many years ago. I can see that the inability to insert fixed format code into a "fully free" member will stop some from adopting this, which is a shame and I wish that IBM would have allowed fixed format lines after the **FREE.

Will you start using "fully free" RPG? Let me know your thoughts in the comments below.


You can learn more about the **FREE compiler directive from the IBM website here.


This article was written for IBM i 7.2 TR3 and 7.1 TR11, and later releases.


  1. As soon as I am able, does rational developer have any issues with the new all free?

    1. A very good question.
      I do not have a RDi licensed to use with the RZKH's IBM i server so I cannot say.

    2. I have 9.6 and it works a hell lot better than the SEU. Still doesn't convert any specification except C specs, and that too with those eye sores "/free" and "/end-free". Worth the pain to remove them, I guess.

  2. RDi actually supported the fully-free syntax with V9.5. It effectively pre-announced the compiler enhancements when the announce cycles got out of sync.

    P.S. Compiler updates are never _part_ of a TR - they are just commonly announced at the same time. So the required PTFs will never be included in TR sets.

  3. P.P.S. It you have a license to RDi Simon you can connect to any number of servers - so you are free to use yours with RZKH's system.

  4. Our user group ( had a session on RDi delivered by IBM and it was apparently ready before the IBM I was ready.

  5. What name does RPG go by that has free format H,F, and D specs? All Free RPG?

  6. I wrote my first fully free RPG program after reading a 4 part article titled "The Geezer's Guide" from Jon Paris published last year in ITJungle's Four Hundred Guru. However it is always helpful to hear on the same topic from a different speaker. It raises new points, show new angels, and help understand better. Thank you Simon

    1. You are welcome. I agree it is always useful to have several sources.

  7. Like always a wonderfully written piece. I've not had the pleasure to write fully free RPG as we're upgrading the i piecemeal at the moment, but we're already enjoying the benefits of all free RPG on 7.2 TR1.

  8. Great article, I have been trying to make full free format work but after installing PTF's, Rdi still only shows 80 columns. If i type past the 80 column mark, the editor beeps and issues msg that only 80 columns are allowed.

    Can anyone assist?

    Thank you

    1. You need to be using RDi 9.5 Anonymous. You don't say which version you are currently using.

      You also need to code:


      In the first 6 positions of the first line in the source. Once you have done that only free-form code can be used. If any fixed form is required (e.g. O-Specs) then they must be included via /Copy.

      Hope that helps.

  9. I am having issues compiling SQLRPGLE with **FREE. Are there know issues with **FREE and embedded SQL?


  10. What if I would like to end the free and start fixed format RPG again? For example, I need to insert a 100 - line code in between an existing code of 1000 lines which is in fixed format. Is there any compiler directive like "**END-FREE" ?

    1. Alas, once you go "fully free", with the **FREE, you cannot go back to using fixed format in the same source unless you include it in a /COPY member.

      /FREE and /END-FREE we "retired" in IBM i 7. TR7. You no longer need them.

  11. hi guys,
    excuse my, I have V7R1M0 into my iSeries.
    I created in myLib a PF-SRC 112 lenght, for full free source what type of source is right? RPGLE?

    1. The source file should be 112 or longer.

      The default source types should be RPGLE or SQLRPGLE.

    2. hi Simon, thank you, I did it, with F6 get my RPGLE source I try to write this:
      01 **free
      02 dcl-s Incoming char(30);
      and press enter I get error: column 6 mast be H or F or C... etc
      any suggestions?

    3. Check this post out as it explains how to turn off syntax checking: Using SEU with totally free RPG

    4. The above link does not work. Try here

  12. hi simon,
    It gives error on my system for **free.
    My PTFs are also in place.
    What else should I check?
    Message is: Form-Type entry for main procedure not valid or out of sequence.

    1. I think you will find that the post Using SEU with totally free RPG explains how to turn off syntax checking.

    2. This link is no longer working... "Using SEU with totally free RPG"

    3. Blogger changed the way the links in comments works.
      Try here

  13. IBM hasn't made all RPG syntax elements to equivalent free form. So fix form code will stay until IBM free them completely. But it seems IBM doesn't intend to free all RPG yet.

    1. Which RPG syntax elements do not have free format equivalents?

  14. I'm a Java developer and trying to learn RPGLE. I have a problem, is that fully free format can do anything like fixed format? is there any restrictions using fully free format or not?

    1. Everything you can do in fixed column RPG you can also do in free format RPG.
      Providing your IBM i has the right release and PTFs there is no reason why you cannot jump right in and be free!

    2. Basically, RPG Full Free Format is the younger, sexier version of the Fixed Format. IBM had to go with the modern times and columnized programming language didn't appeal to many.

      I recently had my RPG training, we started in Free Format (the one where everything except C lines are in fixed) and eventually ended up using Full Free Format.

      In my opinion, this brings RPG to the same level of modernization as "younger" languages.

    3. The reason for fixed columns goes back to the days of punch cards!


To prevent "comment spam" all comments are moderated.
Learn about this website's comments policy here.

Some people have reported that they cannot post a comment using certain computers and browsers. If this is you feel free to use the Contact Form to send me the comment and I will post it for you, please include the title of the post so I know which one to post the comment to.