AS/400e ÉÂÔ ILE RPG for AS/400Programmer's GuideVersion 4 SC09-2507-02
SRTSEQ/ALTSEQ in an RPG Program versus a DDS File ... 279Chapter 16. Accessing Database Files ... 281Database Files . .
Creating a Module Object You bind a module containing NOMAIN to another module using one of thefollowing commands: a. CRTPGM command b. CRTSRVPGM
Creating a Module Object *------------------------------------------------------------------* Subprocedure Trans_Inc *--------------------------
Creating a Module Object * Prototype for Trans_Inc D Trans_Inc PR 11P 2 D Prod 10P 0 VALUE D Quantity 5P 0 VALUE D Discount 2P 2 VALUE* Prototy
Creating a Module Object *=================================================================** MODULE NAME: TRANSRPT* RELATED FILES: TRNSDTA (PF)*
Creating a Module Object A*****************************************************************A* RELATED FILES: TRNSRPT *A* DESCRIPTION: This is the
Binding Modules into a Program Binding Modules into a ProgramBinding is the process of creating a runnable ILE program by combining one ormore modu
Binding Modules into a Program In addition to binding modules together, you can also bind them to service pro-grams (type *SRVPGM). Service program
Binding Modules into a Program terminate when the program does. Whether or not you set on LR, your programwill have a fresh copy of its data the ne
Binding Modules into a Program 9. Once all the imports have been resolved, the binding process completes andthe program object is created.Note: If
Using a Binder Listing Product name Quantity Income------------------------------ -------- ------------Large 245 330,750.00Super 15 52,500.00Sup
Using a Program-Described WORKSTN File without a Format Name ... 340Valid WORKSTN File Operations ... 341EXFMT Operation .
Changing a Module or Program The information in this listing can help you diagnose problems if the binding wasnot successful, or give feedback abou
Changing a Module or Program Note: In the remainder of this section the term 'object' will be used to refer toeither an ILE module or IL
Changing a Module or Program level again afterwards to improve the program efficiency as you get the programready for production. To determine the
Changing a Module or Program An alternative is to compress the object, using the Compress Object (CPROBJ)command. A compressed object takes up less
Changing a Module or Program 90 ILE RPG for AS/400 Programmer's Guide
Service Program Overview Chapter 8. Creating a Service ProgramThis chapter provides:¹ An overview of the service program concept¹ Strategies for cr
Creating a Service Program Using CRTSRVPGM Strategies for Creating Service ProgramsWhen creating a service program, you should keep in mind:1. Whet
Creating a Service Program Using CRTSRVPGM See “Creating the Service Program” on page 97 for an example of using theCRTSRVPGM command.Table 9. Pa
Sample Service Program Sample Service ProgramThe following example shows how to create a service program CVTTOHEX whichconverts character strings t
Sample Service Program *=================================================================** CvtToHex - convert input string to hex output string
Analyzing Your Conversion ... 393Using the Conversion Report ... 394Using the Log File ...
Sample Service Program *-----------------------------------------------------------------** Use the operational descriptors to determine the leng
Sample Service Program *=================================================================** CvtToHex - convert input string to hex output string
Sample Service Program Note that a binding directory is not required here because all modules neededto create the service program have been specifi
Sample Service Program *----------------------------------------------------------------** Program to test Service Program CVTTOHEX * * ** 1. Use
Sample Service Program Updating the Service ProgramBecause of the binder language, the service program could be updated and theprogram CVTHEXPGM wo
Sample Service Program Create Program Page 15769SS1 V4R4M0 990521 MYLIB/CVTHEXPGM AS400S01 07/30/99 23:24:00 Program . . . . . . . . . . . . . .
Sample Service Program 102 ILE RPG for AS/400 Programmer's Guide
Running a Program Using the CL CALL Command Chapter 9. Running a ProgramThis chapter shows you how to:¹ Run a program and pass parameters using the
Running a Program Using the CL CALL Command Passing Parameters using the CL CALL CommandYou use the PARM option of the CL CALL command to pass para
Running a Program Using the CL CALL Command *===============================================================** PROGRAM NAME: EMPRPT2 ** RELATED F
NoticesThis information was developed for products and services offered in the U.S.A. IBMmay not offer the products, services, or features discuss
Running a Program From a Menu-Driven Application A*****************************************************************A* DESCRIPTION: This is the DD
Running a Program From a Menu-Driven Application A* Free Form Menu: PAYROL A*A DSPSIZ(24 80 *DS3 -A 27 132 *DS4) A CHGINPDFT A INDARA A PRINT(*L
Replying to Run-Time Inquiry Messages Running a Program Using a User-Created CommandYou can create a command to run a program by using a command de
Managing Activation Groups where sequence-no is a number from 1-9999, which reflects where in the list theentry is being added, and message-id is t
Managing Activation Groups programs activated within one activation group are developed as one cooperativeapplication.You identify the activation g
Managing Activation Groups If you create an ILE RPG program with ACTGRP(*NEW), you can then call theprogram as many times as you want without retur
Managing Activation Groups Deleting an Activation GroupWhen an activation group is deleted, its resources are reclaimed. The resourcesinclude stati
Managing Dynamically-Allocated Storage For more information on the RCLRSC command, refer to the CL Reference(Abridged). For more information on the
Managing Dynamically-Allocated Storage Note: Although the ALLOC operation code works only with the default heap, theREALLOC and DEALLOC operation
Managing Dynamically-Allocated Storage *-----------------------------------------------------------------** S U B P R O C E D U R E S * *-------
Such information may be available, subject to appropriate terms and conditions,including in some cases, payment of a fee.The licensed program desc
Managing Dynamically-Allocated Storage *-----------------------------------------------------------------* * ** After: Now the names name@, name_
Managing Dynamically-Allocated Storage *-----------------------------------------------------------------** Display - display the list * *------
Managing Dynamically-Allocated Storage *-----------------------------------------------------------------** Free - release the storage used by th
Managing Dynamically-Allocated Storage *-----------------------------------------------------------------** Heap Storage Misuse * *-------------
Managing Dynamically-Allocated Storage procedures in the module DYNARRAY dynamically allocate storage for a practicallyunbounded packed array. The
Managing Dynamically-Allocated Storage *=================================================================* DYNARRAY : Handle a (practically) unbo
Managing Dynamically-Allocated Storage *-----------------------------------------------------------------* Interface to the CEEDSHP API (Discard
Managing Dynamically-Allocated Storage *=================================================================* DYNA_INIT: Initialize the array. ** Fu
Managing Dynamically-Allocated Storage *=================================================================* DYNA_SET: Set an array element. ** Fun
Managing Dynamically-Allocated Storage ** Calculate the new number of elements. If the index is* greater than the current number of elements in th
Registered trademarks and unregistered trademarks are denoted by and respectively. Notices xiii
Managing Dynamically-Allocated Storage The logic of the subprocedures is as follows:1. DYNA_INIT creates the heap using the ILE bindable API CEECRH
Program/Procedure Call Overview Chapter 10. Calling Programs and ProceduresIn ILE, it is possible to call either a program or procedure. Furthermor
Program/Procedure Call Overview ¹ Recursion¹ Parameter passing considerations Calling ProgramsYou can call OPM or ILE programs by using program c
Program/Procedure Call Overview ples of using procedure pointers, see the section on the procedure pointer datatype in ILE RPG for AS/400 Reference
Program/Procedure Call Overview Recursive CallsRecursive calls are only allowed for subprocedures. A recursive call is one whereprocedure A calls
Program/Procedure Call Overview PGM XPRC_BPRC_APRC_CRecursive CallCall Stack (bottom entry is most recent)PRC_AFigure 60. Recursive Call Stack To
Program/Procedure Call Overview Sometimes you may not be sure of the exact format of the data that is beingpassed to you. In this case you may requ
Using a Prototyped Call Table 10. Parameter Passing OptionsParameter Option Prototyped NotPrototypedSee PageCompile-time parametercheckingYes 135
Using a Prototyped Call To call a prototyped program or procedure follow these general steps:1. Include the prototype of the program or procedure t
Passing Prototyped Parameters Examples of Free-Form CallFor examples of using the CALLP operation, see:¹ Figure 22 on page 41¹ Figure 43 on page 97
xiv ILE RPG for AS/400 Programmer's Guide
Passing Prototyped Parameters Passing by ValueWith a prototyped procedure, you can pass a parameter by value instead of byreference. When a paramet
Passing Prototyped Parameters *-------------------------------------------------------------* The procedure returns a value of a 10-digit integer
Passing Prototyped Parameters To pass a parameter by read-only reference, specify the keyword CONST on thedefinition specification of the parameter
Passing Prototyped Parameters are then built by the calling procedure and passed as hidden parameters to thecalled procedure. Operational descripto
Passing Prototyped Parameters Passing *OMITYou can pass *OMIT for a prototyped parameter if the called procedure is awarethat *OMIT might be passe
Passing Prototyped Parameters Checking for the Number of Passed ParametersAt times it may be necessary to check for the number of parameters that a
Passing Prototyped Parameters 2. Correct the street number for printing using the subroutine GetStreet#.3. Concatenate the complete address. 4. Re
Passing Prototyped Parameters *=================================================================** SUBROUTINE: GetStreet#* Get the character form
Passing Prototyped Parameters *=================================================================** PRTADDR - Print an address* Calls FmtAddr to f
Passing Prototyped Parameters *-----------------------------------------------------------------** 'Program 2'- Use of FMTADDR before p
About This GuideThis guide provides information that shows how to use the ILE RPG for AS/400compiler (ILE RPG) in the Integrated Language Environm
Passing Prototyped Parameters Figure 71 on page 146 shows the prototype for QCMDEXC, where the first param-eter is defined with OPTIONS(*VARSIZE) m
For information on the data types supported by different HLLs, consult the appro-priate language manual.Table 11. RPG Parameter Passing MethodsPa
Using the Fixed-Form Call Operations | For ILE C, declare the returned value as a struct with a subfield of type char.| (The RPG return value can a
Using the Fixed-Form Call Operations 2. Optionally code an error indicator (positions 73 and 74) or an LR indicator(positions 75 and 76) or both.Wh
Using the Fixed-Form Call Operations For more information on operational descriptors, see “Using OperationalDescriptors” on page 138.¹ There are fu
Using the Fixed-Form Call Operations If insufficient parameters are specified when calling a procedure, an error occurswhen an unresolved parameter
Returning from a Called Program or Procedure Multiple PLISTs can appear in a procedure. However, only one *ENTRY PLIST canbe specified, and only in
Returning from a Called Program or Procedure ¹ The RETURN operation (with a blank factor 2) is processed, the H1 through H9indicators are not on, a
Returning from a Called Program or Procedure ¹ All files that are open are closed.¹ Any data areas locked by the procedure are unlocked.¹ If the ma
Using Bindable APIs A subprocedure ends abnormally and control returns to the calling procedurewhen an unhandled exception occurs. Again, no furthe
Prerequisite and Related InformationUse the AS/400 Information Center as your starting point for looking up AS/400technical information. You can a
Calling a Graphics Routine You access ILE bindable APIs using the same call mechanisms used by ILE RPGto call procedures, that is, the CALLP operat
Multithreading Considerations ¹ The name of the graphics routine you want to run.¹ The appropriate parameters for the specified graphics routine. T
Multithreading Considerations | THREAD(*SERIALIZE) will protect most of your variables and all your internal| control structures from being accesse
Multithreading Considerations | *-----------------------------------------------------------------------------------| * .---------------.| * | |
Multithreading Considerations | complete their calls, since each module will be locked by the thread in the other| module. This type of problem can
Debugging and Exception HandlingThis section describes how to:¹ Debug an Integrated Language Environment application by using the IntegratedLanguag
162 ILE RPG for AS/400 Programmer's Guide
The ILE Source Debugger Chapter 11. Debugging ProgramsDebugging allows you to detect, diagnose, and eliminate run-time errors in aprogram. You can
The ILE Source Debugger ¹ Equate a shorthand name with a field, expression, or debug commandBefore you can use the source debugger, you must select
The ILE Source Debugger STEP Allows you to run one or more statements of the procedure beingdebugged.| TBREAK Permits you to enter either an uncond
|What's New This Release?| The major enhancements to RPG IV since V4R2 are the support for running ILE| RPG modules safely in a threaded envir
Preparing a Program for Debugging 7. From the help panel which appears, you can select a number of topics per-taining to RPG, such as displaying va
Preparing a Program for Debugging Table 13. Debug ViewsDebug View Debug Data DBGVIEW Param-eter ValueNone No debug data *NONEStatement view(defau
Preparing a Program for Debugging Creating a COPY Source ViewA COPY source view contains text from the root source member, as well as thetext of al
Preparing a Program for Debugging members into the module object. There is no dependency on the source membersupon which it is based, once the list
Starting the ILE Source Debugger If the default values for either create command have been changed, you mustexplicitly specify DBGVIEW(*STMT) and O
Starting the ILE Source Debugger STRDBG ExampleTo start a debug session for the sample debug program DEBUGEX and a calledOPM program RPGPGM, type:
Adding/Removing Programs from a Debug Session Changing the debug options using the SET debug command affects the value forthe corresponding paramet
Adding/Removing Programs from a Debug Session Example of Adding a Service Program to a Debug SessionIn this example you add the service program CVT
Viewing the Program Source Work with Module List System: AS400S1 Type options, press enter.1=Add program 4=Remove program 5=Display module sour
Viewing the Program Source Viewing a Different ModuleTo change the module object that is shown on the Display Module Source display,use option 5 (D
| – *SRCSTMT allows you to assign statement numbers for debugging from| the source IDs and SEU sequence numbers in the compiler listing. (The| sta
Viewing the Program Source Display Module Source Program: DEBUGEX Library: MYLIB Module: CPROC 1 #include <stdlib.h> 2 #include <stri
Setting and Removing Breakpoints Display Module Source ... : Select V
Setting and Removing Breakpoints is shown with the source positioned at the line where the breakpoint occurred. Thisline is highlighted. At this po
Setting and Removing Breakpoints display. A list of options appear which allow you to set or remove breakpoints. Ifyou select 4 (Clear), a job brea
Setting and Removing Breakpoints Display Module Source Program: DEBUGEX Library: MYLIB Module: DBGEX 84 *--------------------------------------
Setting and Removing Breakpoints The current thread is the thread that is currently being debugged. Debug com-mands are issued to this thread. When
Setting and Removing Breakpoints is encountered. The relational operators supported for conditional breakpoints arenoted at the beginning of this s
Setting and Removing Breakpoints 5. After the breakpoint is set, press F12 (Cancel) to leave the Work with ModuleBreakpoints display. Press F3 (End
Setting and Removing Breakpoints This corresponds to the RPG graphic data type.NLSS applies only to non-numeric conditional breakpoint expressions
Setting and Removing Breakpoints Table 14. Non-numeric Conditional Breakpoint ExpressionsType PossibleChar-8 ¹ Character field compared to charac
|Table 1. Changed Language Elements Since V4R2| Language Unit| Element| Description| Control specifi-| cation keywords| OPTION(*{NO}SRCSTMT)| *SR
Setting and Removing Breakpoints | Line <--------------------- Source Specifications ----------------------------------------------><----
Setting and Removing Breakpoints ||| Display Module Source| Program: MYPGM Library: MYLIB Module: MYPGM| 33 002500 * Begin-procedure| 34 0
Setting and Removing Watch Conditions To remove a conditional thread breakpoint using the Work with Module Breakpointsdisplay:1. Type 4 (Clear) in
Setting and Removing Watch Conditions Characteristics of WatchesYou should know the following characteristics about watches before working withthem
Setting and Removing Watch Conditions Setting Watch ConditionsBefore you can set a watch condition, your program must be stopped under debug,and th
Setting and Removing Watch Conditions Work with Watch ... : Display Watch : DEBUGGER : :
Setting and Removing Watch Conditions Displaying Active WatchesTo display a system-wide list of active watches and show which job set them, type:DS
Example of Setting a Watch Condition Example of Setting a Watch ConditionIn this example, you watch a variable SALARY in program MYLIB/PAYROLL. To
Stepping Through the Program Object Display Module Source (Source not available) F3=End program F12=Resume F14=Work with module list F18=Work wi
Stepping Through the Program Object on the debug command line, the next five statements of your program object arerun, then the program object is s
|Table 2 (Page 1 of 2). New Language Elements Since V4R2Language Unit Element Description| Control specifi-| cation keywords| CCSID(*GRAPH:|
Stepping Through the Program Object Stepping Into Call StatementsYou can step into a call statement by using:¹ F22 (Step into) on the Display Modul
Stepping Through the Program Object Example of Stepping Into an OPM Program Using F22In this example, you use the F22 (Step Into) to step into the
Stepping Through the Program Object Display Module Source Program: RPGPGM Library: MYLIB 1 *===================================================
Stepping Through the Program Object Display Module Source Program: DEBUGEX Library: MYLIB Module: DBGEX 141 142 *=============================
Stepping Through the Program Object on the debug command line. The variable field-name is the name of the field, datastructure, or array that you w
Stepping Through the Program Object | Scalar Fields RPG Definition| > EVAL String 6A INZ('ABCDEF')| STRING = 'ABCDEF'| >
Stepping Through the Program Object Displaying the Contents of an ArraySpecifying an array name with EVAL will display the full array. To display o
Stepping Through the Program Object 3 DIM(3) CTDATA Compile-time data: **> EVAL TableA ** Show value at aaaTABLEA = 'aaa' current i
Stepping Through the Program Object ** Note that you can enter the data structure name or a subfield name. **> EVAL DS3TITLE OF DS3 = 'Mr.
Stepping Through the Program Object > EVAL IN02Identifier does not exist.> EVAL *IN02*IN02 = '1'> EVAL *IN(02)*IN(02) = '1&
|Table 2 (Page 2 of 2). New Language Elements Since V4R2| Language Unit| Element| Description| Operation codes| EVALR| Evaluates an assignmen
Stepping Through the Program Object | Displaying UCS-2 Data| The value displayed for UCS-2 fields has been translated into readable characters.| Fo
Stepping Through the Program Object The %SUBSTR built-in function allows you to substring a string variable. The firstparameter must be a string id
Changing the Value of Fields Use the %VARS debug built-in function when the variable name conflicts with anyof the debug command names. For example
Changing the Value of Fields When assigning literals to fields, the normal RPG rules apply:¹ Character literals should be in quotes.¹ Graphic liter
Equating a Name with a Field, Expression, or Command Displaying Attributes of a FieldYou can display the attributes of a field using the Attribute
Sample Source for Debug Examples EQUATE shorthand-name definitionon the debug command line. shorthand-name is the name that you want to equatewith
Sample Source for Debug Examples CRTRPGMOD MODULE(MYLIB/DBGEX) SRCFILE(MYLIB/QRPGLESRC) DBGVIEW(*ALL)TEXT('Main module for Sample Debug Progra
Sample Source for Debug Examples * Pointers D NullPtr S * INZ(*NULL) D BasePtr S * INZ(%ADDR(String)) D ProcPtr S * ProcPtr INZ(%PADDR('c
Sample Source for Debug Examples *=================================================================** Now the operation to modify values or call
Sample Source for Debug Examples *-----------------------------------------------------------------** After the following SETON operation, *IN02
xxii ILE RPG for AS/400 Programmer's Guide
Sample Source for Debug Examples #include <stdlib.h> #include <string.h> #include <stdio.h>extern char EXPORTFLD[6];char *c_p
Exception Handling Overview Chapter 12. Handling ExceptionsThis chapter explains how ILE RPG exception handling works, and how to use: ¹ Exceptio
Exception Handling Overview ¹ Optionally recovering from the exception by passing the exception informationto a piece of code to take any necessary
Exception Handling Overview Program AProgram ASendingTerminatingException CEE9901Proc. P1Proc. P1Proc. P2Proc. P2Proc. P3exceptionoccursProc. P3exc
Exception Handling Overview tion. If it remains unhandled, then the entry is removed and the function check ispercolated. The process repeats until
Exception Handling Overview 2. If an 'E' operation code extender is present on the calculation specification andthe exception is one that
Exception Handling Overview ¹ If there is no *PSSR and a function check occurs, the procedure is removedfrom the call stack and the exception is pe
Using Exception Handlers Using Exception HandlersPlanning the exception handling capability of your application means making thefollowing decisions
Using Exception Handlers (when R is chosen). For example, any read operation will be retried if the readfailed because of record locking.For other
Using Exception Handlers Note: The same exception handling events described would apply to a procedurecall (CALLB operation) as well.Example of Un
ILE RPG IntroductionBefore using ILE RPG to create a program, you must know certain aspects of theenvironment in which you will be using it. This p
The following then occurs:1. Since there are no error indicators coded in PRC2, PRC2 cannot handle thefunction check, and so it is unhandled.2. Si
This section provides some examples of how to use each of these RPG constructs.The ILE RPG for AS/400 Reference provides more information on the *P
When you specify an error indicator or an 'E' extender on an operation code, youcan explicitly call a file error subroutine (INFSR) or a
subroutine is called again. The procedure will loop unless you code the subrou-tine to avoid this problem.To see how to code an error subroutine to
Note that the File specification for PRDMAS identifies both the INFDS and identifiesthe INFSR to be associated with it.The following is done for e
*-----------------------------------------------------------------** Access the product master file using the transaction product * * number. *
Using a Program Error SubroutineTo handle a program error or exception you can write a program error subroutine(*PSSR). When a program error occur
*-----------------------------------------------------------------** Define relevant parts of program status data structure * *-----------------
*-----------------------------------------------------------------** Start of subprocedure definition *----------------------------------------
*-----------------------------------------------------------------** Start of subprocedure definition *-----------------------------------------
2 ILE RPG for AS/400 Programmer's Guide
*=================================================================** NOLOOP: Show how to avoid recursion in a *PSSR subroutine. * *============
5. The ENDSR operation receives control, and the procedure is canceled.The approach used here to avoid looping can also be used within an INFSR err
ILE Condition Handlers ILE Condition HandlersILE condition handlers are exception handlers that are registered at run timeusing the Register ILE Co
ILE Condition Handlers | pointer to a communication area between SHOWERR and RPGHDLR, and a fieldto contain the possible actions, resume or percola
ILE Condition Handlers | D CondTok DS BASED(pCondTok)| D MsgSev 5I 0| D MsgNo 2A| D 1A| D MsgPrefix 3A| D MsgKey 4A| D CommArea DS BAS
ILE Condition Handlers requires a definition for the error-prone array ARR1, and identification of the param-eter lists used by the ILE bindable AP
ILE Condition Handlers | *=================================================================*| * SHOWERR: Show exception handling using a user-def
ILE Condition Handlers | *-----------------------------------------------------------------*| * Register the handler and generate errors *| *--
*=================================================================** *PSSR: Error Subroutine for the procedure * *=============================
handler remains in effect until the call stack entry is removed, or until CEEUTX iscalled to disable it. See the System API Reference for more info
RPG IV Overview Chapter 1. Overview of the RPG IV Programming LanguageThis chapter presents a high-level review of the features of the RPG IV progr
*-----------------------------------------------------------------* Procedure Enabler. This procedure enables a cancel handler,* then gets an er
*-----------------------------------------------------------------* Define the cancel handler. The parameter is a pointer to the* 'communica
If you encounter this problem, you have two possible ways to avoid it:1. Ensure that the caller is in a different activation group from the ILE RP
*----------------------------------------------------------------* Handle information or warning messages, otherwise percolate *----------------
250 ILE RPG for AS/400 Programmer's Guide
Using the DUMP Operation Code Chapter 13. Obtaining a DumpThis chapter describes how to obtain an ILE RPG formatted dump and provides asample forma
Example of a Formatted Dump ¹ If a DUMP operation is bypassed by a GOTO operation, the DUMP operationdoes not occur.Example of a Formatted DumpThe
Example of a Formatted Dump .E/ ILE RPG routine in which the exception or error occurred..F/ CPF or MCH for a machine exception..G/ Information abo
Example of a Formatted Dump INFDS FILE FEEDBACK .I/ File . . . . . . . . . . . . . . . . . : QSYSPRT File Open . . . . . . . . . . . . . . : YES F
Example of a Formatted Dump .J/ This is the file open feedback information for the file. See the Data Man-agement manual for a description of the f
RPG IV Overview Cycle ProgrammingWhen a system processes data, it must do the processing in a particular order.This logical order is provided by:¹
Example of a Formatted Dump ILE RPG FORMATTED DUMP Module Name. . . . . . . . . . . . . . : DBGEX2 Optimization Level . . . . . . . . . . : *NONE
Example of a Formatted Dump DS1 DS OCCURS(3) .R/ OCCURRENCE(1)FLD1 CHAR(5) '1BCDE' 'F1C2C3C4C5'X FLD1A CHAR(1) DIM(5) (1
Example of a Formatted Dump .N/ Beginning of user variables, listed in alphabetical order, and grouped byprocedure. Data that is local to a subproc
Working with Files and DevicesThis section describes how to use files and devices in ILE RPG programs. Specif-ically, it shows how to:¹ Associate a
260 ILE RPG for AS/400 Programmer's Guide
Associating Files with Input/Output Devices Chapter 14. Defining FilesFiles serve as the connecting link between a program and the device used for
Associating Files with Input/Output Devices SPECIAL. Figure 126 on page 262 shows a file description specification for adisplay (WORKSTN) file FILE
Types of File Descriptions RPG programFILEYFile name - FILEYDevice = SEQDevice type =PRINTERFile type =DEVICEFigure 128. Associating a file name
Types of File Descriptions ¹ Less maintenance activity when the file’s record format is changed. You canoften update programs by changing the file’
Defining Externally Described Files .2/ An externally described file (that is, a file with field-level externaldescription) is used as a program-de
RPG IV Overview .2/ RPG reads the next record and sets on the record identifying andcontrol level indicators..3/ RPG processes total calculations (
Defining Externally Described Files Renaming Record-Format NamesMany of the functions that you can specify for externally described files (such ast
Defining Externally Described Files Once a record-format is ignored, it cannot be specified for any other keyword(SFILE, RENAME, or INCLUDE), or fo
Defining Externally Described Files with an indicator, and you then try to rename the field referencing theunprefixed name, you will get an error.
Defining Externally Described Files field in positions 49 through 62 and assign a match-level value in posi-tions 65 and 66.In this example, the CU
Defining Externally Described Files ¹ In the creation of a new record, the fields specified in the output field specifica-tions are placed in the r
Data Management Operations and ILE RPG I/O Operations The RPG program does not provide level checking for program-described files orfor files using
Data Management Operations and ILE RPG I/O Operations Table 17. Data Management Operations and the Corresponding RPG I/O OperationData Management
Overriding and Redirecting File Input and Output Chapter 15. General File ConsiderationsThis chapter provides information on the following aspects
Overriding and Redirecting File Input and Output in the program. For example, if the RPG device name is PRINTER, and the actualfile the program con
File Locking RPG programExecution Time:No OverrideFile name = QTAPEFormat=EDevice = SEQCompile Time:Override FileQTAPE toFile FMT1QTAPEFMT1File typ
AS/400e ÉÂÔILE RPG for AS/400Programmer's GuideVersion 4 SC09-2507-02
Example of an ILE RPG Program Each RPG IV indicator has a two-character name (for example, LR, 01, H3), and isreferred to in some entries of some s
Record Locking Record LockingWhen a record is read by a program, it is read in one of two modes: input orupdate. If a program reads a record for u
Sharing an Open Data Path included. These output operations can be processed by EXCEPT output, detailoutput, or total output.(There are exceptions
Spooling ¹ If a program sharing an open data path for an externally described file tries touse a record format that the first program ignored¹ If a
SRTSEQ/ALTSEQ Output SpoolingOutput spooling is valid for batch or interactive jobs. The description of the file thatis specified in the RPG progr
SRTSEQ/ALTSEQ 280 ILE RPG for AS/400 Programmer's Guide
Database Files Chapter 16. Accessing Database FilesYou can access a database file from your program by associating the file namewith the device DIS
Using Externally Described Disk Files Using Externally Described Disk FilesExternally described DISK files are identified by an E in position 22 of
Using Externally Described Disk Files *.. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ..*A...T.Name++++++.Len++TDpB...F
Using Externally Described Disk Files *.. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ..*A...T.Name++++++RLen++TDpB...F
Using Externally Described Disk Files RPG program, an edit code must be specified for the field in the outputspecifications..2/ The CHECK(MF) entry
Example of an ILE RPG Program *.. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ..*A...T.Name++++++RLen++TDpB...Functions
Using Externally Described Disk Files Valid Search ArgumentsYou can specify a search argument in the ILE RPG operations CHAIN, DELETE,READE, READPE
Using Externally Described Disk Files ¹ A search argument cannot refer to a portion of a key field.If a search argument refers to a partial key, th
Using Program-Described Disk Files no record blocking is done by the compiler, nor by data management. If thekeyword BLOCK is not specified, then d
Using Program-Described Disk Files *.. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ..*A...T.Name++++++.Len++TDpB...Func
Using Program-Described Disk Files On the file description specifications, the length of the key field is defined as 10 inpositions 29 through 33 (
Methods for Processing Disk Files Limits RecordsFor sequential-within-limits processing, the record-address file contains limitsrecords. A limits
Methods for Processing Disk Files Table 19 on page 292 shows the valid entries for positions 28, 34, and 35 of thefile description specification fo
Methods for Processing Disk Files If, in the same job or activation group, two logical files use the same physical file,and one file is processed c
Methods for Processing Disk Files A*****************************************************************A* DESCRIPTION: This is the DDS for the physi
Methods for Processing Disk Files as the ENUM field plus the WEEKNO (week number) field, which is a compositekey. ********************************
Example of an ILE RPG Program ¹ The TRANSACT file is defined as the Input Primary file. The ILE RPG programcycle controls the reading of records fr
Methods for Processing Disk Files EXAMPLE PROGRAM 2 (Sequential-by-Key Using READ): This example is thesame as the previous example except that th
Methods for Processing Disk Files OPRINT H 1P 2 6O 40 'EMPLOYEE WEEKLY WORKING 'O 52 'HOURS REPORT' O H01 1O 12 'EMPLOY
Methods for Processing Disk Files C 01 Z-ADD 0 TOTHRS 5 1 C 01 Z-ADD 0 TOTOVT 5 1 C 01 SETOFF 12 C* C MR IF (*IN02='1') C ADD EHW
Methods for Processing Disk Files Random-by-Key ProcessingFor the random-by-key method of processing, a search argument that identifies thekey of
Methods for Processing Disk Files ***************************************************************** * PROGRAM NAME: EMSTUPD ** RELATED FILES: EM
Methods for Processing Disk Files limits record. If the two limits supplied by the record-address file are equal, onlythe records with the specifie
Methods for Processing Disk Files ***************************************************************** * PROGRAM NAME: ESWLIM1 ** RELATED FILES: EM
Methods for Processing Disk Files ***************************************************************** * PROGRAM NAME: ESWLIM2 ** RELATED FILES: EM
Valid File Operations When you update or add a record to a file by relative record number, the recordmust already have a place in the member. For a
Valid File Operations Table 20. Valid File Operations for Keyed Processing Methods (Random by Key,Sequential by Key, Sequential within Limits)Fil
Example of an ILE RPG Program *.. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+...OFilename++DF..N01N02N03Excnam++++B++A++Sb+S
Valid File Operations Table 21. Valid File Operations for Non-keyed Processing Methods (Sequential,Random by Relative Record Number, and Consecut
Using Commitment Control Using Commitment ControlThis section describes how to use commitment control to process file operations asa group. With co
Using Commitment Control for commitment control before you issue the STRCMTCTL command, the openingof the file will fail.The CL command ENDCMTCTL n
Using Commitment Control The default scope for a commitment definition is to the activation group of theprogram issuing the STRCMTCTL command, that
Using Commitment Control 5. Issue ROLBK.The changes made at step 3 are rolled back by the ROLBK operation at step 5,even though the file has been
Using Commitment Control *.. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+... *FFilename++IPEASFRlen+LKlen+AIDevice+.Keywords+
DDM Files Figure 156 on page 312 is an example showing conditional commitment control.*.. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+.
DDM Files The DDM file provides the information needed for a local system to locate a remotesystem and to access the data in the source file. For m
DDM Files 314 ILE RPG for AS/400 Programmer's Guide
Types of Device Files Chapter 17. Accessing Externally Attached DevicesYou can access externally attached devices from RPG by using device files.De
Example of an ILE RPG Program P CalcPay BD CalcPay PI 8P 2D Rate 5P 2 VALUED Hours 10U 0 VALUED Bonus 5P 2 VALUED Overtime S 5P 2 INZ(0) * Determin
Accessing Printer Devices Accessing Printer DevicesPRINTER files of ILE RPG programs associate with the printer files on the AS/400system:Printer f
Accessing Printer Devices For either a program-described or an externally-described file, you can specify anindicator, *IN01 through *IN99, using t
Accessing Printer Devices ¹ Skipping past the overflow line to any line on the same page sets the overflowindicator on.¹ Skipping past the overflow
Accessing Printer Devices Table 23. Results of the Presence or Absence of an Overflow IndicatorFileDescriptionSpecificationsPositions 44-80Output
Accessing Printer Devices *.. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+... *OFilename++DF..N01N02N03Excnam++++B++A++Sb+Sa+
Accessing Printer Devices OverflowOccursDuringGet aRecordTotalCalculationsTotalOutputOverflowPrintingT = TotalH = HeadingD = DetailE = ExceptionDet
Accessing Printer Devices at overflow output time unless overflow is sensed again since the lasttime the overflow lines were written.Specifying Fet
Accessing Printer Devices The total lines with an F coded in position 18 can fetch the overflow routine. Theyonly do so if overflow is sensed prior
Accessing Printer Devices The values contained in the first four subfields of the ILE PRTCTL data structureare the same as those allowed in positio
Accessing Tape Devices *.. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+... *FFilename++IPEASFRlen+LKlen+AIDevice+.Keywords+++
Example of an ILE RPG Program *------------------------------------------------------------------------* * Constant Declarations * *--------------
Using Sequential Files Accessing Display DevicesYou use display files to exchange information between your program and a displaydevice such as a wo
Using SPECIAL Files Example of Specifying a Sequential FileFigure 162 shows an example of how to specify a SEQ file in an ILE RPG sourcemember.*..
Using SPECIAL Files R Read a record and place it in the area defined by the areaparameter.W The ILE RPG program has placed a record in the areadefi
Using SPECIAL Files Table 27. Valid File Operations for a SPECIAL FileFile Description SpecificationsPositionsCalculation Specifications Position
Using SPECIAL Files *.. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+... * DName+++++++++++ETDsFrom+++To/L+++IDc.Functions+++
Using Externally Described WORKSTN Files Chapter 18. Using WORKSTN FilesInteractive applications on the AS/400 generally involve communication with
Using Externally Described WORKSTN Files In addition to the field descriptions (such as field names and attributes), the DDSfor a display-device fi
Using Externally Described WORKSTN Files *.. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ..*AAN01N02N03T.Name++++++RLen++TDpBLinP
Using Externally Described WORKSTN Files Specifying Function Key Indicators on Display Device FilesThe function key indicators, KA through KN and K
Using Externally Described WORKSTN Files Processing an Externally Described WORKSTN FileWhen an externally-described WORKSTN file is processed, the
Using the OS/400 System *------------------------------------------------------------------------* * Subprocedure -- calculates overtime pay. * *-
Using Externally Described WORKSTN Files Customer Name SearchSearch Code _______Number Name Address City StateXXXX XXXXXXXXXXXXXXXXXXXX XXXXXX
Using Externally Described WORKSTN Files specifications require that a relative-record-number field be specified in the secondposition of the SFILE
Using Program-Described WORKSTN Files *.. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ..*AAN01N02N03T.Name++++++RLen++TDpBLinPosF
Using Program-Described WORKSTN Files ¹ What data is sent¹ What ICF functions to perform.If a format name is used, input and output specifications
Using Program-Described WORKSTN Files Input SpecificationsThe input specifications describe the record that the RPG program receives fromthe displ
Valid WORKSTN File Operations ¹ No indicators are passed to or from the program.¹ No function key indicators are defined.¹ The record is written to
Multiple-Device Files EXFMT OperationThe EXFMT operation is a combination of a WRITE followed by a READ to thesame record format (it corresponds t
Multiple-Device Files operations. See the sections on inviting a program device in ICF Programmingmanual and Data Management manual.¹ The READ oper
Multiple-Device Files ation to the ICF device, you do not need to modify the value again unless aninput operation completes successfully with a dif
Database Physical File Chapter 19. Example of an Interactive ApplicationThis chapter illustrates some common workstation applications and their ILE
AS/400 Tools Table 3. Commonly Used CL CommandsAction CL command ResultUsing System Menus GO MAIN Display main menuGO INFO Display help menuGO CM
Main Menu Inquiry A***************************************************************** A* FILE NAME: CUSMST *A* RELATED PGMS: CUSMNT, SCHZIP, SCH
Main Menu Inquiry A***************************************************************** A* FILE NAME: MAINMENU * A* RELATED PGMS: CUSMAIN *A* DES
Main Menu Inquiry ***************************************************************** * PROGRAM NAME: CUSMAIN ** RELATED FILES: MAINMENU (DSPF) **
File Maintenance 22:30:05 CUSTOMER MAIN INQUIRY 9/30/94Press one of the following PF keys.F3 End JobF5 Maintain Customer FileF6 Search Customer
File Maintenance MNTMENU: DDS for a Display Device File A***************************************************************** A* FILE NAME: MNTMENU
File Maintenance A MODE 8A O 1 4DSPATR(HI) A 1 13'MODE' A DSPATR(HI) A 2 4TIME A DSPATR(HI)A 2 28'CUSTOMER FILE MAINTENANCE&a
File Maintenance Delete, and Display modes. The fields are defined as output/input (B in position38). The fields are protected when Display or Dele
File Maintenance ********************************************************************* SUBROUTINE - ADDSUB ** PURPOSE - ADD NEW CUSTOMER TO FIL
File Maintenance ********************************************************************* SUBROUTINE - DELSUB ** PURPOSE - DELETE CUSTOMER MASTER
File Maintenance change the mode of processing by pressing F5 (ADD), F6 (UPDATE), F7(DELETE), or F8 (DISPLAY).To add a new record to the file, the
AS/400 Tools ¹ Define a flexible environment where production, testing, and maintenance canbe managed simultaneously¹ Organize several developers w
File Maintenance DISPLAY MODE22:31:06 CUSTOMER FILE MAINTENANCE 9/30/94 Customer: 00007 Mikhail Yuri1001 Bay Street Suite 1702 Livonia M
File Maintenance ADD MODE22:32:04 CUSTOMER FILE MAINTENANCE 9/30/94 Customer: 00012Name JUDAH GOULDAddress 2074 BATHURST AVENUE Address Ci
Search by Zip Code UPDATE MODE22:33:17 CUSTOMER FILE MAINTENANCE 9/30/9400010 <--Enter Customer NumberF3 End Job F5 Add F6 Update F7 Delet
Search by Zip Code SZIPMENU: DDS for a Display Device File A***************************************************************** A* FILE NAME: SZIP
Search by Zip Code A 55 SFLCLR A N55 SFLDSPCTL A N55 SFLDSP A SFLSIZ(13) A SFLPAG(13)A ROLLUP(95 'ROLL UP') A OVERLAYA CA04(04 &ap
Search by Zip Code SCHZIP: RPG Source ***************************************************************** * PROGRAM NAME: SCHZIP ** RELATED FILES:
Search by Zip Code ********************************************************************* SUBROUTINE - SFLPRC ** PURPOSE - PROCESS SUBFILE AND D
Search by Zip Code The zip code (ZIP) is used to position the CUSMSTL2 file by the SETLL operation.Notice that the record format name CMLREC2 is us
Search and Inquiry by Name 22:34:45 CUSTOMER SEARCH BY ZIP 9/30/94 Zip Code 11201 Customer Name A/R Balance Rick Coupland 300.00 Mikhail Yu
Search and Inquiry by Name SNAMMENU: DDS for a Display Device File A 55 SFLCLR A N55 SFLDSPCTL A N55 SFLDSPA ROLLUP(95 'ROLL UP') A O
AS/400 Tools ¹ Program verification— performs, at the workstation, the full range of syntax andsemantic checking that the compiler does, without ge
Search and Inquiry by Name ¹ SFLDSPCTL indicates when to display the subfile-control record format (whenindicator 55 is off).¹ SFLDSP indicates whe
Search and Inquiry by Name ******************************************************************** * MAINLINE * **********************************
Search and Inquiry by Name ********************************************************************* SUBROUTINE - SFLCLR ** PURPOSE - CLEAR SUBFILE
Search and Inquiry by Name ¹ To display customer detail by entering X, and pressing ENTER. The user canthen return to the PROMPT screen by pressing
Search and Inquiry by Name The detailed information for the customer selected is shown in Figure 192 onpage 370. At this point the user selects the
Appendixes Copyright IBM Corp. 1994, 1999 371
372 ILE RPG for AS/400 Programmer's Guide
Differences Between OPM RPG/400 and ILE RPG Appendix A. Behavioral Differences Between OPM RPG/400and ILE RPG for AS/400The following lists note di
Differences Between OPM RPG/400 and ILE RPG Running1. The FREE operation is not supported by RPG IV.2. Certain MCH messages may appear in the job
Differences Between OPM RPG/400 and ILE RPG 4. Call performance for LR-on will be greatly improved by having no PSDS, or aPSDS no longer than 80 by
Note! Before using this information and the product it supports, be sure to read the general information under “Notices” on page xi.Third Editio
AS/400 Tools 16 ILE RPG for AS/400 Programmer's Guide
Differences Between OPM RPG/400 and ILE RPG In ILE RPG, the total number of program devices that can be acquired by theprogram cannot be different
Differences Between OPM RPG/400 and ILE RPG give different results than expected when DDS features are used that causemore than one search argument
Differences Between OPM RPG/400 and ILE RPG ¹ The user has not specified that a transparency check should be performedby the compilerIn ILE RPG, if
Conversion Overview Appendix B. Using the RPG III to RPG IV Conversion AidThe RPG IV source specification layouts differ significantly from the Sys
Conversion Overview File ConsiderationsThe Conversion Aid operates on file members. This section presents information ondifferent aspects of files
Conversion Overview If the converted source file has a record length less than 92 characters then anerror message will be issued and the conversion
Converting Your Source In addition to object-authority requirements, there may be additional storagerequirements. Each converted source program is,
Converting Your Source 5. Check the log file or the error report for any errors. For more information, see“Analyzing Your Conversion” on page 393.6
Converting Your Source ┌┐─*LIBL/──────── ┌ ┐─source-file-member-name── ─CVTRPGSRC─ ─FROMFILE──(─ ──┼ ┼─────────────── ─── ──source-file-name─
Converting Your Source source-file-member-nameEnter the name of the source member to be converted.*ALLThe command converts all the members in the s
RPG Programming in ILE Chapter 2. RPG Programming in ILEILE RPG is an implementation of the RPG IV programming language in the Inte-grated Language
Converting Your Source the source members in the FROMFILE are converted. The convertedsource members have the same names as those of the original s
Converting Your Source LOGFILESpecifies the name of the log file that is used to track the conversion informa-tion. Unless *NONE is specified, ther
Converting Your Source Converting All Members in a FileYou can convert all of the members in a source physical file by specifyingFROMMBR(*ALL) and
Converting Your Source Using the TOFILE(*NONE) parameter stops the Conversion Aid from generating aconverted member, but still allows it to produce
Example of Source Conversion Converting Source Members with Embedded SQLWhen converting code that contains embedded SQL and the SQL code is con-tin
Example of Source Conversion H TSTPGM FFILE1 IF E DISK COMM1 FQSYSPRT O F 132 OF LPRINTER LQSYSPRT 60FL 56OL E ARR1 3 3 1 COMM2 E ARR2 3 3
Example of Source Conversion 1 ...H*unctions+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++Comments+++++++++ 2 H DFTNAME(TSTPG
Analyzing Your Conversion ¹ Record address file (RAF) entries on extension specifications have beenreplaced by the keyword RAFDATA on the File Desc
Analyzing Your Conversion Using the Conversion ReportThe Conversion Aid generates a conversion report if you specify theCVTRPT(*YES) parameter on t
Analyzing Your Conversion 5769RG1 V4R4M0 990521 RN IBM ILE RPG AS400S01 12/30/99 20:41:35 Page 2From file . . . . . . . . . . . : MYLIB/QRPGSRC(REP
RPG Programming in ILE Alternatively, you may create a program using separate commands for compilationand binding. This two-step process allows you
Analyzing Your Conversion F i n a l S u m m a r y Message Totals:Information (00) . . . . . . . : 2Warning (10) . . . . . . . : 0Severe Error (30+
Analyzing Your Conversion A R QRNCVTFMA LGCENT 1A COLHDG('CVT' 'CENT')A TEXT('Conversion Century: 0-20th 1-+ A 21st&a
Resolving Conversion Problems Resolving Conversion ProblemsConversion problems may arise for one or more of the following reasons:¹ The RPG III sou
Resolving Conversion Problems Merging ProblemsBecause of differences between the RPG III and RPG IV languages, the Conver-sion Aid must reorder ce
Resolving Conversion Problems There are two methods of correcting this type of problem:1. Use the EXPCPY(*YES) option of the CVTRPGSRC command to i
Resolving Conversion Problems ¹ In renaming an externally described data structure field or an externallydescribed file fieldI* If the RPG III sour
Resolving Conversion Problems Merging an Array with an Externally Described DS SubfieldAs mentioned earlier, you are not allowed to define a standa
Resolving Conversion Problems IDSONE E DSEXTREC I CHARACTER CHAR I I 'XYZ' CHAR C CHAR DSPLYC SETON LRFigure 210. RPG III sourc
Resolving Conversion Problems 404 ILE RPG for AS/400 Programmer's Guide
Reading Syntax Diagrams Appendix C. The Create CommandsThis section provides information on:¹ Using CL commands¹ Syntax diagram and description of
RPG Programming in ILE step process, see Chapter 7, “Creating a Program with the CRTRPGMOD andCRTPGM Commands” on page 73. For more information on
CRTBNDRPG Command ──REQUIRED-PARAMETER──(─ ──┬ ┬─PREDEFINED-VALUE─── ─)───────────────────────────────────── └┘─user-defined-value── ──┬ ┬────
CRTBNDRPG Command ─ ─CRTBNDRPG─ ──┬ ┬──────────────────────────────────────────────── ───────────────────────────────────────────────────── │
CRTBNDRPG Command OPTION Details: ┌ ┐─*XREF─── ┌ ┐─*GEN─── ┌ ┐─*NOSECLVL─ ┌ ┐─*SHOWCPY─── ┌ ┐─*EXPDDS─── ┌ ┐─*EXT─── ┌ ┐─*NOSHOWSKP─├─ ──┼ ┼
CRTBNDRPG Command *LIBLThe system searches the library list to find the library where the source fileis stored. This is the default.*CURLIBThe curr
CRTBNDRPG Command *YESWhen this program is called it will always run in the default activationgroup. The default activation group is the activation
CRTBNDRPG Command *SHOWCPYShow source records of members included by the /COPY compiler direc-tive.*NOSHOWCPYDo not show source records of members
CRTBNDRPG Command | *NODEBUGIO| Do not generate breakpoints for input and output specifications.*NOEVENTFDo not create an Event File for use by CoO
CRTBNDRPG Command *ALLGenerates the listing, source and copy views for debugging the compiledprogram object. The information contained in the listi
CRTBNDRPG Command CVTOPTSpecifies how the ILE RPG compiler handles date, time, timestamp, graphicdata types, and variable-length data types which a
CRTBNDRPG Command library-nameEnter the name of the library where the sort sequence table is stored.LANGIDSpecifies the language identifier to be u
RPG Programming in ILE procedure names are resolved at bind time (that is, when you create the program),static calls are faster than dynamic calls.
CRTBNDRPG Command cific authority to the object. The authority can be altered for all users or forspecified users after the program is created with
CRTBNDRPG Command *NOWhen numeric overflow is detected, a run time error is generated with errorcode RNX0103.FIXNBRSpecifies whether decimal data t
CRTBNDRPG Command Valid values depend on the current version, release, and modification level,and they change with each new release. If you specify
CRTBNDRPG Command *LIBLThe system searches the library list to find the library where the bindingdirectory is stored.*CURLIBThe current library for
CRTRPGMOD Command condition-nameUp to 32 condition names can be specified. Each name can be up to 50characters long. The condition names will be co
CRTRPGMOD Command ─ ─CRTRPGMOD─ ──┬ ┬────────────────────────────────────────────────── ─────────────────────────────────────────────────── │
CRTRPGMOD Command OPTION Details: ┌ ┐─*XREF─── ┌ ┐─*GEN─── ┌ ┐─*NOSECLVL─ ┌ ┐─*SHOWCPY─── ┌ ┐─*EXPDDS─── ┌ ┐─*EXT─── ┌ ┐─*NOSHOWSKP─├─ ──┼ ┼
Compiler Listings Appendix D. Compiler ListingsCompiler listings provide you with information regarding the correctness of yourcode with respect t
Compiler Listings Table 32 (Page 2 of 2). Sections of the Compiler Listing| Listing Section1| OPTION2| DescriptionCode generation errors3Erro
Compiler Listings | 5769RG1 V4R4M0 990521 RN IBM ILE RPG MYLIB/MYSRC .1a/ AS400S01 98/07/27 12:58:46 Page 1| Command ...: CRTBNDRPG| Iss
RPG Programming in ILE ¹ CEEDOD – Decompose Operational DescriptorNote: You cannot use these or any other ILE bindable APIs from within a programc
Compiler Listings Source SectionThe source section shows records that comprise the ILE RPG source specifica-tions. The root source member records
Compiler Listings | with the next sequence number in the listing: sequence number 001700. The three| intervening lines are assigned the SEU sequenc
Compiler Listings | 5769RG1 V4R4M0 990521 RN IBM ILE RPG MYLIB/MYSRC AS400S01 98/07/28 14:21:00 Page 2| .1a/| Line <---------------------- Sou
Compiler Listings | *--------------------------------------------------------------------------------------------* .4/ 1| * Data structure . . .
Compiler Listings | Line <---------------------- Source Specifications ----------------------------><---- Comments ----> Do Page Change
Compiler Listings | Statement Number| Shows the statement number generated from the source ID| number and the SEU sequence number as follows:|stmt_
Compiler Listings | A d d i t i o n a l D i a g n o s t i c M e s s a g e s| Msg id Sv Number Seq Message text| *RNF7066 00 8 000800 Record-Format
Compiler Listings Compile-Time DataThe Compile-Time Data section includes information on ALTSEQ or NLSS tables,and on tables and arrays. In this e
Compiler Listings Key Field InformationThe Key Field Information section shows information about key fields for eachkeyed file. It also shows infor
Compiler Listings | C r o s s R e f e r e n c e| File and Record References:| File Device References (D=Defined)| Record| CUSTFILE DISK 8D|
RPG Programming in ILE 22 ILE RPG for AS/400 Programmer's Guide
Compiler Listings E x t e r n a l R e f e r e n c e sStatically bound procedures: Procedure References PROTOTYPED 2 2 PADDR_PROC 4 CALLB_PROC 6
Compiler Listings | F i n a l S u m m a r y| Message Totals:| Information (00) . . . . . . . : 20| Warning (10) . . . . . . . : 0| Error (20) . .
Compiler Listings 438 ILE RPG for AS/400 Programmer's Guide
BibliographyFor additional information about topics related to ILERPG programming on the AS/400 system, refer to thefollowing IBM AS/400 publicati
embedded SQL statements. Contains examples ofSQL statements and a description of the interactiveSQL function. Describes common concepts andrules f
¹ILE RPG for AS/400 Reference Summary,SX09-1315-01, provides information about the RPGIII and RPG IV programming language. Thismanual contains tabl
442 ILE RPG for AS/400 Programmer's Guide
IndexSpecial Characters/COPY statementconversion problems 389, 398COPY debug view 168in a conversion report 394table in compiler listing 432*CANCL
arrayconversion problems 402displaying while debugging 202loading 403prerun-time arrays 403arrival sequence access path 282ATTR debug commanddefi
call operations (continued)free-form call 133, 134query names of called procedures 149special routines 157using 133call stack 129, 218Call Stack E
OPM-Compatible Application Chapter 3. Program Creation StrategiesThere are many approaches you can take in creating programs using an ILE lan-guage
CL commands (continued)DSPPGMREF 149End Debug (ENDDBG) 170module-related 80MONMSG 247program-related 85RCLACTGR 110RCLRSC 112reading syntax
control-record format, subfile 335Conversion AidSee converting to RPG IVconversion reportsobtaining 389sections of 394using 394conversion, analyz
CRTPGM commandSee Create Program (CRTPGM) commandCRTRPGMOD commandSee Create RPG Module (CRTRPGMOD) commandCRTRPTPGM (create auto report program)
debugging (continued)displaying fields as hexadecimal values 205displaying fields in character format 205displaying fields in UCS-2 format 206displ
DISK file (continued)program-described (continued)processing 291record-address file 290sequential file 290record-format specifications 282DISPLAY
EVAL debug command (continued)using 199event file for CODE/400 411examplescompilingbinding multiple modules 84OPM-compatible program 61program for
externally described file (continued)file description specifications for 265output specifications for 269overriding 267physical and logical files
GGDDM 156generating a programSee compilingSee control specificationsGENLVL parameterCRTBNDRPG command 58, 409CRTRPGMOD command 74Get Descriptive I
indicatorsSee also individual operation codesas error indicators 227displaying while debugging 204error 227function key (KA-KN, KP-KY)with WORKST
listing view, creating 168listing, binderas maintenance resource 86basic 100creating 85determining exports in service program 91sections of 85lis
OPM-Compatible Application Example of OPM-Compatible ProgramFigure 6 shows the run-time view of a sample application where you might want anOPM-com
MODULE parameter 82CRTBNDRPG command 408CRTRPGMOD command 74multiple devices attached to application program 310multiple-device fileWORKSTN 342Nn
overrides, file 267example 274general discussion 273, 304indicated in compiler listing 425overriding external description 267Ppage headings 64page
processing methods (continued)sequential only 293, 304sequential-by-key 293sequential-within-limits 300WORKSTN file 335, 341programabnormal endi
program/procedure call (continued)recursive calls 130returning from a called program or procedure 152returning values 134returning without ending 1
removing observability 88RENAME keyword 266renaming field names 266renaming fields 266renaming record-format names 266REPLACE parameterCRTBNDRPG c
service program (continued)binding with CRTBNDRPG 60changing 93creating 91example 94in advanced application 30reasons for using 91reclaiming res
specifying a return point 237specifying an activation group 110specifying error indicators 227specifying the format of compiler listing 64spooling
TtableSee also arraydisplaying while debugging 202table of parametersCRTBNDRPG command 58CRTRPGMOD command 74CVTRPGSRC command 383tape file 290TBRE
WORKSTN filedefinition 331examples 345externally describedprocessing 335externally-described 331file operation codes allowed with 341function
ÉÂÔÙPart Number: 99H3778Program Number: 5769-RG1Printed in U.S.A. 99H3778SC09-2507-02
ILE Program Using CRTBNDRPG Related InformationConverting to RPG IV “Converting Your Source” on page 382One-step creation process Chapter 6, “Crea
ContentsNotices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiProgramming Interface Information ...
ILE Program Using CRTBNDRPG Example of ILE Program Using CRTBNDRPGFigure 7 shows the run-time view of an application in which an ILE CL programcall
ILE Application Using CRTRPGMOD with programs in different activation groups. If you want to share afile across activation groups, you must open it
ILE Application Using CRTRPGMOD ¹ An advanced applicationThe effect of ILE is the same as described in “Effect of ILE” on page 26.You may want to r
ILE Application Using CRTRPGMOD JobXY Activation GroupRPGRPG *MODULE(Y1)RPG *MODULE(Y2)RPG *MODULE(Y3)RPG *MODULE(Y4)*PGM(X)*PGM(Y)Figure 8. Sing
ILE Application Using CRTRPGMOD JobY Activation GroupCL *MODULE(Y1)RPG *MODULE(Y2)C *MODULE(Y3)RPG *MODULE(Y4)*PGM(Y)Default Activation Group*PGM(Q
A Strategy to Avoid JobXYZ Activation GroupCL *MODULE(X1)RPG *MODULE(X2)C *MODULE(Z1)CL *MODULE(Z2)*PGM(X)*SRVPGM(Y)*SRVPGM(Z)RPGFigure 10. Advan
A Strategy to Avoid JobCL*PGM(X)RPGRPG*PGM(Y)*SRVPGM(Z)Default Activation GroupQILE Activation GroupFigure 11. Scenario to Avoid. An application
Multiple Procedures Module Chapter 4. Creating an Application Using MultipleProceduresThe ability to code more than one procedure in an ILE RPG mod
Multiple Procedures Module Subprocedures offer another feature. You can pass parameters to a subprocedureby value, and you can call a subprocedure
Multiple Procedures Module ¹ The number and nature of the parameters¹ Which parameters must be passed, and which are optionally passed¹ Whether ope
A Strategy to Avoid ... 31Chapter 4. Creating an Application Using Multiple Procedures ... 33A Multiple Proce
Example of Module with Multiple Procedures In order to format the name and address properly, FmtCust calls NumToChar toconvert the customer number
Example of Module with Multiple Procedures Open file, read record, writeoutput records, close filesSubprocedure to determine ifcustomer record is i
Example of Module with Multiple Procedures .1/ All subprocedures begin and end with procedure specifications..2/ After the Begin-Procedure specific
Example of Module with Multiple Procedures *--------------------------------------------------------------** FmtCust formats CUSTNAME, CUSTNUM, S
Example of Module with Multiple Procedures *=================================================================** Source for module CVTPROCS. This
Example of Module with Multiple Procedures The Entire ARRSRPT ProgramThe ARRSRPT program consists of two modules: ARRSRPT and CVTPROCS.Figure 21 sh
Example of Module with Multiple Procedures *--------------------------------------------------------------** P R O T O T Y P E S *--------------
Example of Module with Multiple Procedures * Body of procedure C *ISO MOVE DUEDATE DateDue C CurDate SUBDUR DateDue DaysLate:*DC IF DaysLate &g
Example of Module with Multiple Procedures Sample output for the program ARRSRPT is shown in Figure 23 on page 44.Customer number: 00001ABC Electro
Coding Considerations A*================================================================*A* FILE NAME : CUSTRPTA* RELATED PGMS : ARRSRPTA* DESCRI
Changing the Optimization Level ... 87Removing Observability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
Coding Considerations Program Creation¹ If you specify that a module does not have a main procedure then you cannotuse the CRTBNDRPG command to cr
For Further Information The automatic storage that is associated with earlier invocations is unaffectedby later invocations. All invocations share
For Further Information Prototyped CallTopic SeeFree-form call “Using a Prototyped Call” on page 133General InformationILE RPG for AS/400 Referen
Creating and Running an ILE RPG ApplicationThis section provides you with the information that is needed to create and run ILERPG programs. It desc
50 ILE RPG for AS/400 Programmer's Guide
Chapter 5. Entering Source StatementsThis chapter provides the information you need to enter RPG source statements. Italso briefly describes the to
Using SEU Using the Source Entry Utility (SEU)You can use the Source Entry Utility (SEU) to enter your source statements. SEUalso provides promptin
Using SEU Columns . . . : 6 76 Edit MYLIB/QRPGLESRC SEU==> ___________________________________________________________ EMPRPT FMT H HKeyword
Using SEU *===============================================================** MODULE NAME: EMPRPT* RELATED FILES: EMPMST (PHYSICAL FILE) * QSYSPR
Using SQL Statements A*****************************************************************A* DESCRIPTION: This is the DDS for the physical file EMPM
Using the Fixed-Form Call Operations ... 148Examples of CALL and CALLB ... 150Passing Parameters Using
Using SQL Statements ...+...1...+...2...+...3...+...4...+...5...+...6...+...7.. CC (ILE RPG calculation operations) CC/EXEC SQL (the
Using the CRTBNDRPG Command Chapter 6. Creating a Program with the CRTBNDRPGCommandThis chapter shows you how to create an ILE program using RPG IV
Using the CRTBNDRPG Command command. For more information see Chapter 7, “Creating a Program withthe CRTRPGMOD and CRTPGM Commands” on page 73.You
Using the CRTBNDRPG Command Table 5 (Page 2 of 2). CRTBNDRPG Parameters and Their Default Values Grouped by FunctionALWNULL(*NO) Determines i
Using the CRTBNDRPG Command Figure 31 on page 60 shows the screen which appears after entering theabove command. Display Module Source Program: E
Using the CRTBNDRPG Command Note: DFTACTGRP must be set to *NO in order for you to enter a value for theACTGRP and BNDDIR parameters.For more info
Using the CRTBNDRPG Command *------------------------------------------------------------------------* * DESCRIPTION: This program creates a print
Using a Compiler Listing Using a Compiler ListingThis section discusses how to obtain a listing and how to use it to help you:¹ Fix compilation err
Using a Compiler Listing *SHOWSKPSource lines excluded by conditional compilation directives (appear insource section of listing)*EXPDDSKey field i
Using a Compiler Listing ¹ Select one of the following time separators: *SYSVAL, *BLANK, colon (:),comma (,) or period (.)Anywhere a date or time f
Displaying Attributes of a Field ... 210Equating a Name with a Field, Expression, or Command ... 210Source Debug
Using a Compiler Listing Line <--------------------- Source Specifications ----------------------------------------------><---- Comments -
Using a Compiler Listing Lists the start and end positions along with the literal text or field names. Usethis to check for errors in your output s
Using a Compiler Listing Using Additional-Diagnostic MessagesThe Additional Diagnostic Messages section identifies errors which arise when oneor mo
Using a Compiler Listing Coordinating Listing Options with Debug View OptionsCorrecting run-time errors often involves debugging a program. The fol
Accessing the RETURNCODE Data Area ¹ *SHOWSKP allows you to see the statements that are ignored by the compileras a result of /IF, /ELSEIF, /ELSE,
Accessing the RETURNCODE Data Area 131-140 Source file library name141-150 Source file member name151-160 Compiler listing file name161-170 Compile
Accessing the RETURNCODE Data Area 72 ILE RPG for AS/400 Programmer's Guide
Creating a Module Object Chapter 7. Creating a Program with the CRTRPGMOD andCRTPGM CommandsThe two-step process of program creation consists of co
Creating a Module Object ¹ Reuse pieces of code. This generally results in smaller programs. Smaller pro-grams give you better performance and easi
Creating a Module Object Table 6 (Page 2 of 2). CRTRPGMOD Parameters and Their Default Values Grouped by FunctionDEFINE(*NONE) Specifies cond
Comments to this Manuals