Rpg iv v5r1 enhancements
Download
1 / 48

RPG IV V5R1 Enhancements - PowerPoint PPT Presentation


  • 90 Views
  • Uploaded on

RPG IV V5R1 Enhancements. Presented by Barry Diehl. At a Glance. Built-In Functions (BIFs) Free-format Runtime Control of Files and Members Improved Error Control Increased Java support Miscellaneous Changes. How did it happen?.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' RPG IV V5R1 Enhancements' - giovanna-abbott


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
Rpg iv v5r1 enhancements

RPG IV V5R1 Enhancements

Presented by

Barry Diehl


At a glance
At a Glance

  • Built-In Functions (BIFs)

  • Free-format

  • Runtime Control of Files and Members

  • Improved Error Control

  • Increased Java support

  • Miscellaneous Changes


How did it happen
How did it happen?

  • George Farr of IBM Toronto surveys users giving them a list of possible enhancements.

  • Each enhancement is “priced”

  • Survey participants can spend $100


What didn t make it
What didn’t make it?

  • Multiple dimension arrays

  • Keylists in D specs

  • More H-Spec Keywords

  • Bitwise operations in expressions



Taking time
Taking time

  • %TIME{(expression{:time-format})} %TIMESTAMP{(expression{:*ISO|*ISO0})} %DATE{(expression{:date-format})}

  • If no value specified, current system values are retrieved

  • When the expression is *DATE, UDATE or a timestamp, don’t use the format - the system knows the format


One more time
One More Time

  • %SECONDS(number)

  • %MINUTES(number)

  • %HOURS(number)

  • %DAYS(number)

  • %MONTHS(number)

  • %YEARS(number)

  • Determine date in 3 years newdate = date + %YEARS(3)

  • Determine date 6 months ago loandate = date - %MONTHS(6)


What s the difference
What’s the Difference?

  • %DIFF(op1:op2:*MS|*S|*MN|*H|*D|*M|*Y)

  • Determine the number of days between 2 datesNumDays = %Diff(LoanDate:DueDate:*D)

  • Add number of minutes between the start and endTotalTime = TotalTime + %Diff(StartTime:EndTime:*MN)


Parts is parts
Parts Is Parts

  • Extract a subset of a date, time or timestamp with %SUBDT

  • %SUBDT(value:*MS|*S|*MN|*H|*D|*M|*Y)

  • date = d’1999-02-17’;time = t’01.23.45’;num = %SubDt(date:*Y); // num = 1999num = %SubDt(time:*MN); // num = 23


A well defined search
A Well-Defined Search

  • %LOOKUPxx(arg:array{:startindex{:numelems}}) - returns array index of the element in array that matches

  • Where xx =

    • blank  an exact match

    • LT  value closest to arg, but less than arg

    • LE  an exact match or the value closest to arg, but less than arg

    • GT  value closest to arg, but greater than arg

    • GE  an exact match or the value closest to arg, but greater than arg

  • Zero is returned if no match found

  • %Found and %Equal don’t work on this function

  • Use %TLOOKUPxx for tables


Other functions
Other Functions

  • %ALLOC and %REALLOC

  • %CHECK and %CHECKR

  • %XLATE

  • %SHTDN

  • %SQRT



Free format rules
Free-format Rules

  • /FREE and /END-FREE

  • Write code between columns 8 and 80

  • General form:opcode(extenders) Factor 1 Factor 2 Result

  • Statements end with semi-colon

  • End-of-line comments marked with //

  • Compiler directives can be used

  • Can’t define fields or have result indicators

  • Free and fixed can be mixed


Function replacements
Function Replacements

  • ADDDUR  %YEARS, %MONTHS

  • ALLOC  %ALLOC

  • CHECK  %CHECK

  • CHECKR  %CHECKR

  • EXTRCT  %SUBDT

  • LOOKUP  %LOOKUPxx, %TLOOKUPxx

  • MVR  %REM

  • OCCUR  %OCCUR

  • REALLOC  %REALLOC


Function replacements1
Function Replacements

  • SCAN  %SCAN

  • SHTDN  %SHTDN

  • SQRT  %SQRT

  • SUBDUR  %DIFF or minus sign

  • SUBST  %SUBST

  • TIME  %DATE, %TIME, %TIMESTAMP

  • XFOOT  %XFOOT

  • XLATE  %XLATE


Operator replacement
Operator Replacement

  • ADD  +

  • CAT  +

  • DIV  /

  • MULT  *

  • SUB  -


Generalize
Generalize

  • ANDxx  AND

  • DOUxx  DOU

  • DOWxx  DOW

  • IFxx  IF

  • ORxx  OR

  • WHENxx  WHEN


Social engineering obsolete
Social Engineering - Obsolete

  • BITOFF  use MOVE

  • BITON  use MOVE

  • CABxx

  • CAS and ENDCS

  • COMP

  • GOTO

  • MHHZO

  • MHLZO

  • MLHZO

  • MLLZO

  • TAG


