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:

IBM i
release
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:

  SELECT PTFID,LOADSTAT FROM QSYS2/PTF_INFO
         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:

  CRTSRCPF FILE(QTEMP/QTEMPSRC) RCDLEN(240)

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:

**free
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.

15 comments:

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

    ReplyDelete
    Replies
    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.

      Delete
  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.

    ReplyDelete
  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.

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

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

    ReplyDelete
  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

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

      Delete
  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.

    ReplyDelete
  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

    ReplyDelete
    Replies
    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:

      **FREE

      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.

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

    ReplyDelete
    Replies
    1. http://www-912.ibm.com/n_dir/nas4apar.nsf/c79815e083182fec862564c00079d117/fa2f5bd27cc132f086257f1c0041ecdb?OpenDocument&Highlight=2%2CSE63525

      Delete
  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" ?

    ReplyDelete
    Replies
    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.

      Delete

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.