Now, Get RPG Codes in all three formats only on this website on every RPGLE related programming article.

Fixed, /Free and Fully Free RPG


Define H,F,D,P specs in fully free RPG AS400

Define variables in fully free RPG AS400
Define H, F, D, P specs in fully free RPG AS400
Define H, F, D, P specs in fully free RPG AS400

RPG Free-form Support in AS400

Before moving to the defined variables using free form operation code DCL-S, just to give you a brief idea about RPG Free-form support in AS400. Only H(Control), F(File), D(Definition), C(Calculation), and P(Procedure) specs are supported to code in Free Format. I(Input) and O(Output) specs are still not supported in free-form RPG.

Each free-form statement starts with the operation code and ends with a semicolon. Here is the list of all the new operation codes.

  1. CTL-OPT for H specs (Control)
  2. DCL-F for F specs (File)
  3. DCL-S, DCL-DS, DCL-SUBF, DCL-C, DCL-PR, DCL-PI, DCL-PARM for D specs (Definition)
  4. DCL-PROC for P specs (Procedure)

Advantages of using Fully Free RPG

RPG Free-format syntax is easily understandable by others and also similar to other modern programming languages. We can specify free form code in the form of free form statements rather than specified fixed positions. we can easily code long names in free form RPG and it is still restricted to 8-80 columns however, /Free and /End-Free is not required to code.

Defined H specs in Fixed RPG vs Free form RPG

Here we defined H specs control statements in RPG fixed format and their respective free format. We use CTL-OPT operation code for free form control statements, followed by zero or more keywords same as allowed on H specs(control specs), and ends with a semicolon.

Using H specs only in fixed vs free RPG

  • Fixed RPG
  •      H
    
  • Free RPG
  • CTL-OPT;

    Using H specs additional control statements in fixed vs free RPG

    Below are some possible H specs in Fixed vs Free RPG statements. There are many more to it.

  • Fixed RPG
  •      H DEBUG(*YES)
         H OPTION(*NODEBUGIO:*SRCSTMT:*NOSHOWCPY)
         H COPYRIGHT('WWW.AS400andSQLTricks.com')
         H DFTACTGRP(*NO) ACTGRP(*CALLER) 
         H BNDDIR('BNDDIR1')
         H NOMAIN
         H ALWNULL(*USRCTL)
         H FIXNBR(*ZONED:*INPUTPACKED)
         H DATFMT( *ISO )
         H TIMFMT(∗ISO)
         H CCSID(∗UCS2 :1200)
    
  • Free RPG
  • CTL-OPT DEBUG(*YES);
    CTL-OPT OPTION(*NODEBUGIO:*SRCSTMT:*NOSHOWCPY);
    CTL-OPT COPYRIGHT('WWW.AS400andSQLTricks.com');
    CTL-OPT DFTACTGRP(*NO) ACTGRP(*CALLER);
    CTL-OPT BNDDIR('BNDDIR1');
    CTL-OPT NOMAIN;
    CTL-OPT ALWNULL(*USRCTL);
    CTL-OPT FIXNBR(*ZONED:*INPUTPACKED);
    CTL-OPT DATFMT( *ISO );
    CTL-OPT TIMFMT(∗ISO);
    CTL-OPT CCSID(∗UCS2 :1200);
    

    Define F specs in Fully Free RPG

    Refer to the F specs definition in all free w.r.t fixed format RPG from the below link.
    Define F specs in fully free RPG AS400

    Define D specs in fully free RPG AS400

    Refer to the D specs definition in all free w.r.t fixed format RPG from the below link.
    Define D specs in fully free RPG AS400

    Define P specs in Fixed RPG vs free RPG

    . The free-form procedure statement declaration starts with DCL-PROC, and is followed by a name, then by an optional return type, and then by zero or more keywords, and ends with a semicolon.

    An END-PROC statement (with an optional name) must be specified.

    A procedure Begin and End in Fixed and Free format

  • Fixed RPG
  •      P ADD             B            
         P                 E            
    
  • Free RPG
  • DCL-PROC ADD;  
    END-PROC;
    

    Post a Comment

    © AS400 and SQL Tricks. All rights reserved. Developed by Jago Desain