Enhancements to RPG IV ldRPGWorldrpgworld.com/RPGIVatV6r1.pdf · Rational Developer for System i...

23
Enhancements to RPG IV RPGW ld www.RPGWorld.com © 2008 – Robert Cozzi, Jr. All rights reserved.

Transcript of Enhancements to RPG IV ldRPGWorldrpgworld.com/RPGIVatV6r1.pdf · Rational Developer for System i...

Enhancements to RPG IV

RPGW ldwww.RPGWorld.com

© 2008 – Robert Cozzi, Jr.All rights reserved.

IBM Announced i5/OS V6New RDi for Edit/Compile/Debug/Screen DesignNew Packaging/Pricing for SEU/PDMN F t i RPG IVNew Features in RPG IV

www.RPGWorld.comMay 4 to 7, 2008

Rational Developer for System iRational Software is IBMs new Software CompanyMost developer tools now belong to IBM RationalThis means IBM Rational owns System i DevelopmentThis means IBM Rational owns System i Development

RPG IV and COBOLSEU, PDM, SDA, DFU, DEBUGWDS and WDScWDS and WDScRDi, RDi SOA, and RBD

www.RPGWorld.comMay 4 to 7, 2008

RDi – Rational Developer for System i

Graphical User Interface IDE"Integrated Development Environment"

Evolution of WDScBetter packaging and pricingBetter packaging and pricingSmaller foot print

RDi Replaces SEU/PDM/SDA/DEBUGEditDesign 5250 ScreensCompileDebug

RDi SOA (another package)RDi SOA (another package)Includes all the web development stuff

IBM would like everyone to consider moving their development teams to Rdi.

www.RPGWorld.comMay 4 to 7, 2008

RPG IV Enhancements at V6R1Local Files in subproceduresEliminate the RPG Cycle entirelyT D t St t T l tTrue Data Structure TemplatesQualified Record Format Names

aka, "Qualified Files", QQualifying files at compile-timeLarge Field LengthsMo e A a Ele entMore Array ElementsLonger Data StructuresMiscellaneous features

www.RPGWorld.comMay 4 to 7, 2008

Local Files in subproceduresFile specification can be declared inside of SubproceduresPlace the "F spec" immediately after the "P" specPlace the F spec immediately after the P spec

Before the subprocedure's parameter interface statements

Automatic Open/Close just like global filesAutomatic Open/Close just like global filesFiles are automatically opened when subprocedure is called Files are automatically closed when subprocedure Files are automatically closed when subprocedure returnsThe USROPN (User-controlled Open) keyword is supportedsupported

www.RPGWorld.comMay 4 to 7, 2008

Declaring Local Files in SubproceduresDeclaring Local Files in SubproceduresD custInfo DS TEMPLATE LikeDS(CUSTMAST)

P GetCustInfo B Beginning P spec

FCustMast IF E K DISK EXTDESC('OELIB/CUSTOMER')F QUALIFIEDD GetCustInfo PI 10i 0

g g p

D custNo 7P 0 ConstD rtnInfo LikeDS(custinfo)

D custData DS LikeDS(custmast)( )

/freechain (custno) custmast custData;if %found();

Local File specs appear immediately after the beginning P spec.();

eval-corr rtnInfo = custData;return 0;

endif;return -1;

beginning P spec.

Parameter Interface follows local files

www.RPGWorld.comMay 4 to 7, 2008

;/end-free

P GetCustInfo E

follows local files

Eliminate the RPG Cycle entirelyNormally the RPG Cycle is inserted into every programSecondary modules and service programs have long b bl t id RPG C lbeen able to avoid RPG Cycle

The NOMAIN keyword in those modules eliminated the cycle from the *MODULE being created

New MAIN keyword does the same thing for the entry ew eywo d does t e sa e t g o t e e t y module or program itself

Specify MAIN('ENTRYPROC') on the Header specWhere 'ENTRYPROC' is the subprocedure to run when the program is calledthe program is called.Note, must still be the mainline Calc's subprocedure

Must use PR/PI statements for *ENTRY/PLIST to enable this feature

www.RPGWorld.comMay 4 to 7, 2008

No RPG Cycle

H OPTION(*SRCSTMT:*NODEBUGIO)H DFTACTGRP(*NO)H MAIN('ORDENTRY') Th RPG C l i tH MAIN('ORDENTRY')

Fcustmast...

The RPG Cycle is notembedded in *MODULE.

D ORDENTRY PR EXTPGM('ORDENTRY')D order 7P 0D ORDENTRY PID order 7P 0D order 7P 0

Note: This style parameter list replaces the traditional *ENTRY/PLIST technique

www.RPGWorld.comMay 4 to 7, 2008

ENTRY/PLIST technique.

True Data Structure TemplatesLots of programmers have been using LIKEDS keyword

Declaring data structures based on other data Declaring data structures based on other data structures

The problem is that the original data structure uses storage in the program.New TEMPLATE keyword

Declares a data structure as a template that is used Declares a data structure as a template that is used to define other data structures via the LIKEDS keyword. f No additional storage is defined when

TEMPLATE is used.www.RPGWorld.comMay 4 to 7, 2008

Data Structure TemplatespD dur_t DS Template InzD Years 5i 0D months 5i 0D d 5i 0 D days 5i 0 D hours 5i 0 Inz(-1)D minutes 5i 0 Inz(-1)D seconds 5i 0 Inz(-1)

The template keyword means "this is a template" not a real data structure.

