This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Acknowledgement:• This presentation is a collaborative effort of the IBM Toronto AS/400 Application
Development presentation team, including work done by:• George Farr, Claus Weiss, Don Yantzi, and Barbara Morris
Disclaimer:• The information contained in this document has not been submitted to any
formal IBM test and is distributed on an as is basis without any warranty either express or implied. The use of this information or the implementation of any of these techniques is a customer responsibility and depends on the customers' ability to evaluate and integrate them into the customers' operational environment. While each item may have been reviewed by IBM for accuracy in a specific situation, there is no guarantee that the same or similar results will result elsewhere. Customers attempting to adapt these techniques to their own environment do so at their own risk.
Reproduction:• The base presentation is the property of IBM Corporation. Permission must be
obtained PRIOR to making copies of this material for any reason.
• Indicator Data TypeData areas of type *LGL (logical)Indicator data structure (INDDS)Built-in functions (%EOF, %EQUAL, %FOUND, %OPEN, as well as %ERROR, %STATUS.Indicator data type ('N‘): defines character data in the indicator format.
• Varying length Character field.New Data TypeNew Built-In functions
• ‘Permanent’ compiler optionsUse H specification keyword instead of compile options on CRTBNDRPG and CRTRPGMOD
• Other enhancementsMixed case procedure and variable names on IMPORT & EXPORT keywordsBNDDIR (binding directory) option on CRTRPGMODCustomers Requirements
•Increasing Java-related supportEXTPROC maps to Object (CLASS) methodsCLASS keyword on the D specSTATIC keyword for static methods
•Free Form C-Specification•Monitor operation group•Runtime control of file/member to be opened EXTFILE(filename)
Static name or variable•Date/time/timestamp operations in expressions•ELSEIF Operation instead of nested IFs•Predefined compiler directives•/DEFINE names *VnRnMn, *ILERPG, *CRTBNDRPG *CRTRPGMOD •Qualified names in data structures•More Built-in Functions
• IFS Source File Support• Library qualified access to data areas (not only *LIBL)• Specify selected fields for UPDATE (%FIELDS)
•UPDATE record %fields(field1 : field3)• PCML file generation into IFS• I/O enhancements
•Externally-described DS can hold I/O/B fields•DS can be specified in result field when using I/O operations to an externally described file•Prior to V5R2 only allowed for program-described files
•handles conditional compilation and nested /COPY• 63 Digit support (Packed and Zoned)
• DECPREC (30|31|63)• Second parameter on %TRIMx designated trim characters
• trimchars = ‘*-’; data = ‘**-*a-b-c*-*’; result = %trim(data, trimchars);• resulting value is ‘a-b-c’
• Allow dynamic resizing of arrays, %SUBARR• %SUBARR(array : start : length)• sorta %subarr(myArray:4:10) sorts 10 elements of myArray starting at 4th:
• OPTIONS(*TRIM) on the proc prototype• that parameter is always trimmed of leading and trailing blanks
• Conversion of date/time/timestamp to numeric using %DEC•Example: date is DATE type = D’2003-08-21’; numDDMMYY is numeric•numDDMMYY = %dec(date:*dmy) ; numDDMMYY now contains 210803
• Relax rules for result data structure•Result DS for I/O to a RECORD format may be externally described DS•Data structure may be specified in result field for I/O to externally-described fiel
•CHAIN, READ, READE, READP, READPE• New environment variable for Java method calls (performance enhancement)
Reads from an XML document into a field, data structure or array
First parameter of %XML can be a string actually containing XML data, for example '<a>Hello</a>', or it can be the name of an XML file, for example 'mydata.xml'.
Second optional operand for %XML specifies indicates weather the first operand is string containing XML data, or an XML file. For example, %XML(xmldata : 'doc=file')
D********************************************************D info DSD name 10A D val 5I 0 DIM(2)D**********************************
/free
XML-INTO info %XML('myfile.xml' : 'doc=file');// info now has the value// name = ‘Frank'// val(1) = 10// val(2) = -5
Data structure type definitionsNo more compile-time overridesDefining files locally in subprocedures, and passing files as parametersSignificantly higher limits for the size of variables and array elementsA new kind of RPG main procedureRelaxation of some UCS-2 rules (available for V5R3/4 through PTFs)Run concurrently in multiple threads; RPG doesn’t have to be a bottleneck
Files can be defined within a subprocedureGlobal definition no longer only way to define a file
Advantages: 1. Maintainability :
Coding the file definition in a subprocedure, the RPG programmer can explicitly limit the file’s access to only that subprocedure
1. Reduction of static storage: Defining the file locally reduces of the static storage required by the module, if the file is defined to use automatic storage for the internal storage required to manage the file.
Use to define files to same setting as another File SpecificationIf the file is externally-described, the QUALIFIED keyword is implied. I/O to the file can only be done through data structures.The LIKEFILE keyword is used mostly with file parameters.
Files can now be passed as a parameters between procedures and programs:A prototyped parameter can be defined as a File parameter using the LIKEFILE keyword. Any file related by LIKEFILE keywords to the same original File specification may be passed as a parameter to the procedure. Within the called procedure or program, all supported operations can be done on the file parameter. However, I/O to the file parameter can only be done through data structures.RPG file parameters are not compatible with file parameters in other languages such as C or COBOL.
Larger limit for DIM and OCCURSNo limit on the number of elements in an array or occurrences in a multiple-occurrence data structure.Total size for an array or structure remains at 16,773,104 bytes.Example:
– If the elements of an array are 1 byte in size, the maximum DIM for the array is 16,773,104.
– If the elements of an array are 10 bytes in size, the maximum DIM for the array is 1,677,310 (16773104/10).
Most modern RPG code does not overtly use the RPG CycleNow available - an RPG module with a main procedure that does not rely on the RPG cycle.New Keyword on H Specification - MAIN
– Designates one subprocedure as the main procedure (PEP)Designated subprocedure is like any other subprocedure - no RPG cycle.The prototype for the main subprocedure must have the EXTPGM keywordThe main subprocedure can only be called by a program call.
D ordEntry PR EXTPGM(‘ORDENTRY’)D custname 10A CONST
P ordEntry BD ordEntry PID custname 10A CONST... code the main procedure logic here... when it reaches the end, it just returns... *INLR has no meaningP ordEntry E
Pre V6R1:RPG IV supported the UCS-2 data type; including support for UTF-16
– Extremely difficult to change the data type of a database character or graphic field to be UCS-2.
– Compiler gives diagnostic error messages saying that the UCS-2 field cannot be used with the character data.
RPG IV considers Character, UCS-2 and Graphic to be three separate data types.Using these data types together in the same statement required specific conversion using RPG built-in functions %CHAR, %UCS2 or %GRAPH.
THREAD(*CONCURRENT) available for Control specification of a module– Multiple threads can run in the module at the same time.– By default, static variables will be defined so that each thread will
have its own copy of the static variable.– Individual variables can be defined to be shared by all threads using
STATIC(*ALLTHREAD).– Individual procedures can be serialized so that only one thread can
run them at one time, by specifying SERIALIZE on the Begin Procedure specification.
Considerations: – Using THREAD(*CONCURRENT) increases the total amount of static
storage used• Total size = size required by module X number of threads
For both the RPG IV and ILE COBOL compilersPCML can be placed in a stream file as before, directly in the module, or both.Information can later be retrieved from a program or service program containing the module, using the new QBNRPII API
The PGMINFO command parameter for the CRTRPGMOD, CRTCBLMOD, CRTBNDRPG and CRTBNDCBL commands specifies location for PCML
– The default location is the stream file specified by the INFOSTMF parameter– PGMINFO(*PCML:*MODULE) says to place the PCML information directly
in the module• becomes part of the program or service program containing the module.
– PGMINFO(*PCML:*ALL) says to place the PCML information both in the module and in the INFOSTMF stream file.
Alternate: H spec keyword for RPG or PROCESS option for COBOLThe PGMINFO command parameter can be augmented or overridden by an H spec keyword (ILE RPG) or PROCESS option (ILE COBOL).
– RPG: PGMINFO(*PCML:*MODULE) or PGMINFO(*NO)– COBOL: PGMINFO(PCML MODULE) or PGMINFO(NOPGMINFO)
Priority ? – If the source keyword specifies “module”, then it augments the PGMINFO
command parameter. For example, if the command requested *STMF, and the source keyword specifies *MODULE, then the PCML will be generated both to the stream file and into the module.
– If the keyword specifies “no”, then it overrides the PGMINFO command parameter. No matter what was specified by the command parameter, no PCML information will be generated by the compiler.
PTF support for V5R4Part of this support is available in V5R4 with PTFs.
– The H specification keyword for ILE RPG– The PROCESS option for ILE COBOL– The QBNRPII API
The following V5R4M0 PTFs will provide the various parts of this function• 5722SS1 SI23544 (QBNRPII API)• 5722SS1 SI27064 (Support for compilers)• 5722WDS SI27061 (ILE RPG compiler PTF 1)• 5722WDS SI27065 (ILE RPG compiler PTF 2)• 5722WDS SI27154 (ILE COBOL compiler)
Sorting Arrays Leave and Iter with ConditionSupport Alias namesImplicit conversion between characters and UCS-2Opening of RPG InterfaceTool enhancements
Implicit conversion will be done for string parameters passed by value or by read-only reference. Example:
Procedure is prototyped using a CONST UCS-2 parameterCharacter expression is passed as a parameter on a call to the procedure. This enables creation of a single procedure with the parameters and return
value prototyped with the UCS-2 type. Calling the procedure, you can pass any type of string parameter, and assign
the return value to any type of string variable. Sample
The makeTitle procedure turns value to upper-case and centers it within the provided length
Allows distribution of debuggable programs without exposing source code via listing viewListing view will only be seen by person doing debug if encryption key has been enteredUse DBGENCKEY parameter on CRTRPGMOD, CRTBNDRPG or CRTSQLRPG commands.
Retrieves the maximum number of characters for a varying-length character, UCS-2 or Graphic field
D custDs e ds ALIAS D QUALIFIED EXTNAME(custFile) /free custDs.customer_name = 'John Smith'; custDs.customer_address = '123 Mockingbird Lane'; custDs.id = 12345;
Retrieves the maximum number of characters for a varying-length character, UCS-2 or Graphic fieldUse ALIAS names in externally-described data structuresUse the ALIAS keyword on a Definition specification to indicate that you want to use the alternate names for the subfields of externally-described data structuresUse the ALIAS keyword on a File specification to indicate that you want to use the alternate names for LIKEREC data structures defined from the records of the file
RPG:
A R CUSTREC A CUSTNM 25A ALIAS(CUSTOMER_NAME) A CUSTAD 25A ALIAS(CUSTOMER_ADDRESS) A ID 10P 0
8 IBM Corporation 1994-2002. All rights reserved.References in this document to IBM products or services do not imply that IBM intends to make them available in every country.The following terms are trademarks or registered trademarks of International Business Machines Corporation in the United States, other countries, or both:
Lotus, Freelance Graphics, and Word Pro are registered trademarks of Lotus Development Corporation and/or IBM Corporation.Domino is a trademark of Lotus Development Corporation and/or IBM Corporation.
C-bus is a trademark of Corollary, Inc. in the United States, other countries, or both. Java and all Java-based trademarks are trademarks of Sun Microsystems, Inc. in the United States, other countries, or both. Microsoft, Windows, Windows NT, and the Windows logo are trademarks of Microsoft Corporation in the United States, other countries, or both. ActionMedia, LANDesk, MMX, Pentium and ProShare are trademarks of Intel Corporation in the United States, other countries, or both. UNIX is a registered trademark of The Open Group in the United States and other countries.SET and the SET Logo are trademarks owned by SET Secure Electronic Transaction LLC. Other company, product and service names may be trademarks or service marks of others.
Information is provided "AS IS" without warranty of any kind.
All customer examples described are presented as illustrations of how those customers have used IBM products and the results they may have achieved. Actual environmental costs and performance characteristics may vary by customer.
Information in this presentation concerning non-IBM products was obtained from a supplier of these products, published announcement material, or other publicly available sources and does not constitute an endorsement of such products by IBM. Sources for non-IBM list prices and performance numbers are taken from publicly available information, including vendor announcements and vendor worldwide homepages. IBM has not tested these products and cannot confirm the accuracy of performance, capability, or any other claims related to non-IBM products. Questions on the capability of non-IBM products should be addressed to the supplier of those products.
All statements regarding IBM future direction and intent are subject to change or withdrawal without notice, and represent goals and objectives only. Contact your local IBM office or IBM authorized reseller for the full text of the specific Statement of Direction.
Some information in this presentation addresses anticipated future capabilities. Such information is not intended as a definitive statement of a commitment to specific levels of performance, function or delivery schedules with respect to any future products. Such commitments are only made in IBM product announcements. The information is presented here to communicate IBM's current investment and development activities as a good faith effort to help with our customers' future planning.
Performance is based on measurements and projections using standard IBM benchmarks in a controlled environment. The actual throughput or performance that any user will experience will vary depending upon considerations such as the amount of multiprogramming in the user's job stream, the I/O configuration, the storage configuration, and the workload processed. Therefore, no assurance can be given that an individual user will achieve throughput or performance improvements equivalent to the ratios stated here.
Photographs shown are of engineering prototypes. Changes may be incorporated in production models.
AS/400 IBM(logo)AS/400e iSeriese (logo) business OS/400IBM
Faster return valuesA procedure defined with the RTNPARM keyword handles the return value as a hidden parameter. When a procedthe procedure can be significantly improved by defining the procedure with the RTNPARM keyword.D getFileData pr a varying len(1000000) D rtnparm D file a const varying len(500) D data S a varying len(1000) /fre
%PARMNUM built-in functionThe %PARMNUM(parameter_name) built-in function returns the ordinal number of the parameter within the paramkeyword.D pi D name 100a const varying D id 10i 0 value D errorInfo likeds(errs_t) D options(*nopass) /free // Check if the
Optional prototypesIf a program or procedure is not called by another RPG module, it is optional to specify the prototype. The prototyp
A program that is only intended to be used as an exit program or as the command-processing programA program that is only intended to be called from a different programming language A procedure that is not exported from the module A procedure that is exported from the module but only intended to be called from a different programm
Teraspace storage modelRPG modules and programs can be created to use the teraspace storage model or to inherit the storage model of higher that for the single-level storage model. There are limits for the amount of automatic storage for a single procUse the storage model (STGMDL) parameter on the CRTRPGMOD or CRTBNDRPG command, or use the STGM*TERASPACE
The program or module uses the teraspace storage model. *SNGLVL
The program or module uses the single-level storage model. *INHERIT
The program or module inherits the storage model of its caller. Change to the ACTGRP parameter of the CRTBNDRPG command and the ACTGRP keyword on the Control specificati
The default value of the ACTGRP parameter and keyword is changed from QILE to *STGMDL.ACTGRP(*STGMDL) specifies that the activation group depends on the storage model of the program. When the sACTGRP(*STGMDL) is the same as ACTGRP(QILE).Note:The change to the ACTGRP parameter and keyword does not affect the default way the activation group is assignACTGRP parameter or keyword is not specified, the activation group of the program will default to QILE as it did in