Upload
vishnu400
View
101
Download
2
Embed Size (px)
Citation preview
9/24/2007 ©Countrywide Home Loans, 2002-2003, All rights reserved 1
Free Form RPGFree Form RPGFree Form RPGA few notes about the use
Of Free Form RPG
Presented by:
Jim Low
Arturo Duarte, Jr.
Wednesday, September 25, 2002
9/24/2007 2
RPG IV Free Form Discussion
Topics
� Software Development Improvements
� Faster Coding
� Easier to Understand
� More Built in Functions (BIFs)
� A Few Less Op Codes
� What We Discovered
� Information Sources
� Significant Op Code Changes
� A Look into the Future
� Conclusion: Free-Form Advantages
� Examples of RPGIII v Free-Form
9/24/2007 3
Software Development
Improvements
�Faster Coding
�Easy to understand
�A few more BIFs
�A few less Op Codes
9/24/2007 4
Faster Coding
�Easy to start and end Free Form
– Calculation section start with: /Free (column 7)
– Calculation section end with: /End-Free (column 7)
�Don’t have to deal with columns
– Algebraic Expressions (i.e. X = (Y * Z)/A)
– Type like you read – Left to Right
– Finally do what you profess – get rid of indicators! (mostly)
– Compound IF statements (complex)
– Simple IF statements
9/24/2007 5
Easier to Understand
� Reading a file
– ReadE(EN) filekey filename;
– Compared to:
• C FileKey ReadE(EN) filename
• C Read(EN) filename
� Calling a subprocedure
– Procname(P1 : P2 : P3 : … : Pn);
– Compared to:
• CALL ProcName PLIST
• CALLP ProcName(P1 : P2 : . . . : Pn)
• EVAL RtnValue = ProcName(P1 : P2 : … : Pn)
9/24/2007 6
Easier to Understand (Continued)
� Perform date calculations inline or as a conditional
– Old way:• C Extrct SomeDate:*M MM
– Better way:• MM = %SubDt(SomeDate:*Month);
– Even better:• If %SubDt(SomeDate:*Month) = ReportMonth;
� Date Conversion:– newDateFormat = %char( %date( oldDateFormat: *YMD): *MDY) ;
� Handle in line errors easier– Monitor, On-Error, EndMon Operations for entire blocks of code
9/24/2007 7
A few more BIFs (Built-in-Functions)
�%LookUp, %LookUpXX (LT;LE;GT;GE)
�%Minutes; %Months (converts argument to duration
values for arithmetic operations)
�%Occur (Set occurrence of a multiple occurrence data structure)
�%SHTDN (determining if the operator has requested shutdown)
�%CHAR (Input Value to character conversion – includes
numeric, date, time, timestamp, graphic, and UCS-2)
9/24/2007 8
A Few Less Op Codes (Not Allowed in
Free-Form Coding)
�Move operations
– MOVEA; MOVELL; MOVEHL; MOVELH; MOVE
�Bit Operations
– BITON; BITOFF; TESTB
�And others (see iSeries News; Moving Forward with Free-Format
RPG)
9/24/2007 9
What we Discovered
�An overall 10% improvement in programming
speed (based on measurement of time to create new Display File
programs for CHL-CHL Refi Application)
�Compliance with numeric vs. alpha field handling (i.e. like fields to like fields)
�Clarity in programming
�A strong need for Best Practices (better yet: Standards)
�Think about what is needed first (i.e. define needed
variables then develop solution)
9/24/2007 10
What we Discovered (Continued)
�A number of similarities between Free-
Form and Java.
�Anyone can follow the code.
9/24/2007 11
Information Sources
�IBM RPG/LE V5R1/V5R2 manuals
�iSeries News
�Contact with other experts (both in house and
external).
�Experience with coding (using both traditional and
current technology).
9/24/2007 * 12
Significant Op Code Changes
9/24/2007 * 13
Significant Op Code Changes
9/24/2007 * 14
Significant Op Code Changes
9/24/2007 * 15
A look into the Future
�V5R2 Enhancements
– Eliminate the need for KLIST/KFLD
– Single stroke operands (i.e. +=; -=; /=; etc.)
• FLD1 += 1;
• ADD 1 FLD1
• EVAL FLD1 = FLD1 + 1
– BitWise BIFs (%BITAND; %BITOR; %BITXOR; etc.)
– Complex Data Structures (DIM use at the DS line level;
DIM on each sub-field; and DIMs within each sub-field)
– Update only selected fields
9/24/2007 * 16
A look into the Future (Continued)
�V5R2 Enhancements (Continued)
– BitWise BIFs (%BITAND; %BITOR; %BITXOR; etc.)
• Result = %BitOr(Var.1 : Var.2 : . . . : Var.n);
– Complex Data Structures (DIM use at the DS line level;
DIM on each sub-field; and DIMs within each sub-field)• D DSName DS 100 DIM(100)
• D DSSub1 20 DIM(5)
• D DSSub1a 5 DIM(4) Overlay(DSSub1)
– Update only selected fields
• UPDATE(EN) (Fld1 : Fld2 : Fld3) FileName;
9/24/2007 * 17
Conclusion: Free-Form
�Is Quicker
�Is Easier to Understand
�Helps enforcement of good programming
practices
�Takes advantage of current coding
technology
�Supports business vision and strategic
initiatives.
9/24/2007 * 18
Examples of RPGIII v FreeForm
9/24/2007 * 19
Examples of RPGIII v FreeForm
9/24/2007 * 20
Examples of RPGIII v FreeForm
9/24/2007 * 21
Examples of RPGIII v FreeForm
9/24/2007 * 22
Examples of FreeForm/CODE400