P CalcDur BD CalcDur PID startDate D Const DATFMT(*ISO)D dD t D C t DATFMT(*ISO)Use the Template withD endDate D Const DATFMT(*ISO)D rtnDuration LikeDS(dur_t) DD myDuration DS LikeDS(dur_t) inz(*likeDS)/f

Use the Template with LIKEDS just like any other data structure.

/free// do cool date routine herertnDuration = myDuration;return;

/ d f

www.RPGWorld.comMay 4 to 7, 2008

/end-freeP CalcDur E

Qualified Record Format NamesNew QUALIFIED keyword on File specsRequires the File to be referenced using a

lifi d t f llqualified syntax as follows:read custmast.custrec

Benefits become obvious when two or more files have identical record format names:

read custmast.custrecread custlgl1.custrecg

As is often the case with a physical and logical file being declared in the same program.You get to avoid the RENAME keywordYou get to avoid the RENAME keyword.

www.RPGWorld.comMay 4 to 7, 2008

Example Qualified Record Format

Fcustmast IF E DISK QUALIFIEDFcustlgl1 IF E K DISK QUALIFIED

D cm DS LikeRec(custmast.custrec)D clgl DS LikeRec(custlgl1.custrec)

/freeread custmast.custrec cm;if not %eof(custmast);

chain (cm.custno) custlgl1.custrec clgl;// write HTML table row

endif;/end-free Note: The data structure

name is required when using

www.RPGWorld.comMay 4 to 7, 2008

q gQualified Format names.

Overriding Files at Compile‐timeLots of programmers perform OVRDBF commands at compile-time for files being used in their programs.

New EXTDESC keyword eliminates this yrequirement.

www.RPGWorld.comMay 4 to 7, 2008

Example EXTDESC KeywordExample EXTDESC KeywordTypical File Spec

Fcustmast IF E DISK EXTDESC('MYLIB/CUSTOMER')

The EXTDESC keyword causes the compiler to use the external

EXTFILE(*EXTDESC)

pdescription of the CUSTOMER file in the MYLIB library as the external description for the CUSTMAST file.

Similar to the following:

OVRDBF CUSTMAST TOFILE(MYLIB/CUSTOMER)CRTBNDRPG PGM(…)

Similar to the following:

www.RPGWorld.comMay 4 to 7, 2008

Increased Length LimitsLimit RPGIII RPG IV at V5R4 RPG IV at V6

Field Length 256 65535 16,773,104 (16MB)

Data Struct Length 9999 65535 16 773 104 (16MB)Data Struct Length 9999 65535 16,773,104 (16MB)

Array Elements 999 32767 16,773,104 (16MB)

Constants/Literals 256 2048 16,380

UCS‐2 Literals N/A 1024 8,190

Graphic Literals N/A ??? 16,379

www.RPGWorld.comMay 4 to 7, 2008

Larger Lengths: How'd They Do That?

New LEN keyword on Definition specUse LEN keyword instead of the length entry "column"column

VARYING FieldsHidden 10u0 length instead of 5u0Use VARYING(4) to force new sizeImplied when length is beyond current 64k limitImplied when length is beyond current 64k limit

www.RPGWorld.comMay 4 to 7, 2008

Example Big Field/DS LengthsD myStuff DS Len(1000000) QualifiedD InzD bytesProv 10I 0 Inz(%len(myStuff))D bytesAvail 10I 0D ...D myVaryField S A Len(1280000) VARYING(4)D myBigField S A Len(8000000)

The LEN keyword is used for anyThe LEN keyword is used for any field length. Note that no "TYPE" keyword is provide, so we continue to use the "A" in the Data-Type column.

www.RPGWorld.comMay 4 to 7, 2008

More Array ElementsArray index limitations have been removed

A i d li it i b d T t l S li itArray index limit is based on a Total Space limit(elements * element length) <= 16MB

For example:An array of 1-byte elements, can support up to 16 773 104 elements16,773,104 elements.An array of 100-byte elements can support up to 167,731 elements

www.RPGWorld.comMay 4 to 7, 2008

Miscellaneous Updates (1 or 3)New LIKEFILE keyword

Defines a file "handle" (file as a variable)Allows files to be passed to subprocedures as Allows files to be passed to subprocedures as parameters

EXTNAME keyword enhancedQualified file name is now supported

EXFMT opcode enhancedData Structure I/O buffer can now be used

EXFMT ASKUSER dsName;EXFMT ASKUSER dsName;

www.RPGWorld.comMay 4 to 7, 2008

Miscellaneous Updates (2 of 3)Compiler now throws out unreferenced variables

Previously all unreferenced variables were keptNew OPTION(*NOUNREF) compiler optionNew OPTION( NOUNREF) compiler optionUse it on Header spec or CRTBNDRPG command

USC-2 Variables can be interchanged with character fields seamlessly

Previously it either didn't work or required the use Previously it either didn t work or required the use of the %UCS2 built-in functionNow, it just works; conversion is implied

www.RPGWorld.comMay 4 to 7, 2008

Miscellaneous Updates (3 of 3)%ADDR(varying_field :*DATA)

Returns a pointer to the data in a VARYING field

H THREAD(*CONCURRENT)H THREAD( CONCURRENT)Indicates the program can be run in multiple threads

STATIC(*ALLTHREAD)( )Used on Local VariablesIndicates variable is shared by all threadsDefault behavior is new instance of var for each thread

P myProc B EXPORT SERIALIZENew SERIALIZE keyword on P specsChanges subprocedure to single threaded process

www.RPGWorld.comMay 4 to 7, 2008

Hope to see you at...

May 4 to 7  2008May 4 to 7, 2008Las Vegas

www.RPGWorld.com