sc092507

Telechargé par jzinse
IBM i
Version 7.3
Programming
IBM Rational Development Studio for i
ILE RPG Programmer's Guide
IBM
SC09-2507-10
Note
Before using this information and the product it supports, read the information in “Notices” on page
489.
This edition applies to IBM® Rational® Development Studio for i (product number 5770-WDS) and to all subsequent
releases and modications until otherwise indicated in new editions. This version does not run on all reduced instruction
set computer (RISC) models nor does it run on CISC models.
This document may contain references to Licensed Internal Code. Licensed Internal Code is Machine Code and is
licensed to you under the terms of the IBM License Agreement for Machine Code.
© Copyright International Business Machines Corporation 1994, 2016.
US Government Users Restricted Rights – Use, duplication or disclosure restricted by GSA ADP Schedule Contract with
IBM Corp.
Contents
ILE RPG Programmer's Guide.................................................................................1
About ILE RPG Programmer's Guide........................................................................................................... 3
Who Should Use This Guide................................................................................................................... 3
Prerequisite and Related Information................................................................................................... 3
How to Send Your Comments................................................................................................................ 3
What's New.................................................................................................................................................. 5
What's New since 7.3?........................................................................................................................... 5
What's New in 7.3?...............................................................................................................................15
What's New in 7.2?...............................................................................................................................18
What's New in 7.1?...............................................................................................................................26
What's New in 6.1?...............................................................................................................................30
What's New in V5R4?........................................................................................................................... 34
What's New in V5R3?........................................................................................................................... 38
What's New in V5R2?........................................................................................................................... 42
What's New in V5R1?........................................................................................................................... 44
What's New in V4R4?........................................................................................................................... 50
What's New in V4R2?........................................................................................................................... 54
What's New in V3R7?........................................................................................................................... 58
What's New in V3R6/V3R2?.................................................................................................................61
ILE RPG Introduction.................................................................................................................................65
Overview of the RPG IV Programming Language................................................................................ 65
RPG IV Specications..................................................................................................................... 65
Cycle Programming.........................................................................................................................66
Subprocedure logic................................................................................................................... 67
Indicators........................................................................................................................................67
Operation Codes............................................................................................................................. 67
Example of an ILE RPG Program.................................................................................................... 68
Using IBM i...................................................................................................................................... 73
Interacting with the System......................................................................................................73
Rational Development Studio for i................................................................................................. 74
RPG Programming in ILE......................................................................................................................74
Program Creation............................................................................................................................75
Program Management.................................................................................................................... 76
Program Call....................................................................................................................................76
Source Debugging...........................................................................................................................77
Bindable APIs................................................................................................................................. 77
Multithreaded Applications............................................................................................................ 78
Program Creation Strategies................................................................................................................79
Strategy 1: OPM-Compatible Application...................................................................................... 79
Method.......................................................................................................................................79
Example of OPM-Compatible Program.....................................................................................80
Effect of ILE..........................................................................................................................80
Related Information.................................................................................................................. 80
Strategy 2: ILE Program Using CRTBNDRPG................................................................................. 81
Method.......................................................................................................................................81
Example of ILE Program Using CRTBNDRPG........................................................................... 81
Effect of ILE..........................................................................................................................82
Related Information.................................................................................................................. 83
iii
Strategy 3: ILE Application Using CRTRPGMOD............................................................................ 83
Method.......................................................................................................................................83
Single-Language ILE Application Scenario...............................................................................84
Mixed-Language ILE Application Scenario...............................................................................84
Advanced Application Scenario................................................................................................ 85
Related Information.................................................................................................................. 86
A Strategy to Avoid......................................................................................................................... 86
Creating an Application Using Multiple Procedures............................................................................87
A Multiple Procedures Module — Overview................................................................................... 87
Main Procedures and Subprocedures.......................................................................................87
Prototyped Calls........................................................................................................................ 88
Example of Module with Multiple Procedures............................................................................... 90
The Entire ARRSRPT Program...................................................................................................93
Coding Considerations....................................................................................................................96
General Considerations.............................................................................................................96
Program Creation...................................................................................................................... 96
Main Procedure Considerations................................................................................................97
Subprocedure Considerations.................................................................................................. 97
For Further Information..................................................................................................................98
Main Procedures........................................................................................................................98
Subprocedures.......................................................................................................................... 98
Prototyped Call..........................................................................................................................98
Creating and Running an ILE RPG Application..........................................................................................99
Using Source Files................................................................................................................................ 99
Using Source Physical Files............................................................................................................ 99
Creating a Library and Source Physical File..............................................................................99
Using the Source Entry Utility (SEU).......................................................................................100
Using SQL Statements............................................................................................................ 103
Using IFS Source Files..................................................................................................................104
Include les.............................................................................................................................104
Search Path Within The IFS...............................................................................................105
Creating a Program with the CRTBNDRPG Command...................................................................... 107
Using the CRTBNDRPG Command............................................................................................... 108
Creating a Program for Source Debugging............................................................................. 110
Creating a Program with Static Binding..................................................................................111
Creating an OPM-Compatible Program Object.......................................................................111
Using a Compiler Listing............................................................................................................... 113
Obtaining a Compiler Listing...................................................................................................114
Customizing a Compiler Listing.............................................................................................. 115
Customizing a Page Heading.............................................................................................115
Customizing the Spacing................................................................................................... 115
Indenting Structured Operations...................................................................................... 115
Correcting Compilation Errors................................................................................................ 116
Using In-Line Diagnostic Messages.................................................................................. 117
Using Additional-Diagnostic Messages.............................................................................117
Browsing a Compiler Listing Using SEU............................................................................ 117
Correcting Run-time Errors.....................................................................................................118
Coordinating Listing Options with Debug View Options...................................................118
Using a Compiler Listing for Maintenance..............................................................................118
Accessing the RETURNCODE Data Area...................................................................................... 119
Creating a Program with the CRTRPGMOD and CRTPGM Commands............................................. 120
Creating a Module Object............................................................................................................. 121
Using the CRTRPGMOD Command......................................................................................... 121
Creating a NOMAIN Module.............................................................................................. 123
Creating a Module for Source Debugging............................................................................... 126
Additional Examples............................................................................................................... 127
Behavior of Bound ILE RPG Modules..................................................................................... 128
iv
Related CL Commands............................................................................................................128
Binding Modules into a Program.................................................................................................. 128
Using the CRTPGM Command................................................................................................ 130
Binding Multiple Modules..................................................................................................131
Additional Examples............................................................................................................... 132
Related CL Commands............................................................................................................132
Using a Binder Listing................................................................................................................... 133
Changing a Module or Program.................................................................................................... 133
Using the UPDPGM Command................................................................................................ 134
Changing the Optimization Level............................................................................................ 134
Removing Observability.......................................................................................................... 135
Reducing an Object's Size.......................................................................................................135
Creating a Service Program................................................................................................................135
Service Program Overview........................................................................................................... 135
Strategies for Creating Service Programs.................................................................................... 136
Creating a Service Program Using CRTSRVPGM..........................................................................137
Changing A Service Program...................................................................................................137
Related CL commands............................................................................................................ 137
Sample Service Program.............................................................................................................. 138
Creating the Service Program................................................................................................. 141
Binding to a Program...............................................................................................................141
Updating the Service Program................................................................................................143
Sample Binder Listing............................................................................................................. 144
Running a Program.............................................................................................................................144
Running a Program Using the CL CALL Command.......................................................................145
Passing Parameters using the CL CALL Command................................................................ 145
Running a Program From a Menu-Driven Application................................................................. 147
Running a Program Using a User-Created Command................................................................. 148
Replying to Run-Time Inquiry Messages..................................................................................... 149
Ending an ILE Program................................................................................................................. 149
Managing Activation Groups........................................................................................................ 150
Specifying an Activation Group...............................................................................................150
Running in the OPM Default Activation Group....................................................................... 151
Maintaining OPM RPG/400 and ILE RPG Program Compatibility.......................................... 151
Deleting an Activation Group.................................................................................................. 151
Reclaim Resources Command................................................................................................152
Managing Dynamically-Allocated Storage................................................................................... 152
Managing the Default Heap Using RPG Operations............................................................... 154
Heap Storage Problems.......................................................................................................... 158
Managing Your Own Heap Using ILE Bindable APIs.............................................................. 159
Calling Programs and Procedures..................................................................................................... 165
Program/Procedure Call Overview...............................................................................................166
Calling Programs..................................................................................................................... 166
Calling Procedures.................................................................................................................. 166
The Call Stack..........................................................................................................................167
Recursive Calls........................................................................................................................ 167
Parameter-Passing Considerations........................................................................................170
Using a Prototyped Call................................................................................................................ 171
Using the CALLP Operation.....................................................................................................172
Calling within an Expression................................................................................................... 172
Examples of Free-Form Call................................................................................................... 173
Passing Prototyped Parameters...................................................................................................173
Parameter Passing Styles....................................................................................................... 173
Passing by Reference........................................................................................................ 174
Passing by Value................................................................................................................ 174
Passing by Read-Only Reference......................................................................................174
Advantages of passing by value or read-only reference.................................................. 174
Choosing between parameter passing styles .................................................................. 175
v
1 / 524 100%
La catégorie de ce document est-elle correcte?
Merci pour votre participation!

Faire une suggestion

Avez-vous trouvé des erreurs dans linterface ou les textes ? Ou savez-vous comment améliorer linterface utilisateur de StudyLib ? Nhésitez pas à envoyer vos suggestions. Cest très important pour nous !