Social engineering moving to new
Social Engineering – Moving to New

  • CALL and CALLB  CALLP

  • DEFINE  D spec – use LIKE or DTAARA keywords

  • DO  FOR

  • END  need to qualify the type now

  • MOVE  EVALR or built-in functions

  • MOVEA

  • MOVEL  EVAL or built-in functions

  • PARM and PLIST  use prototype definition

  • SETOFF and SETON  EVAL

  • TESTN and TESTZ

  • Z-ADD and Z-SUB


Free form details
Free-Form Details

  • KLIST and KFLD not included

  • EVAL is optional

  • Debug works fine

  • Most examples in Reference are free-form

  • Macro in CODE/400 performs one-way conversion

  • Mix of Free and Fixed-formats is ok

  • Compiler directives ok - but no SQL











Runtime control of files and members1
Runtime Control of Files and Members

  • Use EXTFILE(file name) and EXTMBR(member name) as keywords in F Spec

  • Need USROPN keyword too

  • OVRDBF still has control



Current checking
Current Checking

  • Error indicator or Extender (E) – doesn’t handle all situations

  • *PSSR or INFSR subroutines – can’t easily return to the statement that caused the problem


Monitor group
Monitor Group

  • MONITOR - marks beginning of code to trap errors

  • ON-ERROR {exception-id1 {:exception-id2…}}Begins the group for one or more status codes. Can also use:

    • *PROGRAM - all program errors

    • *FILE - all file errors

    • *ALL - all errors

  • ENDMON - marks the end of the group




New error processing order
New Error Processing Order

  • Statement indicators

  • Opcode extenders, %STATUS, %ERROR

  • MONITOR group

  • INFSR

  • *PSSR


Increased java support many thanks to george farr of ibm these are his examples
Increased Java Support(Many thanks to George Farr of IBM - these are his examples)


Rpg calling java 3 options
RPG Calling JAVA: 3 options

  • Use QCMDEXC to launch the JVM for the Java class

  • Use system C-APIs to instantiate Java objects and call methods in them (Java Native Invocation or JNI)

  • Use V5R1 RPG enhancements that mask the JVN complexity


Calling java from rpg
Calling Java from RPG

  • Declare Objects

  • Prototype Java Methods

  • Instantiate an Object


Declare objects
Declare Objects

  • D Test S O CLASS(*JAVA:’java.lang.String’)

  • Must declare a field to hold the object reference

    • First parameter must be *JAVA

    • Fields of type ‘O’ cannot be DS subfields

    • Arrays of objects are allowed

    • Fields of type ‘O’ are NOT pointers, they only store references to objects


Prototype java methods
Prototype Java Methods

  • D trimstring PR O EXTPROC(*JAVA:’java.lang.String’:’trim’)D CLASS(*JAVA:’java.lang.String’)D STATIC

  • EXTPROC accepts 3 parameters

    • *JAVA keyword

    • ‘package.class’ name of class containing method

    • Name of method or *CONSTRUCTOR

  • Specify return type

    • Use CLASS keyword if it returns a Java object (‘O’ type)

    • Specify STATIC for static methods


Instantiate an object
Instantiate an Object

  • D crtBigDec PR O EXTPROC(*JAVA:’java.math.BigDecimal’:*CONSTRUCTOR)D CLASS(*JAVA:’java.math.BigDecimal’)D Parm1 8F VALUED*D refflt S O CLASS(*JAVA:’java.math.BigDecimal’)D*D DblField S 8F INZ(‘0’)C* Instantiate the classC*C EVAL refflt = crtBigDec(dblField)

  • Prototype the desired constructor method

  • Declare the object reference variable

  • Call the constructor method, store result


Calling methods example
Calling Methods Example

D fld S 10A INZ(‘ Farr ‘)D str S O CLASS(*JAVA:’java.lang.String’)D*D makestring PR O EXTPROC(*JAVA:’java.lang.String’:*CONSTRUCTOR)D CLASS(*JAVA:’java.lang.String’)D parm 10AD*D makealpha PR 10A EXTPROC(*JAVA:’java.lang.String’:’getBytes’)D*D trimstring PR O EXTPROC(*JAVA:’java.lang.String’:’trim’)D CLASS(*JAVA:’java.lang.String’)C EVAL str = makestring(fld)C EVAL str = trimstring(str)C EVAL fld = makeslpha(str)



Elseif
ELSEIF

  • Can combine an ELSE and IF togetherIf A = 1; X = X + 1;ElseIf A = 2; X = X + 2;ElseIf A = 3; X = X + 3;EndIf;

  • Reduce number of ENDIFs and nesting levels

  • Don’t forget about SELECT


Qualified data structure names
Qualified Data Structure Names

  • New keyword QUALIFIED - allows names to be reused in the program

  • Useful in prototyped parameter definitions

  • New keyword LIKEDS(data structure) - will have the same structure



Summary
Summary

  • Built-In Functions (BIFs)

  • Free-format

  • Runtime Control of Files and Members

  • Improved Error Control

  • Increased Java support

  • Miscellaneous Changes


ad