iSeries
WebSphere
®
Development Studio
ILE RPG Reference
Version 5
SC09-2508-03
iSeries
WebSphere
®
Development Studio
ILE RPG Reference
Version 5
SC09-2508-03
Note!
Before using this information and the product it supports, be sure to read the general information
under “Notices” on page 749.
Fourth Edition (May 2001)
This edition applies to Version 5, Release 1, Modification Level 0, of IBM
®
WebSphere
®
Development Studio for
iSeries (5722-WDS), ILE RPG compiler, and to all subsequent releases and modifications until otherwise indicated in
new editions. This edition applies only to reduced instruction set computer (RISC) systems.
This edition replaces SC09-2508-02.
Order publications through your IBM representative or the IBM branch office serving your locality. Publications are
not stocked at the address given below.
IBM welcomes your comments. You can send your comments to:
IBM Canada Ltd. Laboratory
Information Development
2G/KB7/1150/TOR
1150 Eglinton Avenue East
North York, Ontario, Canada M3C 1H7
You can also send your comments by facsimile (attention: RCF Coordinator), or you can send your comments
electronically to IBM. See “How to Send Your Comments” for a description of the methods.
When you send information to IBM, you grant IBM a nonexclusive right to use or distribute the information in any
way it believes appropriate without incurring any obligation to you.
© Copyright International Business Machines Corporation 1994, 2001. All rights reserved.
US Government Users Restricted Rights – Use, duplication or disclosure restricted by GSA ADP Schedule Contract
with IBM Corp.
Contents
About This Reference ........xi
Who Should Use This Reference .......xi
Prerequisite and Related Information ......xii
HowtoSendYourComments........xii
What's New This Release? .........xiii
Changes to this Reference Since V4R4 ....xvii
Part 1. RPG IV Concepts ......1
Chapter 1. Symbolic Names and
Reserved Words ...........3
SymbolicNames.............3
ArrayNames.............4
Conditional Compile Names ........4
DataStructureNames..........4
EXCEPT Names ............4
Field Names .............4
KLISTNames.............4
Labels ...............4
NamedConstants............4
PLISTNames.............4
PrototypeNames............5
RecordNames.............5
Subroutine Names ...........5
TableNames.............5
RPG IV Words with Special Functions/Reserved
Words ................5
User Date Special Words ..........7
RulesforUserDate...........7
PAGE, PAGE1-PAGE7 ...........8
Rules for PAGE, PAGE1-PAGE7 .......8
Chapter 2. Compiler Directives ....11
/FREE... /END-FREE (Positions 7-11)......11
/TITLE (Positions 7-12) ..........11
/EJECT (Positions 7-12) ..........11
/SPACE (Positions 7-12) ..........12
/COPY or /INCLUDE...........12
Results of the /COPY or /INCLUDE during
Compile..............13
Nested /COPY or /INCLUDE .......13
Using /COPY, /INCLUDE in Source Files with
EmbeddedSQL............14
Conditional Compilation Directives ......14
Defining Conditions ..........14
Predefined Conditions ..........15
Condition Expressions ..........16
Testing Conditions ...........16
The /EOF Directive ..........18
Chapter 3. Program Cycle ......21
GeneralRPGIVProgramCycle........21
Detailed RPG IV Program Cycle .......22
Detailed RPG IV Object Program Cycle ....24
Initialization Subroutine .........28
Ending a Program without a Primary File . . . 30
Program Control of File Processing .....31
Chapter 4. RPG IV Indicators .....35
Indicators Defined on RPG IV Specifications . . . 35
Overflow Indicators ..........35
Record Identifying Indicators .......36
Control Level Indicators (L1-L9) ......37
Field Indicators ............45
Resulting Indicators ..........46
Indicators Not Defined on the RPG IV Specifications 47
ExternalIndicators...........47
InternalIndicators...........48
ReturnIndicator(RT)..........49
UsingIndicators.............49
File Conditioning ...........50
Field Record Relation Indicators ......50
Function Key Indicators .........52
HaltIndicators(H1-H9).........53
Indicators Conditioning Calculations .....54
Indicators Used in Expressions .......57
Indicators Conditioning Output ......57
Indicators Referred to As Data ........60
*IN................60
*INxx...............60
Additional Rules ...........61
SummaryofIndicators ..........62
Chapter 5. File and Program
Exception/Errors ..........65
File Exception/Errors ...........65
FileInformationDataStructure.......65
File Exception/Error Subroutine (INFSR) . . . 79
Program Exception/Errors .........82
ProgramStatusDataStructure.......83
Program Exception/Error Subroutine .....91
Chapter 6. Procedures and
subprocedures ...........93
Subprocedure Definition ..........94
Procedure Interface Definition .......95
ReturnValues ............96
Scope of Definitions ..........96
Subprocedure Calculations ........97
NOMAIN Module............100
Mixing Main Procedures and Exported
Subprocedures .............100
Implicit Opening of Files and Locking of Data
Areas...............100
Implicit Closing of Files and Unlocking of Data
Areas...............101
Initialization of Global Data .......101
Possible Problems ...........101
Recommendations...........101
© Copyright IBM Corp. 1994, 2001 iii
||
||
||
||
|
||
||
|
||
||
|
||
|
||
|
||
||
||
||