230 likes | 691 Views
Free Form RPG. A few notes about the use Of Free Form RPG Presented by: Jim Low Arturo Duarte, Jr. Wednesday, September 25, 2002. RPG IV Free Form Discussion Topics. Software Development Improvements Faster Coding Easier to Understand More Built in Functions (BIFs) A Few Less Op Codes
E N D
Free Form RPG A few notes about the use Of Free Form RPG Presented by: Jim Low Arturo Duarte, Jr. Wednesday, September 25, 2002 ©Countrywide Home Loans, 2002-2003, All rights reserved
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
Software Development Improvements • Faster Coding • Easy to understand • A few more BIFs • A few less Op Codes
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
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)
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
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)
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)
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)
What we Discovered (Continued) • A number of similarities between Free-Form and Java. • Anyone can follow the code.
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).
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 *
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; *
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. *