Contact Us
 
More Info
 

Free Form Conversion Example

With version 5.0 of the RPG Toolbox, it can now convert most fixed format specifications (H, F, D, C and P) into free form syntax. Below is an example of how the RPG Toolbox converts fixed format RPG source code to totally free form RPG. This version of free form was supported by the RPG compiler in IBM i V7R1 technology refresh 7.

Before conversion:
H* Control Specifications
HDATFMT(*USA) COPYRIGHT('LINOMA SOFTWARE')

F* File Specifications
FCDLCM1    IF A E           K DISK    RENAME(CDRCM:CDRCM2)

D* Data Structure
DPhoneDS          DS
D AreaCode                1      3
D Prefix                  4      6
D Last4                   7     10

D* Stand-alone fields
D TotalTax        S              9  2
D INVTOTAL        S              7  2

C     *LIKE         DEFINE    CMCRLM        CRLIMIT
C* Chain to Customer file
C                   MOVE      '000001'      CMIDNO
C     CMIDNO        CHAIN     CDLCM1                             99
C* Found-> Process credit limit
C   99              MOVE      CMCRLM        CRLIMIT
C   99              EXSR      PROCESS
C* Return to caller
C                   SETON                                        LR
C                   RETURN
C* Process credit limit
C     PROCESS       BEGSR
C     CRLIMIT       IFGT      10000
C                   SETON                                        61
C                   MOVEL     'ABC COMPANY' CMNAME
C     CRLIMIT       SUB       INVTOTAL      REMAIN            9 2
C                   END
C                   ENDSR
 
After:
  // Control Specifications
  CTL-OPT DATFMT(*USA) COPYRIGHT('LINOMA SOFTWARE');

  // File Specifications
  DCL-F CDLCM1 DISK(*EXT) USAGE(*INPUT : *OUTPUT)
        KEYED RENAME(CDRCM:CDRCM2);

  // Data Structure
  DCL-DS PhoneDS;
    AreaCode CHAR(3);
    Prefix CHAR(3);
    Last4 CHAR(4);
  END-DS;

  // Stand-alone fields
  DCL-S TotalTax PACKED(9 : 2);
  DCL-S INVTOTAL PACKED(7 : 2);
  DCL-S CRLIMIT LIKE(CMCRLM);
  DCL-S REMAIN PACKED(9 : 2);
  // Prototype for PROCESS
  DCL-PR PROCESS;
  END-PR;

  // Chain to Customer file
  CMIDNO = '000001';
  CHAIN CMIDNO CDLCM1;
  *IN99 = NOT %FOUND;
  // Found-> Process credit limit
  IF *IN99 = *ON;
      CRLIMIT = CMCRLM;
      PROCESS();
  ENDIF;
  // Return to caller
  *INLR = *ON;
  RETURN;
  // Process credit limit
  DCL-PROC PROCESS ;
    IF CRLIMIT > 10000;
      *IN61 = *ON;
      %SUBST(CMNAME:1:11) = 'ABC COMPANY';
      REMAIN = CRLIMIT - INVTOTAL;
    ENDIF;
  END-PROC PROCESS;
1.800.949.4696  |  sales@linomasoftware.com  |  privacy policy
Copyright ©1994 - 2012 Linoma Software  |  All rights reserved