You are on page 1of 668

unisys

ClearPath Enterprise Servers

Report Program Generator (RPG)


Programming Reference Manual
Volume 1: Basic Implementation
ClearPath MCP 12.0

April 2008 8600 0544–103


NO WARRANTIES OF ANY NATURE ARE EXTENDED BY THIS DOCUMENT. Any product or related information
described herein is only furnished pursuant and subject to the terms and conditions of a duly executed agreement to
purchase or lease equipment or to license software. The only warranties made by Unisys, if any, with respect to the
products described in this document are set forth in such agreement. Unisys cannot accept any financial or other
responsibility that may be the result of your use of the information in this document or software material, including
direct, special, or consequential damages.

You should be very careful to ensure that the use of this information and/or software material complies with the
laws, rules, and regulations of the jurisdictions with respect to which it is used.

The information contained herein is subject to change without notice. Revisions may be issued to advise of such
changes and/or additions.

Notice to U.S. Government End Users: This is commercial computer software or hardware documentation developed
at private expense. Use, reproduction, or disclosure by the Government is subject to the terms of Unisys standard
commercial license for the products, and where applicable, the restricted/limited rights provisions of the contract
data rights clauses.

Unisys and ClearPath are registered trademarks of Unisys Corporation in the United States and other countries.
All other brands and products referenced in this document are acknowledged to be the trademarks or registered
trademarks of their respective holders.
Contents

About This Manual

Documentation Updates ........................................................................xxv

Section 1. RPG Programming

RPG Applications .................................................................................. 1–1


File Creation .......................................................................................... 1–2
RPG Dialects ......................................................................................... 1–2
RPG Source Program ............................................................................ 1–2
Source File Organization ....................................................................... 1–3

Section 2. RPG Language Elements

Character Set ........................................................................................ 2–1


Characters Used for Names ................................................ 2–2
Characters Used for Editing................................................. 2–3
Definition of Names .............................................................................. 2–3
Data Structure Names ......................................................... 2–4
Field Names......................................................................... 2–4
File Names........................................................................... 2–4
Labels .................................................................................. 2–4
Library Names...................................................................... 2–4
Library Subroutine Names ................................................... 2–5
Output Group Names .......................................................... 2–5
Subfield Names ................................................................... 2–5
Vector Names ...................................................................... 2–5
Definition of Literals .............................................................................. 2–6
Figurative Constants............................................................ 2–6
Numeric Literal .................................................................... 2–7
Alphanumeric Literal............................................................ 2–8
Hexadecimal Literal ............................................................. 2–9
Definition of Reserved Words............................................................. 2–10
Special Words.................................................................... 2–10
Date Fields (UDATE, JDATE, UMONTH,
UDAY, and UYEAR) .............................................. 2–10
Alphanumeric Aliases for Indicators (*IN and
*INxx).................................................................... 2–13
*PLACE ..................................................................... 2–15
Operation Codes................................................................ 2–15

8600 0544–103 iii


Contents

Section 3. RPG Program Logic Cycle (PLC)

Cycle Initialization (Step 1) .....................................................................3–3


Detail Output (Step 2) ............................................................................3–3
Indicator Initialization (Step 3)................................................................3–4
Last Record (LR) Test (Step 4)...............................................................3–4
Primary and Secondary Files Read (Step 5)...........................................3–4
Record Selection Logic (Step 6) ............................................................3–5
Control Fields and Record Identification (Step 7) ..................................3–5
Orderly End (Step 8) ..............................................................................3–6
Total Calculations (Step 9) .....................................................................3–6
Total Output (Step 10) ...........................................................................3–6
End of Job (EOJ) Test (Step 11) ............................................................3–6
Ending Routine (Step 12) .......................................................................3–6
Overflow Output (Step 13) ....................................................................3–7
Data Extraction (Step 14) .......................................................................3–7
Input File Look-Ahead (Step 15) ............................................................3–7
Detail Calculations (Step 16)..................................................................3–7
Stop (Step 17) ........................................................................................3–8
Restart (Step 18)....................................................................................3–8

Section 4. Disk Files

Disk File Systems ..................................................................................4–1


Comparison of BFS and EFS Files........................................4–2
Alternate Index Files.............................................................4–3
EFS File Attributes................................................................4–4
RECORDLEVELLOCK File Attribute.....................................4–6
Disk File Organization ............................................................................4–6
Sequential Organization........................................................4–6
Direct Organization...............................................................4–8
Indexed Organization............................................................4–9
Disk File Processing.............................................................................4–11
Creating Disk Files..............................................................4–11
Creating BFS Sequential Disk Files ...........................4–12
Creating EFS Sequential Disk Files ...........................4–13
Creating BFS Direct Disk Files...................................4–15
Creating EFS Direct Disk Files...................................4–16
Creating Delete-Capable EFS Direct Files.........4–16
Creating Nondelete-Capable EFS Direct
Files ..............................................................4–18
Creating BFS Indexed Files .......................................4–19
Creating EFS Indexed Files........................................4–20
Processing Disk Files .........................................................4–22
Processing Files Consecutively .................................4–22
Processing Files Sequentially by Key ........................4–25
Processing Files Sequentially within Limits ..............4–28
Using a Limits File.............................................4–28
Using the SETLL Operation ..............................4–32
Processing Files Randomly........................................4–34
Using Relative Record Numbers.......................4–34

iv 8600 0544–103
Contents

Using Record Keys ........................................... 4–36


Using Addrout Files .......................................... 4–39
Processing Files Using Addrout Files ....................... 4–41
Adding Records to Files..................................................... 4–43
Adding Records to the End of a Sequential or
Direct File (BFS) .................................................... 4–43
Adding Records to the End of a Sequential
File (EFS)............................................................... 4–44
Adding Records between Records in
Sequential Files (EFS) ........................................... 4–45
Adding Records to Direct Files (EFS)........................ 4–47
Adding Records to Indexed Files .............................. 4–48
Adding Records without Checking for
Duplicate Keys ............................................. 4–49
Adding Records and Checking for
Duplicate Keys ............................................. 4–49
Deleting Records from Files .............................................. 4–51
Deleting Records from Sequential or Direct
Files (BFS)............................................................. 4–51
Deleting Records from Sequential or Direct
Files (EFS) ............................................................. 4–52
Deleting Records from Indexed Files (BFS and
EFS) ...................................................................... 4–53
Freeing Locked Records.................................................... 4–54

Section 5. Internationalization

Accessing the Internationalization Features ......................................... 5–1


Using the Ccsversion, Language, and Convention
Default Settings............................................................... 5–2
Understanding the Hierarchy for Default Settings .............. 5–3
Understanding the Components of the MLS Environment .................. 5–4
Coded Character Sets and Ccsversions .............................. 5–4
Providing Support for Natural Languages ............................ 5–9
Providing Support for Business and Cultural
Conventions .................................................................. 5–10
Summary of CENTRALSUPPORT Library Procedures........................ 5–13
Library Calls ....................................................................... 5–19
Parameter Categories ........................................................ 5–20
Procedure Descriptions....................................................................... 5–34
CCSTRANTXT .................................................................... 5–34
CCSVSNLIST...................................................................... 5–37
CCSVSNNAME .................................................................. 5–39
CCSVSNNUM .................................................................... 5–41
CENTSTATUS .................................................................... 5–43
CNVCURNCY ..................................................................... 5–46
CNVDATE .......................................................................... 5–48
CNVDATTIM ...................................................................... 5–51
CNVDSPYMDL .................................................................. 5–54
CNVFORMSIZ.................................................................... 5–56
CNVLIST ............................................................................ 5–58

8600 0544–103 v
Contents

CNVNAME..........................................................................5–61
CNVSYMBOLS ...................................................................5–62
CNVTIME............................................................................5–67
CNVTPLT ............................................................................5–70
CSMSG...............................................................................5–72
MCPLANGS........................................................................5–76
TPLTDATE ..........................................................................5–78
TPLTDATTIM......................................................................5–80
TPLTTIME...........................................................................5–82
VSNCOMPTXT ...................................................................5–85
VSNESCAPE.......................................................................5–89
VSNGETORD1....................................................................5–92
VSNINSPTXT ......................................................................5–95
VSNTRANTXT.....................................................................5–98
Errors .................................................................................................5–102

Section 6. Indicator Summary Form

Section 7. Control Specification

Control Specification Coding Form and Summary.................................7–1


Field Definitions .....................................................................................7–3
Sequence Number (Columns 1–5) .......................................7–3
Form Type (Column 6)..........................................................7–3
Comment (Column 7) ...........................................................7–3
Object Output (Column 10) ..................................................7–4
Debug (Column 15) ..............................................................7–4
Sign Position (Column 17) ....................................................7–5
Inverted Print (Column 21) ...................................................7–5
Currency Symbol (Column 22) .............................................7–6
Date Format (Column 23) .....................................................7–6
Date Edit (Column 24) ..........................................................7–7
Collating Sequence (Column 26) ..........................................7–7
External Sign Handling (Column 40).....................................7–8
Forms Position (Column 41).................................................7–9
Zero/Blank Indicator Setting (Column 42).............................7–9
File Translation (Column 43)...............................................7–10
Line Printer Skipping (Column 46)......................................7–10
Run-Time Error (Column 49)...............................................7–11
Halt Indicator (Column 50)..................................................7–11
Source Input Dialect (Column 51) ......................................7–12
Time of File Open (Column 52) ..........................................7–13
Time of File Close (Column 53) ..........................................7–13
Program Identification (Columns 75–80) ............................7–13

vi 8600 0544–103
Contents

Section 8. File Description Specifications

File Specifications Coding Form and Summary .................................... 8–1


Field Definitions .................................................................................... 8–4
Sequence Number (Columns 1–5) ...................................... 8–4
Form Type (Column 6) ......................................................... 8–4
Comment (Column 7) .......................................................... 8–4
Filename (Columns 7–14) .................................................... 8–4
File Type (Column 15).......................................................... 8–5
File Designation (Column 16)............................................... 8–7
File Type and File Designation Fields Summary.................. 8–9
End of File (Column 17) ..................................................... 8–10
Key Description: Multiple Keys (Columns 15–17) ............. 8–10
Sequence (Column 18) ...................................................... 8–12
File Format (Column 19) .................................................... 8–12
Block Length and Record Length (Columns 20–27) .......... 8–14
Processing Mode (Column 28) .......................................... 8–16
Record-Address Field Length (Columns 29–30) ................ 8–16
Record-Address Type (Column 31).................................... 8–17
File Organization Type (Column 32)................................... 8–18
Valid Entries for File Processing, Type, and
Organization .................................................................. 8–19
Overflow Indicator (Columns 33–34) ................................. 8–20
Key Field Starting Location (Columns 35–38).................... 8–20
Extension Code (Column 39) ............................................. 8–21
Device (Columns 40–46).................................................... 8–21
Index Name (Columns 47–52) ........................................... 8–22
File Open or Continuation Line (Column 53) ..................... 8–22
Continuation Options (Columns 54–65)............................. 8–24
File Addition/Unordered (Column 66) ................................ 8–24
File Translation (Column 67) .............................................. 8–26
Duplicate Keys (Column 68) .............................................. 8–26
Delete-Capable File (Column 69) ....................................... 8–27
File Close (Column 70)....................................................... 8–27
File Condition (Columns 71–72)......................................... 8–30
Program Identification (Columns 75–80) ........................... 8–31

Section 9. Attribute Specifications

Attribute Specifications Coding Form and Summary............................ 9–2


Field Definitions .................................................................................... 9–3
Sequence Number (Columns 1–5) ...................................... 9–3
Form Type (Column 6) ......................................................... 9–3
Comment (Column 7) .......................................................... 9–3
Specifications Continuation (Columns 7–8) ......................... 9–4
Attribute Designation (Columns 9–65) ................................ 9–4
Variable Name (Columns 66–71) ......................................... 9–5
Field Length (Columns 72–74)............................................. 9–6
Program Identification (Columns 75–80) ............................. 9–6
Example of Using Attribute Specifications ........................................... 9–7
Attribute Modification ........................................................................... 9–8

8600 0544–103 vii


Contents

Section 10. Extension Specifications

Extension Specifications Coding Form and Summary.........................10–1


Field Definitions ...................................................................................10–3
Sequence Number (Columns 1–5) .....................................10–3
Form Type (Column 6)........................................................10–3
Comment (Column 7) .........................................................10–3
From Filename (Columns 11–18) .......................................10–4
To Filename (Columns 19–26)............................................10–5
Vector Name (Columns 27–32) ..........................................10–5
Entries per Record (Columns 33–35) .................................10–6
Entries per Vector (Columns 36–39) ..................................10–7
Length of Entry (Columns 40–42) ......................................10–7
Packed (Column 43) ...........................................................10–8
Decimal Positions (Column 44) ..........................................10–9
Sequence (Column 45) .......................................................10–9
Alternating Vector Format (Columns 46–57) ....................10–10
Comments (Columns 58–74) ...........................................10–10
Program Identification (Columns 75–80) ..........................10–10
Using Vectors ....................................................................................10–11
Understanding Array and Table Differences ....................10–11
Declaring Vectors .............................................................10–12
Using an Index with a Vector Name.................................10–13
Loading Vectors................................................................10–14
Alternating Vector Format ................................................10–17
Writing Vectors.................................................................10–18

Section 11. Line Counter Specifications

Line Counter Specifications Coding Form and Summary....................11–1


Field Definitions ...................................................................................11–3
Sequence Number (Columns 1–5) .....................................11–3
Form Type (Column 6)........................................................11–3
Comment (Column 7) .........................................................11–3
Filename (Columns 7–14)...................................................11–3
Line Number, FL, Channel Number (Columns 15–
19) ..................................................................................11–4
Line Number and OL or Channel Number
(Columns 20–24) ............................................................11–5
Line Number and Channel Number (Columns 25–
74) ..................................................................................11–6
Program Identification (Columns 75–80) ............................11–7

Section 12. Telecommunications Specifications

Message Control System (MCS) .........................................................12–1


MCS Functions ....................................................................................12–1
Telecommunications Specifications Coding Form and
Summary .........................................................................................12–2
Field Definitions for Telecommunications Specifications....................12–4
Sequence Number (Columns 1–5) .....................................12–4

viii 8600 0544–103


Contents

Form Type (Column 6) ....................................................... 12–4


Comment (Column 7) ........................................................ 12–4
Filename (Columns 7–14) .................................................. 12–5
Station Type (Column 16) .................................................. 12–5
Remote Station Location Identification (Column 40)......... 12–5
Remote Station Identification (Columns 41–47)................ 12–6
Error Indicator (Columns 53–54) ........................................ 12–7
Message Length Identification (Column 63) ..................... 12–7
Message Length (Columns 64–70).................................... 12–8
Program Identification (Columns 75–80) ........................... 12–8
Field Definitions for Telecommunications File Specifications ............ 12–9
Filename (Columns 7–14) .................................................. 12–9
File Type (Column 15)........................................................ 12–9
File Designation (Column 16)........................................... 12–10
End of File (Column 17) ................................................... 12–10
File Format (Column 19) .................................................. 12–10
Block Length (Columns 20–23)........................................ 12–10
Record Length (Columns 24–27) ..................................... 12–11
Processing Mode (Column 28) ........................................ 12–11
Record-Address Field Length (Columns 29–30) .............. 12–11
Record-Address Type (Column 31).................................. 12–11
File Organization Type (Column 32)................................. 12–11
Key Field Starting Location (Columns 35–38).................. 12–11
Device (Columns 40–46).................................................. 12–12
Columns 47 through 70 ................................................... 12–12
File Condition (Columns 71–72)....................................... 12–12

Section 13. Library Specifications

Library Specifications Coding Form and Summary ............................. 13–2


Field Definitions for Library Name Specifications ............................... 13–3
Sequence Number (Columns 1–5) .................................... 13–3
Form Type (Columns 6–18) ............................................... 13–3
Library Name (Columns 19–28) ......................................... 13–3
LIBACCESS (Column 32) ................................................... 13–3
Title or Function Name (Columns 35–74) .......................... 13–4
Field Definitions for Library Attribute Specifications........................... 13–4
Field Definitions for Library Subroutine Specifications ....................... 13–5
Sequence Number (Columns 1–5) .................................... 13–5
Form Type (Columns 6–18) ............................................... 13–5
Library Subroutine Name (Columns 19–28)....................... 13–5
Result Length (Columns 29–31) ........................................ 13–5
Result Decimal Positions (Column 32) .............................. 13–6
Actual Name (Columns 35–74) .......................................... 13–6
Field Definitions for Library Parameter Specifications ........................ 13–7
Sequence Number (Columns 1–5) .................................... 13–7
Form Type (Columns 6–18) ............................................... 13–7
Library Parameter Name (Columns 19–28) ....................... 13–7
Parameter Length (Columns 29–31).................................. 13–7
Parameter Decimal Positions (Column 32)........................ 13–8
Value/Reference (Column 33)............................................ 13–8

8600 0544–103 ix
Contents

Vector Parameter (Column 34)...........................................13–8


Columns 35–74 ..................................................................13–9
Field Definitions for Library Linkage Subroutines ..............................13–10
$SETNAME ......................................................................13–10
$LINKLIB ..........................................................................13–10
$DELINKLIB .....................................................................13–10
$CANCELLIB ....................................................................13–10
Example of Using Library Specifications ...........................................13–12

Section 14. Input Specifications

Input Specifications Coding Form and Summary ................................14–1


Field Definitions ...................................................................................14–4
Sequence Number (Columns 1–5) .....................................14–4
Form Type (Column 6)........................................................14–4
Comment (Column 7) .........................................................14–4
AND and OR Lines (Columns 14–16) .................................14–5
Sequence (Columns 15–16) ...............................................14–5
Number (Column 17) ..........................................................14–6
Option (Column 18) ............................................................14–7
Record Identifying Indicator (Columns 19–20) ...................14–8
Record Identification Codes (Columns 21–41) .................14–14
Packed (Column 43) .........................................................14–16
Field Location (Columns 44–51) .......................................14–22
Decimal Positions (Column 52) ........................................14–23
Field Name (Variable Name) (Columns 53–58).................14–23
Control Level (Columns 59–60) ........................................14–25
Match Field (Columns 61–62) ..........................................14–29
Assignment of Match Fields ...........................14–30
File Processing with Match Fields ..................14–31
Field Record Relations (Columns 63–64) .........................14–34
Field Indicators (Columns 65–70) .....................................14–37
Program Identification (Columns 75–80) ..........................14–38
Header-Trailer or Spread-Record Specifications ................................14–38
Specifications of Data Records ........................................14–38
Header-Trailer Definition Requirements and
Restrictions ..................................................................14–39
Data Structures..................................................................................14–40
Data Structure Name Descriptions ..................................14–41
Data Structure Subfield Descriptions ...............................14–42
Coding of Data Structures ................................................14–43
Description of the Data Structure for a Local Data
Area..............................................................................14–46

Section 15. Calculation Specifications

Calculations Specifications Coding Form and Summary .....................15–1


Field Definitions ...................................................................................15–4
Sequence Number (Columns 1–5) .....................................15–4
Form Type (Column 6)........................................................15–4
Comment (Column 7) .........................................................15–4

x 8600 0544–103
Contents

Control Level (Columns 7–8) ............................................. 15–5


Indicators (Columns 9–17) ................................................. 15–8
Factor 1 (Columns 18–27)................................................ 15–11
Operation (Columns 28–32)............................................. 15–11
Factor 2 (Columns 33–42)................................................ 15–12
Result Field (Columns 43–48).......................................... 15–12
Field Length (Columns 49–51)......................................... 15–13
Decimal Positions (Column 52)........................................ 15–13
Half Adjust (Column 53)................................................... 15–14
Resulting Indicators (Columns 54–59) ............................. 15–14
Comments (Columns 60–74)........................................... 15–16
Program Identification (Columns 75–80) ......................... 15–16

Section 16. Operation Codes

Organization of Operation Codes........................................................ 16–1


Arithmetic Operations ......................................................................... 16–4
Compile-Time Warning Messages with Arithmetic
Operations..................................................................... 16–5
ADD (Add).......................................................................... 16–6
DIV (Divide) ........................................................................ 16–7
MULT (Multiply) ................................................................. 16–8
MVR (Move Remainder) .................................................... 16–8
SQRT (Perform Square Root) ............................................ 16–9
SUB (Subtract) ................................................................. 16–10
XFOOT (Sum Elements of Numeric Array)...................... 16–10
Z-ADD (Zero Then Add) ................................................... 16–11
Z-SUB (Zero Then Subtract)............................................. 16–11
Comparison Operations .................................................................... 16–12
COMP (Compare) ............................................................ 16–12
TESTN (Test for Numeric)................................................ 16–13
TESTZ (Test Zone) ........................................................... 16–14
Move Operations .............................................................................. 16–14
MOVE (Move Rightmost) ................................................ 16–15
MOVEA (Move Array) ...................................................... 16–18
MOVEL (Move Leftmost) ................................................ 16–22
Move Zone Operations ..................................................................... 16–24
MHHZO (Move High to High Zone) ................................. 16–24
MHLZO (Move High to Low Zone) .................................. 16–24
MLHZO (Move Low to High Zone) .................................. 16–24
MLLZO (Move Low to Low Zone) ................................... 16–25
Summary of Move Zone Operations ............................... 16–25
Binary Field Operations..................................................................... 16–26
BITOF (Set Bit Off) .......................................................... 16–27
BITON (Set Bit On) .......................................................... 16–27
TESTB (Test Bits)............................................................. 16–27
Indicator Operations.......................................................................... 16–28
SETOF (Set Off) ............................................................... 16–28
SETON (Set On)............................................................... 16–28
Program Branching Operations......................................................... 16–29
GOTO (Branch to Instruction) .......................................... 16–29

8600 0544–103 xi
Contents

TAG (Identify Entry Point from GOTO).............................16–29


Structured Programming Operations.................................................16–30
Boolean Operators ...........................................................16–31
Nesting Structured Programming Operations..................16–31
ANDxx (Perform Conditional AND)...................................16–32
CASxx and CAS (Select Case
Conditional/Unconditional) ...........................................16–36
CASE (Select Case) ..........................................................16–38
DO, DOUxx, and DOWxx .................................................16–41
IFxx (Execute If–Then)......................................................16–46
IFxx/ELSE (Execute If–Then–Else) ...................................16–47
ORxx (Perform Conditional OR) .......................................16–48
Subroutine Operations.......................................................................16–52
BEGSR (Begin Subroutine) ...............................................16–54
ENDSR (End Subroutine)..................................................16–54
EXSR (Execute Subroutine) ..............................................16–54
Library Operations .............................................................................16–54
EEXSR (Execute External Subroutine)..............................16–54
PARAM (Specify Parameters for EEXSR).........................16–55
I/O Operations ...................................................................................16–58
CHAIN (Access Data File).................................................16–58
CLOSE (Close File for Processing) ...................................16–61
DELET (Delete a Record) .................................................16–63
DSPLY (Display Data) .......................................................16–64
EXCPT (Write Exception Output) .....................................16–65
FORCE (Select Record) ....................................................16–67
READ (Read Sequentially) ................................................16–67
READE (Read Equal Key) .................................................16–68
READP (Read Previous Record) .......................................16–69
RECV (Read Remote File Record) ....................................16–69
SEND (Send Remote File Record)....................................16–69
SETLL (Set Lower Limit) ..................................................16–70
Other Operations ...............................................................................16–71
DEBUG (Debug Program).................................................16–71
DEFN (Define a New Field) ..............................................16–72
DUMP (Perform Symbolic Dump) ....................................16–74
LOKUP (Look Up Vector Entry) ........................................16–76
SORTA (Sort Array)...........................................................16–80
TIME (Provide Current Time)............................................16–81
ZIP (Activate WFL Statement)..........................................16–81
COMS Operations .............................................................................16–82
DMSII Operations ..............................................................................16–82

Section 17. Output-Format Specifications

Output Specifications Coding Form and Summary .............................17–2


Field Definitions ...................................................................................17–4
Sequence Number (Columns 1–5) .....................................17–4
Form Type (Column 6)........................................................17–4
Comment (Column 7) .........................................................17–4
Filename (Columns 7–14)...................................................17–5

xii 8600 0544–103


Contents

Type (Column 15) .............................................................. 17–5


AND and OR Lines (Columns 14–16) ................................ 17–6
Record Addition/Deletion (Columns 16–18) ...................... 17–7
Stacker-Select/Fetch Overflow (Column 16) ..................... 17–8
Space (Columns 17–18)..................................................... 17–9
Skip (Columns 19–22)...................................................... 17–10
Output Indicators (Columns 23–31)................................. 17–12
Field Name (Variable Name) (Columns 32–37) ................ 17–17
Edit Codes (Column 38)................................................... 17–18
Blank After (Column 39) .................................................. 17–19
Field End Position (Columns 40–43) ................................ 17–19
Packed (Column 44)......................................................... 17–20
Constant or Edit Word (Columns 45–70)......................... 17–21
Program Identification (Column 75–80) ........................... 17–21
Constants .......................................................................................... 17–22
Special Word *PLACE ..................................................... 17–23
Edit Codes ....................................................................... 17–25
Edit Words ....................................................................... 17–33
Comparison of Edit Words and Edit Codes ..................... 17–50
Printing Reports ................................................................................ 17–51
Forms Specifications ....................................................... 17–51
Page Formatting .............................................................. 17–52
End of Page (EOP) ........................................................... 17–52
Overflow Indicators ......................................................... 17–53
Overflow .......................................................................... 17–55

Section 18. Alternate Collating Sequence Specifications

Alternate Collating Sequence Specifications Coding Form and


Summary ........................................................................................ 18–2
Field Definitions .................................................................................. 18–3
Sequence Number (Columns 1–5) .................................... 18–3
Form Type (Column 6) ....................................................... 18–3
Comment (Column 7) ........................................................ 18–3
Sequence Specifications (Columns 7–74) ......................... 18–4
Program Identification (Columns 75–80) ........................... 18–4
Examples of Coding Alternate Collating Sequence
Specifications.................................................................................. 18–5
** Specifications ................................................................................. 18–8

Section 19. File Translation Specifications

File Translation Specifications Coding Form and Summary................ 19–2


Field Definitions .................................................................................. 19–3
Sequence Number (Columns 1–5) .................................... 19–3
Form Type (Column 6) ....................................................... 19–3
Comment (Column 7) ........................................................ 19–3
Filename (Columns 7–14) .................................................. 19–3
Translation Table (Columns 15–74).................................... 19–3
Program Identification (Columns 75–80) ........................... 19–4

8600 0544–103 xiii


Contents

Examples of Coding File Translation Specifications ............................19–5


** Specifications..................................................................................19–6

Section 20. Vector Data Specifications

Vector Data Specifications Coding Form and Summary......................20–3


Field Definitions ...................................................................................20–3
Sequence Number (Columns 1–5) .....................................20–3
Form Type (Column 6)........................................................20–4
Comment (Column 7) .........................................................20–4
Vector Specifications (Columns 7–12)................................20–4
SEQ (Columns 14–16) ........................................................20–4
Columns 13, 17–74 ............................................................20–4
Program Identification (Columns 75–80) ............................20–4
Examples of Coding Vector Data Specifications .................................20–5
** Specifications..................................................................................20–7

Section 21. Control of the Compilation Process

Compiler Files ......................................................................................21–1


Compilation of the Program.................................................................21–3
Using CANDE .....................................................................21–3
Using WFL..........................................................................21–4
Compiler Control Records (CCRs) .......................................................21–6
Types of Compiler Control Options .....................................................21–7
CCR Syntax ........................................................................21–8
Compiler Control Options.................................................21–10
ACCESSOPEN (Boolean) .........................................21–10
CLEAR (Immediate) .................................................21–10
CODE (Boolean).......................................................21–10
DELETE (Boolean) ...................................................21–10
DMSNAME (Boolean)..............................................21–11
DOLLARISDATA (Boolean)......................................21–11
DOUBLE (Boolean) ..................................................21–11
EOFCLOSE (Boolean) ..............................................21–11
ERRORLIMIT (Value) ...............................................21–12
ERRORSOURCE (Value) ..........................................21–12
FZONE (Boolean) .....................................................21–13
INCLUDE (Special) ...................................................21–13
KEYEDIOIIOUTPUT (Boolean) .................................21–14
LINEINFO (Boolean) ................................................21–14
LIST (Boolean)..........................................................21–15
LISTDELETED (Boolean)..........................................21–15
LISTDOLLAR (Boolean) ...........................................21–15
LISTINCL (Boolean) .................................................21–15
LISTOMITTED (Boolean) .........................................21–15
LISTP (Boolean) .......................................................21–16
MAP (Boolean).........................................................21–16
MERGE (Boolean) ....................................................21–16
NEW (Boolean) ........................................................21–17
OMIT (Boolean) .......................................................21–18

xiv 8600 0544–103


Contents

PAGE (Immediate) .................................................. 21–18


PAGESIZE (Value) ................................................... 21–18
RSIGN (Boolean) ..................................................... 21–19
SEQ (Boolean)......................................................... 21–19
SEQUENCE BASE (Value)....................................... 21–20
SEQUENCE INCREMENT (Value) ........................... 21–20
STATISTICS (Boolean)............................................. 21–20
SUMMARY (Boolean) ............................................. 21–21
TARGET (Value)....................................................... 21–21
TITLE (Value) ........................................................... 21–22
TITLESPERFILE (Value)........................................... 21–23
UNSEQ (Boolean).................................................... 21–23
USERDEBUG (Boolean) .......................................... 21–23
WARNFATAL (Boolean) .......................................... 21–24
WARNSUPR (Boolean)............................................ 21–24
XREF (Boolean) ....................................................... 21–24
XREFFILES (Boolean).............................................. 21–24
Use of Compiler Directives to Format the Compiler Listing............. 21–25
Compiler Memory Estimate.............................................................. 21–26

Appendix A. System Messages

Appendix B. Reference Tables

Index ............................................................................................. 1

8600 0544–103 xv
Contents

xvi 8600 0544–103


Figures
1–1. RPG Source Program ......................................................................................... 1–3

3–1. Program Logic Cycle (PLC) ................................................................................ 3–2

4–1. Comparison of File Systems .............................................................................. 4–2


4–2. Sequential File Organization............................................................................... 4–7
4–3. Direct File Organization ...................................................................................... 4–8

6–1. Indicator Summary Coding Form ....................................................................... 6–1

7–1. Control Specification Coding Form .................................................................... 7–1

8–1. File Specifications Coding Form......................................................................... 8–1

9–1. Attribute Specifications Coding Form ................................................................ 9–2

10–1. Extension Specifications Coding Form ............................................................ 10–1

11–1. Line Counter Specifications Coding Form ....................................................... 11–1

12–1. Telecommunications Specifications Coding Form........................................... 12–2

13–1. Library Specifications Coding Form ................................................................. 13–2

14–1. Input Specifications Coding Form .................................................................... 14–1


14–2. Records Available for Look-Ahead: Two Input Files ...................................... 14–11
14–3. Records Available for Look-Ahead Fields: One Update File and One
Input File .................................................................................................... 14–12
14–4. Alphanumeric or Unpacked Decimal Format ................................................. 14–17
14–5. Left-Signed Packed Decimal Format.............................................................. 14–17
14–6. Right-Signed Packed Decimal Format............................................................ 14–17
14–7. Unsigned Packed Decimal Format................................................................. 14–18
14–8. Separate Leading Signed Decimal Format..................................................... 14–18
14–9. Separate Trailing Signed Decimal Format ...................................................... 14–18
14–10. Binary Data Format (2 Bytes Long) ................................................................ 14–19
14–11. Binary Data Format (4 Bytes Long) ................................................................ 14–19
14–12. Single-Precision Numeric Format (1 Word Long)........................................... 14–20
14–13. Double-Precision Numeric Format (Word 1) .................................................. 14–21
14–14. Double-Precision Numeric Format (Word 2) .................................................. 14–21

15–1. Calculation Specifications Coding Form........................................................... 15–1

16–1. Nested Structured Programming Operations ................................................ 16–32

8600 0544–103 xvii


Figures

17–1. Output Specifications Coding Form..................................................................17–2


17–2. Printer Overflow and Fetch Routines .............................................................17–56
17–3. Printer Skip Routine ........................................................................................17–57
17–4. Printer Space and Start Routines....................................................................17–58
17–5. Printer Start Routines .....................................................................................17–59
17–6. Printer Overflow Operations for Normal and Fetched Output .......................17–63

18–1. Alternate Collating Sequence Specifications Coding Form ..............................18–2

19–1. File Translation Specifications Coding Form.....................................................19–2

20–1. Vector Data Specifications Coding Form ..........................................................20–3

B–1. 8-Bit Fields (EBCDIC Code)................................................................................ B–2


B–2. 8-Bit Fields (ASCII Code).................................................................................... B–2
B–3. 4-Bit Fields (Hexadecimal Code) ........................................................................ B–2

xviii 8600 0544–103


Tables
2–1. RPG Character Set ............................................................................................. 2–1
2–2. Additional Character Set for Edit Words and Alphanumeric Literals ................. 2–2
2–3. Characters Used for Names............................................................................... 2–2
2–4. Characters Used for Editing ............................................................................... 2–3
2–5. Hexadecimal Digits ............................................................................................ 2–9

4–1. File Specifications: Indexed File or Alternate Index File .................................. 4–30
4–2. File Specifications: Limits File.......................................................................... 4–31
4–3. Extension Specifications: Limits File................................................................ 4–31
4–4. File Specifications: SETLL Operation ............................................................... 4–33
4–5. File Specifications: Addrout Processed Files ................................................... 4–41
4–6. File Specifications: Addrout File....................................................................... 4–42
4–7. Extension Specifications: Addrout File ............................................................ 4–42

5–1. Functional Grouping of CENTRALSUPPORT Library Procedures .................... 5–14


5–2. Cross-Reference of RPG Procedure Names with CENTRALSUPPORT
Library Procedure Names ............................................................................ 5–19
5–3. Specific Descriptions for Internationalization Error Values ............................ 5–102

6–1. Field Definitions Summary (Indicator Summary Form) ...................................... 6–1

7–1. Field Definitions Summary (Control Specification)............................................. 7–1


7–2. Inverted Print Field Entries and Sample Results................................................ 7–6

8–1. Field Definitions Summary (File Specifications)................................................. 8–2


8–2. Summary of File Type and File Designations for Disk Files............................... 8–9
8–3. Minimum and Maximum Block and Record Length Values............................. 8–14
8–4. Default Block and Record Length Values ........................................................ 8–15
8–5. Block and Record Lengths: Resulting Values .................................................. 8–15
8–6. Summary of Processing Mode, Record-Address Type, and File
Organization Column Entries ....................................................................... 8–19
8–7. File Close Options for Tape Files ..................................................................... 8–28
8–8. File Close Options for Disk Files ...................................................................... 8–29

9–1. Field Definitions Summary (Attribute Specifications) ........................................ 9–2

10–1. Field Definitions Summary (Extension Specifications)..................................... 10–2


10–2. Determining Vector Type ................................................................................. 10–7
10–3. Types of Vectors ............................................................................................ 10–11

11–1. Field Definitions Summary (Line Counter Specifications)................................ 11–2

12–1. Field Definitions Summary (Telecommunications Specifications) ................... 12–3

8600 0544–103 xix


Tables

13–1. Field Definitions Summary (Library Specifications) ..........................................13–2


13–2. Library Linkage Subroutine Parameters..........................................................13–11
13–3. Alphanumeric Value Returned by the CURRENT_DATE Procedure...............13–21
13–4. Meaning of Character in Position 17 ..............................................................13–21
13–5. Meaning of Characters in Positions 18–21 .....................................................13–22

14–1. Field Definitions Summary (Input Specifications) .............................................14–2


14–2. Fields for Data Structure Name Descriptions .................................................14–41
14–3. Fields for Data Structure Subfield Descriptions..............................................14–42

15–1. Field Definitions Summary (Calculation Specifications)....................................15–2

16–1. Operation Codes...............................................................................................16–1


16–2. Result Field Contents after Multiplication of 89.67 and 2.148 .........................16–8
16–3. Result Field Contents after SQRT Operation on 2994.42 ..............................16–10
16–4. Results of MOVE Operations: Result Field Larger Than Factor 2 Field ........16–16
16–5. Results of MOVE Operations: Result Field Smaller Than Factor 2 Field.......16–17
16–6. Results of MOVE Operations: Factor 2 and Result Field of Same
Length ........................................................................................................16–17
16–7. Results of MOVEA Operations .......................................................................16–21
16–8. Results of MOVEL Operations .......................................................................16–23
16–9. Move Zone Operations ...................................................................................16–25
16–10. Structured Programming Operations..............................................................16–30
16–11. Boolean Operators and Definitions.................................................................16–31
16–12. Effects of Operations Preceding ANDxx ........................................................16–33
16–13. Effects of Operations Preceding ORxx Operation..........................................16–49
16–14. Parameter Matching .......................................................................................16–56

17–1. Field Definitions Summary (Output Specifications) ..........................................17–2


17–2. Edit Codes ......................................................................................................17–27
17–3. Effects of Edit Codes on Field End Position ...................................................17–28
17–4. Effects of Y Edit Code ....................................................................................17–29
17–5. Effect of Edit Codes on Positive Zero Input String .........................................17–29
17–6. Effects of Edit Codes on Negative Zero Input String .....................................17–30
17–7. Effects of Edit Codes on Positive Data with Two Implied Decimal
Places .........................................................................................................17–31
17–8. Effects of Edit Codes on Negative Data with Two Implied Decimal
Places .........................................................................................................17–32
17–9. Printer Operations: Effects on Overflow Indicators .......................................17–54

18–1. Field Definitions Summary (Alternate Collating Sequence


Specifications) ..............................................................................................18–3

19–1. Field Definitions Summary (File Translation Specifications) .............................19–2

20–1. Field Definitions Summary (Vector Data Specifications) ..................................20–3

21–1. Purposes and Default Devices for Compiler Files ............................................21–2


21–2. Default Values of Compiler Control Options.....................................................21–3

B–1. Character Representation .................................................................................. B–1


B–2. Character Values and Graphics .......................................................................... B–3

xx 8600 0544–103
Examples
2–1. Coding a Page Field ......................................................................................... 2–12
2–2. Coding *INxx Indicators ................................................................................... 2–14
2–3. Coding an *IN Array ......................................................................................... 2–14

4–1. Specifying ALLOCATION and EXTEND Attributes with RPG ............................ 4–5
4–2. Creating a BFS Sequential Disk File................................................................. 4–13
4–3. Creating an EFS Sequential Disk File ............................................................... 4–14
4–4. Creating a BFS Direct File ................................................................................ 4–15
4–5. Creating a Delete-Capable EFS Direct File....................................................... 4–17
4–6. Creating an EFS Direct File (Not Delete-Capable)............................................ 4–18
4–7. Creating a BFS Indexed File............................................................................. 4–19
4–8. Creating an EFS Indexed File ........................................................................... 4–21
4–9. Processing Sequential and Direct Files Consecutively .................................... 4–23
4–10. Processing an Indexed File Consecutively....................................................... 4–24
4–11. Processing an Indexed File Sequentially by Key.............................................. 4–25
4–12. Processing an Alternate Index File Sequentially by Key .................................. 4–26
4–13. Processing an Alternate Index File with a Noncontiguous Key ....................... 4–27
4–14. Processing an Indexed File with a Limits File.................................................. 4–29
4–15. Processing an Indexed File with the SETLL Operation Code .......................... 4–33
4–16. Randomly Processing a Disk File by Relative Record Numbers...................... 4–35
4–17. Randomly Processing an Indexed File with Primary or Alternate Keys ........... 4–37
4–18. Loading a Noncontiguous Key with a CHAIN Operation.................................. 4–38
4–19. Randomly Processing a Disk File with an Addrout File.................................... 4–40
4–20. Adding Records to BFS Sequential or Direct Files .......................................... 4–43
4–21. Adding Records to the End of an EFS Sequential File .................................... 4–44
4–22. Adding Records to Sequential Files by Relative Record Number .................... 4–46
4–23. Adding Records to Direct Files by Relative Record Number .......................... 4–47
4–24. Adding Records without Checking for Duplicate Keys .................................... 4–49
4–25. Adding Records and Checking for Duplicate Keys........................................... 4–50
4–26. Using the DEL Entry to Delete Records from a BFS Direct File...................... 4–51
4–27. Deleting Records from an EFS Sequential or Direct File ................................. 4–52
4–28. Using the DEL Entry to Delete Records from an Indexed File ........................ 4–53
4–29. Using the DELET Operation Code to Delete Records from an Indexed
File ............................................................................................................... 4–54
4–30. Releasing Locked Records by Performing a Free Operation ........................... 4–55

5–1. SYMBOL/INTL/RPG/PROPERTIES Library Specifications File ........................ 5–23


5–2. Coding for the CCSTRANTXT Procedure ......................................................... 5–35
5–3. Coding for the CCSVSNLIST Procedure ......................................................... 5–37
5–4. Coding for the CCSVSNNAME Procedure ....................................................... 5–40
5–5. Coding for the CCSVSNNUM Procedure ......................................................... 5–42
5–6. Coding for the CENTSTATUS Procedure ......................................................... 5–44
5–7. Coding for the CNVCURNCY Procedure .......................................................... 5–47
5–8. Coding for the CNVDATE Procedure .............................................................. 5–48

8600 0544–103 xxi


Examples

5–9. Coding for the CNVDATTIM Procedure............................................................5–51


5–10. Coding for the CNVDSPYMDL Procedure .......................................................5–54
5–11. Coding for the CNVFORMSIZ Procedure ........................................................5–56
5–12. Coding for the CNVLIST Procedure .................................................................5–58
5–13. Coding for the CNVNAME Procedure...............................................................5–61
5–14. Coding for the CNVSYMBOLS Procedure .......................................................5–62
5–15. Coding for the CNVTIME Procedure ................................................................5–67
5–16. Coding for the CNVTPLT Procedure .................................................................5–71
5–17. Coding for the CSMSG Procedure ...................................................................5–73
5–18. Coding for the MCPLANGS Procedure ............................................................5–76
5–19. Coding for the TPLTDATE Procedure ..............................................................5–78
5–20. Coding for the TPLTDATTIM Procedure ..........................................................5–80
5–21. Coding for the TPLTTIME Procedure................................................................5–83
5–22. Coding for the VSNCOMPTXT Procedure ........................................................5–86
5–23. Coding for the VSNESCAPE Procedure............................................................5–90
5–24. Coding for the VSNGETORD1 Procedure ........................................................5–92
5–25. Coding for the VSNINSPTXT Procedure ...........................................................5–96
5–26. Coding for the VSNTRANTXT Procedure..........................................................5–99

7–1. Coding a Control Specification Comment Line...................................................7–3

8–1. Coding a File Specifications Comment Line .......................................................8–4


8–2. BFS File with One Primary Key and Two Alternate Keys .................................8–11
8–3. EFS File with One Primary Key and Two Alternate Keys .................................8–11
8–4. Specifying Record Lengths for Variable-Length Records ................................8–13

9–1. Coding an Attribute Specifications Comment Line ............................................9–3


9–2. Coding Kinds of Attribute Specifications ............................................................9–5
9–3. Determining If a File Is Present on Disk .............................................................9–7
9–4. Assigning and Modifying File Attributes.............................................................9–9

10–1. Coding an Extension Specifications Comment Line.........................................10–3


10–2. Loading Preexecution-Time Vectors...............................................................10–15
10–3. Loading Execution-Time Vectors with Input Specifications ...........................10–16
10–4. Loading Execution-Time Vectors with Calculation Specifications ..................10–17

11–1. Coding a Line Counter Specifications Comment Line......................................11–3


11–2. Coding of Line Counter Specifications .............................................................11–5

12–1. Coding a Telecommunications Specifications Comment Line .........................12–4


12–2. Coding of Data Communications Files (cont.) ................................................12–12

13–1. Coding Library Specifications .........................................................................13–12


13–2. Declaring and Using Subroutines from a Library ...........................................13–13
13–3. Calling the CURRENT_DATE Procedure.........................................................13–20

14–1. Coding for Sequence Checking ........................................................................14–6


14–2. Coding Look-Ahead Fields ..............................................................................14–13
14–3. Coding AND and OR Relationships ................................................................14–14
14–4. Using Duplicate Coding ..................................................................................14–24
14–5. Using an OR Relationship to Eliminate Duplicate Coding ..............................14–25
14–6. Using Control Fields in Two Record TypesSplit Control Fields ......................14–27

xxii 8600 0544–103


Examples

14–7. Using Split Control Fields ............................................................................... 14–28


14–8. Using Match Fields to Process Multiple Files ............................................... 14–32
14–9. Using Match Records for Sequence Checking ............................................. 14–33
14–10. Using Field Record Relation Indicators .......................................................... 14–35
14–11. Using Header-Trailer Specifications .............................................................. 14–39
14–12. Defining Subfields to Overlap ........................................................................ 14–44
14–13. Using a Data Structure Format with Repeating Subfields ............................ 14–44
14–14. Coding a Data Structure for a Local Data Area .............................................. 14–46

15–1. Coding a Calculation Specifications Comment Line ........................................ 15–4


15–2. Coding an L0 Indicator ..................................................................................... 15–6
15–3. Coding AND and OR Relationships.................................................................. 15–7
15–4. Coding Resulting Indicators .......................................................................... 15–15

16–1. Arithmetic Operations ..................................................................................... 16–6


16–2. MOVEA Operations ....................................................................................... 16–20
16–3. Binary Field Operations .................................................................................. 16–27
16–4. GOTO Program Branching Operation ............................................................ 16–29
16–5. ANDxx Structured Programming Operations................................................. 16–35
16–6. CASxx and CAS Structured Programming Operations .................................. 16–37
16–7. CASE Structured Programming Operation .................................................... 16–40
16–8. DO Structured Programming Operation ........................................................ 16–43
16–9. DO Structured Programming Operation with Increment Values ................... 16–43
16–10. DOUxx Structured Programming Operation .................................................. 16–44
16–11. DOWxx Structured Programming Operation ................................................. 16–46
16–12. IFxx Structured Programming Operation ....................................................... 16–47
16–13. IFxx/ELSE Structured Programming Operations............................................ 16–48
16–14. ANDxx Structured Programming Operations ................................................ 16–51
16–15. Subroutine Operation ..................................................................................... 16–53
16–16. PARAM Operation.......................................................................................... 16–57
16–17. Chained Indexed Files .................................................................................... 16–60
16–18. Chained Sequential Files ................................................................................ 16–61
16–19. CLOSE Operation........................................................................................... 16–62
16–20. DSPLY Operations ......................................................................................... 16–65
16–21. EXCPT Operation .......................................................................................... 16–66
16–22. DEBUG Operation .......................................................................................... 16–72
16–23. DEFN Operation ............................................................................................ 16–73
16–24. LOKUP Operations......................................................................................... 16–77
16–25. SORTA Operation .......................................................................................... 16–80
16–26. ZIP Operation ................................................................................................. 16–82

17–1. Coding an Output Specifications Comment Line............................................. 17–4


17–2. Coding Output Indicators ............................................................................... 17–13
17–3. Using the 1P Indicator.................................................................................... 17–16
17–4. Designating an End Position .......................................................................... 17–20
17–5. Coding Output Constants .............................................................................. 17–22
17–6. Using the *PLACE Special Word ................................................................... 17–24
17–7. Comparing Edit Words and Edit Codes ......................................................... 17–50
17–8. Using the Skip to Line Number Option for Overflow .................................... 17–60
17–9. Using the Skip to Channel Option for Overflow ............................................ 17–62

8600 0544–103 xxiii


Examples

18–1. Changing the Collating Sequence Using the Alternate Collating


Sequence Specifications ..............................................................................18–7
18–2. Changing the Collating Sequence Using the ** Specifications........................18–9

20–1. Loading Three Compile-Time Vectors Without Using the SEQ Field ...............20–5
20–2. Loading a Compile-Time Vector Using the SEQ Field ......................................20–6
20–3. Loading Three Compile-Time Vectors Using ** Specifications........................20–7

21–1. Compiling a Source Program without Editing...................................................21–4


21–2. Compiling a Source Program That Merges a Patch File ...................................21–4
21–3. Compiling a Source Program That Creates a New Merged File.......................21–5
21–4. WFL Job with TASKSTRING Attribute..............................................................21–5
21–5. Coding Compiler Control Records (CCRs) ........................................................21–7

xxiv 8600 0544–103


About This Manual

Documentation Updates
This document contains all the information that was available at the time of publication.
Changes identified after release of this document are included in problem list entry (PLE)
18565374. To obtain a copy of the PLE, contact your Unisys representative or access
the current PLE from the Unisys Product Support Web site:

http://www.support.unisys.com/all/ple/18565374

Note: If you are not logged into the Product Support site, you will be asked to do so.

Purpose
This manual describes Report Program Generator I and II. It is a reference document for
the applications programmer using the RPG language to develop programs. This manual
is not a tutorial.

Scope
This manual describes

• Basic concepts of the RPG language


• Language elements
• RPG program logic cycle (PLC)
• RPG specification forms (the use of each field and valid formats to input and output
data)
• The syntax and explanation of certain processor directing specifications—compiler
control records (CCRs) that are intermixed with RPG specifications, but are not
included in the RPG language
In addition, this manual provides supplementary information on using files and vectors,
printing reports, the indicator summary form, reference tables, error messages, and
source-file maintenance. Extensive examples illustrate applications of the RPG language.

Additional publications relate directly to RPG and can be helpful to RPG programmers.
For more information, see the list of related product information in this section.

8600 0544–103 xxv


About This Manual

RPG coding forms are available for each type of RPG specification. A list of the RPG
coding forms and their form numbers follows. Programs can be written on these forms
before they are entered into the computer.

• RPG Alternate Collating Sequence Specifications (1195187)


• RPG Attribute Specifications (1195161)
• RPG Calculation Specifications (1170438)
• RPG Control Specification and Indicator Summary (1195179)
• RPG Database Specification (1170479)
• RPG Extension and Line Counter Specifications (1170461)
• RPG File Description Specifications (1195153)
• RPG File Translation Specifications (1195237)
• RPG Input Specifications (1170420)
• RPG Library Specifications (1195245)
• RPG Output-Format Specifications (1170446)
• RPG Telecommunications Specifications (1170453)
• RPG Vector Data Specifications (1180601)
A Report Program Generator (RPG) Programming Template is also available. This
template gives the format of each type of RPG specification and can be used to interpret
printouts of RPG programs.

The Report Program Generator (RPG) Programming Reference Manual is divided into two
volumes. In this manual, the Report Program Generator (RPG) Reference Manual,
Volume 2: Product Interfaces is referred to as Volume 2.

Volume 2 contains a description of RPG language extensions for the Communications


Management System (COMS) and Data Management System II (DMSII), including
syntax, explanations, and examples that illustrate how to use RPG to interface with each
product.

Audience
The RPG programmer in need of a reference document for programming with RPG
should read this manual.

For the experienced RPG programmer, this manual is a good source of reference
information about available options and features.

Prerequisites
A basic understanding of the RPG language is required. In addition, a basic knowledge of
the system is necessary.

xxvi 8600 0544–103


About This Manual

How to Use This Manual


For complete reference information, this manual should be used with Report Program
Generator (RPG) Reference Manual, Volume 2 and with other documents such as the File
Attributes Programming Reference Manual.

Acronyms are spelled out the first time they occur in the manual.

Organization
The first three sections of this manual are a general introduction to RPG programming.
Section 4 provides many examples of programming with disk files. Section 5 explains
internationalization features that can customize applications to the language and
conventions of a particular locale. Sections 6 through 20 explain the fields of each coding
form. Section 21 describes the compiler control records. Two appendixes are included to
provide related information.

Section 1. RPG Programming


A brief description of RPG language capabilities is provided. The components of an RPG
source program are described.

Section 2. RPG Language Elements


The basic components of the RPG language are described, and the rules for forming
names and literals are defined.

Section 3. RPG Program Logic Cycle (PLC)


The general cycle of operations for an RPG object program is described. In addition, a
diagram (with a detailed explanation) of specific steps taken in the PLC is included.

Section 4. Disk Files


The function and processing of disk files are explained.

Section 5. Internationalization
The internationalization features that can be used to customize an application for the
language and conventions of a particular locality are described.

Section 6. Indicator Summary Form


The summary form used to document RPG programs is illustrated, the fields contained in
this form are listed, and the meaning of each field is provided.

Section 7. Control Specification


The function of the Control Specification is explained, and its field definitions are
described in detail.

8600 0544–103 xxvii


About This Manual

Section 8. File Description Specifications


The function of the File Specifications is explained, and their field definitions are
described in detail.

Section 9. Attribute Specifications


The function of the Attribute Specifications is explained, and their field definitions are
described in detail.

Section 10. Extension Specifications


The function of the Extension Specifications is explained, and their field definitions are
described in detail.

Section 11. Line Counter Specifications


The function of the Line Counter Specifications is explained, and their field definitions are
described in detail.

Section 12. Telecommunications Specifications


The function of the Telecommunications Specifications is explained, and their field
definitions are described in detail.

Section 13. Library Specifications


The specifications used for accessing libraries are discussed. Field definitions for Library
Name Specifications, Library Subroutine Specifications, and Library Parameter
Specifications are described in detail.

Section 14. Input Specifications


The specifications that describe the records and fields in each file to be used as input
data for the program are discussed. Two types of Input Specifications (record type
descriptions and field descriptions) are discussed, and the field definitions for these
specifications are described in detail. In addition, data structures are described in this
section.

Section 15. Calculation Specifications


The function of the Calculation Specifications is explained, the three types of Calculation
Specifications (detail calculations, total calculations, and subroutines) are discussed, and
the field definitions for these specifications are described.

Section 16. Operation Codes


The various types of arithmetic, logical, and I/O operations performed on associated
operands are described.

xxviii 8600 0544–103


About This Manual

Section 17. Output-Format Specifications


The function of the Output Specifications is explained, the subdivisions of these
specifications (record description and field description) are discussed, and the field
definitions for these specifications are described in detail. In addition, a discussion about
printing reports is provided.

Section 18. Alternate Collating Sequence Specifications


The specifications used to modify the EBCDIC collating sequence are described.

Section 19. File Translation Specifications


The specifications used for file data translation between the EBCDIC character set and a
user-specified character set are described.

Section 20. Vector Data Specifications


The specifications used for compile-time vector loading are described.

Section 21. Control of the Compilation Process


Information about using compiler control records (CCRs) to control the compilation of the
program is provided. Additionally, source file maintenance and compiler memory
estimates are described.

Appendix A. System Messages


A list of run-time error messages is given, causes and responses are explained, and
programmed halt messages are described.

Appendix B. Reference Tables


The EBCDIC and ASCII codes are defined.

Related Product Information


Unless otherwise stated, all documents referred to in this publication are MCP/AS
documents. The titles have been shortened for increased usability and ease of reading.

The following documents are included with the software release documentation and
provide general reference information:
• The Glossary includes definitions of terms used in this document.
• The Documentation Road Map is a pictorial representation of the Product Information
(PI) library. You follow paths through the road map based on tasks you want to
perform. The paths lead to the documents you need for those tasks. The Road Map
is available on the PI Library CD-ROM. If you know what you want to do, but don't
know where to find the information, start with the Documentation Road Map.
• The Information Availability List (IAL) lists all user documents, online help, and HTML
files in the library. The list is sorted by title and by part number.

8600 0544–103 xxix


About This Manual

The following documents provide information that is directly related to the primary
subject of this publication.

The following documents are included with the software release documentation and
provide general reference information:

• The Glossary includes definitions of terms used in this document.


• The Documentation Road Map provides a high-level series of graphics that show
paths through the documentation library. It also includes a complete bibliography
with brief descriptions of each document in the library.
• The Information Availability List (IAL) lists all user documents and online help files in
the library and indicates the media (CD-ROM, online help, and paper) on which each
one is available. The list is sorted by title and by part number.
The following documents provide information that is directly related to the primary
subject of this publication.

File Attributes Programming Reference Manual


This manual contains information about each file attribute and each direct I/O buffer
attribute. The manual is written for programmers and operations personnel who need to
understand the functionality of a given attribute. The I/O Subsystem Programming Guide
is a companion manual.

Message Translation Utility (MSGTRANS) Operations Guide


This guide describes how to use the Message Translation Utility (MSGTRANS) to
translate compiled program messages from any natural language to any other natural
language. It provides complete instructions for running and using the screen and batch
interfaces of MSGTRANS. This guide is written for programmers and translators who
create and translate program messages in a MultiLingual System (MLS) environment.

MultiLingual System (MLS) Administration,Operations, and Programming


Guide
This guide describes how to use the MLS environment, which encompasses many
products. The MLS environment includes a collection of operating system features,
productivity tools, utilities, and compiler extensions. The guide explains how these
products are used to create application systems tailored to meet the needs of users in a
multilingual or multicultural business environment. It explains, for example, the
procedures for translating system and application output messages, help text, and user
interface screens from one natural language to one or more other languages; for
instance, from English to French and Spanish. This guide is written for international
vendors, branch systems personnel, system managers, programmers, and customers
who wish to create customized application systems.

xxx 8600 0544–103


About This Manual

Report Program Generator (RPG) Programming Reference Manual, Volume


2: Product Interfaces
This manual describes extensions to the RPG language designed to allow application
programs to interface with the Data Management System II (DMSII) or the
Communications Management System (COMS). This manual is written for applications
programmers who are familiar with RPG programming language concepts and terms.

Report Program Generator (RPG) Programming Template


This programming template is designed to help the programmer align RPG programming
code in the proper fields and columns and for debugging purposes.

Task Attributes Programming Reference Manual


This manual describes all the task attributes available on the system. It also gives
examples of statements for reading and assigning task attributes in various programming
languages. The Task Management Programming Guide is a companion manual.

8600 0544–103 xxxi


About This Manual

xxxii 8600 0544–103


Section 1
RPG Programming

This section provides an overview of the Report Program Generator (RPG) language and
describes the basic concepts of programming in RPG.

The RPG language is machine-independent. Its design enables applications programmers


to prepare computer programs without a thorough knowledge of the operating system.

Because of program logic cycle (PLC) processing, the programmer can focus on the
problem to be solved by the system, rather than on the details of system operation.
Basically, RPG specifies the type of data to be processed and the type of output desired.
The compiler translates the specifications into instructions that do all that is necessary to
produce the required output.

RPG Applications
RPG programs are often used to produce customized reports from data contained in
files; however, RPG can be used for a variety of data processing applications that do not
involve report production in the traditional sense. Primarily, these other applications
update data files stored on magnetic tape, disk, or other machine-readable media.

RPG offers the following advantages to the user:

• Simple, generative syntax for ease of program implementation


• Ease of conversion through standard implementation
• Comprehensive documentation
• Computing power

8600 0544–103 1–1


RPG Programming

File Creation
The Command and Edit (CANDE) message control system (MCS) creates the program
file. CANDE facilitates the editing and management of programs. Additional information
on CANDE is provided in the CANDE Operations Reference Manual.

Either of the following methods can be used to compile and run the program:

• The CANDE message control system (MCS).


• The Work Flow Language (WFL). WFL is a powerful language that can be used to
construct jobs that run tasks and control their execution. Additional information on
the WFL job control language is provided in the Task Attributes Programming
Reference Manual.
Additional information on using CANDE and the WFL control language is provided in
Section 21, “Control of the Compilation Process,” in this manual.

RPG Dialects
RPG for MCP based systems supports two dialects: RPG I and RPG II. The RPG I dialect
is compatible with the IBM 360/20 RPG. The RPG II dialect is compatible with the IBM
System/36 RPG II. Both dialects support MCP based extensions.

If RPG I features are needed, a 1 must be entered in the Source Dialect field (column 51)
of the Control Specification; otherwise, this column should be blank. The source program
is not checked against the syntax of the chosen dialect; this option is used only to
resolve conflicts between the dialects. Provided that no conflict exists, RPG II features
can be used when the RPG I dialect is specified; similarly, RPG I features can be used
when the RPG II dialect is specified.

In this manual, all references to RPG that do not specify a particular dialect refer to
RPG II.

RPG Source Program


A program written in the RPG language is called an RPG source program. The RPG
compiler verifies that the source program is syntactically correct and converts this source
program into a machine-language program (machine code), which in this manual is called
an object program. After compilation, the object program is ready for execution by the
system.

Compiler control records (CCRs) accommodate system-dependent features. These


specifications can appear anywhere in the source program, unless otherwise specified.
(Refer to Section 21, “Control of the Compilation Process.”)

1–2 8600 0544–103


RPG Programming

Source File Organization


An RPG source program is divided into different types of specifications as illustrated by
Figure 1–1. All specification types are optional.

Figure 1–1. RPG Source Program

8600 0544–103 1–3


RPG Programming

The specifications shown in Figure 1–1 are described and must be used in the order
listed in the following table:

Specifications Description

Control Provides information about the program and selects compiler


options. The Control Specification is optional.
Database Establishes the link between an RPG program and DMSII. The
Database Specification is used to invoke a database. For more
information about using DMSII in RPG, refer to Volume 2 of this
manual.
File Describes files used in the program and associates them with
hardware devices.
File Attribute Provides additional file information used by the operating system.
These specifications immediately follow the File Specifications to
which they refer.
Extension Describes vectors (tables and arrays) and record-address files
used in the program.
Line Counter Provides information about the number of lines printed on each
page of printer output. Also, line-channel equations can be
specified to associate print lines with channel punches in a
carriage control tape.
Telecommunicatio Establishes and maintains the link between the RPG program and
ns a message control system (MCS).
Library Links RPG programs to library procedures written in any language
that can be called by an RPG program.
Library Attribute Provides additional library information used by the operating
system. These specifications immediately follow the Library
Specifications to which they refer.
Input Describes the layout of records read by the program.
Calculation Describes the sequence and timing of calculations performed on
data in the program. Calculation Specifications can also describe
input and output control for some files.
Output Specifies the type and format of data written as output from the
program.
Alternate Collating Modifies the EBCDIC collating sequence. ** Specifications
Sequence records also can be used.
File Translation Translates characters between the EBCDIC character set and a
user-specified character set. Can precede or follow the Alternate
Collating Sequence Specifications. ** Specifications records also
can be used.
Vector Data Loads compile-time vector data. ** Specifications records also can
be used.
Vector Data Follow the Vector Data Specifications to provide the data for
Elements compile-time vectors.

1–4 8600 0544–103


RPG Programming

The coded information contained on the specification forms is recorded in the disk or
tape files that constitute the source program. The arrangement of these records in the
source is illustrated in Figure 1–1. Note that either Alternate Collating Sequence or File
Translation Specifications can follow Output Specifications.

If source corrections are necessary, appropriate changes can be made to the program,
and the program can be recompiled.

8600 0544–103 1–5


RPG Programming

1–6 8600 0544–103


Section 2
RPG Language Elements

This section describes the

• RPG character set


• Rules for forming names and literals
• RPG reserved words

Character Set
The RPG character set consists of the characters shown in Table 2–1.

Table 2–1. RPG Character Set

Character Name Character Name

0–9 Numeric characters A–Z Alphabetic characters


Blank or space & Ampersand
. Period or decimal -- Minus sign or hyphen
point
$ Dollar sign * Asterisk
, Comma ' Apostrophe
/ Slash @ At sign
# Pound sign

In addition, the characters shown in Table 2–2 can be used in edit words and
alphanumeric literals.

8600 0544–103 2–1


RPG Language Elements

Table 2–2. Additional Character Set for Edit Words and


Alphanumeric Literals

Character Name Character Name

+ Plus sign < Less than sign


> Greater than sign ( Left parenthesis
) Right parenthesis [ Left bracket
] Right bracket ! Exclamation
point
; Semicolon ? Question mark
: Colon % Percent sign
" Quotation mark _ Underscore
= Equal sign

Characters Used for Names


The character set used to form names consists of the characters shown in Table 2–3.

Table 2–3. Characters Used for


Names

Character Name

0–9 Numeric characters


A–Z Alphabetic characters
$ Dollar sign
@ At sign
# Pound sign
-- Hyphen

The standard characters used in creating identifiers (such as file names, vector names,
field names, and labels) are the letters A through Z and the digits 0 through 9. Additional
characters might be necessary for international usage because of an expanded character
set.

An identifier must start with an alphabetic character, a dollar sign ($), an at sign (@), or a
pound sign (#). When an embedded comma is used to form an indexed vector, the
characters following the comma are assumed to be a subscript for that vector.

2–2 8600 0544–103


RPG Language Elements

Characters Used for Editing


The character set used in edit words in the Output Specifications consists of the
characters shown in Table 2–4.

Table 2–4. Characters Used for Editing

Character Name Character Name

Blank or space 0 Zero


$ Dollar sign . Decimal point
, Comma CR Credit symbol (two
characters)
* Asterisk (check- & Ampersand
protect)
-- Minus sign

Definition of Names
A name must be left-justified in the field; must begin with an alphabetic character, a
dollar sign ($), an at sign (@), or a pound sign (#); and must end with a space or the end of
the field (whichever comes first). After the first character, a name can contain any
combination of characters as defined in the discussion of characters used for names in
this section. Blanks must not appear between the characters in a name.

RPG defines the following types of names:

• Data structure names


• Field names (variable names)
• File names
• Labels
• Library names
• Library subroutine names
• Output group names
• Subfield names
• Vector names (table and array names)
No field name can start with an asterisk (*) because that character is reserved for
system-defined names.

8600 0544–103 2–3


RPG Language Elements

Data Structure Names


A data structure name identifies an alphanumeric field, portions of which can be referred
to by using subfields. Data structure names must not exceed 6 characters and must be
unique among field, vector, and data structure names. For more information on data
structures and subfields, see the discussion of data structures in Section 14, “Input
Specifications.”

Field Names
A field name identifies an individual element of data. A field name is 6 characters or less
and must be unique among vector and field names. A separate memory area is reserved
for each field name.

A field name is defined by the first occurrence of the name that specifies length and
decimal attributes. Any attempt to redefine the name with different attributes results in a
warning.

Signed and unsigned numeric fields can be up to 23 digits long (not including the sign).
The size of alphanumeric fields is restricted by the specification on which they occur. The
largest alphanumeric field allowed in RPG is 9999 bytes.

File Names
A file name designates a set of data items. A file name is 8 characters or less and must
be unique among file and output group names. The length of the file name can be
extended by using the TITLE file attribute. Additional information on the TITLE file
attribute is provided in Section 9, “Attribute Specifications.” The contents of a file are
divided into logical records made up of any consecutive set of data items. A file name
must not contain any special characters other than the hyphen (-), a pound sign (#), a
dollar sign ($), or an at sign (@).

Labels
A label identifies either a point in the Calculation Specifications where a GOTO operation
branches or the beginning of a subroutine. Labels cannot exceed 6 characters in length
and must be unique among labels.

Library Names
A library name identifies the name of a library that provides procedure entry points that
the program intends to call. Library names follow the rules for the definition of names.
The length of the name cannot exceed 10 characters and must be unique among library
names.

2–4 8600 0544–103


RPG Language Elements

Library Subroutine Names


A library subroutine name is a unique name for a library subroutine used by the program.
Library subroutine names follow the rules for the definition of names. Names cannot
exceed 10 characters in length and must be unique among library subroutine names.
Subroutine names beginning with a dollar sign ($) are reserved for system-defined
subroutines.

Output Group Names


An output group name identifies a group of exception records for output during
calculations. The output group name must follow the rules for the formation of a field
name. The output group name cannot be the same name as a file name, a field name, a
data structure name, or a vector name. For more information on output group names,
refer to the Field Name field (columns 32–37) in Section 17, “Output-Format
Specifications.”

Subfield Names
A subfield is an element of a data structure. Subfield names follow the same rules of
formation as field names. In addition, a subfield name cannot be the same as a data
structure name, an array element, a table name, an output group name, or a look-ahead
field. Subfield names must be unique within data structures; the same subfield name
cannot be used in more than one data structure. A data structure name can not be used
as a subfield name in another data structure.

Vector Names
A vector name identifies data that is a table or an array. The vector is loaded with a
number of elementary data items. The entire vector can be accessed by using the vector
name. A vector name is 6 characters or less, and must be unique among vector and field
names. For more information on tables and arrays, see the discussion of using vectors in
Section 10, “Extension Specifications.”

A vector element is referred to by the vector name followed by a comma (,) and an index.
The index can be a numeric literal or a field name defined elsewhere in the program.

8600 0544–103 2–5


RPG Language Elements

Definition of Literals
A literal is an item of data that contains a value identical to the characters being
described. The four classes of literals are figurative constant, numeric, alphanumeric, and
hexadecimal.

Figurative Constants
Figurative constants are literals that have predefined values and implied lengths.
Figurative constants are

*BLANK *BLANKS *ZERO *ZEROS

The following applies to figurative constants:

• *BLANK and *BLANKS are synonyms. *ZERO and *ZEROS are synonyms.
• *BLANK, *BLANKS, *ZERO, and *ZEROS can be used as alphanumeric or numeric
fields.
• The result of moving *BLANK or *BLANKS into an alphanumeric field is a field filled
with blanks (for example, ' '). The result of moving *BLANK or *BLANKS into a
numeric field is a field filled with zeros (for example, '00').
• The result of moving *ZERO or *ZEROS into a numeric field is a field filled with zeros
(for example, '00'). The result of moving *ZERO or *ZEROS into an alphanumeric
field is a field filled with blanks (for example, ' ').
• Figurative constants can be used only in Calculation Specifications.
• The length of the figurative constant is the same as the length of the other factor
field, if it is present. If no other factor field is present, the length of the figurative
constant is equal to the length of the Result Field.
• Figurative constants are considered to be individual items and are like fields when
used with arrays. For example, if the 6-element numeric array NUM contains 1 2 3 4
5 6, then using the ADD operation with *ZERO in Factor 2 causes zero to be added
to each element of the array. The result is 1 2 3 4 5 6.
If the figurative constant *BLANK is used with the MOVEA operation, blanks are moved
into every element of an alphanumeric array, beginning with the specified element, to the
end of the array. For example, the MOVEA operation with *BLANK in Factor 2 and ALP,1
in the Result Field causes the entire array ALP to be filled with blanks.

A figurative constant is placed in the collating sequence where the corresponding blank
or zero is placed; therefore, its placement can be modified by an alternating collating
sequence.

2–6 8600 0544–103


RPG Language Elements

Figurative constants can be used in Factor 1 and Factor 2 of all operations that allow
alphanumeric or numeric fields except as follows:

• Figurative constants are not allowed in Factor 1 of either the DEBUG or the DSPLY
operation.
• Figurative constants are not allowed in Factor 2 of the following operations:
BITOF MHLZO SQRT

BITON MLHZO TESTB

MHHZO MLLZO

Numeric Literal
A numeric literal is defined as an item composed of characters chosen from the digits 0
through 9, the plus (+) or minus (–) sign, and the decimal point or the decimal comma.

The rules for creating a numeric literal are as follows:

• There must be at least one digit in a numeric literal.


• The sign of a numeric literal must be the leftmost character. The literal is defined as a
positive value when no sign is present.
• Only one sign character and one decimal point can be contained in a numeric literal.
• The maximum length of a numeric literal is 10 characters, including the sign and the
decimal point.
• A decimal comma can be used in place of a decimal point if the Inverted Print option
I or J (column 21 in the Control Specification) is used.
• Embedded blanks are not allowed.
Following are five examples of numeric literals:

13247 .005 +1.808 -.09687354 7894.54

8600 0544–103 2–7


RPG Language Elements

Alphanumeric Literal
An alphanumeric literal is composed of any allowable characters enclosed in
apostrophes ('). Consequently, all spaces enclosed in the apostrophes are considered
part of the literal. Two consecutive apostrophes in an alphanumeric literal cause a single
apostrophe to be inserted into the literal string. An alphanumeric literal that consists of
only four consecutive apostrophes results in a literal of a single apostrophe.

The rules for the formation of an alphanumeric literal are

• There must be at least one character in an alphanumeric literal.


• The maximum length of an alphanumeric literal is 8 characters in the Calculation
Specifications and 24 characters in the Output Specifications.
• Alphanumeric literals cannot be used for arithmetic operations.
The following are examples of alphanumeric literals:

Literal in Source Program Literal Stored by Compiler

'ACTUAL' ACTUAL
'-1234.56' -1234.56
'WEEK''S' WEEK'S
'TODAY''S DATE' TODAY'S DATE
'''' '
'A''B' A'B
'A''''B' A''B

2–8 8600 0544–103


RPG Language Elements

Hexadecimal Literal
A hexadecimal literal is used in the formation of alphanumeric characters. This literal can
be used to form bit patterns that cannot otherwise be represented in the RPG source
image.

The rules for creating a hexadecimal literal are

• Hexadecimal literals must contain an even number of hexadecimal digits enclosed in


at signs (@).
• Each pair of hexadecimal digits is treated as an alphanumeric character.
• Rules that apply to alphanumeric literals also apply to hexadecimal literals. However,
hexadecimal literals must not be used for move operations with a numeric Result
Field.
• The maximum length of a hexadecimal literal that can be declared in Calculation
Specifications is 4 bytes (that is, four pairs of hexadecimal digits).
A list of hexadecimal digits and their equivalent binary representations appears in
Table 2–5.

Table 2–5. Hexadecimal Digits

Hex Binary Hex Binary


Digit Representation Digit Representation

0 0000 8 1000
1 0001 9 1001
2 0010 A 1010
3 0011 B 1011
4 0100 C 1100
5 0101 D 1101
6 0110 E 1110
7 0111 F 1111

The following are examples of hexadecimal literals:

@0F@ @3C@

8600 0544–103 2–9


RPG Language Elements

Definition of Reserved Words


Reserved words have a specific function in the RPG syntax. The two types of reserved
words are special words and operation codes.

Special Words
These reserved words are used in the Input, Calculation, and Output Specifications.

The following special words are reserved for use as variables:

UDATE UTIME

JDATE PAGE

UMONTH PAGEn (where n is a digit 1 through 9)

UDAY *IN

UYEAR *INxx (where xx is an indicator)

UDAYNM *PLACE

Each special word has its own defined usage, as described in the following paragraphs.

Date Fields (UDATE, JDATE, UMONTH, UDAY, and UYEAR)


The five special words for the date field enable the program to obtain the value of the
date at the beginning of job (BOJ).

The UDATE date field produces a 6-digit numeric field in one of the following formats,
depending on the entry in the Inverted Print field (column 21) and the Date Format field
(column 23) in the Control Specification:

• MMDDYY (domestic format)


• DDMMYY (international and United Kingdom format)
• YYMMDD
The UDATE field is assigned a value by the system.

To access a 4-digit year, use the CURRENT_DATE procedure in the GENERALSUPPORT


library. Section 13, “Library Specifications,” provides an example of using this
procedure.

The JDATE date field is the Julian date. JDATE is 5 digits long with no decimal places
and has the format YYDDD.

The other three fields, UMONTH, UDAY, and UYEAR, consist of a 2-digit field
representing the month, day, and year, respectively.

2–10 8600 0544–103


RPG Language Elements

The following rules apply to UDATE, JDATE, UMONTH, UDAY, and UYEAR:

• These fields must not be changed by any operation within the program. They must
not be used in Input Specifications, in the Calculation Specifications Result Field, or in
the Output Specifications with the Blank After field specified. These fields are
generally used in compare, test, and output operations, and they can be used as
subscripts.
• The current value of the date is captured at beginning of job (BOJ) and does not
change during the execution of the program.

UDAYNM
The special word UDAYNM enables the program to obtain the name of the current day at
BOJ. UDAYNM is a left-justified, 9-character alphanumeric field. This field cannot be
changed by the RPG program.

UTIME
The special word UTIME enables the program to obtain the time at BOJ. UTIME is a 6-
digit numeric field with the format HHMMSS (where HH, MM, and SS represent hours,
minutes, and seconds, respectively). This field cannot be changed by the RPG program.

Page Fields (PAGE, PAGEn)


If page numbers are needed for output, the special words PAGE and PAGEn indicate
automatic page numbering. Ten possible page entries, PAGE or PAGE1 through PAGE9,
are provided for use with different output files. Page fields can be entered in the Field
Name field (columns 53–58) in the Input Specifications or in the Result Field
(columns 43–48) in the Calculation Specifications.

The field can be defined as any length (refer to the discussion of field lengths earlier in
this section), but it cannot contain any decimal positions. When a page field is specified
without being previously defined in the Input or Calculation Specifications, the field is
assumed to be 4 digits long with no decimal positions. During output, leading zeros are
suppressed and the sign is not printed (unless an edit word or an edit code is specified).

The page field begins at 0 (unless otherwise specified) and is automatically incremented
by 1 before each new page is written.

A page field can be reset at any point during the program by setting it to 0 before it is
printed (refer to Example 2–1).

8600 0544–103 2–11


RPG Language Elements

A page field can be set to 0 in one of two ways:

• Using the Blank After field (column 39) in the Output Specifications to clear the field
to 0 after output.
• Assigning an output indicator to the page field. If the indicator is on, the field is set to
0 before normal incrementing takes place. The indicator is only used to determine
whether to set the field to 0; it does not condition the printing of the field.
It is not recommended that the same PAGE and PAGEn entry be used for different
output files. Page fields are not restricted to printer files.

Example
Example 2–1 shows the use of page fields, as follows:

• PAGE1, associated with the file FILEOUT, is incremented by 1 before each page of
FILEOUT is printed.
• PAGE2, associated with the file PRINT, is cleared to 0 after each page of PRINT is
printed because B is inserted in the Blank After field.
• PAGE3, associated with the file PRINT2, is set to 0 before each page of PRINT2 is
printed if the output indicator 01 is on. If the output indicator 01 is not on for a given
output, PAGE3 is not reset to 0. The value of PAGE3 is written to PRINT2 regardless
of the value of indicator 01.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*
02000FFILEIN IP 80 80 DISK
04000FFILEOUT O 132 132 PRINTER
06000FPRINT O 132 132 PRINTER
08000FPRINT2 O 132 132 PRINTER
10000IFILEIN AA 01
12000OFILEOUT D
14000O PAGE1 5
16000OPRINT D
18000O PAGE2 B 5
20000OPRINT2 D
22000O 01 PAGE3 5

Example 2–1. Coding a Page Field

2–12 8600 0544–103


RPG Language Elements

Alphanumeric Aliases for Indicators (*IN and *INxx)


*INxx and *IN are alphanumeric aliases for indicators. *INxx refers to an indicator by
name (xx is the indicator name). *IN is an array that can be used to refer to indicators 01
through 99.

*INxx Alias
An indicator can be referred to as a 1–character alphanumeric field having the name
*INxx, where xx is the indicator name. For example, *IN22 refers to indicator 22.
Likewise, *INLR refers to the LR indicator. Allowing indicators to be used as an
alphanumeric field creates the alias for the indicator.

The status of the indicator (on or off) is determined by the low-order bit of the
alphanumeric field. If the low-order bit is on, the indicator is on. If the low-order bit is off,
the indicator is off.

The alphanumeric aliases for the following indicators are declared automatically by the
compiler and are available for every RPG program. It is not necessary to declare them
individually.

Type Indicators

User 01–99
Control L0–L9, LR
Data Management DA–DH, DJ--DU, D1
Exception
Overflow OA–OG, OV
External U1–U8
Halt H0–H9
Matching Record MR

8600 0544–103 2–13


RPG Language Elements

Example
Example 2–2 shows the use of alphanumeric aliases for indicators 01 through 05 to set
them according to the first 5 bytes of an input data record.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*
00100IINFILE 10
00200I 1 1 *IN01
00300I 2 2 *IN02
00400I 3 3 *IN03
00500I 4 4 *IN04
00600I 5 5 *IN05

Example 2–2. Coding *INxx Indicators

*IN Alias
Indicators 01 through 99 also can be referred to as elements of the *IN alphanumeric
array. For example, *IN,34 is a 1-byte alphanumeric array element corresponding to
indicator 34. The array *IN has ninety-nine 1-byte elements.

Using the *IN array has several advantages. For example, the *IN array can be used if
calling a subroutine might make undesirable changes to indicators. Using the *IN array
enables the state of the indicators (on or off) to be saved before a subroutine is
executed. The state of the indicators then can be restored after the subroutine has
completed execution.

Example
Example 2–3 shows the use of the *IN array. Indicators 01 through 20 are saved before a
subroutine call and are restored after the subroutine is completed.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*
00100C MOVEA*IN SAVE20 20
00200C EXSR SUB1
00300C MOVEASAVE20 *IN

Example 2–3. Coding an *IN Array

Like the alphanumeric aliases, the *IN array is declared automatically by the compiler and
is available for every RPG program. The *IN array cannot be declared explicitly.

2–14 8600 0544–103


RPG Language Elements

*PLACE
The special word *PLACE enables the same fields to be written in more than one place
in an output record. *PLACE is valid only in Output Specifications. Information on
*PLACE is provided in the discussion of constants in Section 17, “Output-Format
Specifications.”

Operation Codes
The following reserved words specify operations that can be performed on data items:

ADD (Add) MHLZO (Move high to low zone)

ANDxx (Perform conditional AND) MLHZO (Move low to high zone)

BEGSR (Begin subroutine) MLLZO (Move low to low zone)

BITOF (Set bit off) MOVE (Move rightmost)

BITON (Set bit on) MOVEA (Move array)

CAS (Select case unconditional) MOVEL (Move leftmost)

CASxx (Select case conditional) MULT (Multiply)

CASE (Select case) MVR (Move remainder)

CHAIN (Access data file) ORxx (Perform conditional OR)

CLOSE (Close file for processing) PARAM (Specify parameters for EEXSR)

COMP (Compare) READ (Read sequentially)

DEBUG (Debug program) READE (Read equal key)

DEFN (Define a new field) READP (Read previous record)

DELET (Delete a record) RECV (Read remote file record)

DIV (Divide) SEND (Send remote file record)

DO (Do) SETLL (Set lower limit)

DOUxx (Do until) SETOF (Set off)

DOWxx (Do while) SETON (Set on)

DSPLY (Display data) SORTA (Sort array)

DUMP (Perform symbolic dump) SQRT (Perform square root)

EEXSR (Execute external subroutine) SUB (Subtract)

8600 0544–103 2–15


RPG Language Elements

ENDSR (End subroutine) TAG (Identify entry point from GOTO)

EXCPT (Write exception output) TESTB (Test bits)

EXSR (Execute subroutine) TESTN (Test for numeric)

FORCE (Select record) TESTZ (Test zone)

GOTO (Branch to instruction) TIME (Provide current time)

IFxx (Execute if-then) XFOOT (Sum elements of numeric array)

IFxx/ELSE (Execute if-then-else) Z-ADD (Zero then add)

LOKUP (Look up vector entry) Z-SUB (Zero then subtract)

MHHZO (Move high to high zone) ZIP (Activate WFL statement)

These reserved words are used in the Calculation Specifications. A complete description
of the operation codes is presented in Section 16, “Operation Codes.”

2–16 8600 0544–103


Section 3
RPG Program Logic Cycle (PLC)

To understand RPG, it is essential to understand the program logic cycle (PLC) because
the RPG object program goes through the same cycle of operations for each record.
After the program reads a record, calculation operations and output occur at two different
times. First, the program performs all total calculation operations and all total output
operations. Total calculations are those conditioned by control level indicators in the
Control Level field (columns 7–8) in the Calculation Specifications. Total output operations
are those with a T in the Type field (column 15) in the Output Specifications. Second, the
program performs all detail calculations and detail output operations.

The program performs total calculations before it makes available the information on the
record selected for processing. It performs detail calculations after it makes available the
information on the selected record (refer to Figure 3–1). The following paragraphs
describe this important concept in more detail.

Whenever the program reads a record with a control field specified, it determines if
information in the control field is different from the control field information in the
previous record. A change in the control field information indicates that all records from a
particular control group have been read and that a new group is starting.

When the program has read all the records from a group, it turns on the control level
indicators. Then, the program can perform operations, using information accumulated
from all records in that group. At this time, the program performs all calculations
conditioned by control level indicators. Similarly, the program performs total output
immediately after it completes all total calculation operations. The program uses the
information from the records in the previous control group, not the information from the
record in the current cycle.

Detail calculations occur after the information in the selected record becomes available
(refer to Figure 3–1). Detail calculations are used to calculate values that are needed each
time a record is processed and to calculate totals for the current control group if control
fields are specified. After the program completes detail calculation operations, it
performs detail output operations.

Figure 3–1 shows the PLC.

8600 0544–103 3–1


RPG Program Logic Cycle (PLC)

Figure 3–1. Program Logic Cycle (PLC)

The following descriptions apply to Figure 3–1. Operations performed at each step in the
PLC are described in order under the heading corresponding to each step.

3–2 8600 0544–103


RPG Program Logic Cycle (PLC)

Cycle Initialization (Step 1)


The program initializes all variables, arrays, tables, indicators, control fields, match fields,
and date fields that have not already been initialized. Following are the processes in this
step:

• The data space is initialized. All numeric fields are initialized to zero (0),and all
alphanumeric fields are initialized to blank. Control-field storage space is initialized to
binary zero (0). Match-field storage space is initialized to either the highest or the
lowest possible value, depending on whether the match sequence is descending or
ascending. Refer to the discussion about Match fields (columns 61–62) in Section 14,
“Input Specifications.” All indicators, except for 1P, are turned off. Table pointers are
initialized to point to the first entry in each table.
• If the Zero/Blank Indicator Setting field (column 42) in the Control Specification
contains an S or if the Zero/Blank Indicator Setting field is blank and the Source Input
Dialect field (column 51) in the Control Specification contains a 1, then Zero/Blank
indicators are turned on, unless the indicator is one of the halt indicators (H0–H9).
• The program obtains the system date and time and initializes the date and time fields
to the appropriate formats and values.
• The external indicators (U1–U8) are initialized based on the task attributes SW1
through SW8.
• Preexecution-time vector data are loaded from the input table files; then the input
table files are closed.
• Other files used by the program are opened, if appropriate.
• The program turns on the first-control-cycle switch. This switch is used to suppress
total output and calculations until the first record has been processed.

Detail Output (Step 2)


The program performs heading and detail output on operations that meet indicator
conditions, except output operations conditioned by overflow indicators. The first page
indicator (1P) is turned on, if applicable.

Forms alignment can be requested during the first cycle by designating 1 in the Forms
Positioning field (column 41) of the Control Specification. If so, the operator can repeat
this step as many times as necessary to align the form.

8600 0544–103 3–3


RPG Program Logic Cycle (PLC)

Indicator Initialization (Step 3)


Following are the processes in this step:

• All overflow indicators are turned off unless the overflow indicator was turned on
during detail output in the current cycle (step 2) or during detail calculations in the
previous cycle (step 16).
• For any file having an overflow indicator that was turned on during detail output or
calculations, the overflow indicator assigned to the file remains unchanged.
• The halt indicators are tested. If any halt indicators are on, the operator has the
option to stop or continue the program, unless this option has been overridden by an
entry in the Halt Indicator field (column 50) in the Control Specification.
• All of the following indicators are turned off: record identification, halt, first page and
control level.
• If the RPG I dialect is specified in the Source Input Dialect field (column 51) in the
Control Specification, the last record (LR) indicator is turned off.
• The L0 indicator is turned on.

Last Record (LR) Test (Step 4)


RPG II programs test the LR indicator. If the LR indicator is on, the program branches to
step 8.

Primary and Secondary Files Read (Step 5)


Following are the processes in this step:

• If the first-control-cycle switch is on, the program reads records from each primary
and secondary file. On subsequent cycles, the program reads a record from the file
processed during the previous cycle unless that file is declared as an input look-
ahead file.
• If all the required files have reached end of file (EOF)as specified in the End of File
field (column 17) in the File Specifications, the program branches to step 8.
• If all the required files have not reached EOF, the program checks the Record
Identification Codes field (columns 21–41) in the Input Specifications and carries out
the record-type sequence checking specified in the Sequence field (columns 15–16)
in the Input Specifications.

3–4 8600 0544–103


RPG Program Logic Cycle (PLC)

Record Selection Logic (Step 6)


Following are the processes performed in step 6:

• If the FORCE operation was performed during the previous program cycle, the
program selects the forced file for processing and then branches to step 7. If the
FORCE operation was not performed during the previous cycle, the program inspects
the current records from each primary and secondary file in the order that the files
were specified in the File Specifications. The program selects for processing the first
file that has no match fields specified and then branches to step 7.
• If all records have match fields, the program selects for processing the record with
the highest-priority matching field value. This value is either the highest collating
value for the descending matching sequence or the lowest collating value for the
ascending matching sequence. If two or more files have equal highest-priority
matching field values, the program selects the file that was specified first in the File
Specifications.
If the record does not have match fields specified, the program branches to step 7.
• The program compares the match field value of the selected record to the match
field value of the previous record with match fields. If the selected record is in
sequence, the program branches to step 7; otherwise, the program displays an error
message indicating that a match sequence error has occurred. If the Run-Time Error
field (column 49) in the Control Specification was used to override the error handling
option, the operator indicates whether the program should end (by branching to step
17) or should continue reading the next record (by branching to the restart point at
step 18.)

Control Fields and Record Identification (Step 7)


Following are the processes in step 7:

• If there is a record identifying indicator for the record selected in step 6, it is turned
on.
• If any file read in step 5 of this cycle was defined as an update or combined file with
a look-ahead option, the program extracts look-ahead fields.
• If the record selected has control fields specified, the program tests the values of the
fields for control breaks. The program extracts the control fields from the record and
tests for each level against the control field storage area. If the contents are unequal,
a control break has occurred. The program turns on the appropriate control level
indicators and stores the new control field values in the control field storage area.
• If the first-control-cycle switch is on, it is turned off and the program branches to
step 11; otherwise, the program branches to step 9.

8600 0544–103 3–5


RPG Program Logic Cycle (PLC)

Orderly End (Step 8)


This step is reached in one of two ways:

• The program requires final totals and end of job (EOJ) processing as the result of
normal processing.
• An abnormal condition causes the operator or the program to have the program end
in an orderly manner.
The program turns on the indicators L0 through L9 and LR and branches to step 9.

Total Calculations (Step 9)


The program performs total calculations as determined by the control level conditioning
indicators in the Calculation Specifications. Following are the processes in step 9:

• The program selects a total calculation line that appears with a control level indicator
(L0–L9 or LR).
• The program branches to step 10 if all the total calculations have been processed or
if none appear.
• If the control level indicator is on and the conditions specified in the Indicators field
(columns 9–17) of the Calculation Specifications are satisfied, the program performs
the operation specified by the Operation field (columns 28–32) in the Calculation
Specifications.
• The program repeats step 9.

Total Output (Step 10)


With the exception of output operations conditioned by overflow indicators, the program
performs all total output operations that have met indicator conditions. If the overflow
condition is detected for a printer file, the program turns on the overflow indicator
assigned to that file.

End of Job (EOJ) Test (Step 11)


If the LR indicator is on, the program goes on to step 12; otherwise, it branches to
step 13.

Ending Routine (Step 12)


The program writes any vectors specified with an entry in the To Filename field
(columns 19–26) in the Extension Specifications. Any file maintenance required is
performed (for example, sorting of indexed files). Any open files are closed, and the
program ends.

3–6 8600 0544–103


RPG Program Logic Cycle (PLC)

Overflow Output (Step 13)


The program performs overflow printing for each printer file on which overflow has
occurred during this cycle.

• If an overflow indicator is assigned in the File Specifications or if overflow output is


indicated in the Output Specifications, then the program tests the overflow indicator
to determine if it is on. If it is on, the program performs any total output and then
detail output for that file, conditioned on the overflow indicator.
• If no overflow indicator is assigned and no overflow output is indicated, the program
tests whether the overflow condition has occurred. If overflow did occur, the
program generates a skip to a new page.

Data Extraction (Step 14)


If a match has occurred, then the matching record (MR) indicator is turned on; otherwise,
MR is turned off. A match occurs if the selected record has a match field that has the
same value as the match control value, and this value was originally selected from the
primary file.

Data are extracted from the current record and made available to the program for
processing. Any field indicators specified are turned on or off to reflect the status of the
data field values.

Input File Look-Ahead (Step 15)


If the current record is from an input file with look-ahead fields, then the program reads
the next record from that file and extracts the look-ahead fields.

Detail Calculations (Step 16)


The program performs detail calculations in the following order as determined by the
conditioning indicators specified in columns 9 through 17 in the Calculation
Specifications:

• The program selects a detail calculation line.


• If all detail calculations have been processed or if none appears, the program
branches to step 2.
• The program carries out the operation specified by the Operation field (columns 28–
32) and turns on the indicators in the Resulting Indicators field (columns 54–59)
according to the operation.
• The program repeats step 16.

8600 0544–103 3–7


RPG Program Logic Cycle (PLC)

Stop (Step 17)


This step occurs when an abnormal condition is present, and the operator or the program
begins an orderly end. If this point is reached twice, the program aborts and sends a
message that indicates the orderly end has failed once and cannot be relied on to
succeed.

Restart (Step 18)


This step occurs when an operator or the program chooses to restart the program by
reading the next record (step 5). Restart occurs after an abnormal matching sequence,
record identification, or record sequencing condition.

3–8 8600 0544–103


Section 4
Disk Files

This section contains discussions of the disk file systems, organization of disk files,
creation of disk files, processing of disk files, and addition and deletion of records from
disk files.

Disk File Systems


The following disk file systems can be used when KEYEDIOII is installed. The
KEYEDIOIIOUTPUT compiler control option determines which file system is enabled.

• Basic File System (BFS)


• Extended File System (EFS)
EFS is enabled when KEYEDIOIIOUTPUT is TRUE, and BFS is enabled when
KEYEDIOIIOUTPUT is FALSE. KEYEDIOII controls sequential, direct, and indexed EFS
files and BFS indexed files. Refer to the KEYEDIOII Programming Reference Manual for
information about installing KEYEDIOII.

The discussions of disk files in this manual assume that KEYEDIOII is installed on the
system. If this is not the case, the syntax for the file system enabled is the same as BFS.
However, record-level locking and alternate index files for indexed files exist only with
KEYEDIOII.

There are few differences between BFS and EFS files. For the differences that do exist,
BFS and EFS disk files require slightly different syntax in an RPG program. These
differences are indicated at appropriate places in the manual.

Both kinds of files can be used in the same RPG program. It is the responsibility of the
user to remember the type of file being used.

8600 0544–103 4–1


Disk Files

Comparison of BFS and EFS Files


The differences between BFS and EFS disk files are in the following areas:

• Direct file support


• Alternate index files
• Delete capability
• Record-level locking
Figure 4–1 illustrates the features of the file systems provided by KEYEDIOII.

Figure 4–1. Comparison of File Systems

The following summarizes the features of the file systems:

• Both BFS and EFS disk files support sequential, direct, and indexed file organizations.
The file organization reflects how records are placed in the file when the file is
created. BFS and EFS handle direct file support differently. For additional information,
refer to “Disk File Organization” later in this section.
• Alternate index files are files that contain indexes for another file (the parent file).
Alternate index files enable an EFS sequential or direct file to be accessed by a key
field in each record. Alternate index files also enable a BFS or an EFS indexed file to
be accessed by a key other than the primary key that was declared when the
indexed file was created.
Alternate index files can be created with SYSTEM/KEYEDIOII/UTILITY once the
parent file is created. All alternate index files are updated when the parent file is
updated.

4–2 8600 0544–103


Disk Files

• The EFS supports record deletion. The DELETE-CAPABLE attribute is a permanent


attribute that is specified when the file is created. When TRUE, this attribute enables
a program to delete records from an EFS file. Once deleted, a record in an EFS file
cannot be read.
The DELETE-CAPABLE attribute is not valid for BFS files. When an RPG program
attempts to delete a record from either a BFS sequential or direct file, the record is
filled with blanks, but not actually deleted. Once deleted, a record in a BFS sequential
or direct file can still be read. The deleted record is read as a blank record.
• Record-level locking protects a record read by a program from being read by another
program while it is still being processed. Record-level locking is allowed on EFS
sequential and direct files. It is not allowed on BFS sequential and direct files.
However, both BFS and EFS indexed files have record-level locking.
For more information, see “RECORDLEVELLOCK File Attribute” later in this section.

Alternate Index Files


Alternate index files can be created by specifying additional record fields as the keys for
existing files. SYSTEM/KEYEDIOII/UTILITY is used to define a field as the key to the file
(the field is a field in the record of the data file).

The keys created by the utilities are called alternate keys or alternate indexes. The keys
are stored in key files called alternate index files. Each new key that is defined is stored
in its own alternate index file.

An alternate index file is specified in the File Specifications exactly like an EFS indexed
file or a BFS indexed file. Although alternate index files are used and accessed like
indexed files, they have the following additional features:

• Alternate index files can be created for EFS sequential and direct files. If either an
EFS sequential or direct file needs to be accessed by a field in each record, alternate
index files can be created to access the data file by using alternate keys. Each
alternate index file defines one alternate key.
The application then can process the EFS sequential file randomly by key, while still
retaining the ability to process the file consecutively or randomly by relative record
number. SYSTEM/KEYEDIOII/UTILITY must be used to create an alternate index file.
Sequential and direct files do not have primary keys. After the alternate index file for
an EFS sequential or direct file is created, the data file retains the basic
characteristics and properties of either an EFS sequential file or direct file.
• The key defined for an alternate index file can be either a single field or up to three
noncontiguous fields. Each alternate index file uses one or more parts of a record to
define a key. If the key comes from noncontiguous fields, the Key Field Starting
Location field (columns 35–38) in the File Specifications must contain the letters
EXTK. The Record Address Field Length field (columns 29–30) is used to define the
total length of all parts of the key. Fields of a noncontiguous key must not overlap.

8600 0544–103 4–3


Disk Files

• Alternate index files can be removed or re-created without destroying records in the
data file; however, if a data file is opened for processing after an alternate index file
was removed, the system waits until an alternate index file with the same title
becomes available. If this occurs, the program must be ended and
SYSTEM/KEYEDIOII/UTILITY must be run to re-create the alternate index file. Then
the program is run again.
• When a file is updated, the keys in all associated alternate index files are also
updated. For example, suppose that a program reads a record and changes a field in
it. When the record is written back to the data file, all associated alternate index files
are also updated by the system. As the number of alternate index files increases,
system performance degrades.

EFS File Attributes


A file attribute describes a characteristic of a file. For example, the length of the records
in the file is an important characteristic of a file and is described by the MAXRECSIZE file
attribute.

An attribute is specified in the program and its values is assigned at compile time. The
$KEYEDIOIIOUTPUT compiler control option must be TRUE for EFS attributes to be
assigned their values.

The coding required for the EFS file attributes is described on the following pages.

ALLOCATION Attribute
The ALLOCATION attribute is required only for EFS files. The ALLOCATION attribute
must be specified when an EFS file is created. The value of this attribute describes how
many records can initially be stored in a file when it is created. For example, if the
ALLOCATION attribute of a file is 10 records, then 10 records can be stored in the file
before it becomes full, at which time the file must be extended before any additional
records can be stored.

The value for the ALLOCATION attribute is designated in the Attribute Specifications. For
example, if ALLOCATION 1000 is coded in the Attribute Specifications and a direct file is
being created, then the direct file initially contains enough disk space to hold 1000
records. The value is in units of records, not blocks. If the value is not specified, the
default value is 0. For more information on the ALLOCATION attribute, refer to the
discussion of creating disk files in this section.

DELETE-CAPABLE Attribute
The DELETE-CAPABLE attribute is valid only for EFS files. DELETE-CAPABLE is specified
TRUE by entering a D in the Delete-Capable field (column 69) of the File Specifications
when the EFS file is created. When the DELETE-CAPABLE attribute is TRUE, the
program can delete records from the file and reuse the space. The value of the DELETE-
CAPABLE attribute cannot be changed after the file has been created. The default value
of the DELETE-CAPABLE attribute is FALSE.

4–4 8600 0544–103


Disk Files

EXTEND Attribute
The EXTEND attribute is valid only for EFS files. EXTEND can be specified either when a
file is created, or after a file is created. The value of EXTEND is always described in units
of records. The value of the EXTEND attribute describes how many records of additional
space to give to a file. This additional space is called the extend area. For example, if a
file has an EXTEND value of 5, space is made for five additional records each time the file
needs to be extended. An EXTEND value of 0 indicates that the file cannot be extended.
The default value of EXTEND is 0. EXTEND is examined by the system each time the file
is opened. If a value for EXTEND is not specified when a file is opened, a value of 0 is
assumed.

The value for the EXTEND attribute is designated in the Attribute Specifications. For
example, if EXTEND 100 is coded in the Attribute Specifications, room for 100 additional
records is added. For more information on the EXTEND attribute, refer to the discussion
of creating disk files in this section.

Example
Example 4–1 shows how an EFS direct file DIRDISK is created with an ALLOCATION
attribute of 10 records and an EXTEND attribute area of 5 records.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
01000$SET KEYEDIOIIOUTPUT
01500F*
02000F* The compiler control option $KEYEDIOIIOUTPUT must be TRUE to
03000F* create an EFS file.
03500F*
04000FDIRDISK OC 400 80R DISK
05000A*
06000A* The Attribute Specifications for a file must immediately
07000A* follow its File Specifications. The following two Attribute
08000A* Specifications indicate that DIRDISK will have an EXTEND
09000A* area of 5 and an ALLOCATION of 10. A value must be specified
09500A* for ALLOCATION when an EFS disk file is created.
10000A*
11000A ALLOCATION 10
12000A EXTEND 5
13000F*
14000FINPUT IPE 80 80 DISK
15000IINPUT AA 01
16000I 1 50DIRKEY
17000I 1 70 DATA
18000C DIRKEY CHAINDIRDISK 99
19000ODIRDISK D 01
20000O DATA 70

Example 4–1. Specifying ALLOCATION and EXTEND Attributes with RPG

8600 0544–103 4–5


Disk Files

RECORDLEVELLOCK File Attribute


When a record is locked, no other programs with update access to the file can access
the record. Record-level locking is controlled by the RECORDLEVELLOCK file attribute.
RECORDLEVELLOCK is a permanent attribute of a file. This means that the value of
RECORDLEVELLOCK cannot be modified after a file has been created. By default,
RECORDLEVELLOCK is TRUE on EFS files and FALSE on BFS indexed files (and not
allowed for BFS sequential and direct files). If RECORDLEVELLOCK is TRUE when the
file is created, record-level locking turns on. Attribute Specifications are used to give a
value of TRUE or FALSE to the RECORDLEVELLOCK attribute to override the default
settings. If record-level locking is not desired on an EFS file, the RECORDLEVELLOCK
attribute should be specified as FALSE for the file in the program that creates the file.

A program releases a locked record if at least one of the following is true:

• The program updates the record.


• The program deletes the record from the file.
• The program reads another record.
• The program performs an I/O operation on the file that results in an error.
• The program adds a new record to the file.
• The program ends or closes the file.
• The program performs a free operation. A free operation is an output with no field
descriptions. Additional information on this operation is provided in the discussion of
freeing locked records.

Disk File Organization


File organization determines how records are ordered in a file. Disk files can be organized
as sequential, direct, or indexed files.

The organization of a disk file is specified by RPG syntax when the file is created. It is
important to consider the organization of a file before writing a program to read or modify
the file.

Sequential Organization
Records in sequential files are organized chronologically according to the order in which
each record is placed in the file. For example, the first record written to the file is placed
in the first record position, the second record written to the file is placed in the second
record position, and so on.

Records in sequential files can be accessed sequentially, randomly, or both randomly and
sequentially. Refer to the discussion of disk file processing in this section for more
information.

4–6 8600 0544–103


Disk Files

A sequential file is best suited for an application that processes a file in order, from
beginning to end. Figure 4–2 illustrates the organization of a sequential file.

Figure 4–2. Sequential File Organization

8600 0544–103 4–7


Disk Files

There are differences between BFS and EFS sequential files in terms of the location of
added records. Following is a summary of those differences:

• BFS sequential files


Records added to BFS sequential files are always placed at the end of the file. After
adding records, a program must close and reopen the file before it can consecutively
read the added records.
• EFS sequential files
Records added to EFS sequential files are usually placed at the end of the file.
However, records can also be inserted between records of an EFS sequential file if
the file is delete-capable and records have been deleted. For more information, refer
to “Adding Records to Files” in this section. A program can read the added records
consecutively without closing and reopening the file.

Direct Organization
Files that have a direct organization are called direct files. In a direct file, records are
assigned specific record positions, regardless of the chronological order in which they are
placed in the file. Relative record numbers specify the position of each record in the file in
relation to the beginning of the file as shown in the following figure.

Records in direct files can be accessed sequentially, randomly, or both randomly and
sequentially. For more information, refer to “Disk File Processing” in this section.
Figure 4–3 illustrates the organization of a direct file.

Figure 4–3. Direct File Organization

Direct files are useful for applications in which unordered transactions are processed and
an immediate inquiry capability is required.

4–8 8600 0544–103


Disk Files

There are differences between BFS and EFS direct files in terms of record processing.
Following is a summary of those differences:

• BFS direct files


Records are written randomly by relative record number to positions in the file. Thus,
some spaces in the file might not contain valid data. For example, if a program
creates a direct file with records in positions 1, 3, and 5, then positions 2 and 4
contain invalid data.
Records are added at the end of the file. Added records can be read randomly by
relative record number; however, added records cannot be read sequentially until the
file is closed and then reopened.
• EFS direct files
When an EFS direct file is created, the system initializes the record space allocated
to the file to one of the following two values:
− If the value of the DELETE-CAPABLE attribute is TRUE, the records allocated to
the file are marked as deleted.
− If the value of the DELETE-CAPABLE attribute is FALSE, the records are
initialized to blanks.
The ALLOCATION attribute designates the initial number of blank or deleted records
in the file. For more information, refer to the discussions of creating disk files, and
the ALLOCATION and DELETE-CAPABLE attributes in this section.
Records can be added between records of an EFS direct file if the file is delete-
capable. Records also can be added at the end of the file, and read either randomly
or sequentially in the same cycle. For more information, refer to the discussion of
adding records to a disk file in this section.

Indexed Organization
It is important to understand the structure of indexed files before using them. Note that
an indexed file is composed of the following two files:

• The data file


• The key file containing the indexes to data records
When an indexed file is created, a field in each record of the data file is defined as the
key field. This key field is used to build the key file. The key that is defined when the file
is created is called the primary key.

The key fields are sorted so that they are in ascending order. The key fields in the records
are described when the indexed file is declared. Refer to the discussion of the Record-
Address Field Length field (columns 29–30) and the Key Field Starting Location
(columns 35–38) field in Section 8, “File Description Specifications,” for more
information.

8600 0544–103 4–9


Disk Files

An indexed file can be loaded in

• Ascending key sequence


The data records used to load the indexed file must already be in ascending order by
primary key.
• Unordered sequence
The data records used to load the indexed file do not need to be in ascending primary
key field order.
Refer to the discussion of the File Addition/Unordered field (column 66) in Section 8, “File
Description Specifications,” for more information.

The primary key in a record cannot be modified. If alternate keys exist, they can be
changed, except when the file is processed by addrout. If an invalid key modification
occurs, an ATTEMPT TO MODIFY A PRIMARY KEY WITH A REWRITE error message is
displayed. Refer to Appendix A, “System Messages,” for an explanation of the error.

Once an indexed file is created, none of the attributes of the key can be changed when
the file is subsequently accessed. At run time, coded key information is checked. If it is
not correct, a run-time RECORD KEY MISMATCH error message is displayed. Refer to
Appendix A, “System Messages,” for information about the error.

The advantage of an indexed file is that the indexes enable the program to locate data
records quickly by key without searching sequentially through the file. Indexed files also
make it possible to retrieve records either randomly or within specified ranges.

BFS and EFS indexed files have the following different requirements for specifying
alternate keys and group keys. A group key is composed of multiple, noncontiguous key
fields. The key fields are concatenated to form a key for accessing files. Duplicate
primary keys cannot be used for BFS and EFS indexed files.

• BFS indexed files


A key description is required for each alternate index file that is created. Group keys
are not allowed.
• EFS indexed files
Only the primary key is described with a key description. Group keys are allowed.

4–10 8600 0544–103


Disk Files

Disk File Processing


The following discussion of typical disk file processing includes

• Creating disk files


• Processing disk files
• Adding and deleting records
• Freeing locked records

Creating Disk Files


RPG programs can create sequential, direct, and indexed disk files. Consider the
following questions when creating a disk file:

• Will the file be a sequential, direct, or indexed file?


• Will the file be created as an EFS file or a BFS file?
• If the file is an EFS file, will it be delete-capable?
• If the file is an EFS file, how many records will it contain? That is, what is the
ALLOCATION attribute for the file?
• What is the desired record length?
For more information about these considerations, refer to the discussion of file systems
in this section.

The File Specifications must contain the following information for a disk file to be
created:

• The File Type field (column 15) must contain the letter O to indicate that records are
to be written to the file.
• The Block Length and Record Length fields (columns 20–27) are used to specify the
number of characters contained in each record and block of the file. After a file has
been created, its record length cannot be changed.
Records are grouped together on disk in entities called blocks. Grouping records this way
makes the system run faster by reducing I/O operations. The Block Length field
(columns 20–23) must be a multiple of the Record Length field (columns 24–27). For
example, if the record length is 80 characters, an acceptable block length is 640
characters (because 80 * 8 = 640). In general, when a file is processed consecutively, the
execution time improves as the block length increases. If the Block Length field is not
specified, the system chooses a block length.

8600 0544–103 4–11


Disk Files

For EFS files only, the file attributes described in the following list are specified when the
file is created:

• The ALLOCATION attribute designates the number of records that are stored in the
file when the file is full. For example, if ALLOCATION is 10, then 10 records can be
stored in the file before it becomes full. This attribute must be specified.
• The EXTEND attribute identifies the number of additional records to assign to a file if
the file is extended when it becomes full. For example, if EXTEND is 2, space for two
records is added to the end of the file each time it becomes full.
• The DELETE-CAPABLE attribute, when specified, enables records to be deleted from
a file.
The RECORDLEVELLOCK attribute is allowed for all EFS files and BFS indexed files.
Refer to “Freeing Locked Records” later in this section.

The following pages show many examples of creating BFS and EFS sequential, direct,
and indexed files.

Creating BFS Sequential Disk Files


For a sequential file to be created, the following entries are required in the File
Specifications:

• The File Type field (column 15) must contain the letter O.
• The File Designation field (column 16) and the File Organization Type field
(column 32) must be blank.
• The Record Length field (columns 24–27) must indicate how long each record will be
in the new file.
• The Device field (columns 40–46) must contain DISK.

4–12 8600 0544–103


Disk Files

Example
Example 4–2 shows the creation of a BFS sequential file called SEQ. The records in SEQ
are 80 characters long. Records are read from two files, NAMEFIL and ADDRFIL. Fields
are extracted from records in NAMEFIL and ADDRFIL, and combined to form SEQ.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
01000FNAMEFIL IP 540 60 DISK
02000FADDRFIL IS 160 40 DISK
02500F*
03000F* Column 15 must contain the letter O to create a sequential
04000F* file. Column 16 (File Designation) and column 32 (File
05000F* Organization) must both be blank. Columns 24-27 (Record
06000F* Length) indicate that the records of SEQ are 80 bytes long
07000F* and blocked so that each block has three records (240/80=3).
07500F*
08000FSEQ O 240 80 DISK
09000INAMEFIL NS 01
10000I 2 8 EMPNO
11000I 10 29 NAME
12000IADDRFIL NS 02
13000I 2 8 EMPNO
14000I 10 39 ADDR
14500O*
15000O* The NAME and ADDR fields are extracted from NAMEFIL and
16000O* ADDRFIL. They are used to build the output record for SEQ.
16500O*
17000OSEQ D 02
18000O EMPNO 8
19000O NAME 28
20000O ADDR 58

Example 4–2. Creating a BFS Sequential Disk File

Creating EFS Sequential Disk Files


For a sequential file to be created, the following entries are required in the File
Specifications:

• The File Type field (column 15) must contain the letter O.
• The File Designation field (column 16) and the File Organization Type field
(column 32) must be blank.
• The Record Length field (columns 24–27) must indicate how long each record will be
in the new file.
• The Device field (columns 40–46) must contain DISK.
In addition, for EFS files, a value must be provided for the ALLOCATION attribute.
Specifying values for the EXTEND and DELETE-CAPABLE attributes is optional. Values
for the ALLOCATION, EXTEND, and DELETE-CAPABLE attributes are specified
programmatically in conjunction with the $KEYEDIOIIOUTPUT compiler control option.

8600 0544–103 4–13


Disk Files

Example
Example 4–3 shows how to create an EFS sequential disk file. The $KEYEDIOIIOUTPUT
compiler control option must be TRUE, the ALLOCATION and EXTEND attributes are
assigned using Attribute Specifications, and the DELETE-CAPABLE attribute is assigned
using the Delete-Capable field (column 69) of the File Specifications.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
01000$SET KEYEDIOIIOUTPUT
01500F*
02000F* The compiler control option $KEYEDIOIIOUTPUT must be TRUE
03000F* to create an EFS disk file. To create a sequential file,
04000F* the file is declared as an output file and column 16 (File
05000F* Designation) is blank. SEQ is delete-capable as indicated by
06000F* the D in column 69 (Delete-Capable field).
07000F*
08000FSEQ O 240 60 DISK D
09000A*
10000A* The Attribute Specifications for a file must immediately
11000A* follow the File Specifications. The following two Attribute
12000A* Specifications indicate that SEQ will have an EXTEND
13000A* area of 100 records and an ALLOCATION of 1200 records.
13500A* A value for ALLOCATION is required when an EFS disk
13250A* file is created.
14000A*
15000A ALLOCATION 1200
16000A EXTEND 100
17000F*
18000FNAMEFIL IP F 540 60 DISK
19000FADDRFIL IS F 160 40 DISK

20000INAMEFIL NS 01
21000I 2 8 EMPNO
22000I 10 29 NAME
23000IADDRFIL NS 02
24000I 2 8 EMPNO
25000I 10 39 ADDR
25500O*
26000O* The NAME and ADDR fields are extracted from NAMEFIL and
27000O* ADDRFIL. They are used to build the output record for SEQ.
27500O*
28000OSEQ D 02
29000O EMPNO 8
30000O NAME 28
31000O ADDR 58

Example 4–3. Creating an EFS Sequential Disk File

4–14 8600 0544–103


Disk Files

Creating BFS Direct Disk Files


For a direct file to be created, the following entries are required in the File Specifications:

• The File Type field (column 15) must contain the letter O.
• The File Designation field (column 16) must contain the letter C.
• The Processing Mode field (column 28) must contain the letter R to indicate that the
file is processed randomly by relative record number.
• The Device field (columns 40–46) must contain DISK.
When a direct file is created, the CHAIN operation code is used with a relative record
number in Factor 1 to select a record location in the file. The record is then written to that
record location as defined in the Output Specifications.

Example
Example 4–4 shows the use of the CHAIN operation to create a BFS direct file.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
01000F* When a direct file is created, the file must be defined as
02000F* an output chained file in columns 15 and 16, respectively.
03000F* Also, an R must be in the Processing Mode field (column 28).
04500F*
05000FDIRDISK OC 400 80R DISK
06000FINPUT IPE 80 80 DISK
07000IINPUT AA 01
08000I 1 50 DIRKEY
09000I 1 70 DATA

09500C*
10000C* The CHAIN operation code is used to select a record
11000C* position in the file based on the numeric value of DIRKEY.
13000C*
14000C DIRKEY CHAINDIRDISK
14500C*
15000O* The output goes to the record selected by the CHAIN.
15500O*
16000ODIRDISK D 01
17000O DATA 70

Example 4–4. Creating a BFS Direct File

8600 0544–103 4–15


Disk Files

Creating EFS Direct Disk Files


For a direct file to be created, the following entries are required in the File Specifications:

• The File Type field (column 15) must contain the letter O.
• The File Designation field (column 16) must contain the letter C.
• The Processing Mode field (column 28) must contain the letter R to indicate that the
file is processed randomly by relative record number.
• The Device field (columns 40–46) must contain DISK.
In addition, for EFS direct files, a value must also be specified for the ALLOCATION
attribute. Values for the EXTEND and DELETE-CAPABLE attributes are optional. More
information on the ALLOCATION, EXTEND, and DELETE-CAPABLE attributes is provided
in the discussion of EFS disk file attributes in this section.

When an EFS direct file is created, the number of records initially in the file is determined
by the value of the ALLOCATION attribute. If the file is delete-capable, all records are
initially marked as deleted. If the file is not delete-capable, all records are automatically
initialized to blanks.

Deleted records occupy space in the file, but they cannot be read. An attempt to use the
CHAIN operation to read a deleted record results in a Not Found condition. When a file is
read sequentially, using a cycle-driven file or the READ operation, deleted records are
skipped.

Creating Delete-Capable EFS Direct Files

Records can be deleted from a delete-capable EFS direct file. It is important to


understand that deleted records cannot be read.

Deleted records cannot be read with the CHAIN operation; instead, a relative record
number is entered in the RECNO field to indicate the position of the output record in the
file. Records can be written only to positions in the file containing deleted records.
Records can be written at exception, total, or detail output time. The RECNO field is
specified on a File Specifications continuation line. For more information on fields in
continuation lines, refer to Section 8, “File Description Specifications.”

Example
Example 4–5 shows how to use a RECNO continuation line to create an EFS direct file
that is delete-capable. The file must be specified as an output file in the File Type field
(column 15). In addition, the Processing Mode field (column 28) must contain the letter R.
The R indicates that the file is processed randomly by relative record number.
Additionally, a RECNO continuation line record must follow the File Specifications record.
This continuation line must have a K in column 53, followed by RECNO in columns 54
through 58. The RECNO identifier is placed in columns 60 through 65. This identifier
must be defined as a 7-digit numeric field with zero decimal positions. A relative record
number must be placed in this field. The system uses the value of the RECNO identifier
to determine the location to store the record in the file when the output occurs.

The compiler control option $KEYEDIOIIOUTPUT must be TRUE, and ALLOCATION,


EXTEND, and DELETE-CAPABLE attributes are specified programmatically.

4–16 8600 0544–103


Disk Files

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00400$SET KEYEDIOIIOUTPUT
00500FINFILE IP 80 80 DISK
00600F*
01000F* When a delete-capable EFS direct file is created,
02000F* the file must be defined as an output file (column 15)
03000F* that is processed randomly by relative record number
04000F* (an R in column 28). In addition, the file must have
05000F* a RECNO continuation line immediately following the main
05100F* file description.
05500F*
06000FDIRDISK O 80 80R DISK D
06500F*
07000F* The following line is a RECNO continuation line. A K in
08000F* column 53 denotes a continuation line. CUSTNO is the
09000F* RECNO identifier.
09500F*
10000F KRECNO CUSTNO
10500A ALLOCATION 1000
10800A EXTEND 200
11000IINFILE 011 98 1 C1
12000I 2 80CUSTNO
13000I 10 29 NAME
14010I 021 99 1 C2
15000I 2 39 DATA
15500O*
16000O* The record is output to the record specified by the value
17000O* of the RECNO identifier CUSTNO.
17500O*
18000ODIRDISK D 99
20000O NAME 28
21000O DATA 68

Example 4–5. Creating a Delete-Capable EFS Direct File

8600 0544–103 4–17


Disk Files

Creating Nondelete-Capable EFS Direct Files

When a direct file is created, the file must be specified in the File Specifications as
output and chained (in columns 15 and 16, respectively). In addition, an R must be in the
Processing Mode field (column 28). The R indicates that the file is processed randomly
by a relative record number.
The CHAIN operation code is used with a relative record number in Factor 1 to select the
desired record location in the file. The record is then sent to the selected location as
defined in the Output Specifications.
Example
Example 4–6 shows the creation of a direct file that is not delete-capable; that is, the
DELETE-CAPABLE attribute is FALSE. The $KEYEDIOIIOUTPUT compiler control option
must be TRUE. The ALLOCATION and EXTEND attributes are designated in the Attribute
Specifications. All records are automatically initialized to blanks because the file is not
delete-capable. When a blank record is read with the CHAIN operation, the next output
operation updates that record, as specified by the Output Specifications. If a record is not
found with the CHAIN operation, indicator 30 turns on, and no output occurs.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00300$SET KEYEDIOIIOUTPUT
00500FINFILE IP 80 80 DISK
01000F* When an EFS direct file is created, the file must be
02000F* defined as an output chained file in columns 15 and 16,
03000F* respectively. An R must be in column 28 (Processing Mode).
04500F*
06000FDIRDISK OC 80 80R DISK
06500A ALLOCATION 1000
06800A EXTEND 200
08000IINFILE 011 98 1 C1
09000I 2 80CUSTNO
10000I 10 29 NAME
11000I 021 99 1 C2
12000I 2 39 DATA
12500C*
13000C* CHAIN is used to read a record randomly by relative record
14000C* number. If a record is not found, indicator 30 turns on.
14500C*
15000C 99 CUSTNO CHAINDIRDISK 30
16100O*
16200O* If the CHAIN successfully reads a blank record, the contents
16300O* of the record are updated and written back to the file.
16400O*
17000ODIRDISK D 99N30
18000O CUSTNO 8
19000O NAME 28
20000O DATA 68

Example 4–6. Creating an EFS Direct File (Not Delete-Capable)

4–18 8600 0544–103


Disk Files

Creating BFS Indexed Files


Creating a BFS indexed file is similar to creating a sequential file except that the File
Specifications must contain a description of all the key fields for the file. The following
entries are necessary:

• The file must be an output file with a blank in the File Designation field (column 16).
• The File Organization Type field (column 32) must contain an I to indicate that the file
is an indexed file.
• All key fields must be defined when the file is created. The Key Field Starting
Location field (columns 35–38) defines the position in the record where the key field
begins.
• The Record-Address Field Length field (columns 29–30) defines the length of the key.
• The Record-Address Type field (column 31) describes whether the key is
alphanumeric or numeric.
There should be a key description for each alternate key. All alternate key descriptions
follow the main file description. For more information on describing multiple index keys
for BFS indexed files, refer to Section 8, “File Description Specifications.”

Example
Example 4–7 shows a program that reads records from a file called EMPDATA and
creates an BFS indexed file called INXDISK. The records in EMPDATA are not in primary
key order, so the File Addition/Unordered field (column 66) of INXDISK must contain a U.
Otherwise, records are written out of primary key order and a KEY OUT OF SEQUENCE
error can occur. Refer to Appendix A, “System Messages,” for more information on the
error. INXDISK contains two keys. The primary key is in packed decimal format and is
based on the CUSTNO field. The alternate key is in alphanumeric format and is based on
the ADDR field.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
01000FEMPDATA IP 80 80 DISK
02000F* When an indexed file is created, column 15 must contain the
03000F* letter O, and column 16 (File Designation) must be blank.
04000F* Note the I in column 32 (File Organization). Column 66
05000F* contains a U because the records to be written to INXDISK
06000F* are not in primary key order. Note that the key starts in
07000F* position 2 of the record, and is 7 bytes long. The P in
08000F* column 31 indicates that the key is stored in packed decimal
08250F* format. (Seven bytes packed is 14 digits.)
08500F*
09000FINXDISK O 80 80 7PI 2 DISK U
09500F*
10000F* The following line describes the alternate key. The key
11000F* starts in column 29 and is 30 positions long. The A in
12000F* column 31 indicates that the key is in alphanumeric format.
12500F*

Example 4–7. Creating a BFS Indexed File (cont.)

8600 0544–103 4–19


Disk Files

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
13000F KEY 30A 29
14000IEMPDATA 011 98 1 C1
15000I 2 150CUSTNO
16000I 16 35 NAME
17000I 021 99 1 C2
18000I 2 150CUSTNO
19000I 16 45 ADDR
20000OINXDISK D 99
21000O CUSTNO 8P
22000O NAME 28
23000O ADDR 58

Example 4–7. Creating a BFS Indexed File

Creating EFS Indexed Files


When an EFS indexed file is created, the file must be specified as an output file. The
following conditions must be true when the file is created:

• The file must be an output file with a blank in the File Designation field (column 16).
• The File Organization Type field (column 32) must contain an I to indicate that the file
is an indexed file.
• Only the primary key is defined when an EFS indexed file is created.
• The Key Field Starting Location field (columns 35–38) defines the position in the
record where the primary key field begins.
• The Record-Address Field Length field (columns 29–30) defines the length of the
primary key.
• The Record-Address Type field (column 31) describes whether the key is
alphanumeric or numeric.
• If alternate keys for the file are necessary, they must be created separately with
SYSTEM/KEYEDIOII/UTILITY.
When any kind of EFS disk file is created, the ALLOCATION attribute must be specified.
The EXTEND and DELETE-CAPABLE attributes are optional. These attributes are set
programmatically in conjunction with the $KEYEDIOIIOUTPUT compiler control option.

Unlike BFS indexed files, EFS indexed files can have group keys. Group keys must be
specified with the KEYEDIOII utility when the file is created. For more information about
creating a file that enables group keys, refer to the discussion about the Add Index
screen in the KEYEDIOII Programming Reference Manual.

4–20 8600 0544–103


Disk Files

Example
Example 4–8 shows how to create an EFS indexed file. Values for the ALLOCATION,
EXTEND, and DELETE-CAPABLE attributes are assigned at compile time. For these
attributes to be assigned at compile time, the compiler control option
$KEYEDIOIIOUTPUT must be TRUE. Values for ALLOCATION and EXTEND are assigned
in the Attribute Specifications, and the value for DELETE-CAPABLE is assigned by putting
a D in column 69 in the File Specifications for the file. The program reads records from a
file called EMPDATA. The records in EMPDATA are already in primary key order, so the
File Addition/Unordered field (column 66) is blank. The primary key of INXDISK is in
alphanumeric format and is based on the NAME field.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00100$SET KEYEDIOIIOUTPUT
00200F*
00300F* When $KEYEDIOIIOUTPUT is TRUE, all disk files
00400F* created in the program are EFS files.
00500F*
01000FEMPDATA IP 80 80 DISK
01500F*
01800F* When the indexed file called INXDISK is created, column 15
02000F* must contain the letter O, and column 16 (File Designation)
03000F* must be blank. Also, an I must be specified in column 32
04000F* (File Organization). Column 66 contains a blank because
05000F* the records being written to INXDISK are already in primary
06000F* key order. Note that the key starts in position 9 of the
07000F* record and is 20 positions long. The A in column 31 indicates
08000F* the key is stored in alphanumeric format. The D in column
09000F* 69 indicates that the file is delete-capable.
10000F*
11000FINXDISK O F 80 80 20AI 9 DISK D
12000A*
13000A* The ALLOCATION and EXTEND attributes for an EFS file follow
14000A* immediately after the File Specifications for the file.
16000A*
17000A ALLOCATION 100
18000A EXTEND 50
19000A*
20000IEMPDATA 011 98 1 C1
21000I 2 80CUSTNO
22000I 10 29 NAME
23000I 021 99 1 C2
24000I 2 80CUSTNO
25000I 10 39 ADDR
26000OINXDISK D 99
27000O CUSTNO 8
28000O NAME 28
29000O ADDR 58

Example 4–8. Creating an EFS Indexed File

8600 0544–103 4–21


Disk Files

Processing Disk Files


The way files are processed is largely independent of the type of file organization used to
create the file. The major types of file processing are

• Consecutive
• Sequential-by-key
• Sequential-within-limits
• Random (which includes processing by addrout)
• Random-by-key
It is important not to confuse the way a file is processed with the way it is organized. A
file that is organized sequentially can still be processed either randomly by relative record
number or consecutively. Likewise, a direct file can be processed consecutively or
randomly by relative record number.

In general, EFS and BFS files are processed in the same manner.

Processing Files Consecutively


Consecutive file processing reads the records of a file in the order of occurrence within
the file. Sequential files are normally processed consecutively. Direct and indexed files
also can be processed consecutively. The file can be designated in the File Specifications
as primary, secondary, demand, or full-procedural in order to be processed consecutively.
If the file is designated as demand or full-procedural, the file must be read with the READ
operation.

The data records of an indexed file can be processed consecutively. For indexed files,
consecutive processing ignores the index and accesses records in the order in which
they physically appear in the file, starting from the beginning of the file. The records are
not guaranteed to be in any particular order. To process an indexed file consecutively, the
indexed file is defined as an input file with a blank in the File Organization Type field
(column 32). The indexed file can be designated as primary, secondary, demand, or full-
procedural. Refer to the discussion of sequential-by-key file processing in this section for
information on retrieving records sequentially by key.

4–22 8600 0544–103


Disk Files

Example
Example 4–9 shows consecutive file processing. SEQDISK is a sequential file declared as
the primary file. The PLC reads the file consecutively. DIRDISK is a demand direct file
that is read consecutively with the READ operation in the Calculation Specifications. In
this example, a record read from the primary file is used to update the record read from
the demand file.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00500F* By designating SEQDISK as a primary file, the program reads
00550F* consecutively using the PLC.
00600F*
00800FSEQDISK IP 80 80 DISK
00805F*
00810F* Designating DIRDISK as a demand file causes the program to
00820F* read consecutively using the READ operation.
00850F*
00900FDIRDISK UD 80 80 DISK
01100ISEQDISK AA 01
01200I 1 50AMT1
01400IDIRDISK BB 02
01410I 2 80AMT2
01500C 01 READ DIRDISK 36
01550C*
01600C* Calculate a new value for AMT2.
01650C*
01700C 01 02 AMT1 ADD AMT2 AMT2
01750C*
01800O* Update DIRDISK with new value of AMT2.
01850O*
01900ODIRDISK D 01 02
02000O AMT2 8

Example 4–9. Processing Sequential and Direct Files Consecutively

8600 0544–103 4–23


Disk Files

Example
Example 4–10 shows an indexed file processed consecutively. The indexed file, INXDISK,
is designated as full-procedural. Records are read with the READ operation in the
Calculation Specifications. When a record is read from INXDISK, its contents are
displayed on the ODT with the file SCREEN.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00490F*
00500F* INXDISK is an indexed file treated like a sequential file. For
00510F* this to occur, column 32 must be blank. If column 32 contained
00520F* an I, the records would be retrieved sequentially by key.
00530F* Note that the rest of the primary key description is also empty.
00540F*
00800FINXDISK IF 180 60 DISK
00840F*
00850F* SCREEN displays the contents of each record on the ODT.
00860F*
00900FSCREEN D ODT
01100IINXDISK AA 01
01200I 1 60 REC1
01300C LOOP TAG
01400C READ INXDISK LR
01500C NLR REC1 DSPLYSCREEN
01600C NLR GOTO LOOP

Example 4–10. Processing an Indexed File Consecutively

4–24 8600 0544–103


Disk Files

Processing Files Sequentially by Key


Sequential-by-key file processing reads records from an indexed disk file in key
sequence. The key can be any one of the indexes specified during creation of the file, or
it can be an alternate key in an alternate index file. Records are read until all the records
in the file are processed or until the program goes to EOJ. The file must be an indexed
file designated as primary, secondary, demand, or full-procedural. If the file is designated
as demand or full-procedural, the file must be read with the READ operation. Refer to
Section 8, “File Description Specifications,” for information about file designation.

Example
Example 4–11 shows sequential-by-key file processing. INDX1 and INDX2 are both
indexed files. The letter I in the File Organization field (column 32) of the File
Specifications indicates that the files are read in key order.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00020F* INDX1 is an indexed file. It is the primary file and is
00030F* processed sequentially by key using the PLC. For an indexed
00040F* file to be processed sequentially by key, the file description
00050F* must contain a description of the key.
00060F*
00300FINDX1 IP A 80 80 6AI 1 DISK KEY1
00400F*
00500F* INDX2 is also an indexed file, but it is processed
00600F* sequentially by key using the READ operation code. The
00700F* key of the file must be described, and column 32 must
00800F* contain an I.
00900F*
00910FINDX2 UD A 132 132 5AI 1 DISK KEY2
00920IINDX1 AA 01
00930I 11 150FIELD1
00940I 16 200FIELD2
00950I 23 25 FIELD3
01000IINDX2 BB 02
01100I 11 170AMT1
01200I 20 22 NAME
01300C 01 READ INDX2 20
01500C 01 FIELD1 ADD FIELD2 TOTAL 100
01550C 01N20 NAME COMP FIELD3 03
01600C 01 03N20AMT1 ADD TOTAL TOTAL
01800OINDX2 D 01 03N20
01900O FIELD1 15
02000O FIELD2 25
02100O FIELD3 35
02200O TOTAL 45

Example 4–11. Processing an Indexed File Sequentially by Key

8600 0544–103 4–25


Disk Files

Alternate index files, like indexed files, can be processed sequentially by key.

When a file is processed using an alternate index file, the alternate index file, not the data
file, is specified in the RPG program.

Example
Example 4–12 shows an indexed file that is processed sequentially by key. The alternate
index file used is called ALTINX. The records in the indexed file contain an employee
number (EMPNO) and the name of the employee (NAME), as well as other information
that is not used. The employee name is the primary key for the indexed file.

ALTINX reads the indexed file. The indexed file itself is not specified in the program.
ALTINX contains the alternate key based on an employee number.

The File Specifications for the alternate index file are the same as for an indexed file. The
program reads from the file ALTINX. The program returns the data records of the indexed
file, in order of employee number. As the records are read sequentially by key they are
written to a printer file.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00100F* Note that the alternate index file is treated just like an
00200F* indexed file. The letter I is in column 32. The alternate
00300F* index file must have the same record size as that of the data
00400F* file. The length of the alternate key is specified in columns
00500F* 29-30, and the starting position in columns 35-38.
00550F*
00600FALTINX IF 80 80 6AI 32 DISK
00700FPRINT O 132 132 PRINTER
00800IALTINX AA 01
00900I 1 30 NAME
01000I 32 37 EMPNO
01100I 40 80 ADDR
01150C*
01160C* Because ALTINX is designated as a full-procedural file, the
01200C* READ operation is used to read ALTINX sequentially by key.
01250C*
01300C READ ALTINX LR
01400C NLR EXCPTPRINT
01500OPRINT E 01
01600O EMPNO 6
01700O NAME 37
01800O ADDR 80

Example 4–12. Processing an Alternate Index File Sequentially by Key

4–26 8600 0544–103


Disk Files

Up to three noncontiguous fields can be used as the key for an alternate index file. The
following entries in the File Specifications are required when noncontiguous fields are
used as the key for an alternate index file:

• The Record-Address Field Length field (column 29–30) must contain the total length
of all fields that define the key. For example, if the key consists of positions 1
through 6, 10 through 12, and 20 through 30 of the data record, then the total length
of the key is 20. The fields of the key must not overlap.
• The Record-Address Type field (column 31) must contain an A for an alphanumeric or
zoned-decimal key.
• The Key Field Starting Location field (columns 35–38) must contain EXTK to indicate
that a key has noncontiguous fields.
Example
Example 4–13 shows an alternate index file (ALT1) with noncontiguous keys. The code is
a modification of the example presented in Example 4–12. ALT1 uses positions 40
through 80 and positions 1 through 11 of the data record as the key.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00100F* Because ALT1 has a noncontiguous key, EXTK is designated in
00200F* columns 35-38. Column 31 must contain an A if the key is
00300F* noncontiguous. Columns 29-30 contain the total length of
00400F* the key.
00450F*
00500FALT1 IF 80 80 52AI EXTK DISK
00600FPRINT O 132 132 PRINTER
00700IALT1 AA 01
00800I 1 30 NAME
00900I 32 37 EMPNO
01000I 40 80 ADDR
01100I 1 80 REC
01150C*
01200C* Use the READ operation to read ALT1 sequentially by key.
01250C*
01300C READ ALT1 LR
01400C NLR EXCPTPRINT
01500OPRINT E 01
01600O REC 80

Example 4–13. Processing an Alternate Index File with a Noncontiguous


Key

8600 0544–103 4–27


Disk Files

Processing Files Sequentially within Limits


Sequential-within-limits file processing can be used through the following two ways:

• Limits file
• SETLL operation
It is not possible to process the same file with both methods in the same program. Only
indexed and alternate index files can be processed sequentially within limits.

Using a Limits File

A limits file is a record-address file containing limits. It can be used only to process an
indexed file or an alternate index file designated as a primary, secondary, demand, or full-
procedural file. Each record of the limits file contains a pair of key values: a lower key
limit and an upper key limit.

When a data file is processed using a limits file, the following actions occur:

• Each record is read from the limits file. The lower and upper limits are set according
to the values of the record that are read.
• All records with keys greater than, or equal to, the lower limit and less than, or equal
to, the upper limit are read from the indexed or alternate index file in ascending key
sequence.
• When the upper key limit is exceeded, the next record that contains the next set of
limits is read from the limits file and processing of the indexed or alternate index file
continues. Records are read in this way until either the limits file reaches EOF or the
program ends.
The limits file has the following format restrictions:

• Each record contains only one pair of limits.


• The record length of a limits file must be greater than, or equal to, twice the length of
the key.
• The low record key starts in position 1 of the record. The upper key limit starts
immediately after the end of the lower key limit.
• The field length for the lower and upper keys must be equal to the key length
specified for the limits file in the Record-Address Field Length field (columns 29–30)
of the File Specifications. Therefore, leading zeros might be required when numeric
keys are used.
• An alphanumeric key can contain blanks.
• The same set of limits can occur more than once in a limits file.
• The lower and upper keys can have the same value. If they do, only a record whose
key is equal to that value is read.
A limits file contains key values, not relative record numbers. If records are added to the
data file, the limits file might require modification to process the new records.

4–28 8600 0544–103


Disk Files

Example
Example 4–14 shows sequential-within-limits file processing with a limits file. An indexed
file INXDISK is processed with the limits file LIMIT.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00190F*
00200F* INXDISK is processed using a limits file. Note the
00210F* L in the Processing Mode field.
00220F*
00290FINXDISK IP 80 80L 6AI 1 DISK
00300F*
00310F* LIMIT is the limits file. Note that column 16 contains
00320F* an R indicating that the file is a record-address file.
00330F* Also, E must be specified in column 39 to indicate that
00340F* the file is described in the Extension Specifications.
00350F*
00400FLIMIT IRE 80 80 6A EDISK
00490FPRINT O 132 132 PRINTER
00500E*
00510E* The limits file is associated with the file to be processed
00520E* sequentially within limits by using Extension Specifications.
00530E*
00550E LIMIT INXDISK
00600IINXDISK AA 01
00700I 11 150FIELD1
00800I 16 200FIELD2
00900I 23 280FIELD3
01800OPRINT D 01
01900O FIELD1 15
02000O FIELD2 25
02100O FIELD3 35

Example 4–14. Processing an Indexed File with a Limits File

8600 0544–103 4–29


Disk Files

The fields listed in Table 4–1 are coding options in the File Specifications for an indexed
file or an alternate index file processed sequentially within limits.

Table 4–1. File Specifications: Indexed File or Alternate Index File

Column Field Name Entry Description


Number

7–14 Filename Name of File name.


file
15 File Type I Input file.
U Update file.
16 File Designation P Primary file.
S Secondary file.
D Demand file
F Full-procedural file.
28 Processing Mode L Processing within limits.
29–30 Record-Address Field nn Key length in bytes.
Length
31 Record-Address Type K,A,N Alphanumeric or zoned-
decimal key.
P,J Packed key.
L,R Numeric key.
32 File Organization Type I Indexed or alternate index
file.
35–38 Key Field Starting nnnn Key starting position.
Location
EXTK For an alternate index file
with noncontiguous keys.
40–46 Device DISK File must be assigned to
disk.
66 File Addition/Unordered Blank Additions and deletions
are not allowed.

4–30 8600 0544–103


Disk Files

The fields listed in Table 4–2 must be coded in the File Specifications for the limits file
used with an indexed or alternate index file.

Table 4–2. File Specifications: Limits File

Column Field Name Entry Description


Number

7–14 Filename Name of File name.


file
15 File Type I Input file.
16 File Designation R Record-address file.
20–23 Block Length Blank Unblocked records.
nnnn Block length in bytes; must be a
multiple of the Record Length field.
24–27 Record Length nnnn Record length; must be at least
twice as large as the Record-Address
Field Length field.
29–30 Record-Address nn Key length in bytes.
Field Length
31 Record-Address K,A,N Alphanumeric or zoned-decimal key.
Type
P,J Packed key.
L,R Numeric key.
39 Extension Code E A further description of the limits file
is coded in the Extension
Specifications.
40–46 Device DISK Must be disk.

The fields listed in Table 4–3 must be coded in the Extension Specifications when a limits
file is used.

Table 4–3. Extension Specifications: Limits File

Column Field Name Description


Number

11–18 From Filename The name of the limits file must be specified as it
appears in the File Specifications.
19–26 To Filename The name of the indexed or alternate index file
associated with the limits file must be specified as it
appears in the File Specifications.

8600 0544–103 4–31


Disk Files

Using the SETLL Operation

The SETLL operation can also be used to process indexed files and alternate index files
sequentially within limits. The file must be designated as demand or full-procedural. The
lower key limit is set with the SETLL operation code in the Calculation Specifications. The
highest key value in the file is automatically treated as the upper key limit. The lower limit
can be changed either before or after the upper limit is reached. When the SETLL
operation is used, a limits file cannot be used. A CHAIN operation destroys the current
lower limit.

Processing an alternate index file sequentially within limits with the SETLL operation
uses the same method as the CHAIN operation of loading the key field in Factor 1 if the
key has noncontiguous fields.

Records are read in ascending key sequence, starting from the lower limit specified by
the SETLL operation. After each SETLL operation, records are read in ascending
sequence starting at the new lower limit. If a READ operation occurs before the first
SETLL operation, the record with the lowest key is read first. The file is processed
sequentially by key until a SETLL operation occurs.

The data file is at EOF when the record with the highest key is read. If another READ
operation occurs before a SETLL operation, the condition is treated like any other EOF
condition occurring on a READ operation.

Several demand or full-procedural files can be processed by different SETLL operations in


the same program.

Example
Example 4–15 shows sequential-within-limits file processing using the SETLL operation.

4–32 8600 0544–103


Disk Files

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00240FINPUT IP 80 80 DISK
00250F*
00260F* INXDISK is an indexed file processed sequentially within
00270F* limits using the SETLL operation. Note that L is specified
00280F* in the Processing Mode field.
00290F*
00300FINXDISK ID 80 80L 6AI 1 DISK
00500FPRINT O 132 132 PRINTER
00610IINPUT AA 01
00620I 2 60AMT
00630I 10 151LOW
00700IINXDISK BB 02
00800I 11 150FIELD1
00900I 16 200FIELD2
00990I 23 280FIELD3
01000C*
01010C* SETLL sets the lower limit so that the following READ
01020C* operation reads the indexed file sequentially within limits.
01030C*
01050C 01 LOW SETLLINXDISK
01060C 01 READ INXDISK
01100C 01 02 FIELD1 ADD FIELD2 TOTAL 80
01300OPRINT D 01
01400O TOTAL 15

Example 4–15. Processing an Indexed File with the SETLL Operation Code

The fields listed in Table 4–4 must be coded in the File Specifications when the SETLL
operation code is used to process an indexed file or an alternate index file sequentially
within limits.

Table 4–4. File Specifications: SETLL Operation

Column Field Name Entry Description


Number

7–14 Filename Nam File name.


e of
file
15 File Type I Input file.
U Update file.
16 File Designation D Demand file.
F Full-procedural file.
17 End of File Blank No EOF check exists.

continued

8600 0544–103 4–33


Disk Files

Table 4–4. File Specifications: SETLL Operation (cont.)

Column Field Name Entry Description


Number

28 Processing Mode L Processing within limits.


29–30 Record-Address Field nn Key length in bytes.
Length
31 Record-Address Type K,A,N Alphanumeric key or zoned-
decimal key.
P,J Packed key.
L,R Numeric key.
32 File Organization Type I Indexed file or alternate index
file.
35–38 Key Field Starting Location nnnn Key starting position.
EXTK Alternate index file with
noncontiguous keys.
40–46 Device DISK File must be assigned to disk.
66 File Addition/Unordered Blank Additions are not allowed.
A Add records to the file.

Processing Files Randomly


Processing a file randomly means that records are selected and updated by specifying
their positions within the file. Random file processing can be used for sequential, direct,
indexed, and alternate index files. A file can be processed randomly by the use of

• Relative record numbers


• Record keys (with indexed files and alternate index files only)
• An addrout file

Using Relative Record Numbers

Relative record numbers can be used to select records in sequential, direct, and indexed
files. A relative record number identifies the position of the record in the file relative to
the beginning of the file. For example, the relative record numbers for the first, third,
seventh, and eighth records are 1, 3, 7, and 8, respectively.

The CHAIN operation code in the Calculation Specifications is used to read randomly by
relative record number. Factor 1 specifies the relative record number. Factor 2 contains
the name of the file to be read randomly. The file must be designated as chained,
demand, or full-procedural. For more information, refer to the discussion of File
Designation field (column 16) in Section 8, “File Description Specifications.”

4–34 8600 0544–103


Disk Files

Indexed files also can be processed randomly using relative record numbers. The file
must be designated as a demand, a chained, or a full-procedural file, and column 32 of
the File Specifications must be blank. Refer to the discussion of the File Organization
Type field (column 32) in Section 8, “File Description Specifications,” for more
information. If a program treats an indexed file as a nonindexed file, then the file can be
accessed by relative record numbers and all indexes are ignored.

Example
Example 4–16 shows the processing of a sequential, a direct, and an indexed file
randomly by relative record number. The primaryfile contains a list of employee numbers
that are used as relative record numbers to read the HOURS, WAGE, and YRPAY files.
MAST and YRPAY are updated with new pay totals. HOURS is a sequential file
containing the number of hours worked by an employee during the week. WAGE is a
direct file that contains the hourly wages of the employees. YRPAY is an indexed file that
contains the year-to-date pay.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00200FMAST UP 80 80 DISK
00290F*
00300F* Designate HOURS as a chained file. It is read using
00310F* the CHAIN operation.
00320F*
00390FHOURS IC 80 80 DISK
00400F*
00410F* Designate WAGE as a full-procedural file. It can be
00420F* processed randomly or consecutively.
00430F*
00450FWAGE UF 80 80 DISK
00490F*
00500F* Designate YRPAY (an indexed file) as a demand file. Like
00510F* full-procedural files, demand files can also be processed
00520F* randomly or sequentially. Note that column 32 is blank
00530F* so that the index is ignored.
00540F*
00550FYRPAY UD 80 80 DISK
00600IMAST AA 01
00700I 1 40EMPNO
00800I 10 172PAY
00815IHOURS BB 02
00820I 5 70HRS
00900IWAGE CC 03
01000I 1 62WAGE1
01010IYRPAY DD 04
01100I 10 202YRPY
01105C*
01110C* EMPNO contains the employee number that is used as a
01115C* relative record number to CHAIN to the correct record
01120C* IN HOURS, WAGE, AND YRPAY.

Example 4–16. Randomly Processing a Disk File by Relative Record Numbers


(cont.)

8600 0544–103 4–35


Disk Files

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
01130C*
01200C 01 EMPNO CHAINHOURS
01300C 01 EMPNO CHAINWAGE 99
01310C 01 EMPNO CHAINYRPAY
01400C 02 03 04HRS MULT WAGE1 PAY
01500C 02 03 04PAY ADD YRPY YRPY
01600C 02 03 04 EXCPTYRPAY
01800OMAST D 02 03 04
01900O PAY 17
02000OYRPAY E
02100O YRPY 20

Example 4–16. Randomly Processing a Disk File by Relative Record Numbers

Using Record Keys

An indexed file or an alternate index file can be processed randomly with a key value.
Each record in an indexed file has a field that is designated as the key field. Each key
identifies a record in the file, and the key can be used to access that record randomly.

For an indexed or alternate index file to be processed randomly by key, the file must be
designated as a demand, chained, or full-procedural file. The CHAIN operation code in the
Calculation Specifications is used to read randomly by key. Factor 1 contains the value of
the key. Factor 2 contains the name of the file to be read. For indexed files with multiple
keys, the Result Field (columns 43–48) of the CHAIN operation specifies the name of the
key that is used. If an indexed file has only one key, the Result Field of the CHAIN
operation does not need to be specified.

4–36 8600 0544–103


Disk Files

Example
Example 4–17 shows an indexed file, INXDISK, that is processed randomly by key. This
program reads a master file, MAST, which contains records with employee names and
numbers and verifies that the data in INXDISK is correct. Each record in INXDISK
contains an employee number, the name of the employee, and other information about
the employee. The file has two keys. The primary key is the employee number. The
alternate key is the employee name.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00300FMAST IP 240 80 DISK
00350F*
00410F* Write any discrepancies between MAST and INXDISK
00420F* to the printer file.
00430F*
00450FPRINT O 132 132 PRINTER
00470F*
00500F* Designate INXDISK (an indexed file) as a chained file.
00510F* Note that the primary key is named EMPKEY, and that the
00520F* alternate key is named NAMKEY.
00530F*
00550FINXDISK IC 80 80 4AI 1 DISK EMPKEY
00555F*
00560F* Specify the alternate key.
00570F*
00580F KEY 20A 10 NAMKEY
00600IMAST AA 01
00700I 1 40ENUM
00710I 5 24 ENAM
00720I 1 50 RECORD
00815IINXDISK BB 02
00820I 1 40EMPNO
00900I 10 29 NAME
01000C*
01110C* Use the value of ENUM to CHAIN to INXDISK using the
01120C* primary key EMPKEY.
01150C*
01200C 01 ENUM CHAININXDISK EMPKEY 20
01250C N20 NAME COMP ENAM 50
01255C*
01260C* Use the value of ENAM to CHAIN to INXDISK using the
01270C* alternate key NAMKEY.
01280C*
01300C 01 ENAM CHAININXDISK NAMKEY 21
01400C N21 EMPNO COMP ENUM 51
01500C N50N51 EXCPTPRINT
01800OPRINT E
01900O 14 '*** mismatch:'
02000O RECORD 64
02010O 81 ': is in error ***'

Example 4–17. Randomly Processing an Indexed File with Primary or


Alternate Keys

8600 0544–103 4–37


Disk Files

The CHAIN operation code is used to read an alternate index file randomly by key. If the
key has noncontiguous fields, the field in Factor 1 of the CHAIN operation must be
specified. An easy way of designating the field is to use a data structure with subfields
for each part of the noncontiguous key.
Example
Example 4–18 shows how to use data structure subfields to load a noncontiguous key
for a CHAIN operation.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00100FMASTER IP 80 80 DISK
00150F*
00200F* Because NONCONT has a noncontiguous key, EXTK is
00300F* specified in columns 35-38. Column 31 must contain an A
00400F* if the key is noncontiguous. Columns 29-30 contain the
00500F* total length of the key.
00550F*
00600FNONCONT IC 80 80 52AI EXTK DISK
00700FPRINT O 132 132 PRINTER
00800IMASTER AA 01
00900I 1 30 NAME
01000I 32 37 EMPNO
01100I 40 80 ADDR
01200INONCONT BB 02
01300I 1 80 REC
01400INAME DS
01450I*
01500I* This data structure is used to divide NAME into subfields.
01550I*
01600I 1 11 KEYNM
01700I 12 30 FILLR
01800I DS
01850I*
01900I* KEYDS is used to set up the noncontiguous key.
01950I*
02000I 1 40 ADDRS
02100I 41 52 NAM
02200I 1 52 KEYDS
02250C*
02300C* Move parts of the input record into KEYDS
02350C*
02400C 01 MOVE KEYNM NAM
02500C 01 MOVE ADDR ADDRS
02600C 01 KEYDS CHAINNONCONT 99
02700C 01N99 EXCPTPRINT
02800OPRINT E
02900O REC 80

Example 4–18. Loading a Noncontiguous Key with a CHAIN Operation

4–38 8600 0544–103


Disk Files

Using Addrout Files

Addrout files are record-address files that contain relative record numbers. SORT
programs create addrout files. An addrout file can be used to process any sequential,
direct, or indexed file.

A SORT program creates an addrout file by processing the data file with a certain key or
keys. The order of the relative record numbers in the addrout file is the same as the
record sequence based on that key. When the data file is processed as an addrout file,
records are retrieved in sequence by that key. If necessary, several addrout files can be
created based on different keys. An addrout file can thus process the data sequentially in
order of a particular key, without physically sorting the data records. For more
information on sorting records, refer to the SORT Language Programming Reference
Manual.

For example, suppose that a sequential file has three records and each record is 2
characters long. The first record contains AB, the second record contains BA, and the
third record contains CC. In addition, suppose that records must be retrieved in
alphabetic order based on the second character of each record. Record number 2 must
be retrieved first because A is the second character of this record; record 1 must be
retrieved second because B is the second character; and record 3 must be retrieved
third. The SORT program can create an addrout file that contains the numbers 2, 1, and
3. When the sequential file is processed by the addrout file, the records are retrieved by
the relative record numbers in the addrout file; that is, in alphabetic order based on the
second character of the record.

Records are read until either the addrout file reaches EOF or the program ends for some
other reason.

Update files can be processed by addrout files. If the data file is an indexed file, the key
fields specified at the time the data file was created are protected and cannot be updated
or changed.

Because an addrout file contains relative record numbers of records within a data file, the
user must ensure that the addrout file does not become outdated because of changes to
the data file.

The following are four actions that can cause a file to become outdated:

• The key within a data record is changed when the file is updated.
• Records are added to, or deleted from, the data file.
• The data file is sorted.
• The data file is an indexed sequential file and is consolidated (crunched).
If the addrout file becomes outdated, data records can no longer be retrieved in correct
key sequence. A new addrout file must be created.

8600 0544–103 4–39


Disk Files

The file processed by an addrout file can be designated as a primary, secondary,


demand, or full-procedural file. If the file is designated as demand or full-procedural, the
READ operation in the Calculation Specifications must be used.

Note: A data file can be processed in different programs by using several addrout files
based on different keys. If the value of any of these keys is changed in a data record, the
corresponding addrout file is outdated. Before modifying a key, consider whether the
data file is used by several programs and, by several different users. If an addrout file
contains a relative record number for a record that does not exist, a KEY NOT FOUND
run-time error occurs. Refer to Appendix A, “System Messages,” for the list of error
messages.

Example
Example 4–19 shows addrout file processing.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00200F* INPUT is the file being processed using an addrout file.
00210F* An R in column 28 and the letter I in column 31 indicate
00220F* that relative record numbers from an addrout file are used
00230F* to process this file.
00250F*
00300FINPUT IP 80 80R I DISK
00305F*
00310F* RADDR is the addrout file. Column 16 must contain an R.
00320F* Columns 31 and 32 must contain an I and a T, respectively. In
00330F* this example, the relative record numbers are 6 positions long.
00350F* If the addrout file is produced with the GSORT compiler control
00360F* option of SORT, the record length and key field length is 3.
00380F*
00400FRADDR IRE 132 6 6IT EDISK
00500FPRINT O 132 132 PRINTER
00600E RADDR INPUT
00700IINPUT AA 01
00800I 2 60AMT1
00900I 10 140AMT2
02200C 01 AMT1 ADD TOTAL TOTAL 90
02600C 01 TOTAL COMP AMT2 L1
02800OPRINT T L1
02900O TOTAL 15

Example 4–19. Randomly Processing a Disk File with an Addrout File

4–40 8600 0544–103


Disk Files

Processing Files Using Addrout Files


The following tables describe the File Specifications and Extension Specifications used to
process a file randomly with an addrout file.

If an alternate index file is processed with an addrout file and if the alternate index file
contains a noncontiguous key, the Key Field Starting Location field (columns 35–38) must
contain EXTK. Otherwise, processing an alternate index file with an addrout file is like
processing an index file with an addrout file.

The fields listed in Table 4–5 must be coded in the File Specifications when an addrout
file is used to randomly process a disk file.

Table 4–5. File Specifications: Addrout Processed Files

Column Field Name Entry Description


Number

7–14 Filename Name File name.


of file
15 File Type I Input file.
U Update file.
16 File Designation P Primary file.
S Secondary file.
D Demand file.
F Full-procedural file.
17 End of File Blank No EOF test for this file.
20–23 Block Length Blank Unblocked records.
nnnn Block length in bytes; must be a
multiple of the Record Length field.
24–27 Record Length nnnn Record length; must be at least as
large as the Record-Address Field
Length field.
28 Processing Mode Blank, Addrout file processing.
R
31 Record-Address I Addrout file processing.
Type
35–38 Key Field Starting nnnn Start position of the key if the file is
Location indexed.
EXTK Use if key of alternate index file is
noncontiguous.
40–46 Device DISK File must be assigned to disk.
66 File Blank Additions are not allowed.
Addition/Unordered

8600 0544–103 4–41


Disk Files

The fields listed in Table 4–6 must be coded in the File Specifications for an addrout file.

Table 4–6. File Specifications: Addrout File

Column Field Name Entry Description


Number

7–14 Filename Name File name.


of file
15 File Type I Input file.
16 File Designation R Record-address file.
20–23 Block Length Blank Unblocked records.
nnnn Block length in bytes; must be a
multiple of the Record Length field.
24–27 Record Length 3 Record length in bytes (GSORT).
6 Record length in bytes (Sort).
29–30 Record-Address 3 Record key length in bytes (GSORT).
Field Length
6 Record key length in bytes (Sort).
31 Record-Address I Addrout file.
Type
32 File Organization T Addrout file.
Type
39 Extension Code E A further description of the addrout
file is coded in the Extension
Specifications.
40–46 Device DISK, Addrout file must be assigned to disk
TAPE or tape.
71–72 File Condition Blank External indicators are not allowed
with addrout files.

The fields listed in Table 4–7 must be coded in the Extension Specifications for a disk file
processed by an addrout file.

Table 4–7. Extension Specifications: Addrout File

Column Field Name Description


Number

11-18 From The name of the addrout file must be stated as it


Filename appears in the File Specifications.
19–26 To Filename The name of the disk file associated with the addrout file
must be stated as it appears in the File Specifications.

4–42 8600 0544–103


Disk Files

Adding Records to Files


It is important to answer the following questions to write a program that adds records to
a file:

• Is the file either an EFS sequential file or an EFS direct file (rather than a BFS
sequential file or a BFS direct file)?
• If so, was the file created as a delete-capable file?
If the file is an EFS sequential or direct file that is delete-capable, then records can be
added between other records or at the end of the file. If the file is a BFS sequential or
direct file or an EFS sequential or direct file that is not delete-capable, then records can
be added only at the end of the file.

Adding Records to the End of a Sequential or Direct File (BFS)


When records are added to a BFS sequential or direct file, the records are always added
at the end of the file (and the EOF pointer is incremented by 1 for each record added).
The file type can be declared as an input, update, or output file. The file can be
designated as a primary, secondary, demand, chained, or full-procedural file. If the file
type is output, the File Designation field must be blank.

The File Addition field (column 66) in the File Specifications must contain an A or B to
specify that records are to be added to the file. In addition, the Record Addition/Deletion
field (columns 16–18) in the Output Specifications must contain ADD to indicate addition
to the file.

If the file is designated as a demand or full-procedural file, a READ operation cannot read
the added records. The READ operation encounters the original EOF if an attempt is
made to read the added records. However, the added records can be read with the
CHAIN operation.

Example
Example 4–20 shows one method of adding records to the end of a BFS sequential or
direct file.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
02000FINFILE IP 80 80 DISK
02500F*
03000F* To add records, the File Specifications must have an A or B in
03500F* column 66.
03700F*
04000FDSKFILE UC 80 80 DISK A

Example 4–20. Adding Records to BFS Sequential or Direct Files (cont.)

8600 0544–103 4–43


Disk Files

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
10000IINFILE NS 20
10010I 2 7 CUSTNO
10020I 10 29 DATA
17000IDSKFILE NS 30
17010I 2 7 CUSTNO
17020I 10 39 NAME
17030I 40 59 DATA
17500O*
18000O* The Output Specifications must contain an ADD in columns 16-18
18100O* in order to add records.
19000O*
20000ODSKFILE DADD 20
21000O CUSTNO 7
22000O NAME 39
26000O DATA 59

Example 4–20. Adding Records to BFS Sequential or Direct Files

Adding Records to the End of a Sequential File (EFS)


For records to be added to the end of an EFS sequential file, the file must be declared to
be an output file with addition (A or B in column 66). The File Designation field
(column 16) of the File Specifications must be blank. The Output Specifications must
contain ADD in the Record Addition/Deletion field (columns 16–18). This method of
adding records does not succeed if the file is an EFS direct file. Information on adding
records to an EFS direct file is provided later in this section.

Example
Example 4–21 shows how records are added to the end of an EFS sequential file.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
01000$SET KEYIOIIOUTPUT
02000FINFILE IP 80 80 DISK
02500F*
03000F* Note that column 16 (File Designation) must be blank and
03250F* column 66 contains an A.
03500F*
04000FSEQDISK O F 80 80 DISK A
05000A EXTEND 50
12000IINFILE 011 98 1 C1
14000I 2 7 CUSTNO
16000I 10 39 NAME
16010I 021 99 1 C2

Example 4–21. Adding Records to the End of an EFS Sequential File (cont.)

4–44 8600 0544–103


Disk Files

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
17000I 2 7 CUSTNO
17010I 10 29 DATA
17500O*
18000O* The Output Specifications must contain an ADD in columns 16-18
18100O* in order to add records.
18500O*
20000OSEQDISK DADD 99
21000O CUSTNO 7
22000O NAME 39
26000O DATA 59

Example 4–21. Adding Records to the End of an EFS Sequential File

Adding Records between Records in Sequential Files (EFS)


Records can be added between records in an EFS sequential file if the file was created
as delete-capable and records have been deleted from the file. Records are added in the
spaces containing deleted records. In this sense, records are added between existing
records in a file.

It is important to remember the following about delete-capable files:

• Deleted records cannot be read. A READ operation skips over deleted records until it
reaches EOF or finds a valid record (one that is not deleted). A CHAIN operation to a
deleted record returns a KEY NOT FOUND error message if no resulting indicator is
specified. If a resulting indicator is specified, the indicator is turned on.
• If an attempt is made to add a record to a record position that currently contains a
valid record, an ADD TO NON-DELETED RECORD error message occurs.
A continuation line record must be used to write a program that adds records between
existing records of an EFS sequential file. The continuation line is part of the File
Specifications for the file to which records are added.

The following entries for a continuation line must be entered on the File Specifications
immediately following the file definition:

• Column 53 must contain a K.


• Columns 54 through 58 must contain RECNO.
• Columns 60 through 65 contain the RECNO identifier. This identifier must be defined
as a 7-digit numeric field with no decimal positions. This field has a relative record
number placed in it before the record is written to a selected location defined in the
Output Specifications.
The syntax for a continuation line is valid only if the $KEYEDIOIIOUTPUT compiler control
option is TRUE. For more information on the syntax of continuation lines, refer to
Section 8, “File Description Specifications.”

The RECNO field contains the relative record number of the position in the file to which
the record is to be added. The RECNO identifier must contain the relative record number
of a record that is currently deleted. A record can be added between records only if the

8600 0544–103 4–45


Disk Files

relative record number contains a deleted record number. An error occurs if the record
position in the file contains a record that was not deleted.
To construct a program that adds records between records of a sequential file, the file
must be processed randomly (chained or full-procedural), and the continuation line syntax
must be used. The file must be declared as an input or update file with addition (an A or
B in column 66 of the File Specifications).
Example
Example 4–22 shows the RECNO field with a chained update file. The program attempts
to read a record with the CHAIN operation. If the record was deleted, the resulting
indicator is turned on. The next line is conditioned by the resulting indicator of the CHAIN
operation. The program places into the RECNO field the relative record number of the
failed CHAIN operation. When the program tries to write the record, it uses the relative
record number in the RECNO field to identify the relative position in the file to place the
record.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
01000$SET KEYEDIOIIOUTPUT
01050F*
01100F* For the continuation line syntax to be used, the
01200F* $KEYEDIOIIOUTPUT compiler control option must be TRUE.
01250F*
01500FINPUT IP 40 40 DISK
02000FSEQDISK UC 40 40 DISK A
02200F*
02500F* The following record is the continuation line.
02600F* The K in column 53 specifies a continuation line.
02700F*
03000F KRECNO RRN
10000IINPUT NS 01
10100I 2 70CUSTNO
10200I 8 37 REC
12000ISEQDISK NS 02
14000I 2 70NUM
16000I 10 39 RECORD
17000C 01 CUSTNO CHAINSEQDISK 20
17200C*
17500C* The following record defines the RECNO field RRN
17600C* and also places the relative record number of the
17700C* failed chain in RRN.
17750C*
18000C 01 20 Z-ADDCUSTNO RRN 70
20000O* The Output Specifications must contain ADD in
20100O* columns 16-18 in order to add records.
21000O*
22100OSEQDISK DADD 01 20
22200O CUSTNO 7
22300O REC 39

Example 4–22. Adding Records to Sequential Files by Relative Record


Number

4–46 8600 0544–103


Disk Files

Adding Records to Direct Files (EFS)


Records can be added to an EFS direct file only if the file was specified as delete-capable
when it was created. Records are added to the spaces occupied by deleted records. An
attempt to add a record in a space where a record already exists causes an ADD TO
NON-DELETED RECORD error message. Also, an attempt to read a record randomly or
add a record that is beyond the extend area of a direct file results in a BEYOND EXTEND
AREA error message.

A program that adds records to a direct file should process an input or update file
randomly (chained, demand, or full-procedural). Because deleted records cannot be read,
a continuation line must follow the File Specifications of the file to which records are to
be added. The continuation line contains a K in column 53, RECNO in columns 54 through
58, and a 7-digit numeric field with no decimal positions in columns 60 through 65. The
RECNO field must contain the relative record number where the output record is to be
added. The syntax for a continuation line is valid only if the $KEYEDIOIIOUTPUT compiler
control option is TRUE. For more information on the syntax of continuation lines, refer to
Section 8, “File Description Specifications.”

Example
Example 4–23 shows the use of the RECNO field with a chained update EFS direct file.
The program reads the file NEWFL that contains customer numbers and data, and uses
the customer number to read a record with the CHAIN operation to the master customer
file CSTMAST. If the CHAIN operation is successful, the record is updated with
information in the NEWFL file. If the CHAIN operation is not successful (in other words, if
the CHAIN operation tried to read a deleted record), the customer number is placed into
the RECNO field, and the primary customer file record is added to the master customer
file (CSTMAST).

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
01000$SET KEYEDIOIIOUTPUT
01050F*
01100F* For the continuation line syntax to be used, the
01200F* $KEYEDIOIIOUTPUT compiler control option must be TRUE.
01300F*
01500FNEWFL IP 80 80 DISK
02000FCSTMAST UC 80 80 DISK A
02300F*
02500F* The following record is the continuation line.
02700F*
03000F KRECNO RRN
10000INEWFL NS 01
10100I 2 70RECNUM
10200I 8 77 RECDAT
12000ICSTMAST NS 02

Example 4–23. Adding Records to Direct Files by Relative Record Number


(cont.)

8600 0544–103 4–47


Disk Files

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
14000I 2 70CUSTNO
16000I 8 77 DATA
17000C 01 RECNUM CHAINCSTMAST 10
17300C*
17500C* The following record defines the RECNO identifier RRN
17600C* and places the relative record number of the failed
17700C* CHAIN operation in RRN.
17800C*
18000C 01 10 Z-ADDRECNUM RRN 70
19000C 01 10 EXCPTCSTMAST
19500C*
20000O* The Output Specifications must contain an ADD in
20100O* columns 16-18 in order to add records.
20150O*
22100OCSTMAST EADD
22200O RECNUM 7
22300O RECDAT 77
23000OCSTMAST D 01 02N10
23100O RECNUM 7
23200O RECDAT 77

Example 4–23. Adding Records to Direct Files by Relative Record Number

Adding Records to Indexed Files


When records are added to an indexed file, the data portion of the record is inserted into
the data file, and the primary and alternate keys (if any exist) are inserted by key order
into their respective key files.

Duplicate keys can exist for indexed files. Duplicate keys are keys that contain the same
value. For example, if two keys contain a key value of A and there are records AB and
AC, the first key might point to AB (the first record) and the second key to AC (the
second record).

A program written to add records to an indexed file might have to handle duplicate key
errors if duplicate keys are not allowed in the key files. A DUPLICATE KEY error message
is displayed if an attempt is made to write a record with a duplicate key value to an
indexed file.

4–48 8600 0544–103


Disk Files

Adding Records without Checking for Duplicate Keys

There are no duplicate keys, records can be added without checking for duplicates.

Example

Example 4–24 shows how to add records to a file when there is no need to check
for duplicate keys. The file is specified as an output file with addition (an A
or B in column 66 of the File Specifications for the file). Because the file is
indexed, the File Organization field must contain the letter I, and a primary
key must be described. If the indexed file has alternate keys, descriptions of
the alternate keys are not required in the program. For a record to be added,
ADD is entered in the Record Addition/Deletion field (columns 16–18) of the
Output Specifications record description.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
01000FINPUT IP F 80 80 DISK
01500F*
02000F* Records are added to INXDISK without checking for duplicate
03000F* keys. The file is declared as an output file with addition
04000F* (an A in column 66). Note that the primary key must be
05000F* described. INXDISK has a primary key that starts in
06000F* position 2 of the record and is 7 characters long.
06500F*
07000FINXDISK O 80 80 7AI 2 DISK A
08000IINPUT NS 20
09000I 2 60 RECORD
09500O*
10000O* In order for records to be added, ADD must be specified in
11000O* columns 16-18 of the Output Specifications record description.
11500O*
12000OINXDISK DADD 20
13000O RECORD 60

Example 4–24. Adding Records without Checking for Duplicate Keys

Adding Records and Checking for Duplicate Keys

If duplicate keys are not allowed, it is a good idea to check for them before adding
records. To check for duplicate keys, the program reads records from the indexed file
and then checks to see if the key field in the record just read matches the key field of the
record to be added. If the key fields match, a duplicate record exists.

8600 0544–103 4–49


Disk Files

Example
Example 4–25 checks for duplicate keys. The program uses the key field of the record to
read randomly by key with the CHAIN operation. If the CHAIN operation is successful, a
record with the given key already exists in the file. If the CHAIN operation fails, records
can be added safely without causing a DUPLICATE KEY error.

The file is specified as an update file and designated as full-procedural. In addition, an A is


specified in the File Specifications. ADD is entered in the Record Addition/Deletion field
(columns 16–18) of the Output Specifications record description. The CHAIN operation is
used to read a record in the file and to condition the record addition on the resulting
indicator of the CHAIN operation.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
01000F* INPUT contains the records to be added to INXDISK.
02000F* CUSTNO is the field of the INPUT record that contains the
03000F* key value for INXDISK.
03500F*
04000FINPUT IP 80 80 DISK
04500F*
05000F* Records are added to the indexed file INXDISK. Note that
06000F* INXDISK is an update file designated as full-procedural.
06500F*
07000FINXDISK UF 80 80 7AI 2 DISK A
08000FERROR O 132 132 PRINTER
09000IINPUT NS 01
10000I 1 70CUSTNO
11000I 8 37 INREC
12000IINXDISK NS 02
13000I 2 80NUM
14000I 10 39 RECORD
14500C*
15000C* CHAIN to a record using the key field of the record to
16000C* be added. The record addition is conditioned on the result
17000C* of the CHAIN. If the record to be added causes a DUPLICATE
18000C* KEY error, it is written to a printer file. If the addition
19000C* does not cause an error, the record is added to INXDISK.
20500C*
21000C 01 CUSTNO CHAININXDISK 99
22000C 01 EXCPT
23000OINXDISK EADD 99
24000O CUSTNO 8
25000O INREC 39
26000OERROR E N99
27000O 15 'Duplicate Key:'
28000O CUSTNO 25

Example 4–25. Adding Records and Checking for Duplicate Keys

4–50 8600 0544–103


Disk Files

Deleting Records from Files


The way in which records are deleted from a file depends on whether the file is an EFS
or BFS file. Records deleted from BFS sequential and direct files are filled with blanks
and can still be read. Records deleted from EFS sequential and direct files cannot be
read. Deleted records from BFS or EFS indexed files cannot be read.

Deleting Records from Sequential or Direct Files (BFS)


If a sequential file or a direct file is a BFS file, records cannot really be deleted from the
file. Instead, a record is filled with blanks and then it is written to the file. If an attempt is
made to read the deleted record from the file, a blank record is returned.

For records to be deleted from a BFS sequential or direct file, the file must be declared in
the program as an input or update file with a blank, D, or B in the File Addition/Unordered
field (column 66) of the File Specifications; also the DEL entry must be coded in the
Record Addition/Deletion field (columns 16–18) of the Output Specifications. Coding the
DEL entry in the Output Specifications fills the current record in the file with blanks.

The DELET operation code cannot be used to delete records from a sequential or direct
file. It is used for indexed files only.

Example
Example 4–26 shows the use of the DEL entry in the Output Specifications to delete a
record from the direct file CSTMAST.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
01000FINFILE IP F 180 10 DISK
02000FCSTMAST UC F 80 80 DISK
10000IINFILE NS 01
10100I 3 100RECNUM
12000ICSTMAST NS 02
14000I 2 70CUSTNO
16000I 8 77 DATA
17000C 01 RECNUM CHAINCSTMAST 99
18000OCSTMAST DDEL N99

Example 4–26. Using the DEL Entry to Delete Records from a BFS Direct
File

8600 0544–103 4–51


Disk Files

Deleting Records from Sequential or Direct Files (EFS)


For records to be deleted from a sequential or direct file, the file must be an EFS file and
it must be delete-capable. Records cannot be deleted from a BFS file or an EFS file that
is not delete-capable. A file is delete-capable if the Delete-Capable field (column 69) in the
File Specifications contained a D when the file is created.

Records are deleted from a file in the sense that deleted records cannot be read. A READ
operation skips over deleted records until it encounters EOF or finds a valid (nondeleted)
record. A CHAIN operation returns a KEY NOT FOUND error message if the record in the
file is deleted. If a program attempts to delete a record from a file that is not delete-
capable, an error occurs. If a program attempts to delete a record from a BFS sequential
or direct file, unexpected results can occur. At best, a record filled with blanks is
returned. A discussion of this process is provided in the description of deleting records
from BFS sequential and direct files earlier in this section.

For a record to be deleted from an EFS sequential or direct file, the DEL entry must be
added in the Record-Addition/Deletion field (columns 16–18) of the Output Specifications.
(The DELET operation code is allowed with indexed files only.) Coding the DEL entry in
the Output Specifications deletes the current record in the file.

Example
Example 4–27 shows the use of the PLC to read records sequentially. Then, records are
deleted by using the DEL entry on the output record.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
01000FSEQDISK IP F 80 80 DISK
02000ISEQDISK NS 02
02100I 1 80 DATA
02900O*
02910O* Note that the DEL entry is specified in columns 16-18.
02920O* Records are read consecutively using the PLC. This
029300* program deletes every record in SEQDISK.
02940O*
03000OSEQDISK DDEL 02

Example 4–27. Deleting Records from an EFS Sequential or Direct File

4–52 8600 0544–103


Disk Files

Deleting Records from Indexed Files (BFS and EFS)


Records can be deleted from an indexed file. Once a record is deleted, neither a CHAIN
operation nor a READ operation can retrieve it.

The following are two methods of deleting records from an indexed file:

• The use of the DELET operation code in the Calculation Specifications


• By using the DEL entry in the Output Specifications
For either method to be used, the file must be declared in the program as an input
indexed or update indexed file. If the file is an EFS indexed file, it must be created as a
delete-capable file.

The DELET operation code takes as input the key of the record to be deleted. If no key is
given (that is, no Factor 1 exists), then the current record is deleted.

The DEL entry on the Output Specifications deletes the current record in the file. The
DEL entry requires that the input record is read sequentially by key or randomly by key.
After the record is read, the subsequent update deletes the record.

Example
Examples 4–28 and 4–29 have the same function, but use different methods to delete
the record that was read.

Example 4–28 randomly reads records in an indexed file with the CHAIN operation. The
CHAIN operation uses keys that are read from the primary file. The program then deletes
the record that was read by using the DEL entry on the Output Specifications.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
02000FINPUT IP 80 80 DISK
04000FINXDISK UC 80 80 6AI 2 DISK
05000IINPUT NS 01
05100I 2 7 NAME
05200I 10 80 RECORD
07000IINXDISK NS 02
07100I 1 80 DATA
08000C 01 NAME CHAININXDISK 20
09000OINXDISK DDEL N20

Example 4–28. Using the DEL Entry to Delete Records from an Indexed
File

8600 0544–103 4–53


Disk Files

Example 4–29 reads records in an indexed file with the CHAIN operation. The CHAIN
operation uses keys that are read from the primary file. Then the program deletes the
record that was read by using the DELET operation code.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
02000FINPUT IP 80 80 DISK
04000FINXDISK IC 80 80 6AI 2 DISK
05000IINPUT NS 01
05100I 2 7 NAME
05200I 10 80 RECORD
07000IINXDISK NS 02
07100I 1 80 DATA
08000C 01 NAME DELETINXDISK 20

Example 4–29. Using the DELET Operation Code to Delete Records


from an Indexed File

Freeing Locked Records


When a record is locked, no other program can access the record. Record-level locking is
supported on all EFS disk files as well as on BFS indexed files.

Performing a free operation unlocks a locked record. The free operation can be
performed with Output Specifications that have no field description.

Example
Example 4–30, the program reads and then frees records in the ORDMAST file. Because
there can be concurrent executions of this program (using different TRANS files), a
record should not be held while the result of the transaction is being printed. If a record is
held, other programs wanting access to the same record have to wait.

4–54 8600 0544–103


Disk Files

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
01000FTRANS IP F 80 80 DISK
02000FORDMAST UF F 80 80 10AI 1 DISK
03000FTRANLISTO 132 PRINTER
04000I*
05000I* If the first character of the record is U, update the
06000I* ORDMAST file.
07000I*
08000ITRANS 011 99 1 CU
09000I 2 110ICSTNO
10000I 12 160IQTY
11000IORDMAST NS 02
12000I 1 100CUSTNO
13000I 11 150QTY
14000I 16 200ORD#
15000C ICSTNO CHAINORDMAST 20
16000C 99N20 IQTY ADD QTY QTY
16500C*
17000C* The TRANLIST record is freed so other programs are not
18000C* denied access to the record while the result of the
19000C* transaction is printed.
19500C*
20000C* N20 EXCPTFREE
21000C EXCPTTRANLIST
21500O*
22000O* The free operation occurs here (output with no field
22300O* descriptions).
22500O*
23000OORDMAST E N20 FREE
24000O*
25000OTRANLISTE 20 ERROR
26000O ICSTNO 12
27000O 38 'ERROR: NO MATCH'
28000OTRANLISTE 99
29000O CUSTNO 10
30000O QTY 20
31000O ORD# 30

Example 4–30. Releasing Locked Records by Performing a Free Operation

Other methods exist to unlock a locked record. For a list of these methods, refer to the
discussion of the RECORDLEVELLOCK attribute in this section.

8600 0544–103 4–55


Disk Files

4–56 8600 0544–103


Section 5
Internationalization

Internationalization refers to the software, firmware, and hardware features that enable
you to develop and run application systems that can be customized to meet the needs of
a specific language, culture, or business environment. The internationalization features
provide support for several character sets, different international business and cultural
conventions, extensions to data communications protocols, and the ability to use one or
more natural languages concurrently.

This section describes the internationalization features you can use to customize an
application for the language and conventions of a particular locality. Using these features
to write or modify an application is termed localization. The MultiLingual System (MLS)
environment enables you to process information to localize your applications. Some of
the localization methods included in the MLS environment include translating messages
to another language, choosing a particular character set to be used for data processing,
and defining date, time, number, and currency formats for a particular business
application.

In addition to the information described in this section, refer to the MultiLingual System
(MLS) Administration, Operations, and Programming Guide for information. The MLS
Guide provides definitions for, and detailed information about, the ccsversions, character
sets, languages, and conventions provided in the system software. It also provides
procedures for setting system values for the internationalization features.

Accessing the Internationalization Features


You can use the following two methods separately or together to localize your programs.
Both of these methods are fully described later in this section.

• RPG provides language syntax that enables localization of your program. For
example, when you specify a particular ccsversion in your program, the compiler
uses the collating sequence associated with the ccsversion for alphanumeric
comparisons.
• The system provides a system library, CENTRALSUPPORT, that contains procedures
for localizing a program. The procedures can be accessed through calls. When a call
occurs, input parameters describe the type of information that is needed of the
action that has to be performed. Output parameters are returned with the result of
the procedure call. For example, a program can call the procedure CNVTIME to
format the time according to the language and convention specified in a program.

8600 0544–103 5–1


Internationalization

A program must designate that it uses internationalization features; otherwise, it will not
access them. A program is not affected by the features described in this section unless a
program specifically invokes them. Any programs that already exist and do not make use
of internationalization features are not affected by the features.

Using the Ccsversion, Language, and Convention Default


Settings
The program can choose the specific ccsversion, language, and convention settings that
it needs by setting the input parameters to a procedure. The system also has default
settings for the internationalization features at other levels. These default settings can be
accessed also by the program. See “Understanding the Hierarchy for Default Settings”
later in this section for information on the available levels and on the features supported
at each level.

The current system default settings can be determined by using one of the following two
methods:

• The program calls the CENTRALSTATUS procedure in the CENTRALSUPPORT


library.
• A system administrator, a privileged user, or a user who is allowed to use the system
console can use MARC menus and screens or the SYSTEMOPTIONS system
command. Refer to the MLS Guide or the Menu-Assisted Resource Control (MARC)
Operations Guide for the instructions to display the default ccsversion, language, or
convention with MARC.
The system default settings are as follows:

Feature Default

Ccsversion ASeriesNative
Language English
Convention ASeriesNative

Before you change the default settings for localization, you must consider the feature
and the level at which the feature is defined. As an example, the ccsversion can be
changed only at the system operations level. A program can avoid making specific
settings by taking advantage of the default settings. For example, if the system default
ccsversion is France, the language is Francais, and the convention is FranceListing, the
program can use those default settings without coding the settings within the program.
A program can use the default settings with the use of predefined values as input
parameters. These parameters tell the procedure to use the current default setting. See
“Input Parameters” later in this section for specific information on those parameters.

5–2 8600 0544–103


Internationalization

Understanding the Hierarchy for Default Settings


The default settings for the internationalization features can be established at the
following levels:

Setting When Established

Task Established at task initiation


Session Handled by MARC or CANDE commands or by programs which
support sessioning
Usercode Established in the USERDATAFILE file
System Established with a system or MARC command

There is a priority associated with these levels. A setting at the task level overrides a
setting at the session level. A setting at the session level overrides a setting at the
usercode level. A setting at the usercode level overrides a setting at the system level,
and so on. A language and convention can be established at any level, but the ccsversion
can be established only at the system level.

Two task attributes enable you to change the language, the convention, or both. These
attributes are the LANGUAGE and the CONVENTION task attributes. By using these
attributes, you have the option to select from among multiple languages and conventions
when running a program. Information on the use of task attributes is provided in the Task
Attributes Reference Manual.

The LANGUAGE task attribute establishes the language used by a program at run time.

The CONVENTION task attribute establishes the convention used by a program at run
time. For example, an international bank might have a program to print bank statements
for customers in different countries. This program could have a general routine to format
dates, times, currency, and numerics according to the selected conventions. To print a
bank statement for a French customer, this program could set the CONVENTION task
attribute to FranceBureautique and process the general routine. For a customer in
Sweden, the program could set the CONVENTION task attribute to Sweden and process
the general routine.

As you code your program you can use the defaults in both the source code and the calls
to the CENTRALSUPPORT library, or you can use the settings of your choice. The task
level and system level are probably the most useful levels for your program. Because the
language and convention features have task attributes defined, you can access or set
these task attributes in your program.

8600 0544–103 5–3


Internationalization

Understanding the Components of the MLS


Environment
The following four components of the MLS environment support different languages and
cultures:

• Coded character sets


• Ccsversions
• Languages
• Conventions
The following paragraphs describe the function of each of these components.

Coded Character Sets and Ccsversions


A coded character set is a set of rules that establishes a character set and the one-to-one
relationship between the characters of the set and their code values. The same character
set can exist with different encodings. For example, the LATIN1-based character set can
be encoded in an International Organization for Standardization (ISO) format or an
EBCDIC format. Coded character sets are defined in the MLS Guide.

A coded character set name and number is given for each unique coded character set
definition. This name or number may also be used to set the INTMODE or EXTMODE file
attributes for a file. Refer to the File Attributes Reference Manual for information on how
to use these attributes.

A ccsversion is a collection of information necessary to apply a coded character set in a


given country, language, or line of business. This information includes the processing
requirements such as data classes, lowercase-to-uppercase mapping, ordering of
characters, and the presentation set and escapement rules necessary for output. A
ccsversion name and number is given to each unique group of information. A ccsversion
name or number may also be used to set the CCSVERSION file attribute for a file. Refer
to the File Attributes Reference Manual for information on how to use this attribute.

Each SSR includes a data file, SYSTEM/CCSFILE, containing all coded character sets and
ccsversions that are supported on the system. You cannot choose a coded character set
directly, but by choosing a ccsversion, you implicitly designate the default coded
character set for your system.

Data can be entered and manipulated in only one coded character set and ccsversion at a
time. Although there are many ccsversions which can be accessed, there is only one
ccsversion active for the entire system at one time. This is called the system default
ccsversion. See “Using the Ccsversion, Language, and Convention Default Settings” and
“Understanding the Hierarchy for Default Settings” earlier in this section.

Several ways exist to determine which coded character sets and ccsversions are
available on your system.

5–4 8600 0544–103


Internationalization

• Look in the MLS Guide. Your system might have a subset of the ones defined in that
guide.
• Use the MARC menus and screens or the system command SYSTEMOPTIONS.
Refer to the MLS Guide or the System Commands Operations Reference Manual.
• Call the CCSVSNLIST procedure.
You might want to refer to the MLS Guide for a complete understanding of ccsversions
and the relationship of a coded character set and a ccsversion.

All coded character set and ccsversion information on your system can be accessed by
calling CENTRALSUPPORT library procedures. To call these CENTRALSUPPORT library
procedures, an RPG program should first include a file provided on the release media that
declares all the library procedures. This file is called *SYMBOL/INTL/RPG/PROPERTIES.
The procedures can then be used in the program. There are comments in this file that
describe parameter constants and their values as well as error values. The method for
including *SYMBOL/INTL/RPG/PROPERTIES in your RPG program is shown in each of
the CENTRALSUPPORT library procedures detailed later in this section. If the file is not
included, any library procedure that is used must be declared individually in the program.

Many of the procedures require the specification of a coded character set or ccsversion
as an input parameter. A program can choose a specific coded character set or
ccsversion by calling the procedures using the name or number of the coded character
set or the ccsversion as an input parameter. For example, by calling the VSNTRANTXT
procedure with the ccsversion name ASeriesNative, then calling the VSNTRANTXT
procedure again with the ccsversion name SWISS, your program could access data in the
ASeriesNative ccsversion and then access data in the Swiss ccsversion. A program can
also use the system default setting by using predefined values as input parameters. See
“Input Parameters” later in this section for information on these parameters.

Mapping Tables
A mapping table is used to map one group of characters to another group of characters
or another representation of the original characters. Many CENTRALSUPPORT library
procedures store coded character set and ccsversion information in ALGOL-type
translate tables as a way of defining, processing, and mapping data. For example, a
translate table can exist to translate lowercase characters to uppercase characters. It is
not necessary to understand the layout of an ALGOL-type translate table because the
table is usually not visible to your program. A description of translate tables is provided in
the ALGOL Programming Reference Manual, Volume 1: Basic Implementation.

The internationalization procedures provide you with access to mapping tables that apply
to data specified in coded character sets or specified ccsversions. These mapping tables
are as follows:

• Mapping data from one coded character set to another coded character set
• Mapping data from lowercase to uppercase characters
• Mapping data from uppercase to lowercase characters
• Mapping data from alternative numeric digits defined in a ccsversion to numeric
digits in U.S. EBCDIC

8600 0544–103 5–5


Internationalization

• Mapping data from numeric digits in U.S. EBCDIC to alternative numeric digits
defined in a ccsversion
• Mapping characters to their escapement values
You must use procedures from the CENTRALSUPPORT library to access these translate
tables or to process data using these tables. For example, you use the CCSTRANTXT
procedure to translate data from one coded character set to another coded character set.
You use the VSNTRANTXT procedure to map lowercase data to uppercase.

See the MLS Guide for definitions of mapping tables for each coded character set and
ccsversion.

Data Classes
A data class is a group of characters sharing common attributes such as alphabetic, upon
which membership tests can be made. Some characters might not have a data class
assigned to them. Many CENTRALSUPPORT library procedures store ccsversion
information in ALGOL-type truthset tables as a way to define ccsversion data classes. A
truthset is a method of storing the declared set of characters that defines a data class in
ALGOL. It is not necessary to understand the layout of an ALGOL-type truthset because
the truthset is usually not visible to your program. A description of truthsets is provided
in the ALGOL Programming Reference Manual, Volume 1: Basic Implementation.

The internationalization features provide you with access to truthsets that apply to a
ccsversion. These truthsets are:

• Ccsversion alphabetic
• Ccsversion numeric
• Ccsversion graphics
• Ccsversion spaces
• Ccsversion lowercase
• Ccsversion uppercase
The alphabetic truthset contains those characters which are considered alphabetic for a
specified ccsversion. The numeric truthset contains those characters which are
considered to be numbers for a specified ccsversion, and so on.

You can use procedures from the CENTRALSUPPORT library to access these truthsets
or to process data using these truthsets. For example, if a program manipulates an
employee identification number such as 555962364, it might then need to verify that the
text is all numeric. The program can call the VSNINSPTXT CENTRALSUPPORT library
procedure to compare the text to the numeric truthset. This procedure returns the
information that the text is all numeric.

Refer to the MLS Guide for definitions of ccsversions and data classes.

5–6 8600 0544–103


Internationalization

Text Comparisons
You might need to perform a text comparison to sort and merge text, to compare
relationships between two pieces of text, or to index a file. The traditional method for
handling text comparisons is based on a strict binary comparison of the character values.
The binary method of comparison is not meaningful when used for sorting text if the
binary ordering of the coded characters does not match the ordering sequence of the
alphabet of the language. This situation is the case for most coded character sets.

Because the binary method is not sufficient for all usage requirements, the system
software supports the definitions of two other levels of ordering.

The first level is called Ordering. Each character gets an ordering sequence value (OSV).
An OSV is an integer from 0 (zero) through 255, assigned to each code position in a
character set. The OSV signifies a relative ordering value of a character. An OSV of 0
(zero) indicates that the character comes before a character with an OSV of 1. More than
one character can be assigned the same OSV.

The second level is called Collating. Each character gets an OSV and a priority sequence
value (PSV). A PSV is an integer from 1 to 15 that is assigned to each code position in a
character set. The PSV is a relative priority value within each OSV. Each character with a
unique OSV has a PSV of 1; however, if 2 characters have the same OSV, they will have
different PSVs for additional differentiation.

When comparing two strings of data, we call a comparison which uses only 1 level, the
Ordering level, an equivalent comparison. A comparison which utilizes both levels,
Ordering and Collating, is called a logical comparison.

You can use the following three types of text comparisons by calling the VSNCOMPTXT
procedure of the CENTRALSUPPORT library.

The Order Type Is a Comparison Based on the . . .

Binary Hexadecimal code values of the


characters
Equivalent OSVs of the characters
Logical OSVs plus the PSVs of the characters

8600 0544–103 5–7


Internationalization

In addition to the three types of ordering, the system also supports the following two
types of character substitution:

Substitution Orders . . .

Many to One A predetermined string of up to three characters ordered


as if it were one character, assigning it a single OSV and
PSV pair. Even if a character is part of a predetermined
string of characters that is ordered as a single value, the
character still has an OSV and a PSV pair assigned to it to
allow for cases in which the character appears in other
strings or individually. For example, in Spanish, the letter
pair ch is ordered as if it were a single letter, different
from either c or h, and ordering between c and d.
One to Many A single character ordered as a string of two or three OSV
and PSV pairs. For example, the á (the German sharp S)
character is ordered as though it were ss.

You can also specify a collating sequence to be used for text comparisons. When an
internationalized collating sequence has been specified at the program level and you are
trying to compare two alphanumeric strings, the compiler generates the text comparison
routines.

To enable your RPG program to have automatic access to the system default collating
sequence, code the entry N in the Collating Sequence field (column 26 of the Control
Specification). This entry specifies that the system default internationalization collating
sequence should be applied to process alphanumeric data. This processing includes
match field sequence checking, match field processing, and the application of the COMP,
IFxx, DOUxx, DOWxx, CASxx, and LOKUP operation codes. You can define a specific
collating sequence by using an S entry in the Collating Sequence field and using the
Alternate Collating Sequence Specifications.

You can direct your RPG program to sort using a different collating sequence by entering
a C in the Decimal Positions field (column 52 of the Calculation Specifications) on the
same line as the SORTA operation. The C indicates that the collating sequence specified
in the Collating Sequence field (column 26 of the Control Specification) will be used.

Historically, text was sorted by using a standard system-provided method that is based
on a strict binary comparison of the character values. Within a program, you might also
specify a collating sequence to be used for text comparisons.

Often with international coded character sets, the binary method of comparison does not
result in a meaningful ordering of the text to be sorted. This situation occurs when the
binary ordering of the coded characters does not match the ordering sequence of the
alphabet. Your program can call the CENTRALSUPPORT library procedures listed in Table
5–1 under the category “Comparing and Sorting Text” to obtain ordering information of
the ccsversion, and to sort or compare text based on this information.

5–8 8600 0544–103


Internationalization

Creating Indexed Files


If you are creating a localized indexed file, you must use the KEYLENGTH and
COMPARISON pseudo file attributes to specify the key value and the type of comparison
to be done.

Like file attributes, you must code pseudo file attributes for a file in File Specifications
immediately after the specification for that file. However, the pseudo file attributes can
appear in any sequence in File Attribute Specifications. Because you cannot interrogate
or modify pseudo file attributes, you cannot declare them with a variable name.

A run-time error occurs when you open an indexed file for output if the system default
ccsversion does not match the system default ccsversion in effect at the time the
program was compiled.

Providing Support for Natural Languages


The natural language feature enables users of your application program to communicate
with the computer system in their natural language. A natural language is a human
language in contrast to a computer programming language.

You must code your RPG program in the subset of the standard U.S. EBCDIC character
set defined by the RPG language. Only the contents of string literals, data items with
variable character data, or comments can be in a character set other than that subset.

If your program interacts with a user, has a user interface (screens, forms), displays
messages or takes in user input, then those aspects of the program should be in the
natural language of the user. For example, French would be used in screen and system
message displays for users whose natural language is French.

Refer to the MLS Guide for a list of user interfaces that can be localized. The following
text explains how to develop an RPG application program which supports messages in
the natural language of the user.

Creating Messages for an Application Program


In the MLS environment, the messages handled by your application program are grouped
into the following categories:

Category Is a Message . . .

Output That an application program displays to the user. Some examples of output
message messages are error messages and prompts for input. An output message
is localized so that it can be displayed in the language of the user.
Input Received by an interactive program either from a user or from another
message program in response to a prompt for input. The input message might be in
a language that the program cannot recognize. In this case, the message
must be translated so that it can be understood by the program.

8600 0544–103 5–9


Internationalization

If you develop input and output messages within an output message array, you make the
localization process easier. When messages are in an output message array, the
translator can use the MSGTRANS utility to localize the messages into one or more
natural languages. The MSGTRANS utility finds all output message arrays in a program
and presents them to a translator for translation. If messages are not in output message
arrays, a translator searches the source file for each message and then translates the
message.

You can create an output message array by creating an ALGOL library that contains
OUTPUTMESSAGE ARRAY declarations.

An output message array contains output messages to be used by the MultiLingual


System (MLS). ALGOL statements within the output message array declaration contain
output messages or translate input messages. You can then call the library from your
application program. The MLS Guide describes the procedures for creating and using
output message arrays.

There is a program on the release media that demonstrates how to create an ALGOL
library containing output message arrays. The program is called
EXAMPLE/MLS/ALGOL/LIBRARY. For more information on how to call an ALGOL library
from an RPG program, see the MLS Guide.

Creating MultiLingual Messages for Translation


The following are guidelines for creating messages that can be multilingual:

• Put all output messages in output message arrays.


• Accept or display any messages through a library interface using methods similar to
those provided on the release media.
• Allow more space for translated messages. Because the English language is more
compact than many other natural languages, a message in English generally
becomes about 33 percent longer after it is translated into another language. For
example, if a program can display an 80-character message, an English message
should be only 60 characters long so that the translated message can expand by one-
third and not exceed the maximum display size.
• Use complete sentences for messages because phrases are hard to translate
accurately.
• Do not use abbreviations because they also are hard to translate.

Providing Support for Business and Cultural Conventions


The business and cultural features enable users of an application program to display and
receive data according to local conventions. A convention consists of formatting
instructions for date, time, numeric, currency, and default page size.

The release media contains standard convention definitions for many formatting styles.
For example, some of the conventions are Denmark, Italy, Turkey, and UnitedKingdom1.

5–10 8600 0544–103


Internationalization

These convention definitions contain information to create formats for time, date,
numbers, currency, and page size required by a particular locality.

Each SSR includes a data file named SYSTEM/CONVENTIONS that contains all the
convention definitions supported on the system. Although you can access many
conventions, only one convention is active at a time for the entire system. This
convention is called the system default convention.

Several ways exist for accessing the conventions:

• Look in the MLS Guide. Your system might have a subset of the ones defined in that
guide.
• Use the MARC menus and screens or the system command SYSTEMOPTIONS.
Refer to the MLS Guide or the System Commands Operations Reference Manual.
• Call the CENTRALSUPPORT library procedures. To display the names of the
conventions available on the host computer, use the CNVNAME CENTRALSUPPORT
library procedure.
The MLS Guide provides complete information on all of the conventions. There are
comments in the file SYMBOL/RPG/INTL/PROPERTIES that describe parameter
constants and their values. These constants and values can be used in your program. The
comments in the file also describe error values.

If none of the conventions provided on the release media meet your needs, you can
define a new convention. You must use a template to define a convention. A template is
a group of predefined control characters that describe the components for date, time,
numeric, or currency. For example, the data item 02251990 and the template
!0o!/!dd!/!yyyy! produce the formatted date, 02/25/1990. To use some of the
CENTRALSUPPORT library procedures, you must understand how templates are
defined. The MLS Guide describes how to define a template.

Using the Date and Time Features


Date and time features are provided by several CENTRALSUPPORT library Features.
Additionally, the RPG programming language provides date features for standard use.

Each of the following features applies to date handling throughout the entire RPG
program:

• The Date Format field (column 23 of the Control Specification) provides MMDDYY,
DDMMYY, and YYMMDD date formats for the predefined field UDATE. JDATE is a
predefined field that contains the Julian date in YYDDD format.
• The Date Edit field (column 24 of the Control Specification) is used to specify any
character as a date separator, including blank.

8600 0544–103 5–11


Internationalization

In addition to using the features in RPG, you can call the CENTRALSUPPORT library
procedures to format your date and time items. The following types of procedures are
available to format the date and time:

Procedure Type Description

Convention You supply the convention name and the value for the date or
time. The procedure returns the date or time value in the format
used by the convention. All the conventions are described in the
MLS Guide.
Template You supply the following: the format that you want for the date or
time in a template parameter; the value for the date or time. You
must use predefined control characters to create the template.
These control characters are described in the MLS Guide.
System The system supplies the date and time. There is a procedure that
formats the system date, the system time, or both according to a
convention and a procedure that formats the system date, the
system time, or both according to a template that you supply.

Example
You can use the CNVDATTIM procedure to display the system date and time according
to the language and convention you choose. If you designate the ASeriesNative
convention and the ENGLISH language, the date and time may be displayed as follows:

9:25 AM Monday, July 4, 1988

If you designate the FranceListing convention and the French language, the same date
and time may be displayed as follows:

9h25, lundi 4 juillet 1988

Table 5–1 lists other procedures that can be called to inquire about the conventions
available on the system.

Using the Numerics and Currency Features


Numeric and currency features are provided by the RPG programming language and by
several CENTRALSUPPORT library procedures.

The RPG compiler provides you with the following ways to edit currency and numeric
displays:

• The Currency Edit field (column 22 of the Control Specification) is used to specify any
single character to be used as the currency symbol in place of the dollar sign ($).
• RPG also has a domestic, international, and United Kingdom format for numerics and
dates. You use the Inverted Print field (column 21 of the Control Specification) to use
these formats. Both the international and United Kingdom formats use a period (.) as
the thousands separator and a comma (,) as the decimal point. In addition, the
Inverted Print field changes the default date format and separator.

5–12 8600 0544–103


Internationalization

In addition to using the features in RPG, you can call the CENTRALSUPPORT library
procedures to inquire about numeric symbols or format currency amounts. All numeric or
currency symbols can be retrieved with a CENTRALSUPPORT library call. Monetary
amounts in real number form can be formatted according to different conventions.

You can use the CNVCURNCY procedure to format a monetary value according to the
convention you choose. For example, if you designate the Greece convention, the
monetary amount 12345.67 is formatted as follows:

DR.12 345,67

Using the Page Size Formatting Features


The CNVFORMSIZ CENTRALSUPPORT procedure enables you to retrieve default lines-
per-page and characters-per-line values for a specified convention.

For example, the Netherlands convention definition specifies 70 lines as the default page
length and 82 characters as the default page width, while the Zimbabwe convention
definition specifies 66 lines as the default page length and 132 lines as the default page
width.

Summary of CENTRALSUPPORT Library Procedures


The CENTRALSUPPORT library procedures are integer-valued procedures. The
procedures return values in the output parameters and as the procedure result. You can
check the result returned by each procedure by using standard programming practices.
The result is useful in deciding if an error has occurred. The possible values for each
procedure result are listed in the description of each procedure. The meanings of the
result values are described under “Errors” at the end of this section.

The CENTRALSUPPORT library procedures are called by application programs and


system software.

Following are some of the tasks your program can perform by calling
CENTRALSUPPORT library procedures:

• Identify available coded character sets and ccsversions.


• Map data from one coded character set to another.
• Process data according to a ccsversion.
• Compare and sort text.
• Position characters.
• Determine available natural languages.
• Access CENTRALSUPPORT library messages.
• Identify available convention definitions.
• Obtain information about conventions.

8600 0544–103 5–13


Internationalization

• Format dates according to a convention.


• Format times according to a convention.
• Format monetary data according to a convention.
• Determine the default page size.
Table 5–1 lists the CENTRALSUPPORT library procedures according to the tasks the
procedures perform. The table also describes the purpose of each procedure.

Table 5–1. Functional Grouping of CENTRALSUPPORT Library Procedures

Category and Explanation


Procedure Name

Identifying Available Coded Character Sets and Ccsversions


CENTSTATUS Obtains the values of the default settings for internationalization features on the
host computer. This procedure returns the names of the default ccsversion,
language, and convention. It also returns the number of the default ccsversion.
CCSVSNLIST Returns the names and numbers of all coded character sets or all ccsversions
available on the host computer. The names and numbers are listed in two
arrays. These arrays are ordered so that the names in the names array
correspond to the numbers in the numbers array.
CCSVSNNUM Verifies that a designated coded character set or ccsversion name is valid on
the host computer. If the coded character set or ccsversion is valid, the
procedure returns the corresponding number.
CCSVSNNAME Verifies that the designated coded character set or ccsversion number is valid
on the host computer. If the coded character set or ccsversion is valid, the
procedure returns the corresponding name.
Mapping Data from One Coded Character Set to Another
CCSTRANTXT Maps data from one coded character set to another coded character set by
using a translate table. Characters are translated using a one-to-one mapping
between the two coded character sets.
Processing Data According to Ccsversion
VSNINSPTXT Compares the input text to a designated ccsversion truthset to determine
whether the characters in the text are in the truthset. You can use this
procedure to determine if characters are in one of the following truthsets:
• Alphabetic
• Numeric
• Spaces
• Presentation
• Lowercase
• Uppercase

5–14 8600 0544–103


Internationalization

Table 5–1. Functional Grouping of CENTRALSUPPORT Library Procedures

Category and Explanation


Procedure Name

VSNTRANTXT Translates data using a designated ccsversion.


You can use this procedure to perform the following types of translations:
• Lowercase to uppercase characters
• Uppercase to lowercase characters
• The digits 0 through 9 to alternate digits
• Alternate digits to the digits 0 through 9
• Characters to their character escapement directions
Comparing and Sorting Text
VSNCOMPTXT Compares two strings using one of the following comparison methods for a
designated ccsversion:
• Binary comparison, which is based on the binary values of the characters
• Equivalent comparison, which is based on the ordering sequence values of
characters
• Logical comparison, which is based on the ordering sequence values and
priority sequence values of characters
VSNGETORD1 Returns the ordering information for the input text. The ordering information
determines how the input text is collated. It includes the ordering and priority
sequence values of the characters and any substitution of characters to be
made when the input text is sorted. You can choose one of the following types
of ordering information:
• Equivalent ordering information, which comprises only the ordering
sequence values
• Logical ordering information, which comprises the ordering sequence
values followed by the priority sequence values.
Positioning Characters
VSNESCAPE Takes the input text and rearranges it according to the escapement rules of the
ccsversion. Both the character advance direction and the character escapement
direction are used. If the character direction is position, then the start position
of the text is the leftmost position of the starting character. If the character
advance is negative, then the starting position for the text is the rightmost
position of the last character. From that point on, the character advance
direction value and the character escapement direction values, in combination,
control where each character should be placed in relation to the previous
character.
Determining Available Natural Language
MCPLANGS Returns the names of the languages that are currently bound to the MCP.

8600 0544–103 5–15


Internationalization

Table 5–1. Functional Grouping of CENTRALSUPPORT Library Procedures

Category and Explanation


Procedure Name

Accessing CENTRALSUPPORT Library Messages


CSMSG Returns text of the message associated with the designated
CENTRALSUPPORT error number. Your program can specify the maximum
message length desired. If the returned message is shorter, it is padded with
blanks.
An entire message consists of three parts:
• The header, which always takes up the first 80 characters of the return
message
• The general description, which takes the next 80 characters
• The specific description, which has no maximum length
Identifying Available Convention Definitions
CENTSTATUS Obtains the values of the default settings for internationalization features on the
host computer. This procedure returns the names of the default ccsversion,
language, and convention. It also returns the number of the default ccsversion.
CNVLIST Returns the names of the conventions available on the host system.
CNVNAME Returns a value that indicates whether the specified convention name is
currently defined on the host system.
Obtaining Convention Information
CNVSYMBOLS Returns the numeric and monetary symbols defined for a designated
convention. The symbols in the convention are
• Numeric positive symbol
• Numeric negative symbol
• Numeric thousands separator symbol
• Numeric decimal symbol
• Numeric left enclosure symbol
• Numeric right enclosure symbol
• Numeric grouping
• Monetary positive symbol
• Monetary negative symbol
• International currency notation
• National currency symbol
• Monetary grouping
• Monetary thousands separator symbol
• Monetary left enclosure symbol
• Monetary right enclosure symbol
• Monetary decimal symbol

5–16 8600 0544–103


Internationalization

Table 5–1. Functional Grouping of CENTRALSUPPORT Library Procedures

Category and Explanation


Procedure Name

CNVTPLT Returns the requested template for a designated convention. You can obtain
the template for the following:
• Long date format
• Short date format
• Numeric date format
• Long time format
• Numeric time format
• Monetary format
• Numeric format
Formatting Dates According to Convention
CNVDSPYMDL Returns either the date or time display model defined for the designated
convention. The components of the model are translated to the designated
language.
CNVDATE Formats a numeric date that has the form YYYYMMDD. The numeric date is
passed as a parameter to the procedure according to a designated convention
and language. The date can be formatted using the long, short, or numeric date
format defined in the convention.
TPLTDATTIM Returns the system date, the time, or both in the designated language,
formatted according to a template passed to this procedure.
CNVDATTIM Returns the system date, the time, or both, formatted according to the
designated convention template and language. You can choose from the
following types of formats:
• Long date and long time
• Long date and numeric time
• Short date and long time
• Short date and numeric time
• Numeric date and long time
• Numeric date and numeric time
• Long date only
• Short date only
• Long time only
• Numeric time only
TPLTDATE Formats a numeric date passed as a parameter to the procedure according to a
template and language passed as parameters of the procedure.
Formatting Times According to Convention
CNVDSPYMDL Returns either the date or time display model defined for the designated
convention. The components of the model are translated to the designated
language.

8600 0544–103 5–17


Internationalization

Table 5–1. Functional Grouping of CENTRALSUPPORT Library Procedures

Category and Explanation


Procedure Name

CNVTIME Formats a time with the form HHMMSSPPPP. The time is passed as a
parameter to the procedure according to a designated convention and
language. The time can be formatted using the long or numeric time format
defined in the convention.
TPLTTIME Formats a time passed as a parameter to the procedure according to a template
and language passed as parameters of the procedure.
TPLTDATTIM Returns the system date, the time, or both in the designated language,
formatted according to a template passed to this procedure.
CNVDATTIM Returns the system date, the time, or both, formatted according to the
designated convention template and language. You can choose from the
following types of formats:
• Long date and long time
• Long date and numeric time
• Short date and long time
• Short date and numeric time
• Numeric date and long time
• Numeric date and numeric time
• Long date only
• Short date only
• Long time only
• Numeric time only
Formatting Monetary Data According to Convention
CNVCURNCY Formats a monetary value passed as a parameter to the procedure according to
the monetary editing format template defined in the designated convention.
Determining Default Page Size
CNVFORMSIZ Returns the default lines-per-page and characters-per-line values defined in a
designated convention for presentation devices such as terminals or printers.

5–18 8600 0544–103


Internationalization

Library Calls
You can access the procedures in the CENTRALSUPPORT library by using the following
instructions:

1. Use the INCLUDE compiler control option to include part or all of the file
*SYMBOL/INTL/RPG/PROPERTIES. The library declarations must precede the Input
Specifications.
2. Use the EEXSR (Exit to External Subroutine) operation in the Operation field
(columns 28–32) of the Calculation Specifications to call a library subroutine. The
library subroutine name must be the name of the procedure in the
CENTRALSUPPORT library.
3. Use the PARAM (Specify Parameters for EEXSR) operation in the Operation field of
the Calculation Specifications to list the parameters of the procedure.
4. Specify the results of the procedure in the Result Field(columns 43–48) of the
Calculation Specifications.
An example of the declarations and the syntax necessary to invoke the
CENTRALSUPPORT library is provided in the description of each procedure later in this
section.

Table 5–2 lists a cross reference of CENTRALSUPPORT library procedure names. The
column on the left displays the procedure name to use when coding your RPG program.
The column on the right displays the procedure name as it appears in the
CENTRALSUPPORT library.

Table 5–2. Cross-Reference of RPG Procedure Names with


CENTRALSUPPORT Library Procedure Names

RPG Procedure Name CENTRALSUPPORT Library Procedure Name

CCSTRANTXT CCSTOCCS_TRANS_TEXT_STAR
CCSVSNLIST CCSVSN_NAMES_NUMS_STAR
CCSVSNNAME VALIDATE_NUM_RETURN_NAME_STAR
CCSVSNNUM VALIDATE_NAME_RETURN_NUM_STAR
CENTSTATUS CENTRALSTATUS_STAR
CNVCURNCY CNV_CURRENCYEDIT_RPG
CNVDATE CNV_FORMATDATE_STAR
CNVDATTIM CNV_SYSTEMDATETIME_STAR
CNVDSPYMDL CNV_DISPLAYMODEL_STAR
CNVFORMSIZ CNV_FORMSIZE_STAR
CNVLIST CNV_NAMES_STAR

8600 0544–103 5–19


Internationalization

Table 5–2. Cross-Reference of RPG Procedure Names with


CENTRALSUPPORT Library Procedure Names

RPG Procedure Name CENTRALSUPPORT Library Procedure Name

CNVNAME CNV_VALIDATENAME_STAR
CNVSYMBOLS CNV_SYMBOLS_STAR
CNVTIME CNV_FORMATTIME_STAR
CNVTPLT CNV_TEMPLATE_STAR
CSMSG GET_CS_MSG_STAR
MCPLANGS MCP_BOUND_LANGUAGES_STAR
TPLTDATE CNV_FORMATDATETMP_STAR
TPLTDATTIM CNV_SYSTEMDATETIMETMP_STAR
TPLTTIME CNV_FORMATTIMETMP_STAR
VSNCOMPTXT VSNCOMPARE_TEXT_STAR
VSNESCAPE VSNESCAPEMENT_STAR
VSNGETORD1 VSNGETORDERINGFORONE_TEXT_STAR
VSNINSPTXT VSNINSPECT_TEXT_STAR
VSNTRANTXT VSNTRANS_TEXT_STAR

Parameter Categories
Integer parameters are passed by both value and reference. The CENTRALSUPPORT
library procedures return output parameters and procedure result values.

The parameter types are further described on the following pages.

5–20 8600 0544–103


Internationalization

Input Parameters
In many cases, you need to supply the ccsversion name or number, the language name,
or the convention name as input parameters. You can obtain this information in the
following ways:

• The MLS Guide describes all the possible ccsversions, languages, and conventions
that the system software release provides. However, your system might have a
subset of the ones provided. Some customized conventions may not be listed in the
MLS Guide. These conventions may be identified by the next two methods.
• If you are a system administrator, a privileged user, or are allowed to use the system
console, you can use MARC menus and screens, or the SYSOPS command to list
the options that exist on your system. The MLS Guide provides the instructions you
need to obtain this information.
• You can call procedures in the CENTRALSUPPORT library that will return this
information to you. If you are writing an application to be used on another system,
you might want to use these library procedures to verify that the ccsversion, the
language, or the convention specified by the user is valid on the system.
For any procedure which accepts a ccsversion number as an input parameter, you can
specify a –2 as input to indicate that the system default value should be used. For any
procedure that accepts a ccsversion name as an input parameter, you can specify all
blanks or all zeros as inputs to indicate that the system default value should be used. For
any procedure that accepts a language or convention name as an input parameter, you
can specify all blanks or all zeros as input to indicate that the task attribute should be
used. If the task attribute is not available, the CENTRALSUPPORT library searches down
the hierarchy until a usable value is found.

Input Parameters with Type Values


Many of the internationalization procedures have an input parameter that indicates the
type of information to be applied or returned in the procedure. The values in these
parameters are referred to as type values. The values used in convention procedures are
common across all convention procedures. The values used in coded character set and
ccsversion procedures are common across all coded character set and ccsversion
procedures.

The MLS Guide provides complete information on all of the conventions. There are
comments in the file SYMBOL/RPG/INTL/PROPERTIES that describe parameter
constants and their values. These constants and values can be used in your program. The
comments in the file also describe error values.

For example, a parameter indicating the type of date or time formatting is used in a
number of the procedures. The type value indicates the type of format to be used. For
example, a value of 3 indicates the long time format.

8600 0544–103 5–21


Internationalization

Output Parameters
These parameters contain the output produced by the procedure. For example, the
output parameter of the CCSTRANTXT procedure contains the translated text produced
by the procedure.

Result Parameter
All the library procedures return a value as the procedure result that indicate whether an
error occurred during the execution of the procedure. In general, a returned value of 1
means that no error occurred and any other value means an error occurred. However,
the CNVNAME and VSNCOMPTXT procedures are exceptions to this rule. For these
procedures, the returned value can be 0 (zero), 1, or another value. A returned value of 0
(zero) means that no error occurred and the condition is FALSE. A returned value of 1
means that no error occurred and the condition is TRUE. Any other value means that an
error occurred.

Each procedure lists the values that can be returned by that procedure. The meanings of
these values are explained at the end of this section. You can use these values to call the
CSMSG procedure and display the error that occurred, or you can code error routines to
handle the possible errors.

Refer to the CSMSG procedure later in this section for more information about using that
procedure.

There are comments in the file SYMBOL/RPG/INTL/PROPERTIES that describe


parameter constants and their values. These constants and values can be used in your
program. The comments in the file also describe error values.

Example
Example 5–1 displays the procedure declaration portion of the CENTRALSUPPORT
Library Specifications file “SYMBOL/INTL/RPG/PROPERTIES”. The file is comprised of
Library Name Specifications, Library Subroutine Specifications and Library Parameter
Specifications. The Library Name declarations for type values and error message values
have been omitted from the example because these values are included in the individual
procedure descriptions. Table 5–3, located at the end of the section, displays the error
message values and their meaning.

All lines in the example with an asterisk (*) in column 7 are comment lines. Comment
lines are not used in the procedures; they are used for explanation and clarification.

Each time a program calls one of the RPG internationalization procedures in the
CENTRALSUPPORT procedure library, the procedure is loaded into the computer's main
processing unit. All of the procedures in the example are explained in detail later in this
section.

5–22 8600 0544–103


Internationalization

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00010H*COPYRIGHT* * * * * * * * * * * * * * * * * * * * * * * * * * * *
:
Copyright information
:
00150L**************** CENTRALSUPPORT Library Declaration **************
00200L*
00250LIBRARY NAME CENTRALSUP F CENTRALSUPPORT
:
Error message and type value information
:
20000L* CentralSupport subroutine declarations:
20050L*
20100L******************************************************************
20150L*
20200LIBRARY SUBR CSMSG 110 GET_CS_MSG_STAR
20250L* ===== ===============
20300L*
20350L* Parameter ALGOL Equivalent
20400L* --------- ----------------
20450L* MSG_NUM INTEGER MSG_NUM
20500L* LANG EBCDIC ARRAY LANG [*]
20550L* INTEGER LANG_SIZE
20600L* MSG EBCDIC ARRAY MSG [*]
20650L* INTEGER MSG_SIZE
20700L* MSG_LEN INTEGER MSG_LEN
20750L*
20800LIBRARY PARAM MSG_NUM 110V
20850LIBRARY PARAM LANG RL
20900LIBRARY PARAM MSG RL
20950LIBRARY PARAM MSG_LEN 110R
21000L*
21050L******************************************************************
21100L*
21150LIBRARY SUBR CENTSTATUS 110 CENTRALSTATUS_STAR
21200L* ========== ==================
21250L*
21300L* Parameter ALGOL Equivalent
21350L* --------- ----------------
21400L* SYS_INFO EBCDIC ARRAY SYS_INFO [*]
21450L* INTEGER SYS_INFO_SIZE
21500L* CTL_INFO INTEGER ARRAY CONTROL_INFO [*]
21550L* INTEGER CONTROL_INFO_SIZE
21600L*
21650LIBRARY PARAM SYS_INFO RL

Example 5–1. SYMBOL/INTL/RPG/PROPERTIES Library Specifications File (cont.)

8600 0544–103 5–23


Internationalization

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
21700LIBRARY PARAM CTL_INFO 110RL
21750L*
21800L******************************************************************
21850L*
21900LIBRARY SUBR CCSVSNNUM 110 VALIDATE_NAME_RETURN_NUM_STAR
21950L* ========= =============================
22000L*
22050L* Parameter ALGOL Equivalent
22100L* --------- ----------------
22150L* CCSVSN INTEGER CCSVSN_TYPE
22200L* NAMEARY EBCDIC ARRAY NAME_ARY [*]
22250L* INTEGER NAME_SIZE
22300L* NUM INTEGER NUM
22350L*
22400LIBRARY PARAM CCSVSN 110V
22450LIBRARY PARAM NAMEARY RL
22500LIBRARY PARAM NUM 110R
22550L*
22600L******************************************************************
22650L*
22700LIBRARY SUBR CCSVSNNAME 110 VALIDATE_NUM_RETURN_NAME_STAR
22750L* ========== =============================
22800L*
22850L* Parameter ALGOL Equivalent
22900L* --------- ----------------
22950L* CCSVSN INTEGER CCSVSN_TYPE
23000L* NUM INTEGER NUM
23050L* NAMEARY EBCDIC ARRAY NAME_ARY [*]
23100L* INTEGER NAME_SIZE
23150L*
23200LIBRARY PARAM CCSVSN 110V
23250LIBRARY PARAM NUM 110V
23300LIBRARY PARAM NAMEARY RL
23350L*
23400L******************************************************************
23450L*
23500LIBRARY SUBR CCSVSNLIST 110 CCSVSN_NAMES_NUMS_STAR
23550L* ========== ======================
23600L*
23650L* Parameter ALGOL Equivalent
23700L* --------- ----------------
23750L* CCSVSN INTEGER CCSVSN_TYPE
23800L* TOTAL INTEGER TOTAL
23850L* NAMESARY EBCDIC ARRAY NAMES_ARY [*]
23900L* INTEGER NAMES_SIZE

Example 5–1. SYMBOL/INTL/RPG/PROPERTIES Library Specifications File (cont.)

5–24 8600 0544–103


Internationalization

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
23950L* NUMSARY EBCDIC ARRAY NUMS_ARY [*]
24000L* INTEGER NUMS_ARY
24050L*
24100LIBRARY PARAM CCSVSN 110V
24150LIBRARY PARAM TOTAL 110R
24200LIBRARY PARAM NAMESARY RL
24250LIBRARY PARAM NUMSARY 110RL
24300L*
24350L******************************************************************
24400L*
24450LIBRARY SUBR CCSTRANTXT 110 CCSTOCCS_TRANS_TEXT_STAR
24500L* ========== ========================
24550L*
24600L* Parameter ALGOL Equivalent
24650L* --------- ----------------
24700L* CCSFROM INTEGER CCSNUMFROM
24750L* CCSTO INTEGER CCSNUMTO
24800L* SOURCE EBCDIC ARRAY SOURCE [*]
24850L* INTEGER SOURCE_SIZE
24900L* STRT_SRCE INTEGER SOURCE_START
24950L* DEST EBCDIC ARRAY DEST [*]
25000L* INTEGER DEST_SIZE
25050L* STRT_DEST INTEGER DEST_START
25100L* TRANSLEN INTEGER TRANSLEN
25150L*
25200LIBRARY PARAM CCSFROM 110V
25250LIBRARY PARAM CCSTO 110V
25300LIBRARY PARAM SOURCE RL
25350LIBRARY PARAM STRT_SRCE 110V
25400LIBRARY PARAM DEST RL
25450LIBRARY PARAM STRT_DEST 110V
25500LIBRARY PARAM TRANSLEN 110V
25550L*
25600L******************************************************************
25650L*
25700LIBRARY SUBR VSNTRANTXT 110 VSNTRANS_TEXT_STAR
25750L* ========== ==================
25800L*
25850L* Parameter ALGOL Equivalent
25900L* --------- ----------------
25950L* VSNNUM INTEGER VSN_NUM
26000L* SOURCE EBCDIC ARRAY SOURCE [*]
26050L* INTEGER SOURCE_SIZE
26100L* SRCE_STRT INTEGER SOURCE_START
26150L* DEST EBCDIC ARRAY DEST [*]
26200L* INTEGER DEST_SIZE
26250L* DEST_STRT INTEGER DEST_START
26300L* TRANSLEN INTEGER TRANSLEN

Example 5–1. SYMBOL/INTL/RPG/PROPERTIES Library Specifications File (cont.)

8600 0544–103 5–25


Internationalization

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
26350L* TTABLETYP INTEGER TTABLE_TYPE
26400L*
26450LIBRARY PARAM VSNNUM 110V
26500LIBRARY PARAM SOURCE RL
26550LIBRARY PARAM SRCE_STRT 110V
26600LIBRARY PARAM DEST RL
26650LIBRARY PARAM DEST_STRT 110V
26700LIBRARY PARAM TRANSLEN 110V
26750LIBRARY PARAM TTABLETYP 110V
26800L*
26850L******************************************************************
26900L*
26950LIBRARY SUBR VSNINSPTXT 110 VSNINSPECT_TEXT_STAR
27000L* ========== ====================
27050L*
27100L* Parameter ALGOL Equivalent
27150L* --------- ----------------
27200L* VSNNUM INTEGER VSN_NUM
27250L* TEXT EBCDIC ARRAY TEXT [*]
27300L* INTEGER TEXT_SIZE
27350L* TEXT_STRT INTEGER TEXT_START
27400L* INSPLEN INTEGER INSPECT_LEN
27450L* TSET_TYPE INTEGER TSET_TYPE
27500L* FLAG INTEGER FLAG
27550L* NUMSEEN INTEGER SCANNED_CHARS
27600L*
27650LIBRARY PARAM VSNNUM 110V
27700LIBRARY PARAM TEXT RL
27750LIBRARY PARAM TEXT_STRT 110V
27800LIBRARY PARAM INSPLEN 110V
27850LIBRARY PARAM TSET_TYPE 110V
27900LIBRARY PARAM FLAG 110V
27950LIBRARY PARAM NUMSEEN 110R
28000L*
28050L******************************************************************
28100L*
28150LIBRARY SUBR VSNCOMPTXT 110 VSNCOMPARE_TEXT_STAR
28200L* ========== ====================
28250L*
28300L* Parameter ALGOL Equivalent
28350L* --------- ----------------
28400L* VSNNUM INTEGER VSN_NUM
28450L* TEXT1 EBCDIC ARRAY TEXT1 [*]
28500L* INTEGER TEXT1_SIZE
28550L* TXT1_STRT INTEGER TEXT1_START
28600L* TEXT2 EBCDIC ARRAY TEXT2 [*]
28650L* INTEGER TEXT2_SIZE

Example 5–1. SYMBOL/INTL/RPG/PROPERTIES Library Specifications File (cont.)

5–26 8600 0544–103


Internationalization

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
28700L* TXT2_STRT INTEGER TEXT2_STRT
28750L* COMPLEN INTEGER COMPARE_LEN
28800L* RLTN INTEGER RLTN
28850L* ORD_TYPE INTEGER ORD_TYPE
28900L*
28950LIBRARY PARAM VSNNUM 110V
29000LIBRARY PARAM TEXT1 RL
29050LIBRARY PARAM TXT1_STRT 110V
29100LIBRARY PARAM TEXT2 RL
29150LIBRARY PARAM TXT2_STRT 110V
29200LIBRARY PARAM COMPLEN 110V
29250LIBRARY PARAM RLTN 110V
29300LIBRARY PARAM ORD_TYPE 110V
29350L*
29400L******************************************************************
29450L*
29500LIBRARY SUBR VSNGETORD1 110 VSNGETORDERINGFOR_ONE_TEXT_STAR
29550L* ========== ===============================
29600L*
29650L* Parameter ALGOL Equivalent
29700L* --------- ----------------
29750L* VSNNUM INTEGER VSN_NUM
29800L* SOURCE EBCDIC ARRAY SOURCE [*]
29850L* INTEGER SOURCE_SIZE
29900L* SRC_STRT INTEGER SOURCE_START
29950L* ITEXTLEN INTEGER ITEXT_LEN
30000L* DEST EBCDIC ARRAY DEST [*]
30050L* INTEGER DEST_SIZE
30100L* DEST_STRT INTEGER DEST_START
30150L* MAXOSVS INTEGER MAX_OSVS
30200L* TOT_STRG INTEGER TOTAL_STORAGE
30250L* ORD_TYPE INTEGER ORD_TYPE
30300L*
30350LIBRARY PARAM VSNNUM 110V
30400LIBRARY PARAM SOURCE RL
30450LIBRARY PARAM SRC_STRT 110V
30500LIBRARY PARAM ITEXTLEN 110V
30550LIBRARY PARAM DEST RL
30600LIBRARY PARAM DEST_STRT 110V
30650LIBRARY PARAM MAXOSVS 110V
30700LIBRARY PARAM TOT_STRG 110V
30750LIBRARY PARAM ORD_TYPE 110V
30800L*
30805L******************************************************************
30810L*
30815LIBRARY SUBR MCPLANGS 110 MCP_BOUND_LANGUAGES_STAR
30820L* ======== ========================

Example 5–1. SYMBOL/INTL/RPG/PROPERTIES Library Specifications File (cont.)

8600 0544–103 5–27


Internationalization

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
30825L*
30830L* Parameter ALGOL Equivalent
30835L* --------- ----------------
30840L* TOTAL INTEGER TOTAL
30845L* LANGS_ARY EBCDIC ARRAY LANGUAGES_ARRAY [*]
30850L* INTEGER LANG_ARY_SIZE
30855L*
30860LIBRARY PARAM TOTAL 110
30865LIBRARY PARAM LANGS_ARY RL
30870L*
30875L******************************************************************
30880L*
30885LIBRARY SUBR VSNESCAPE 110 VSNESCAPEMENT_STAR
30890L* ========= ==================
30895L*
30900L* Parameter ALGOL Equivalent
30905L* --------- ----------------
30910L* VSNNUM INTEGER VSN_NUM
30915L* SOURCE EBCDIC ARRAY SOURCE [*]
30920L* INTEGER SOURCE_SIZE
30925L* SRC_STRT INTEGER SOURCE_START
30935L* DEST EBCDIC ARRAY DEST [*]
30940L* INTEGER DEST_SIZE
30950L* TRANSLEN INTEGER TRANS_LEN
30955L*
30960LIBRARY PARAM VSNNUM 110V
30965LIBRARY PARAM SOURCE RL
30970LIBRARY PARAM SRC_STRT 110V
30980LIBRARY PARAM DEST RL
30990LIBRARY PARAM TRANSLEN 110R
30995L*
40000L******************************************************************
40050L* CentralSupport Conventions procedures:
40100L*
40150L*
40200LIBRARY SUBR CNVLIST 110 CNV_NAMES_STAR
40250L* ======= ==============
40300L*
40350L* Parameter ALGOL Equivalent
40400L* --------- ----------------
40450L* TOTAL INTEGER TOTAL
40500L* NAMESARY EBCDIC ARRAY NAMES_ARY [*]
40550L* INTEGER NAMESARY_SIZE
40600L*
40650LIBRARY PARAM TOTAL 110R
40700LIBRARY PARAM NAMES_ARY RL

Example 5–1. SYMBOL/INTL/RPG/PROPERTIES Library Specifications File (cont.)

5–28 8600 0544–103


Internationalization

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
40750L*
40800L******************************************************************
40850L*
40900LIBRARY SUBR CNVTPLT 110 CNV_TEMPLATE_STAR
40950L* ======= =================
41000L*
41050L* Parameter ALGOL Equivalent
41100L* --------- ----------------
41150L* TYP INTEGER TYP
41200L* CNV_NAME EBCDIC ARRAY CNV_NAME [*]
41250L* INTEGER CNVNAME_SIZE
41300L* TPLT_LEN INTEGER TMP_LEN
41350L* TPLT_ARY EBCDIC ARRAY TMP_ARY [*]
41400L*
41450LIBRARY PARAM TYP 110V
41500LIBRARY PARAM CNV_NAME RL
41550LIBRARY PARAM TPLT_LEN 110R
41600LIBRARY PARAM TPLT_ARY RL
41650L*
41700L******************************************************************
41750L*
41800LIBRARY SUBR CNVFORMSIZ 110 CNV_FORMSIZE_STAR
41850L* ========== =================
41900L*
41950L* Parameter ALGOL Equivalent
42000L* --------- ----------------
42050L* CNV_NAME EBCDIC ARRAY CNV_NAME [*]
42100L* INTEGER CNVNAME_SIZE
42150L* LPP INTEGER LPP (LINES PER PAGE)
42200L* CPL INTEGER CPL (CHARACTERS PER LINE)
42250L*
42300LIBRARY PARAM CNV_NAME RL
42350LIBRARY PARAM LPP 110R
42400LIBRARY PARAM CPL 110R
42450L*
42500L******************************************************************
42550L*
42600LIBRARY SUBR CNVSYMBOLS 110 CNV_SYMBOLS_STAR
42650L* ========== ================
42700L*
42750L* Parameter ALGOL Equivalent
42800L* --------- ----------------
42850L* CNV_NAME EBCDIC ARRAY CNV_NAME [*]
42900L* INTEGER CNVNAME_SIZE
42950L* TOTAL INTEGER TOTAL
42960L* SYM_LRY INTEGER ARRAY SYMLEN_ARY [*]
42980L* INTEGER SYMLYN_SIZE

Example 5–1. SYMBOL/INTL/RPG/PROPERTIES Library Specifications File (cont.)

8600 0544–103 5–29


Internationalization

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
43000L* SYM_ARY EBCDIC ARRAY SYM_ARY [*]
43050L* INTEGER SYMARY_SIZE
43100L*
43150L*LIBRARY PARAM CNV_NAME RL
43200L*LIBRARY PARAM TOTAL 110R
43220L*LIBRARY PARAM SYM_LRY 110RL
43250L*LIBRARY PARAM SYM_ARY RL
43300L*
43350L*********************************************************************
43400L*
43450LIBRARY SUBR CNVDSPYMDL 110 CNV_DISPLAYMODEL_STAR
43500L* ========== =====================
43550L*
43600L* Parameter ALGOL Equivalent
43650L* --------- ----------------
43700L* TYP INTEGER TYP
43750l* CNV_NAME EBCDIC ARRAY CNV_NAME [*]
43800L INTEGER CNVNAME_SIZE *
43850L* LANG_NAME EBCDIC ARRAY LANG_NAME [*]
43900L* INTEGER LANGNAME_SIZE
43950L* DM_LEN INTEGER DM_LEN
44000L* DM_ARY EBCDIC ARRAY DM_ARY [*]
44050L* INTEGER DMARY_SIZE
44100L*
44150LIBRARY PARAM TYP 110V
44200LIBRARY PARAM CNV_NAME RL
44250LIBRARY PARAM LANG_NAME RL
44300LIBRARY PARAM DM_LEN 110R
44350LIBRARY PARAM DM_ARY RL
44400L*
44450L************************************************************************44
500L*
44550LIBRARY SUBR CNVDATTIM 110 CNV_SYSTEMDATETIME_STAR
44600L* ========= =======================
44650L*
44700L* Parameter ALGOL Equivalent
44750L* --------- ----------------
44800L* TYP INTEGER TYPE
44850L* CNV_NAME EBCDIC ARRAY CNV_NAME [*]
44900L* INTEGER CNVNAME_SIZE *
44950L* LANG_NAME EBCDIC ARRAY LANG_NAME [*]
45000L* INTEGER LANGNAME_SIZE
45050L* DATE_LEN INTEGER DATE_LEN (LENGTH OF DATE IN SDT_ARY)
45100L* SDT_LEN INTEGER SDT_LEN
45150L* SDT_ARY EBCDIC ARRARY SDT_ARY [*] (SYSTEM DATE/TIME ARRAY)
45200L* INTEGER SDTARY_SIZE
45250L*
45300LIBRARY PARAM TYPE 110V

Example 5–1. SYMBOL/INTL/RPG/PROPERTIES Library Specifications File (cont.)

5–30 8600 0544–103


Internationalization

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
45350LIBRARY PARAM CNV_NAME RL
45400LIBRARY PARAM LANG_NAME RL
45450LIBRARY PARAM DATE_LEN 110R
45500LIBRARY PARAM SDT_LEN 110R
45550LIBRARY PARAM SDT_ARY RL
45600L*
45650L************************************************************************
45700L*
45750LIBRARY SUBR TPLTDATTIM 110 CNV_SYSTEMDATETIMETMP_STAR
45800L* ========== ==========================
45850L*
45900L* Parameter ALGOL Equivalent
45950L* --------- ----------------
46000L* TPLT_ARY EBCDIC ARRAY TMP_ARY [*]
46050L* INTEGER TMPARY_SIZE
46100L* LANG_NAME EBCDIC ARRAY LANG_NAME [*]
46150L* INTEGER LANGNAME_SIZE
46200L* DTPLT_LEN INTEGER DTEMP_LEN (LENGTH OF DATE IN TPLT_ARY)
46250L* DATE_LEN INTEGER DATE_LEN (LENGTH OF DATE IN SDT_ARY)
46300L* SDT_LEN INTEGER SDT_LEN
46350L* SDT_ARY EBCDIC ARRARY SDT_ARY [*] (SYSTEM DATE/TIME ARRAY)
46400L* INTEGER SDTARY_SIZE
46450L*
46500LIBRARY PARAM TPLT_ARY RL
46550LIBRARY PARAM LANG_NAME RL
46600LIBRARY PARAM DTPLT_LEN 110R
46650LIBRARY PARAM DATE_LEN 110R
46700LIBRARY PARAM SDT_LEN 110R
46750LIBRARY PARAM SDT_ARY RL
46800L*
46850L*************************************************************************4
6900L*
46950LIBRARY SUBR CNVDATE 110 CNV_FORMATDATE_STAR
47000L ======= ===================
47050L*
47100L* Parameter ALGOL Equivalent
47150L* --------- ----------------
47200L* TYP INTEGER TYP
47250L* DATE_ARY EBCDIC ARRAY DATE_ARY [*]
47300L* INTEGER DATEARY_SIZE
47350L* CNV_NAME EBCDIC ARRAY CNV_NAME [*]
47400L* INTEGER CNVNAME_SIZE *
47450L* LANG_NAME EBCDIC ARRAY LANG_NAME [*]
47500L* INTEGER LANGNAME_SIZE
47550L* FD_LEN INTEGER FD_LEN (FORMATTED DATE_LENGTH)
47600L* FD_ARY EBCDIC ARRAY FD_ARY [*]
47650L* INTEGER FDARY_SIZE

Example 5–1. SYMBOL/INTL/RPG/PROPERTIES Library Specifications File (cont.)

8600 0544–103 5–31


Internationalization

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
47700L*
47750LIBRARY PARAM TYPE 110V
47800LIBRARY PARAM DATE_ARY RL
47850LIBRARY PARAM CNV_NAME RL
47900LIBRARY PARAM LANG_NAME RL
47950LIBRARY PARAM FD_LEN 11OR
48000LIBRARY PARAM FD_ARY RL
48050L*
48100L************************************************************************48
150L*
48200LIBRARY SUBR TPLTDATE 110 CNV_FORMATDATETMP_STAR
48250L* ======== ======================
48300L*
48350L* Parameter ALGOL Equivalent
48400L* --------- ----------------
48450L* DATE_ARY EBCDIC ARRAY DATE_ARY [*]
48500L* INTEGER DATEARY_SIZE
48550L* TPLT_ARY EBCDIC ARRAY TMP_ARY [*]
48600L* INTEGER TMPARY_SIZE
48650L* LANG_NAME EBCDIC ARRAY LANG_NAME [*]
48700L* INTEGER LANGNAME_SIZE
48750L* FD_LEN INTEGER FD_LEN (FORMATTED DATE LENGTH)
48800L* FD_ARY EBCDIC ARRAY FD_ARY [*]
48850L* INTEGER FDARY_SIZE
48900L*
48950LIBRARY PARAM DATE_ARY RL
49000LIBRARY PARAM TPLT_ARY RL
49050LIBRARY PARAM LANG_NAME RL
49100LIBRARY PARAM FD_LEN 110R
49150LIBRARY PARAM FD_ARY RL
49200L*
49250L******************************************************************
49300L*
49350LIBRARY SUBR CNVTIME 110 CNV_FORMATTIME_STAR
49400L* ======= ===================
49450L*
49500L* Parameter ALGOL Equivalent
49550L* --------- ----------------
49600L* TYP INTEGER TYP
49650L* TIME_ARY EBCDIC ARRAY TIME_ARY [*]
49700L* INTEGER TIMEARY_SIZE
49750L* CNV_NAME EBCDIC ARRAY CNV_NAME [*]
49800L* INTEGER CNVNAME_SIZE
49850L* LANG_NAME EBCDIC ARRAY LANG_NAME [*]
49900L* INTEGER LANGNAME_SIZE
49950L* FT_LEN INTEGER FT_LEN (FORMATTED TIME LENGTH)
50000L* FT_ARY EBCDIC ARRAY FT_ARY [*]
50050L* INTEGER FTARY_SIZE

Example 5–1. SYMBOL/INTL/RPG/PROPERTIES Library Specifications File (cont.)

5–32 8600 0544–103


Internationalization

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
50100L*
50150LIBRARY PARAM TYP 110V
50200LIBRARY PARAM TIME_ARY RL
50250LIBRARY PARAM CNV_NAME RL
50300LIBRARY PARAM LANG_NAME RL
50350LIBRARY PARAM FT_LEN 110R
50400LIBRARY PARAM FT_ARY RL
50450L*
50500L******************************************************************
50550L*
50600LIBRARY SUBR TPLTTIME 110 CNV_FORMATTIMETMP_STAR
50650L* ======== ======================
50700L*
50750L* Parameter ALGOL Equivalent
50800L* --------- ----------------
50850L* TIME_ARY EBCDIC ARRAY TIME_ARY [*]
50900L* INTEGER TIMEARY_SIZE
50950L* TPLT_ARY EBCDIC ARRAY TMP_ARY [*]
51000L* INTEGER TMPARY_SIZE
51050L* LANG_NAME EBCDIC ARRAY LANG_NAME [*]
51100L* INTEGER LANGNAME_ARY
51150L* FT_LEN INTEGER FT_LEN (FORMATTED TIME LENGTH)
51200L* FT_ARY EBCDIC ARRAY FT_ARY [*]
51250L* INTEGER FTARY_SIZE
51300L*
51350LIBRARY PARAM TIME_ARY RL
51400LIBRARY PARAM TPLT_ARY RL
51450LIBRARY PARAM LANG_NAME RL
51500LIBRARY PARAM FT_LEN 110R
51550LIBRARY PARAM FT_ARY RL
51600L*
51650L******************************************************************
51700L*
51750LIBRARY SUBR CNVCURNCY 110 CNV_CURRENCYEDIT_RPG
51800L* ========= ====================
51850L*
51900L* Parameter ALGOL Equivalent
51950L* --------- ----------------
52000L* AMT INTEGER AMT
52050L* PRECISN INTEGER PRECISION
52100L* CNV_NAME EBCDIC ARRAY CNV_NAME [*]
52150L* INTEGER CNVNAME_SIZE
52200L* CE_LEN INTEGER CE_LEN (EDITTED CURRENCY VALUE LENGTH)
52250L* CE_ARY EBCDIC ARRAY CE_ARY [*]
52300L* INTEGER CEARY_SIZE

Example 5–1. SYMBOL/INTL/RPG/PROPERTIES Library Specifications File (cont.)

8600 0544–103 5–33


Internationalization

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
52350L*
52400LIBRARY PARAM AMT 110R
52450LIBRARY PARAM PRECSN 110V
52500LIBRARY PARAM CNV_NAME RL
52550LIBRARY PARAM CE_LEN 110R
52600LIBRARY PARAM CE_ARY RL
52650L*
52700L******************************************************************
53850L*
53900LIBRARY SUBR CNVNAME 110 CNV_VALIDATENAME_STAR
53950L* ======= =====================
54000L*
54050L* Parameter ALGOL Equivalent
54100L* --------- ----------------
54150L* CNV_NAME EBCDIC ARRAY CNV_NAME [*]
54200L* INTEGER CNVNAME_SIZE
54250L*
54300LIBRARY PARAM CNV_NAME RL
54350L*

Example 5–1. SYMBOL/INTL/RPG/PROPERTIES Library Specifications File

Procedure Descriptions
The following pages describe the internationalization procedures accessible from an RPG
program. The procedures reside in the CENTRALSUPPORT library.

Each description includes a general overview of the procedure, an example showing how
to call the procedure, the output produced by the procedure and an explanation of the
parameters used in the example. Not all parameters used to produce the output will be
displayed in the output.

CCSTRANTXT
The CCSTRANTXT procedure translates text from the coded character set specified in
the first parameter to the coded character set specified in the second parameter by using
a translate table. Characters are translated using a one-to-one mapping between two
coded character sets.

For example, you might want to translate text from the LATIN1 EBCDIC coded character
set to the LATIN1 ISO coded character set. Refer to the MLS Guide for a list of the
character set numbers that are available as inputs to this procedure.

Although there are many coded character set numbers, there is not a mapping table
between every combination of coded character sets. The procedure returns an error
indicating the data was not found if you pass two valid coded character set numbers for a
table that does not exist.

5–34 8600 0544–103


Internationalization

Refer to the MLS Guide for a list of the coded character set numbers and the mapping
table available as inputs to this procedure.

Example
Example 5–2 shows the parameter declarations and the specifications required to call the
CCSTRANTXT library procedure. Each of the parameters is explained in the text following
the example.

This example takes the input string “pa¤uelo,” which is encoded in the Latin1EBCDIC
coded character set, and translates it to the Latin1ISO coded character set. The string
“pa¤uelo” is represented by the following hexadecimal codes in Latin1EBCDIC:
978149A4859396. In Latin1ISO, the hexadecimal codes are 83969586519985958385.
You can use the MLS Guide to determine that the coded character set number for
Latin1EBCDIC is 12 and Latin1ISO is 13. You can also retrieve these numbers by calling
the procedure CCSVSNNUM with the coded character set names.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
01000FPRINT O DISK
01500A TITLE 'OUT/RPG/CCSTRANTXT'
05000$$ INCLUDE "SYMBOL/INTL/RPG/PROPERTIES"
18000C Z-ADD12 CCSFRM 110
20000C Z-ADD13 CCSTO 110
22000C*
24000C Z-ADD0 STRTS 110
26000C Z-ADD0 STRTD 110
28000C Z-ADD7 TLEN 110
28200C*
28300C MOVEL'pa¤uelo' SOURCE 10
30000C*
32000C EEXSRCCSTRANTXTRSLT 110
34000C PARAMCCSFRM
36000C PARAMCCSTO
38000C PARAM SOURCE
40000C PARAMSTRTS
42000C PARAM DEST 10
44000C PARAMSTRTD
46000C PARAMTLEN
48000C*
48500C EXCPT
48600C* If RSLT contains the value 1, DEST should contain the following
48800C* hex codes "7061F175656C6F"
49000C*
62000C SETON LR
64000OPRINT E
66000O 'RESULT = '
68000O RSLT 3

Example 5–2. Coding for the CCSTRANTXT Procedure

8600 0544–103 5–35


Internationalization

Explanation
CCSFRM is a numeric field passed to the procedure. It contains the number of the coded
character set from which you are translating.

CCSTO is a numeric field passed to the procedure. It contains the number of the coded
character set to which you are translating the text.

SOURCE is an alphanumeric array passed to the procedure. It contains the text to


translate. The recommended array size for SOURCE is determined by the caller.

STRTS is a numeric field passed to the procedure. It contains the byte offset, relative to
0 (zero), in SOURCE where the translation starts.

DEST is an alphanumeric array returned by the procedure. It contains the translated text.
The recommended array size for DEST is the same as the size for SOURCE.

STRTD is a numeric field passed to the procedure. It contains the byte offset in DEST,
relative to 0 (zero), where the translated text is to be placed.

TLEN is a numeric field passed to the procedure. It specifies the number of characters in
SOURCE to be translated, beginning at STRTS.

RSLT is a numeric field returned as the value of the procedure. It indicates whether an
error occurred during the execution of the procedure. An explanation of the error result
values can be found under “Errors” at the end of this section. You should check the
value of the procedure result whenever you use this procedure.

Possible values returned by the CCSTRANTXT procedure are as follows:

1 1000 3000 4002

1001 3001

1002 3003

Output
Sample output from Example 5–2 follows:

RESULT = 1
DEST-TEXT = pa¤uelo

5–36 8600 0544–103


Internationalization

See Also
For more information on the error result values, see Table 5–3 later in this section.

CCSVSNLIST
This procedure returns a list of the coded character set names and numbers or a list of
the ccsversion names and numbers that are available on your system. You specify which
list you want with the first parameter to the procedure. The names and numbers are
listed in two arrays. These arrays are ordered so that the names in the names array
correspond to the numbers in the numbers array.

You might use this procedure to create a menu that lists the ccsversions from which a
user can choose. You might also use this procedure to verify that the ccsversion to be
used by your program is available on the host computer.

Example
Example 5–3 shows the parameter declarations and the specifications required to call the
CCSVSNLIST procedure. Each of the parameters is explained in the text following the
example.

This example returns a list of available ccsversion names and numbers on a system. This
is an arbitrary list of ccsversions and might not be the same on every system.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00200F* THIS PROGRAM TESTS THE CCSVSNLIST PROCEDURE. ALL THE CCSVERSION
00400F* NAMES AND NUMBERS ARE PRINTED IN FILE FILE1.
01000FFILE1 O DISK
01500A TITLE 'OUT/RPG/CCSVSNLIST'
02000E NAMS 20 17
04000E NUMS 20 11 0
06000$$INCLUDE "SYMBOL/INTL/RPG/PROPERTIES"
08000C Z-ADD1 CCSVSN 110
10000C*
12000C EEXSRCCSVSNLISTRSLT 110
14000C PARAMCCSVSN
16000C PARAM TOTAL 110
18000C PARAM NAMS
20000C PARAM NUMS
20500C*
21000C EXCPTHEAD
22000C*
24000C RSLT IFEQ 1
26000C 1 DO TOTAL I 110
28000C EXCPT
30000C END DO
32000C END IF

Example 5–3. Coding for the CCSVSNLIST Procedure (cont.)

8600 0544–103 5–37


Internationalization

34000C*
36000C SETON LR
36200OFILE1 E HEAD
36400O 'RESULT = '
36600O RSLT 3
36650OFILE1 E HEAD
36700O ' '
36800OFILE1 E HEAD
37000O 20 'CCSVERSION NAME'
37200O 45 'CCSVERSION NUMBER'
37400OFILE1 E HEAD
37600O 20 '---------------'
37800O 45 '-----------------'
38000OFILE1 E
42000O NAMS,I 22
44000O NUMS,I3 37

Example 5–3. Coding for the CCSVSNLIST Procedure

Explanation
CCSVSN is a numeric field passed to the procedure. It allows you to specify either of the
following two types of information to be returned in the output parameters:

Value Meaning

0 Coded character set names and numbers

1 Ccsversion names and numbers

In the above example, the names and numbers of the ccsversions are requested.

TOTAL is a numeric field returned by the procedure. It contains the number of coded
character set or ccsversion entries that exist.

NAMS is an alphanumeric array returned by the procedure. Each entry contains the name
of a coded character set or ccsversion defined in the file SYSTEM/CCSFILE. Each name
uses one element of NAMS and is 17 characters long. The MLS Guide also lists all the
coded character sets and ccsversions. The recommended array size is 340 characters.

NUMS is a numeric array returned by the procedure. NUMS contains all the coded
character set or ccsversion numbers defined in the file SYSTEM/CCSFILE. Each number
uses one element of NUMS. Each element in NUMS corresponds to a parallel entry in
NAMS. The recommended array size for NUMS is 20 words. The MLS Guide also
provides all the numbers for the coded character sets and ccsversions.

RSLT is a numeric field returned as the value of the procedure. It indicates whether an
error occurred in the CCSVSNLIST procedure. Any values other than 1 indicate an error.

5–38 8600 0544–103


Internationalization

An explanation of the error result values can be found under “Errors” at the end of this
section. You should check the procedure result whenever you use this procedure.

Possible values returned by the CCSVSNLIST procedure are as follows:

1 1001 3000

3001

3006

Output
Sample output from Example 5–3 follows:

RESULT = 1

CCSVERSION NAME CCSVERSION NUMBER


--------------- -----------------
ASERIESNATIVE 0
SWISS 64
SWEDISH1 99
SPANISH 98
CANADAEBCDIC 74
CANADAGP 75
FRANCE 35
NORWAY 71

See Also
For more information on the error result values, see Table 5–3 later in this section.

CCSVSNNAME
This procedure examines the number of a coded character set or ccsversion to
determine if it resides in the file SYSTEM/CCSFILE. The first parameter designates
whether a coded character set or ccsversion is to be examined. The second parameter
specifies the number to be validated. The procedure returns the name of the given coded
character set or ccsversion number. If you supply the value –2 in the NUM parameter
when you are checking a ccsversion, the procedure checks the name of the system
default ccsversion. Refer to the MLS Guide for the list of numbers for coded character
sets and ccsversions.

As an example, you can use this procedure to display the name of the coded character
set or the ccsversion being used.

Example
Example 5–4 shows the parameter declarations and the specifications required to call the
CCSVSNNAME procedure. Each of the parameters is explained in the text following the
example.

8600 0544–103 5–39


Internationalization

This example checks to see if the ccsversion number 75 is valid. Assume for this
example that 75 is valid and its associated name is CanadaGP.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00200F* THIS PROGRAM TESTS THE CCSVSNNAME PROCEDURE.
01000FFILE1 O DISK
01500A TITLE 'OUT/RPG/CCSVSNNAME'
02000E NAMARY 1 17
06000$$INCLUDE "SYMBOL/INTL/RPG/PROPERTIES"
08000C Z-ADD1 CCSVSN 110
09000C Z-ADD75 NUM 110
10000C*
12000C EEXSRCCSVSNNAMERSLT 110
14000C PARAMCCSVSN
16000C PARAMNUM
18000C PARAM NAMARY
20500C*
21000C EXCPTHEAD
22000C RSLT IFEQ 1
24000C EXCPT
26000C END
34000C*
36000C SETON LR
36200OFILE1 E HEAD
36220O RSLT 3
36400O 9 'RESULT = '
36800OFILE1 E
37000O 'NAME = '
37200O NAMARY

Example 5–4. Coding for the CCSVSNNAME Procedure

Explanation
CCSVSN is a numeric field passed to the procedure. It enables you to specify either of
the following two values to be returned in output parameters:

Value Meaning

0 Coded character set name

1 Ccsversion name

In Example 5–4, a ccsversion name is requested. MOVEL initializes the ccsversion name
CANADAGP and left justifies it.

NUM is a numeric field passed to the procedure. It contains the number of the coded
character set or ccsversion for which the name is being requested. The ccsversion
number 75 is being requested in Example 5–4. A value of –2 indicates that the system
default ccsversion number is examined. Refer to the MLS Guide for more information on
ccsversions.

5–40 8600 0544–103


Internationalization

NAMARY is an alphanumeric array returned by the procedure. It contains the coded


character set or ccsversion name. The maximum length of a name is 17 characters.

RSLT is a numeric field returned as the value of the procedure. It indicates whether an
error occurred in the CCSVSNNAME procedure. Any value other than 1 indicates an
error. An explanation of the error result values can be found under “Errors” at the end of
this section. You should check the value of the procedure result whenever you use this
procedure.

Possible values returned by the CCSVSNNAME procedure are as follows:

1 1001 3000 3006

1002 3001

1002 3003

Output
Sample output from Example 5–4 follows:

RESULT = 1
NAME = CANADAGP

See Also
For more information on the error result values, see Table 5–3 later in this section.

CCSVSNNUM
This procedure examines a coded character set or ccsversion name to determine if it
resides in the file SYSTEM/CCSFILE. The first parameter specifies whether you want to
examine a coded character set or ccsversion. The next parameter specifies the name to
be validated. The procedure returns the number of the coded character set or ccsversion
in the last parameter.

You might use this procedure to obtain the ccsversion number needed as a parameter to
other CENTRALSUPPORT library procedures.

Example
Example 5–5 shows the parameter declarations and the specifications required to call the
CCSVSNNUM procedure. Each of the parameters is explained in the text following the
example.

8600 0544–103 5–41


Internationalization

This example checks to see if a ccsversion named CanadaGP is valid. Assume for this
example that CanadaGP is valid and its associated number is 75.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00200F* THIS PROGRAM TESTS THE CCSVSNNUM PROCEDURE.
01000FFILE1 O DISK
01500A TITLE 'OUT/RPG/CCSVSNNUM'
02000E NAMARY 1 17
06000$$INCLUDE "SYMBOL/INTL/RPG/PROPERTIES"
08000C Z-ADD1 CCSVSN 110
09000C MOVEL'CANADAGP'NAMARY
10000C*
12000C EEXSRCCSVSNNUM RSLT 110
14000C PARAMCCSVSN
16000C PARAM NAMARY
18000C PARAM NUM 110
20500C*
21000C EXCPTHEAD
22000C RSLT IFEQ 1
24000C EXCPT
26000C END
34000C*
36000C SETON LR
36200OFILE1 E HEAD
36400O 'RESULT = '
36600O RSLT 3
36800OFILE1 E
37000O 'NUM = '
37200O NUM 3

Example 5–5. Coding for the CCSVSNNUM Procedure

Explanation
CCSVSN is a numeric field passed to the procedure. It enables you to specify either of
the following two values to be returned in the output parameters:

Value Meaning

0 Coded character set number

1 Ccsversion number

In Example 5–5, a ccsversion number is to be examined.

NAMARY is an alphanumeric array passed to the procedure that contains the coded
character set or ccsversion name for which a number is being requested. The name can
be up to 17 characters long. If this parameter contains zeros or blanks and type is equal
to 1, the procedure validates the system default ccsversion.

5–42 8600 0544–103


Internationalization

NUM is a numeric field returned by the procedure that contains the specified coded
character set or ccsversion number. The value –2 indicates that the system default
ccsversion is being validated.

RSLT is a numeric field returned by the procedure that indicates whether an error
occurred during the execution of the procedure. The meanings of the result values are
explained under “Errors” at the end of this section. You should check the value of the
procedure result whenever you use this procedure.

Possible values returned by the CCSVSNNUM procedure are as follows:

1 1001 3000 3004

1002 3002 3006

Output
Sample output from Example 5–5 follows:

RESULT = 1
NUM = 75

See Also
For more information on the error result values, see Table 5–3 later in this section.

CENTSTATUS
The CENTSTATUS procedure returns the name and number of the system default
ccsversion, the name of the system default language, and the name of the system
default convention.

You might use this procedure to provide a means for your application users to inquire
about the default settings on the host computer.

Example
Example 5–6 shows the parameter declarations and the specifications required to call the
CENTSTATUS procedure. Each of the parameters is explained in the text following the
example.

This example returns the current values for the system default ccsversion, language, and
convention. These are arbitrary system values and might not be the same on every
system.

8600 0544–103 5–43


Internationalization

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00200F* THIS PROGRAM TESTS THE CENTSTATUS PROCEDURE. THE CURRENT
00400F* CCSVERSION, LANGUAGE, AND CONVENTION ARE PRINTED IN FILE FILE1.
01000FFILE1 O DISK
01500A TITLE 'OUT/RPG/CENTSTATUS'
02000E CNTL 8 11 0
06000$$INCLUDE "SYMBOL/INTL/RPG/PROPERTIES"
07000ISYSINF DS
08000I 1 17 VSNNAM
09000I 18 34 LNGNAM
10000I 35 51 CNVNAM
12000C EEXSRCENTSTATUSRSLT 110
14000C PARAM SYSINF
16000C PARAM CNTL
18000C*
20000C EXCPTHEAD1
22000C*
24000C RSLT IFEQ 1
25000C EXCPTSYSGP
26000C EXCPTHEAD2
28000C EXCPTCNTLGP
32000C END IF
34000C*
36000C SETON LR
36020OFILE1 E HEAD1
36040O 'RESULT = '
36060O RSLT 3
36065OFILE1 E HEAD1
36070O ' '
36080OFILE1 E HEAD1
36100O 'SYSTEM DEFAULTS'
36120OFILE1 E HEAD1
36140O '---------------'
36200OFILE1 E SYSGP
36400O 'CCSVERSION:'
36600O VSNNAM 30
36700OFILE1 E SYSGP
36800O 'LANGUAGE:'
37000O LNGNAM 30
37100OFILE1 E SYSGP
37200O 'CONVENTION:'
37400O CNVNAM 30
37420OFILE1 E HEAD2
37440O ' '
37450OFILE1 E HEAD2
37500O 'CONTROL ARRAY'
37550OFILE1 E HEAD2
37600O 'FIELD MEANING'

Example 5–6. Coding for the CENTSTATUS Procedure (cont.)

5–44 8600 0544–103


Internationalization

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
37650O 50 'LOCATION'
37700O 64 'VALUE'
37750OFILE1 E HEAD2
37800O '-------------'
37850O 50 '--------'
37900O 64 '-----'
38000OFILE1 E CNTLGP
38500O 'SYSTEM DEFAULT '
39000O 'CCSVERSION NUMBER'
40000O CNTL,13 62
42000O 47 '1'

Example 5–6. Coding for the CENTSTATUS Procedure

Explanation
SYSINF is an alphanumeric field returned by the procedure. It contains three items, each
17 characters long, in the following order:

1. System default ccsversion name


2. System default language name
3. System default convention name
Names shorter than 17 characters are padded on the right with blanks. The
recommended field size is 51 characters.

CNTL is an alphanumeric array returned by the procedure. It should be one word long. It
contains the following information:

Location Information

CNTL,1 System default ccsversion number

CNTL,2 through Reserved


CNTL,8

The recommended array size for CNTL is 8 words.

RSLT is a numeric field returned by the procedure. It indicates whether an error occurred
during the execution of the procedure. Any values other than 1 indicate an error. An
explanation of the error result values can be found under “Errors” at the end of this
section. You should check the value of the procedure result whenever you use this
procedure.

8600 0544–103 5–45


Internationalization

Possible values returned by the CENTSTATUS procedure are as follows:

1 1001 3000

1002 3001

Output
Sample output from Example 5–6 follows:

RESULT = 1

SYSTEM DEFAULTS
---------------
CCSVERSION: ASERIESNATIVE
LANGUAGE: ENGLISH
CONVENTION: ASERIESNATIVE

CONTROL ARRAY
FIELD MEANING LOCATION VALUE
------------- -------- -----
SYSTEM DEFAULT CCSVERSION NUMBER 1 0

See Also
For more information on the error result values, see Table 5–3 later in this section.

CNVCURNCY
The CNVCURNCY procedure receives a monetary value and formats it to an edited
monetary value. The procedure uses the monetary template of the convention you
specify to accomplish the editing.

The MLS Guide describes all the conventions and the type of currency editing associated
with each convention.

You might want to print a report with the numeric and currency formats for the Costa
Rica conventions (for example, CRC 89.99), or for the Norway conventions (for example,
NKR 89.99).

Example
Example 5–7 shows the parameter declarations and the specifications required to call the
CNVCURNCY library procedure. Each of the parameters is explained in the text following
the example.

This example converts a real number and edits monetary symbols from convention
Denmark into an EBCDIC string.

5–46 8600 0544–103


Internationalization

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00100E CEARY 1100
00200$$INCLUDE "SYMBOL/INTL/RPG/PROPERTIES"
00110IINFODS DS
00120I 1 51 SYSINF
00130I 1 17 VSNNAM
00140I 18 34 LNGNAM
00150I 35 51 CNVNAM
00900C EEXSRCNVCURNCY RSLT 110
01000C PARAMAMT
01100C PARAMPRECISN
01200C PARAM CNVNAM
01300C PARAM CELEN 110
01400C PARAM CEARY

Example 5–7. Coding for the CNVCURNCY Procedure

Explanation
AMT is a numeric field passed to the procedure. It contains the monetary value to be
formatted.

PRECISN is a numeric field that specifies the number of digits in AMT to be placed after
the decimal symbol. The value of PRECISN ranges from 0 (zero) through 9.

CNVNAM is an alphanumeric field passed to the procedure. It contains the name of the
convention to be used to format the monetary value. If this parameter contains all blanks
or zeros, the procedure will use the hierarchy to determine the convention to be used.
Refer to the MLS Guide for the list of convention names and the explanation of the
hierarchy.

CELEN is a numeric field returned by the procedure. It contains the length of the
formatted integer value CEARY.

CEARY is an alphanumeric array returned by the procedure. It contains the value of the
formatted integer. The recommended array size for CEARY is 20 characters.

RSLT is a numeric field returned as the procedure result. It indicates whether an error
occurred during the execution of the procedure. Any value other than 1 indicates an
error. An explanation of the error result values can be found under “Errors” at the end of
this section. You should check the value of the procedure result whenever you use this
procedure.

Possible values returned by the CNVCURNCY procedure are as follows:

1 1001 2002 3000

1002 3002

8600 0544–103 5–47


Internationalization

Output
Sample output from Example 5–7 follows:

RESULT = 1
CEARY = Kr.12 345,67

See Also
For more information on the error result values, see Table 5–3 later in this section.

CNVDATE
The CNVDATE procedure receives a date and formats it using the convention and
language you have specified.

You might use this procedure to output a date according to the Greek long-date format
and Greek language, for example.

Example
Example 5–8 shows the parameter declarations and the specifications required to call the
CNVDATE library procedure. Each of the parameters is explained in the text following the
example.

This example formats the date in numeric form using the ASeriesNative convention. The
system default language is specified.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00200F* THIS PROGRAM TESTS THE CNVDATE PROCEDURE. IT FORMATS A DATE IN
00400F* NUMERIC FORM USING NETHERLANDS CONVENTION. THE SYSTEM DEFAULT
00600F* LANGUAGE IS SPECIFIED.
01000FFILE1 O DISK
01500A TITLE 'OUT/RPG/CNVDATE'
06000$$INCLUDE "SYMBOL/INTL/RPG/PROPERTIES"
06500ICNVNAM DS
07000I 1 8 CNVSTR
07500I 9 16 CNVMID
08000I 17 17 CNVEND
10000C*
10200C Z-ADD2 TYPE 110 NUMERIC DATE
10500C MOVE '17760704'DATARY 8
10600C MOVE 'NETHERLA'CNVSTR
10800C MOVE 'NDS 'CNVMID
11000C MOVE ' ' CNVEND
11200C*

Example 5–8. Coding for the CNVDATE Procedure (cont.)

5–48 8600 0544–103


Internationalization

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
12000C EEXSRCNVDATE RSLT 110
16000C PARAMTYPE
17000C PARAM DATARY
18000C PARAM CNVNAM
18500C PARAM LNGNAM 17
19000C PARAM FDLEN 110
20000C PARAM FDARY 10
20500C*
21000C EXCPTHEAD
22000C*
24000C RSLT IFEQ 1
28000C EXCPT
32000C END
34000C*
36000C SETON LR
36200OFILE1 E HEAD
36400O 'RESULT = '
36600O RSLT 3
36650OFILE1 E HEAD
36700O ' '
36800OFILE1 E
37000O 'FDARY = '
37600O FDARY

Example 5–8. Coding for the CNVDATE Procedure

Explanation
TYPE is a numeric field that is passed to the procedure. The value in TYPE determines
which of the following three formats will be used to format the date:

Value Meaning

0 Long date format

1 Short date format

2 Numeric date format

Example 5–8 requests the numeric date format.

DATARY is an alphanumeric array passed to the procedure. It contains the date to be


formatted. The date must be in the form YYYYMMDD, left-justified. The array has fixed
positions. You must use blanks or zeros in any fields that you omit. The date requested in
Example 5–8 is 17760704 (July 4, 1776).

CNVNAM is an alphanumeric array passed to the procedure. It contains the name of the
convention to be used to edit the date value. If this parameter contains all blanks or 17
character zeros, the procedure uses the hierarchy to determine the convention to be
used. Refer to the MLS Guide for the list of convention names and the explanation of the
hierarchy.

8600 0544–103 5–49


Internationalization

LNGNAM is an alphanumeric array passed to the procedure. It contains the language to


be used to format the date. If this parameter contains all blanks or 17 character zeros,
the procedure uses the hierarchy to determine the language to be used. Refer to the
MLS Guide for information about determining the valid language names on your system
and the explanation of the hierarchy. Example 5–8 requests the Netherlands language.

FDLEN is a numeric field returned by the procedure. It contains the length of the
formatted date.

FDARY is an alphanumeric array returned by the procedure. It contains the formatted


date. The recommended length of the formatted date is 45 characters.

RSLT is a numeric field returned as the procedure result. It indicates whether an error
occurred during the execution of the procedure. Values other than 1 indicate an error. An
explanation of the error result values can be found under “Errors” at the end of this
section. You should check the value of the procedure result whenever you use this
procedure.

Possible values returned by the CNVDATE procedure are as follows:

1 1001 2001 3000 3012 3048

2002 3001 3045 3059

3002 3046

3006 3047

Output
Sample output from Example 5–8 follows:

RESULT = 1

FDARY = 4.7.76

See Also
For more information on the error result values, see Table 5–3 later in this section.

5–50 8600 0544–103


Internationalization

CNVDATTIM
This procedure formats the system-provided date, the time, or both according to the
template retrieved from the specified convention. It translates the date and time
components to the specified natural language. The system computes both the date and
time from the result of a single function call. Thus, the possibility that the date and time
are split across midnight does not exist.

You might use this procedure to output the system date, the time, or both in the Spain
convention and the Spanish language, for example.

Example
Example 5–9 shows the parameter declarations and the specifications required to call the
CNVDATTIM library procedure. Each of the parameters is explained in the text following
the example.

This example formats system date and time according to formatting definitions in
ASeriesNative convention. The form of date and time is specified by TYPE (long date
format). The formatted date is translated to English and returned in SDTARY.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00200F* THIS PROGRAM TESTS THE CNVDATTIM PROCEDURE.
01000FFILE1 O DISK
01500A TITLE 'OUT/RPG/CNVDATTIM'
06000$$INCLUDE "SYMBOL/INTL/RPG/PROPERTIES"
06500ICNVNAM DS
07000I 1 8 CNVSTR
07500I 9 16 CNVMID
08000I 17 17 CNVEND
10000C*
10200C Z-ADD6 TYPE 110 LNG DATE NUM
10400C MOVEL'ENGLISH' LNGNAM 17
10600C MOVE 'ASERIESN'CNVSTR
10800C MOVE 'ATIVE 'CNVMID
11000C MOVE ' ' CNVEND
11200C*
12000C EEXSRCNVDATTIM RSLT 110
16000C PARAMTYPE
18000C PARAM CNVNAM
18500C PARAM LNGNAM
19000C PARAM DATLEN 110
19500C PARAM SDTLEN 110
20000C PARAM SDTARY 60
20500C*
21000C EXCPTHEAD
22000C*

Example 5–9. Coding for the CNVDATTIM Procedure

8600 0544–103 5–51


Internationalization

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
24000C RSLT IFEQ 1
28000C EXCPT
32000C END
34000C*
36000C SETON LR
36200OFILE1 E HEAD
36400O 'RESULT = '
36600O RSLT 3
36650OFILE1 E HEAD
36700O ' '
36800OFILE1 E
37000O 'SDTARY = '
37600O SDTARY

Example 5–9. Coding for the CNVDATTIM Procedure

Explanation
TYPE is a numeric field passed to the procedure that indicates which of the following
date and time formats is used when the information is returned:

Value Meaning

0 Long date format

1 Short date format

2 Numeric date format

3 Long time format

4 Numeric time format

5 Long date and long time

6 Long date and numeric time

7 Short date and long time

8 Short date and numeric time

9 Numeric date and long time

10 Numeric date and numeric time

The format requested in Example 5–9 is the long date format.

CNVNAM is an alphanumeric field passed to the procedure. It contains the name of the
convention to be used to edit the date and time value. If this parameter contains all
blanks or 17 character zeros, the procedure will use the hierarchy to determine the
convention to be used. Refer to the MLS Guide for the list of convention names and the
explanation of the hierarchy. Example 5–9 requests the ASeriesNative convention.

5–52 8600 0544–103


Internationalization

LNGNAM is an alphanumeric field passed to the procedure. LNGNAM contains the


language to be used to format the date and time value. If this parameter contains all
blanks or 17 character zeros, the procedure uses the hierarchy to determine the language
to be used. Refer to the MLS Guide for information about determining the valid language
names on your system and the explanation of the hierarchy. Example 5–9 requests the
English language.

DATLEN is a numeric field returned by the procedure. It contains the length of the
formatted date portion of the date and time. If this parameter is 0 (zero), there is no
formatted date in the output.

SDTLEN is a numeric field returned by the procedure that contains the length of the
formatted date, the time, or both. Use the expression SDTLEN-DATLEN to determine the
length of the formatted time in the output array.

SDTARY is an alphanumeric array returned by the procedure that contains the formatted
date, the formatted time, or both.

RSLT is a numeric field returned as the procedure result. It indicates whether an error
occurred during the execution of the procedure. Values other than 1 indicate an error. An
explanation of the error result values can be found under “Errors” at the end of this
section. You should check the value of the procedure result whenever you use this
procedure.

Possible values returned by the CNVDATTIM procedure are as follows:

1 1001 2001 3000 3046 3053

1002 2002 3001 3047 3054

2004 3006 3048 3055

3011 3051

3045 3052

Output
Sample output from Example 5–9 follows:

RESULT = 1

SDTARY = Friday, November 30, 1990 10:44:51

See Also
For more information on the error result values, see Table 5–3 later in this section.

8600 0544–103 5–53


Internationalization

CNVDSPYMDL
This procedure returns a either a numeric date or numeric time display model. A display
model is a format that you can display to the user to show the form of the requested
input. For example, YYDDMM is a display model that shows a user that the date must be
entered in that form. The procedure creates the display model according to the
convention and language that you specify.

Example
Example 5–10 shows the parameter declarations and the specifications required to call
the CNVDSPYMDL library procedure. Each of the parameters is explained in the text
following the example.

This example obtains a date display model from the ASeriesNative convention. The
display model is translated to English and returned in DMARY.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00200F* THIS PROGRAM TESTS THE CNVDSPYMDL PROCEDURE.
01000FFILE1 O DISK
01500A TITLE 'OUT/RPG/CNVDSPYMDL'
06000$$INCLUDE "SYMBOL/INTL/RPG/PROPERTIES"
06500ICNVNAM DS
07000I 1 8 CNVSTR
07500I 9 16 CNVMID
08000I 17 17 CNVEND
10200C Z-ADD0 TYPE 110
10500C MOVE 'ASERIESN'CNVSTR
10600C MOVE 'ATIVE 'CNVMID
10700C MOVE ' ' CNVEND
10800C MOVEL'ENGLISH' LNGNAM 17
11000C*
12000C EEXSRCNVDSPYMDLRSLT 110
14000C PARAMTYPE
16000C PARAM CNVNAM
17000C PARAM LNGNAM
18000C PARAM DMLEN 110
19000C PARAM DMARY 10
20500C*
21000C EXCPTHEAD
22000C*
24000C RSLT IFEQ 1
26000C EXCPT

Example 5–10. Coding for the CNVDSPYMDL Procedure (cont.)

5–54 8600 0544–103


Internationalization

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
28000C END
34000C*
36000C SETON LR
36200OFILE1 E HEAD
36400O 'RESULT = '
36600O RSLT 3
38000OFILE1 E HEAD
40000O ' '
42000OFILE1 E
44000O 'DMARY = '
46000O DMARY

Example 5–10. Coding for the CNVDSPYMDL Procedure

Explanation
TYPE is a numeric field passed to the procedure. It indicates whether you want the
display model to be a numeric date or a numeric time, as follows:

Value Meaning

0 Indicates that the display model will be a numeric date

1 Indicates that the display model will be a numeric time

Example 5–10 requests a numeric date display model.

CNVNAM is an alphanumeric field passed to the procedure. It contains the name of the
convention from which the date or time model is retrieved. If this parameter contains all
blanks or zeros, the procedure will use the hierarchy to determine the convention to be
used. Refer to the MLS Guide for the list of convention names and the explanation of the
hierarchy. Example 5–10 requests the ASeriesNative convention.

LNGNAM is an alphanumeric field passed to the procedure. It contains the name of the
language in which the date or time components are to be displayed. The language in
Example 5–10 is English. If this parameter contains all blanks or zeros, the procedure
uses the hierarchy to determine the language to be used. Refer to the MLS Guide for
information about determining the valid language names on your system and the
explanation of the hierarchy.

DMLEN is a numeric field returned by the procedure that contains the length of data in
DMARY.

DMARY is an alphanumeric array returned by the procedure. It contains the display


model. The recommended array size for DMARY is 10 characters.

RSLT is a numeric field returned as the procedure result. It indicates whether an error
occurred during the execution of the procedure. Values other than 1 indicate an error. An

8600 0544–103 5–55


Internationalization

explanation of the error result values can be found under “Errors” at the end of this
section. You should check the value of the procedure result whenever you use this
procedure.

Possible values returned by the CNVDSPYMDL procedure are as follows:

1 1001 2001 3000

1002 2002 3001

3002

3006

Output
Sample output from Example 5–10 follows:

RESULT = 1

DMARY = mm/dd/yyyy

See Also
For more information on the error result values, see Table 5–3 later in this section.

CNVFORMSIZ
This procedure returns the default lines-per-page and characters-per-line values from the
specified convention. Each convention provides these values for use with printed output.
Example
Example 5–11 shows the parameter declarations and the specifications required to call
the CNVFORMSIZ library procedure. Each of the parameters is explained in the text
following the example.
This example obtains paper dimensions (line per page and characters per line) from the
Denmark convention.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00200F* THIS PROGRAM TESTS THE CNVFORMSIZ PROCEDURE.
01000FFILE1 O DISK
01500A TITLE 'OUT/RPG/CNVFORMSIZ'
06000$$INCLUDE "SYMBOL/INTL/RPG/PROPERTIES"
10000C*
10600C MOVEL'DENMARK' CNVNAM 17

Example 5–11. Coding for the CNVFORMSIZ Procedure (cont.)

5–56 8600 0544–103


Internationalization

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
11200C*
12000C EEXSRCNVFORMSIZRSLT 110
14000C PARAM CNVNAM
18000C PARAM LPP 110
18500C PARAM CPL 110
20500C*
21000C EXCPTHEAD
22000C*
24000C RSLT IFEQ 1
28000C EXCPT
32000C END
34000C*
36000C SETON LR
36200OFILE1 E HEAD
36400O 'RESULT = '
36600O RSLT 3
36650OFILE1 E HEAD
36700O ' '
36800OFILE1 E
37000O 'LINES PER PAGE = '
37600O LPP 3
38000OFILE1 E
40000O 'CHARACTERS PER LINE = '
42000O CPL 3

Example 5–11. Coding for the CNVFORMSIZ Procedure

Explanation
CNVNAM is an alphanumeric field passed to the procedure. It contains the name of the
convention to be used to specify the default printer form sizes. If this parameter contains
all blanks or zeros, the procedure will use the hierarchy to determine the convention to
be used. Refer to the MLS Guide for the list of convention names and the explanation of
the hierarchy. Example 5–11 requests the Denmark convention.

LPP is a numeric field returned by the procedure. It contains the default number of lines
per page specified in the convention you referenced.

CPL is a numeric field returned by the procedure. It contains the default number of
characters per line specified in the convention you referenced.

RSLT is a numeric field returned as the procedure result. It indicates whether an error
occurred during the execution of the procedure. Values other than 1 indicate an error. An
explanation of the error result values can be found under “Errors” at the end of this
section. You should check the value of the procedure result whenever you use this
procedure.

8600 0544–103 5–57


Internationalization

Possible values returned by the CNVFORMSIZ procedure are as follows:

1 1001 2002 3000

1002

Output
Sample output from Example 5–11 follows:

RESULT = 1

LINES PER PAGE = 70


CHARACTERS PER LINE = 82

See Also
For more information on the error result values, see Table 5–3 later in this section.

CNVLIST
This procedure returns a list of convention names and the total number of conventions
that are available on the system. The first name listed is the system default name.
You might use this procedure to obtain the name of a convention to be used as input to
another procedure.
Example
Example 5–12 shows the parameter declarations and the specifications required to call
the CNVLIST library procedure. Each of the parameters is explained in the text following
the example.
This example obtains the names of the conventions currently available on the system.
Note that this is an arbitrary list that may differ from system to system.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00200F* THIS PROGRAM TESTS THE CNVLIST PROCEDURE. ALL THE CONVENTION
00400F* NAMES ARE PRINTED IN FILE FILE1.
01000FFILE1 O DISK
01500A TITLE 'OUT/RPG/CNVLIST'
02000E NAMS 45 17
06000$$INCLUDE "SYMBOL/INTL/RPG/PROPERTIES"
10000C*
12000C EEXSRCNVLIST RSLT 110
16000C PARAM TOTAL 110
18000C PARAM NAMS
20500C*
21000C EXCPTHEAD
22000C*
24000C RSLT IFEQ 1
26000C 1 DO TOTAL I 110
28000C EXCPT

Example 5–12. Coding for the CNVLIST Procedure (cont.)

5–58 8600 0544–103


Internationalization

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
30000C END DO
32000C END IF
34000C*
36000C SETON LR
36200OFILE1 E HEAD
36400O 'RESULT = '
36600O RSLT 3
36650OFILE1 E HEAD
36700O ' '
36800OFILE1 E HEAD
37000O 20 'CONVENTION NAMES'
37400OFILE1 E HEAD
37600O 20 '----------------'
38000OFILE1 E
42000O NAMS,I 22

Example 5–12. Coding for the CNVLIST Procedure

Explanation
TOTAL is a numeric field returned by the procedure. It contains the total number of
conventions that reside on the system.

NAMS is an alphanumeric array returned by the procedure. Each element of the array
contains the name of a convention defined in the SYSTEM/CONVENTIONS file. Each
name uses one element of NAMS. Each name can be up to 17 characters long and is
left-justified in the field. If there are less than 17 characters in the name, the field is filled
on the right with blanks.

RSLT is a numeric field returned as the procedure result. It indicates whether an error
occurred during the execution of the procedure. Values other than 1 indicate an error. An
explanation of the error result values can be found under “Errors” at the end of this
section. You should check the value of the procedure result whenever you use this
procedure.

Possible values returned by the CNVLIST procedure are as follows:

1 1001 3001

8600 0544–103 5–59


Internationalization

Output
Sample output from Example 5–12 follows:

RESULT = 1

CONVENTION NAMES
----------------
ASERIESNATIVE
Netherlands
Denmark
UnitedKingdom1
Turkey
Norway
Sweden
Greece
FranceListing
FranceBureautique
EuropeanStandard
Belgium
Spain
Switzerland
Zimbabwe
Italy
UnitedKingdom2
KENYA
NIGERIA
SOUTHAFRICA
CYRILLIC
BRAZIL
NEWZEALAND
STNDYUGOSLAVIAN
FRENCHCANADA
ARGENTINA
CHILE
COLOMBIA
COSTARICA
MEXICO
PERU
VENEZUELA
AUSTRALIA
EGYPT

See Also
For more information on the error result values, see Table 5–3 later in this section.

5–60 8600 0544–103


Internationalization

CNVNAME
This procedure returns a value that indicates whether the convention name specified is
currently defined on the system.

You might use this procedure to ensure that a convention used as an input parameter
exists on the system on which your program is running.

Example
Example 5–13 shows the parameter declarations and the specifications required to call
the CNVNAME library procedure. Each of the parameters is explained in the text
following the example.

This example determines whether or not a convention named Sweden is currently


available on the system.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00200F* THIS PROGRAM TESTS THE CNVNAME PROCEDURE.
01000FFILE1 O DISK
01500A TITLE 'OUT/RPG/CNVNAME'
06000$$INCLUDE "SYMBOL/INTL/RPG/PROPERTIES"
10000C*
10500C MOVEL'SWEDEN' CNVNAM 17
11000C*
12000C EEXSRCNVNAME RSLT 110
16000C PARAM CNVNAM
20500C*
21000C EXCPT
34000C*
36000C SETON LR
36200OFILE1 E
36400O 'RESULT = '
36600O RSLT 3

Example 5–13. Coding for the CNVNAME Procedure

Explanation
CNVNAM is an alphanumeric field passed to the procedure. It contains the name of the
convention that is to be checked. The convention to be checked in Example 5–13 is
Sweden.
RSLT is a numeric field returned as the procedure result. It indicates whether a
convention name is valid. The possible values for RSLT and their meanings are as
follows:
Value Meaning

0 The convention name is not valid.

1 The convention name is valid.

8600 0544–103 5–61


Internationalization

Output
Sample output from Example 5–13 follows:

RESULT = 1

CNVSYMBOLS
This procedure returns a list of numeric and monetary symbols defined for a specified
convention.

Example
Example 5–14 shows the parameter declarations and the specifications required to call
the CNVSYMBOLS library procedure. Each of the parameters is explained in the text
following the example.

This example obtains monetary and numeric symbols, monetary and numeric grouping
specifications, and international currency notation defined for the Norway convention.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00200F* THIS PROGRAM TESTS THE CNVSYMBOLS PROCEDURE.
01000FFILE1 O DISK
01500A TITLE 'OUT/RPG/CNVSYMBOLS'
02000E SLN 18 11 0
04000E SAR 18 12
06000$$INCLUDE "SYMBOL/INTL/RPG/PROPERTIES"
10000C*
10500C MOVEL'NORWAY' CNVNAM 17
11000C*
12000C EEXSRCNVSYMBOLSRSLT 110
16000C PARAM CNVNAM
18000C PARAM TOTAL 110
19000C PARAM SLN
20000C PARAM SAR
20500C*
21000C EXCPTHEAD
22000C*
24000C RSLT IFEQ 1
28000C EXCPT
32000C END
34000C*
36000C SETON LR
36200OFILE1 E HEAD

Example 5–14. Coding for the CNVSYMBOLS Procedure (cont.)

5–62 8600 0544–103


Internationalization

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
36400O 'RESULT = '
36600O RSLT 3
36650OFILE1 E HEAD
36700O ' '
36800OFILE1 E
37000O 'FIELD MEANING'
37100O 50 'SYMBOL LENGTH'
37200O 75 'CONVENTION SYMBOL'
37400OFILE1 E
37600O '-------------'
38000O 50 '-------------'
40000O 75 '-----------------'
41000OFILE1 E
42000O 'INTERNATIONAL CURRENCY '
42500O 'NOTATION:'
43000O SLN,1 3 45
43500O SAR,1 78
44000OFILE1 E
45000O 'NATIONAL CURRENCY '
45100O 'NOTATION:"
45200O SLN,2 3 45
45400O SAR,2 78
46000OFILE1 E
47000O 'MONETARY THOUSANDS '
47500O 'SEPARATOR:'
47600O SLN,3 3 45
47800O SAR,3 78
48000OFILE1 E
49000O 'MONETARY DECIMAL SYMBOL:'
49200O SLN,4 3 45
49400O SAR,4 78
50000OFILE1 E
51000O 'MONETARY POSITIVE '
51500O 'SYMBOL:'
51600O SLN,5 3 45
51800O SAR,5 78
52000OFILE1 E
53000O 'MONETARY NEGATIVE '
53500O 'SYMBOL:'
53600O SLN,6 3 45
53800O SAR,6 78
54000OFILE1 E
55000O 'MONETARY LEFT ENCLOSURE '
56000O 'SYMBOL:'
56200O SLN,7 3 45
56400O SAR,7 78

Example 5–14. Coding for the CNVSYMBOLS Procedure (cont.)

8600 0544–103 5–63


Internationalization

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
57000OFILE1 E
58000O 'MONETARY RIGHT '
9000O 'ENCLOSURE SYMBOL:'
59200O SLN,8 3 45
59400O SAR,8 78
60000OFILE1 E
61000O 'NUMERIC THOUSANDS '
61500O 'SEPARATOR:'
61600O SLN,9 3 45
61800O SAR,9 78
62000OFILE1 E
63000O 'NUMERIC DECIMAL SYMBOL:'
63200O SLN,103 45
63400O SAR,10 78
64000OFILE1 E
65000O 'NUMERIC POSITIVE SYMBOL:'
65200O SLN,113 45
65400O SAR,11 78
66000OFILE1 E
68000O 'NUMERIC NEGATIVE SYMBOL:'
68200O SLN,123 45
68400O SAR,12 78
69000OFILE1 E
70000O 'NUMERIC LEFT ENCLOSURE '
71000O 'SYMBOL:'
71200O SLN,133 45
71400O SAR,13 78
72000OFILE1 E
73000O 'NUMERIC RIGHT ENCLOSURE '
74000O 'SYMBOL:'
74200O SLN,143 45
74400O SAR,14 78
75000OFILE1 E
76000O 'MONETARY GROUPING '
77000O 'SPECIFICATION:'
78000O SLN,153 45
80000O SAR,15 78
80500O SAR,16 90
81000OFILE1 E
82000O 'NUMERIC GROUPING '
83000O 'SPECIFICATION:'
84000O SLN,153 45
85000O SAR,17 78
86000O SAR,18 90

Example 5–14. Coding for the CNVSYMBOLS Procedure

5–64 8600 0544–103


Internationalization

Explanation
CNVNAM is an alphanumeric field passed to the procedure. It contains the name of the
convention to be used to retrieve the monetary and numeric symbols. Norway is the
convention specified in Example 5–14. If this parameter contains all blanks or zeros, the
procedure will use the hierarchy to determine the convention to be used. Refer to the
MLS Guide for the list of convention names and the explanation of the hierarchy.

TOTAL is a numeric field returned by the procedure. It contains the total number of
symbols returned.

SLN is an alphanumeric array returned by the procedure. It contains the lengths of all
symbols being returned in SAR. It has a maximum of 16 words returned.

SAR is an alphanumeric array returned by the procedure. Each element of the array
contains a symbol defined in the monetary and numeric template for the specified
convention. The corresponding entry in SLN contains the length of each symbol. A
maximum of 216 characters can be returned in SAR.

SLN and SAR are parallel arrays. Each entry in SLN specifies the number of characters
the corresponding entry in SAR has. If an entry in SLN is 0 (zero), it indicates that the
symbol is not defined and the corresponding entry in SAR is filled with blanks. If an entry
in SLN is not zero, but the corresponding SAR is all blanks, then the number of blanks
specified by the SLN entry is the symbol.

The procedure returns the convention-defined monetary and numeric templates in fixed-
length fields. Each field is 12 characters long except where noted.

The following shows the monetary and numeric symbols that are returned in the SAR
array and the offset of the field in which the symbol is returned:

Monetary Symbol Offset Numeric Symbol Offset

International currency 0 Thousands 96


notation separator
National currency symbol 12 Decimal symbol 108
Thousands separator 24 Positive sign 120
Decimal symbol 36 Negative sign 132
Positive sign 48 Left enclosure 144
Negative sign 60 Right enclosure 156
Left enclosure 72 Monetary grouping 168
Right enclosure 84 Numeric grouping 192

The monetary and numeric groupings each occupy two adjacent fields (24 bytes) in SAR.
The monetary and numeric groupings, when present, are character strings consisting of
unsigned integers separated by commas. The integers specify the number of digits in
each group. They appear exactly as they are declared in the monetary and numeric
templates including embedded commas.

8600 0544–103 5–65


Internationalization

The following table shows the offset in bytes of the fields in the SLN array which contain
the symbol lengths for the monetary and numeric symbols:

Offset Contains Length of Offset Contains Length of

0 International currency notation 8 Numeric thousands


separator
1 National currency symbol 9 Numeric decimal symbol
2 Monetary thousands 10 Numeric positive symbol
separator
3 Monetary decimal symbol 11 Numeric negative symbol
4 Monetary positive symbol 12 Numeric left enclosure
symbol
5 Monetary negative symbol 13 Numeric right enclosure
symbol
6 Monetary left enclosure 14 Monetary grouping
symbol
7 Monetary right enclosure 15 Numeric grouping
symbol

RSLT is a numeric field returned as the procedure result. It indicates whether an error
occurred during the execution of the procedure. Values other than 1 indicate an error. An
explanation of the error result values can be found under “Errors” at the end of this
section. You should check the value of the procedure result whenever you use this
procedure.

Possible values returned by the CNVSYMBOLS procedure are as follows:

1 1001 2002 3000

1002 2004 3001

3002

5–66 8600 0544–103


Internationalization

Output
Sample output from Example 5–14 follows:

RESULT = 1

FIELD MEANING SYMBOL LENGTH CONVENTION SYM


------------- ------------- --------------
INTERNATIONAL CURRENCY NOTATION: 3 NKR
NATIONAL CURRENCY NOTATION: 3 KR.
MONETARY THOUSANDS SEPARATOR: 1
MONETARY DECIMAL SYMBOL: 1 ,
MONETARY POSITIVE SYMBOL: 0
MONETARY NEGATIVE SYMBOL: 1 -
MONETARY LEFT ENCLOSURE SYMBOL: 0
MONETARY RIGHT ENCLOSURE SYMBOL: 0
NUMERIC THOUSANDS SEPARATOR: 1
NUMERIC DECIMAL SYMBOL: 1 ,
NUMERIC POSITIVE SYMBOL: 0
NUMERIC NEGATIVE SYMBOL: 1 -
NUMERIC LEFT ENCLOSURE SYMBOL: 0
NUMERIC RIGHT ENCLOSURE SYMBOL: 0
MONETARY GROUPING SPECIFICATION: 1 3
NUMERIC GROUPING SPECIFICATION: 1 3

See Also
For more information on the error result values, see Table 5–3 later in this section.

CNVTIME
This procedure formats the time you supply according to the convention and language
you specify.

Example
Example 5–15 shows the parameter declarations and the specifications required to call
the CNVTIME library procedure. Each of the parameters is explained in the text following
the example.

This example formats the time in numeric form using the Belgium convention. The
formatted time is returned in FTARY.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00200F* THIS PROGRAM TESTS THE CNVTIME PROCEDURE. IT FORMATS A TIME IN
00400F* NUMERIC FORM USING BELGIUM CONVENTION. THE SYSTEM DEFAULT
00600F* LANGUAGE IS SPECIFIED.

Example 5–15. Coding for the CNVTIME Procedure (cont.)

8600 0544–103 5–67


Internationalization

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
01000FFILE1 O DISK
01500A TITLE 'OUT/RPG/CNVTIME'
06000$$INCLUDE "SYMBOL/INTL/RPG/PROPERTIES"
06500ICNVNAM DS
07000I 1 8 CNVSTR
07500I 9 16 CNVMID
08000I 17 17 CNVEND
10000C*
10200C Z-ADD4 TYPE 110 NUMERIC TIME
10500C MOVEL'114958' TIMARY 10
10600C MOVE 'BELGIUM 'CNVSTR
10800C MOVE ' 'CNVMID
11000C MOVE ' ' CNVEND
11200C*
12000C EEXSRCNVTIME RSLT 110
16000C PARAMTYPE
17000C PARAM TIMARY
18000C PARAM CNVNAM
18500C PARAM LNGNAM 17
19000C PARAM FTLEN 110
20000C PARAM FTARY 45
20500C*
21000C EXCPTHEAD
22000C*
24000C RSLT IFEQ 1
28000C EXCPT
32000C END
34000C*
36000C SETON LR
36200OFILE1 E HEAD
36400O 'RESULT = '
36600O RSLT 3
36650OFILE1 E HEAD
36700O ' '
36800OFILE1 E
37000O 'FTARY = '
37600O FTARY

Example 5–15. Coding for the CNVTIME Procedure

5–68 8600 0544–103


Internationalization

Explanation
TYPE is a numeric field passed to the procedure. It indicates which of the following two
formats are to be used to edit the time:

Value Meaning

3 Long time format

4 Numeric time format

The format requested in Example 5–15 is numeric time.

TIMARY is an alphanumeric array passed to the procedure. It contains the time to be


formatted in the form HHMMSSPPPP, left-justified. The partial seconds field, PPPP, is
optional. The spaces of the field have fixed positions. You must use blanks or zeros in
any spaces that you omit. The time to be formatted in Example 5–15 is 114958.

CNVNAM is an alphanumeric field passed to the procedure. It contains the name of the
convention to be used to edit the time value. If this parameter contains all blanks or
zeros, the procedure will use the hierarchy to determine the convention to be used.
Refer to the MLS Guide for the list of convention names and the explanation of the
hierarchy. The name of the convention in Example 5–15 is Belgium.

LNGNAM is an alphanumeric field passed to the procedure. It contains the language to


be used to format the time. If this parameter contains all blanks or zeros, as is the case in
Example 5–15, the procedure uses the hierarchy to determine the language to be used.
Refer to the MLS Guide for information about determining the valid language names on
your system and the explanation of the hierarchy.

FTLEN is a numeric field returned by the procedure. It contains the length of the edited
time value.

FTARY is a numeric field returned by the procedure. It contains the edited time value.
The recommended length of formatted time is 45 characters.

RSLT is a numeric field returned as the procedure result. It indicates whether an error
occurred during the execution of the procedure. Values other than 1 indicate an error. An
explanation of the error result values can be found under “Errors” at the end of this
section. You should check the value of the procedure result whenever you use this
procedure.

Possible values returned by the CNVTIME procedure are as follows:

1 1001 2001 3000 3011 3053

1002 2002 3001 3013 3054

3002 3051 3055

3006 3052

8600 0544–103 5–69


Internationalization

Output
Sample output from Example 5–15 follows:

RESULT = 1

FTARY = 11:49:58

See Also
For more information on the error result values, see Table 5–3 later in this section.

CNVTPLT
This procedure returns the requested type of formatting template retrieved from the
convention definition you specify in CNVNAME.

You might want to use this procedure to improve the performance of your program. For
example, you can use the CNVTPLT procedure with a procedure that accepts a template
as an input parameter. Using both procedures enables the procedure that accepts a
template as input to be called repeatedly without it trying to locate the template at each
call.

This combination of procedures can be used as an alternative to calling a procedure that


does not take a template as input. Procedures that do not take templates as input try to
locate a template each time those procedures are called.

Example
Example 5–16 shows the parameter declarations and the specifications required to call
the CNVTPLT library procedure. Each of the parameters is explained in the text following
the example.

This example retrieves a monetary editing template from the Turkey convention. The
template is returned in TMPARY.

5–70 8600 0544–103


Internationalization

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00200F* THIS PROGRAM TESTS THE CNVTPLT PROCEDURE.
01000FFILE1 O DISK
01500A TITLE 'OUT/RPG/CNVTPLT'
06000$$INCLUDE "SYMBOL/INTL/RPG/PROPERTIES"
10000C*
10400C MOVEL'TURKEY' CNVNAM 17
10600C Z-ADD5 TYP 110 MONETARY TPLT
11200C*
12000C EEXSRCNVTPLT RSLT 110
16000C PARAMTYP
18000C PARAM CNVNAM
18500C PARAM TMPLEN 110
19500C PARAM TMPARY 48
20500C*
21000C EXCPTHEAD
22000C*
24000C RSLT IFEQ 1
28000C EXCPT
32000C END
34000C*
36000C SETON LR
36200OFILE1 E HEAD
36400O 'RESULT = '
36600O RSLT 3
36650OFILE1 E HEAD
36700O ' '
36720OFILE1 E
36740O 'TMPLEN = '
36760O TMPLEN3
36800OFILE1 E
37000O 'TMPARY = '
37600O TMPARY

Example 5–16. Coding for the CNVTPLT Procedure

Explanation
TYP is a numeric field passed to the procedure that specifies the type of template to be
returned (monetary template format in Example 5–16). This parameter can have the
following values:

Value Meaning

0 Long date format

1 Short date format

2 Numeric date format

8600 0544–103 5–71


Internationalization

Value Meaning

3 Long time format

4 Numeric time format

5 Monetary template format

6 Numeric template format

CNVNAM is an alphanumeric array passed to the procedure. It contains the name of the
convention that you specify. In Example 5–16, the convention is Turkey. If this parameter
contains all blanks or zeros, the procedure will use the hierarchy to determine the
convention to be used. Refer to Refer to the MLS Guide for the list of convention names
and the explanation of the hierarchy.

TMPLEN is a numeric field returned by the procedure that contains the length of the
template being returned.

TMPARY is an alphanumeric field returned by the procedure that contains the requested
template. The recommended length of a template is 48 characters.

RSLT is a numeric field returned as the procedure result. It indicates whether an error
occurred in the CNVTPLT procedure. Any value other than 1 indicates an error. An
explanation of the error result values can be found under “Errors” at the end of this
section. You should check the value of the procedure result whenever you use this
procedure.

Possible values returned by the CNVTPLT procedure are as follows:

1 1001 2002 3006

Output
Sample output from Example 5–16 follows:

RESULT = 1

TMPLEN = 23
TMPARY =!T[.:0,3]D[,]#N[-]C[T]!

See Also
For more information on the error result values, see Table 5–3 later in this section.

CSMSG
This procedure returns an alphanumeric array of message text associated with the
designated message number. You might want to use this procedure to retrieve the text
of an error message so that it can be displayed by your program. The message number is
obtained as the result value returned from a call to one of the CENTRALSUPPORT
procedures. A message number greater than or equal to 1000 indicates an error
message.

5–72 8600 0544–103


Internationalization

When you call CSMSG, you can designate the language into which the message is to be
translated, and the desired length of the returned message. If the returned text is shorter
than the length specified, the procedure pads the remaining portion of the field with
blanks.

An entire message consists of the following three parts:

• The header, which comprises the first 80 characters of the message text returned by
CSMSG. The text in the header provides the error number and a concise text
description.
• The short description, which comprises the second 80 characters of the message
text returned by CSMSG. If space is a consideration, you might want to limit the
description of the error to the header and short description.
• The long description, which comprises the remaining characters of the message text
returned by CSMSG. The long description provides a complete explanation of the
error that was returned.
Part or all of the message text can be returned. Note that the header part starts at offset
1, the short description at offset 81, and the long description at offset 161. For example,
if you specify MSGLEN to be equal to 200 characters, then MSG would contain the
header message beginning at offset 1 and padded with blanks to offset 80, if necessary,
followed by the short description beginning at offset 81 padded with blanks to offset
160, if necessary, followed by the first 40 characters of the long description beginning at
offset 161.

The desired message length should be at least 80 characters, equal to one line of text.
Anything less results in an incomplete message. Using a length of either 80, 160, or 999
is recommended. The value of 999 causes the entire message to be returned.

Example
Example 5–17 shows the parameter declarations and the specifications required to call
CSMSG. Each of the parameters is explained in the text following the example.

This example illustrates how to get the message text associated with a
CENTRALSUPPORT error message. Assume that the sample call to CCSVSNNUM
returns the error 3004 (The requested name was not found). When the error is returned,
this example gets the first 160 characters (2 lines) of the message text for the error.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00200F* THIS PROGRAM TESTS THE CSMSG PROCEDURE. THIS PROGRAM
00400F* INTENTIONALLY RECEIVES AN ERROR FROM THE CCSVSNNUM PROCEDURE AND
00500F* THEN USES CSMSG TO OBTAIN THE ERROR MESSAGE TEXT.
01000FFILE1 O DISK
01500A TITLE 'OUT/RPG/CSMSG'
02000E NAMARY 1 17
04000E MSG 2 80

Example 5–17. Coding for the CSMSG Procedure (cont.)

8600 0544–103 5–73


Internationalization

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.

06000$$INCLUDE "SYMBOL/INTL/RPG/PROPERTIES"
07000ISYSINF DS
08000I 1 17 VSNNAM
09000I 18 34 LNGNAM
10000I 35 51 CNVNAM
10500C Z-ADD1 CCSVSN 110
11000C MOVEL'BADNAME' NAMARY
11500C*
12000C EEXSRCCSVSNNUM RSLT 110
14000C PARAMCCSVSN
16000C PARAM NAMARY
18000C PARAM NUM 110
22000C*
24000C RSLT IFNE 1
25000C Z-ADD160 MSGLEN 110
25500C*
26000C EEXSRCSMSG RSLT2 110
26500C PARAMRSLT
27000C PARAM LNGNAM
27500C PARAM MSG
28000C PARAM MSGLEN
28200C*
28400C EXCPTHEAD
28500C*
29000C RSLT2 IFEQ 1
29500C EXCPT
30000C END IFEQ
30500C*
32000C END IFNE
34000C*
36000C SETON LR
36020OFILE1 E HEAD
36040O 'RESULT FROM CCSVSNNUM = '
36060O RSLT 3
36065OFILE1 E HEAD
36070O ' '
36080OFILE1 E HEAD
36100O 'RESULT FROM CSMSG = '
36120O RSLT2 3
36125OFILE1 E HEAD
36130O ' '
36140OFILE1 E HEAD
36160O 'MSG = '
36200OFILE1 E
36400O MSG,1
36500OFILE1 E
36600O MSG,2

Example 5–17. Coding for the CSMSG Procedure

5–74 8600 0544–103


Internationalization

Explanation
RSLT is a numeric field passed to the procedure. It contains the number of the message
for which you want the text. These values are returned by calls on other
CENTRALSUPPORT procedures. The message numbers and their meanings are listed at
the end of this section. In Example 5–17, the RSLT field is from an executed
CCSVSNNUM procedure that requested a ccsversion number from the name
BADNAME.

LNGNAM is an alphanumeric field passed to the procedure. It specifies the language the
message is to be displayed in. If this parameter contains all blanks or zeros, the
procedure uses the default language hierarchy to determine the language to be used.
Refer to the MLS Guide for details about determining the valid language names on the
system and for the explanation of the default language hierarchy. The recommended
array size for LNGNAM is 17 characters.

MSG is an alphanumeric field returned by the procedure. It contains the message text
associated with the specified message number.

MSGLEN is a numeric field passed to the procedure that specifies the maximum length
of the message to be returned as input. It also contains an update value as an output
parameter. For output, MSGLEN specifies the actual length of the message returned by
the procedure. If MSGLEN is equal to 0 (zero), one line of text (80 characters) is returned.
If MSGLEN is between 1 and 79, then only a partial message is returned. MSGLEN
should not be greater than the size of MSG. Recommended values for MSGLEN are 80,
160, or a large number that returns all of the message. MSGLEN in Example 5–17 is 160.

RSLT2 is a numeric field returned by the procedure that indicates whether an error
occurred during the execution of the procedure. Values other than 1 indicate an error. An
explanation of the error result values can be found under “Errors” at the end of this
section. You should check the procedure result whenever you use this procedure.

Possible values returned by the CSMSG procedure are as follows:

1 1001 2004 3001

1002 3002

3003

8600 0544–103 5–75


Internationalization

Output
Sample output from Example 5–17 follows:

RESULT FROM CCSVSNNUM = 3004

RESULT FROM CSMSG = 1

MSG =
>>> CENTRALSUPPORT INTERFACE ERROR (#3004) <<<
INVALID CHARACTER SET OR CCSVERSION NAME

See Also
For more information on the error result values, see Table 5–3 later in this section.

MCPLANGS
This procedure returns the names of the languages that are currently bound to the
operating system. For information about binding languages to the operating system, see
the MLS Guide. You might use this procedure to see what languages are available on
your system.

Example
Example 5–18 shows the parameter declarations and the specifications required to call
the MCPLANGS library procedure. Each of the parameters is explained in the text
following the example.

This example returns the languages bound by the operating system. Assume for this
example that the bound language is German.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00200F* THIS PROGRAM TESTS THE MCPLANGS PROCEDURE.
01000FFILE1 O DISK
01500A TITLE 'OUT/RPG/MCPLANGS'
02000E LNGS 20 17
06000$$INCLUDE "SYMBOL/INTL/RPG/PROPERTIES"
11500C*
12000C EEXSRMCPLANGS RSLT 110
14000C PARAM TOTAL 110
16000C PARAM LNGS
18000C*
20000C EXCPTHEAD
22000C*
24000C RSLT IFEQ 1
26000C 1 DO TOTAL I 110
29500C EXCPT
29600C END DO

Example 5–18. Coding for the MCPLANGS Procedure (cont.)

5–76 8600 0544–103


Internationalization

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
30000C END IFEQ
30500C*
36000C SETON LR
36050OFILE1 E HEAD
36100O 'RESULT = '
36150O RSLT 3
36152OFILE1 E HEAD
36154O ' '
36160OFILE1 E HEAD
36170O 'LANGUAGES'
36175OFILE1 E HEAD
36180O '---------'
36200OFILE1 E
36400O LNGS,I

Example 5–18. Coding for the MCPLANGS Procedure

TOTAL is a numeric field returned by the procedure. It contains the total number of
languages that are bound to the operating system.

LNGSRY is an alphanumeric field returned by the procedure. It contains the names of the
languages bound to the operating system. The maximum length of each name is 17
characters, and the names are left-justified. For any name that is less than 17 characters,
the field is filled on the right with blanks. It is recommended that the size of the array be
84 characters, or 20 17-character elements. An array of that size holds 5 names.

RSLT is a numeric field returned as the procedure result. It indicates whether an error
occurred during the execution of the procedure. Values other than 1 indicate an error. An
explanation of the error result values can be found under “Errors” at the end of this
section. You should check the value of the procedure result whenever you use this
procedure.

Possible values returned by the MCPLANGS procedure are as follows:

1 1001 3000

1002 3001

Output
Sample output from Example 5–18 follows:

RESULT = 1

LANGUAGES
---------
ENGLISH

See Also
For more information on the error result values, see Table 5–3 later in this section.

8600 0544–103 5–77


Internationalization

TPLTDATE
This procedure formats a date according to a template. You specify the template and the
date value and the language in which the date is to be displayed. The procedure then
returns the formatted date. The template may be retrieved for any convention from the
CNVTPLT procedure. It may also be created by the user.
Example
Example 5–19 shows the parameter declarations and the specifications required to call
the TPLTDATE library procedure. Each of the parameters is explained in the text
following the example.
This example formats a date using a template provided by the calling program. The
formatted date is translated to English and returned in FDARY. The date consists of an
unabridged day of week name, abbreviated month name, numeric day of month, day of
month suffix rd, and numeric year.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00200F* THIS PROGRAM TESTS THE TPLTDATE PROCEDURE.
01000FFILE1 O DISK
01500A TITLE 'OUT/RPG/TPLTDATE'
02000E TPLARY 1 1 23
06000$$INCLUDE "SYMBOL/INTL/RPG/PROPERTIES"
10000C*
10200C MOVE '19901003'DATARY 8
10400C MOVEL'ENGLISH' LNGNAM 17
11200C*
12000C EEXSRTPLTDATE RSLT 110
16000C PARAM DATARY
18000C PARAM TPLARY
18500C PARAM LNGNAM
19500C PARAM FDLEN 110
20000C PARAM FDARY 40
20500C*
21000C EXCPTHEAD
22000C*
24000C RSLT IFEQ 1
28000C EXCPT
32000C END
34000C*
36000C SETON LR
36200OFILE1 E HEAD
36400O 'RESULT = '
36600O RSLT 3

Example 5–19. Coding for the TPLTDATE Procedure (cont.)

5–78 8600 0544–103


Internationalization

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
36650OFILE1 E HEAD
36700O ' '
36800OFILE1 E
37000O 'FDARY = '
37600O FDARY
38000VVECTOR SEQ
40000!W!, !1N!. !DE!, !YYYY!

Example 5–19. Coding for the TPLTDATE Procedure

Explanation
DATARY is an alphanumeric array passed to the procedure. It contains the date to be
formatted. The date must be in the form YYYYMMDD. The spaces of the field have fixed
positions. You must use blanks or zeros in any fields that you omit. The date requested in
Example 5–19 is October 3, 1990.

TPLARY is an alphanumeric array passed to the procedure. The template must use the
control characters described in the MLS Guide. The recommended length of a template
is 48 characters.

LNGNAM is an alphanumeric field passed to the procedure. It contains the name of the
language to be used to format the date. If this parameter contains all blanks or zeros, the
procedure uses the hierarchy to determine the language to be used. Refer to the MLS
Guide for information about determining the valid language names on your system. The
English language is requested in Example 5–19 and is left-justified by the MOVEL
operation.

FDLEN is a numeric field returned by the procedure that contains the length of the
formatted date.

FDARY is an alphanumeric array returned by the procedure that contains the formatted
date. The recommended length of the formatted date is 45 characters.

RSLT is a numeric field returned as the procedure result. It indicates whether an error
occurred during the execution of the procedure. Values other than 1 indicate an error. An
explanation of the error result values can be found under “Errors” at the end of this
section. You should check the value of the procedure result whenever you use this
procedure.

Possible values returned by the TPLTDATE procedure are as follows:

1 1001 2001 3000 3011 3045 3048

1002 3001 3012 3046 3058

3002 3030 3047 3059

8600 0544–103 5–79


Internationalization

Output
Sample output from Example 5–19 follows:

RESULT = 1

FDARY = Wednesday, Oct. 3rd, 1990

See Also
For more information on the error result values, see Table 5–3 later in this section.

TPLTDATTIM
This procedure formats the system-provided date, the time, or both according to a
template and language that you supply. The system obtains the date and time from a
single function call to avoid the possibility of splitting the date and time across midnight.
The template may be retrieved for any convention from the CNVTPLT procedure. It may
also be created by the user.

Example
Example 5–20 shows the parameter declarations and the specifications required to call
the TPLTDATTIM library procedure. Each of the parameters is explained in the text
following the example.

This example formats system date and time according to a template provided by the
calling program in TMPARY. The formatted date and time are translated to English and
returned in SDTARY. DTPLEN is set to the length of the template in TMPARY.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00200F* THIS PROGRAM TESTS THE TPLTDATTIM PROCEDURE.
01000FFILE1 O DISK
01500A TITLE 'OUT/RPG/TPLTDATTIM'
02000E TPLARY 1 1 35
06000$$INCLUDE "SYMBOL/INTL/RPG/PROPERTIES"
10000C*
10400C MOVEL'ENGLISH' LNGNAM 17
11000C Z-ADD21 DTPLEN 110 DATE TEMPLATE
11200C*
12000C EEXSRTPLTDATTIMRSLT 110
16000C PARAM TPLARY
18000C PARAM LNGNAM
18500C PARAMDTPLEN
19000C PARAM DATLEN 110
19500C PARAM SDTLEN 110
20000C PARAM SDTARY 40
20500C*

Example 5–20. Coding for the TPLTDATTIM Procedure (cont.)

5–80 8600 0544–103


Internationalization

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
21000C EXCPTHEAD
22000C*
24000C RSLT IFEQ 1
28000C EXCPT
32000C END
34000C*
36000C SETON LR
36200OFILE1 E HEAD
36400O 'RESULT = '
36600O RSLT 3
36650OFILE1 E HEAD
36700O ' '
36800OFILE1 E
37000O 'SDTARY = '
37600O SDTARY
38000VVECTOR SEQ
40000!W!, !N! !D!, !YYYY! !0T!:!0M!:!0S!

Example 5–20. Coding for the TPLTDATTIM Procedure

Explanation
TPLARY is an alphanumeric array passed to the procedure. It contains the template you
specify, left-justified in the field. It contains the template used to format the date. If both
date and time templates are present, the date template must appear first. The
recommended length of a template is 48 characters. Refer to the MLS Guide for
information about creating a template.

LNGNAM is an alphanumeric field passed to the procedure. It contains the name of the
language to be used to format the value of the date, the time, or both. If this parameter
contains all blanks or zeros, the procedure uses the hierarchy to determine the language
to be used. Refer to the MLS Guide for information about determining the valid language
names on your system and the explanation of the hierarchy. English is the language
requested in Example 5–20.

DTPLEN is a numeric field passed to the procedure. It specifies the length of the date
template in TPLARY. If DTPLEN is 0 (zero), it indicates there is no date template in
TPLARY. If you specify both a date and time template, then the date template must
appear first in TPLARY. The length of the date template requested in Example 5–20 is 18.
The date and time are formatted if both date and time templates are present, the date is
formatted if only the date template is present, and the time is formatted if only the time
template is present.

DATLEN is a numeric field returned by the procedure. It contains the length of the
formatted date portion of the date and time.

SDTLEN is a numeric field returned by the procedure that contains the length of the
formatted date, the time, or both. Use the expression SDTLEN-DATLEN to determine the
length of the formatted time in the output array.

8600 0544–103 5–81


Internationalization

SDTARY is an alphanumeric array returned by the procedure. It contains the formatted


date, the formatted time, or both. The recommended length of date for SDTARY is 45
characters and the recommended length of time is also 45 characters.

RSLT is a numeric field returned as the procedure result. It indicates whether an error
occurred during the execution of the procedure. Values other than 1 indicate an error. An
explanation of the error result values can be found under “Errors” at the end of this
section. You should check the value of the procedure result whenever you use this
procedure.

Possible values returned by the TPLTDATTIM procedure are as follows:

1 1001 2001 3000 3011 3047 3052 3055


1002 3001 3045 3048 3053
3002 3046 3051 3054
Output
Sample output from Example 5–20 follows:

RESULT = 1

SDTARY = Friday, November 30, 1990 14:06:56

See Also
For more information on the error result values, see Table 5–3 later in this section.

TPLTTIME
This procedure formats the time you supply according to the convention and language
you specify. The template may be retrieved for any convention from the CNVTPLT
procedure. It may also be created by the user.

With this procedure, if the time template is !0t!:!0m!:0s!, the language is English, and
the input time is 1255016256, the numeric time is formatted as 12:55:01.

Example
Example 5–21 shows the parameter declarations and the specifications required to call
the TPLTTIME library procedure. Each of the parameters is explained in the text following
the example.

This example formats a caller-supplied time using a template also passed by the calling
program. Alphabetic time components are translated to English and returned in FTARY.

5–82 8600 0544–103


Internationalization

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00200F* THIS PROGRAM TESTS THE TPLTTIME PROCEDURE.
01000FFILE1 O DISK
01500A TITLE 'OUT/RPG/TPLTTIME'
02000E TPLARY 1 1 23
06000$$INCLUDE "SYMBOL/INTL/RPG/PROPERTIES"
10000C*
10200C MOVEL'114958' TIMARY 10
10400C MOVEL'ENGLISH' LNGNAM 17
11200C*
12000C EEXSRTPLTTIME RSLT 110
16000C PARAM TIMARY
18000C PARAM TPLARY
18500C PARAM LNGNAM
19500C PARAM FTLEN 110
20000C PARAM FTARY 40
20500C*
21000C EXCPTHEAD
22000C*
24000C RSLT IFEQ 1
28000C EXCPT
32000C END
34000C*
36000C SETON LR
36200OFILE1 E HEAD
36400O 'RESULT = '
36600O RSLT 3
36650OFILE1 E HEAD
36700O ' '
36800OFILE1 E
37000O 'FTARY = '
37600O FTARY
38000VVECTOR SEQ
40000!T! !I! !M! !K! !S! !R!

Example 5–21. Coding for the TPLTTIME Procedure

Explanation
TIMARY is an alphanumeric array passed to the procedure. It contains the time to be
formatted in the form HHMMSSPPPP, left-justified. The partial seconds field, PPPP, is
optional. The spaces of the field have fixed positions. You must use blanks or zeros in
any fields that you omit. Example 5–21 request that the time 114958 be formatted.

TPLARY is an alphanumeric array passed to the procedure. It contains the template you
specify, left-justified in the field. The recommended length of a template is 48 characters.
Refer to the MLS Guide for information about creating a template.

8600 0544–103 5–83


Internationalization

LNGNAME is an alphanumeric field passed to the procedure. It contains the language to


be used to format the time. If this parameter contains all blanks or zeros, the procedure
uses the hierarchy to determine the language to be used. Refer to the MLS Guide for
information about determining the valid language names on your system and the
explanation of the hierarchy. The language requested in Example 5–21 is English.

FTLEN is a numeric field returned by the procedure. It contains the length of the edited
time value.

FTARY is an alphanumeric array returned by the procedure. It contains the edited time
value. The recommended length of formatted time is 45 characters.

RSLT is a numeric field returned as the procedure result. It indicates whether an error
occurred during the execution of the procedure. Values other than 1 indicate an error. An
explanation of the error result values can be found under “Errors” at the end of this
section. You should check the value of the procedure result whenever you use this
procedure.

Possible values returned by the TPLTTIME procedure are as follows:

1 1001 2001 3000 3011 3051 3054

1002 3001 3013 3052 3055

3002 3030 3053

Output
Sample output from Example 5–21 follows:

RESULT = 1

FTARY = 11 hours 49 minutes 58 seconds

See Also
For more information on the error result values, see Table 5–3 later in this section.

5–84 8600 0544–103


Internationalization

VSNCOMPTXT
This procedure compares two records, using one of three comparison methods along
with the compare relationship to be checked. The comparison is specified as one of the
following types:

• A binary comparison, which is based on the hex code values of the characters
• An equivalent comparison, which is based on the OSVs of the characters
• A logical comparison, which is based on the OSVs plus the PSVs of the characters
The procedure retrieves the OSVs and PSVs from the SYSTEM/CCSFILE based on the
specified ccsversion.

Example
Example 5–22 shows the parameter declarations and the specifications required to call
the VSNCOMPTXT library procedure. Each of the parameters is explained in the text
following the example.

This example compares two strings using the CanadaEBCDIC ccsversion. The first string
is “hotel” and the second string is “h“tel.” Assume the following ordering values for the
characters:

Character Ordering Sequence Value Priority Sequence


Value

e 69 2
h 72 2
l 76 2
o 79 2
t 84 2
“ 79 8

The compare relation value 2 is in the RLTN parameter to determine if “hotel” is equal to
“h“tel” using a logical comparison. You can use the MLS Guide to determine that the
ccsversion number for CanadaEBCDIC is 74. You can also retrieve this number by calling
the procedure CCSVSNNUM with the name CanadaEBCDIC.

8600 0544–103 5–85


Internationalization

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00200F* THIS PROGRAM TESTS THE VSNCOMPTXT PROCEDURE.
01000FFILE1 O DISK
01500A TITLE 'OUT/RPG/VSNCOMPTXT'
06000$$INCLUDE "SYMBOL/INTL/RPG/PROPERTIES"
06500C MOVE 'hotel' TEXT1 5
07000C Z-ADD0 TEXT1S 110 TEXT1 START
07500C MOVE 'h“tel' TEXT2 5
08500C Z-ADD0 TEXT2S 110 TEXT2 START
09000C Z-ADD5 CLEN 110 COMPARE LENGT
09500C Z-ADD74 VSNNUM 110 CANADAEBCDIC
10000C Z-ADD2 RLTN 110 EQUAL COMPARE
10500C Z-ADD2 ORDTYP 110 LOGICAL ORDER
11000C*
12000C EEXSRVSNCOMPTXTRSLT 110
14000C PARAMVSNNUM
16000C PARAM TEXT1
16200C PARAMTEXT1S
16400C PARAM TEXT2 5
16600C PARAMTEXT2S
16800C PARAMCLEN
17000C PARAMRLTN
17200C PARAMORDTYP
18000C*
20000C EXCPT
34000C*
36000C SETON LR
36020OFILE1 E
36040O 'RESULT = '
36060O RSLT 3

Example 5–22. Coding for the VSNCOMPTXT Procedure

Explanation
VSNNUM is a numeric field passed to the procedure. It contains the number of the
ccsversion that is used to compare the text records. The number can be obtained by
referring to the MLS Guide. The following values are allowed:

Value Meaning

Greater than or Specifies a ccsversion. The numbers of the ccsversions are listed in
equal to 0 the MLS Guide.

–2 Use the system default ccsversion. If the system default ccsversion is


not available, an error is returned.

TEXT1 is an alphanumeric field passed to the procedure. It contains the first text to be
compared. The recommended array size for TEXT1 is determined by the caller.

5–86 8600 0544–103


Internationalization

TEXT1S is a numeric field passed to the procedure. It contains the byte offset in TEXT1,
relative to 0 (zero), at which the comparison begins.

TEXT2 is an alphanumeric field passed to the procedure. It contains the second text to be
compared. The recommended array size for TETXT2 is determined by the caller.

TEXT2S is a numeric field passed to the procedure. It contains the byte offset in TEXT2,
relative to 0 (zero), at which the comparison begins.

CLEN is a numeric field passed to the procedure. It contains the number of characters to
compare. This value cannot be longer than the length of the text records.

The strings to be compared must be of equal length or padded with blanks up to the
CLEN value. If all pairs of characters compare equally, the strings are considered equal.
Otherwise, the first pair of unequal characters encountered is compared to determine
their relative ordering. The string that contains the character with the higher ordering
(higher PSV and higher OSV) is considered to be the string with the greater value. If
substitution forms strings of unequal length, the comparison proceeds as if the shorter
string were padded with blanks on the right. This padding ensures that the strings are of
equal length.

RLTN is a numeric field passed to the procedure. It indicates the relational operator of the
comparison. The valid values are

Value Meaning

0 TEXT1 is less than TEXT2.

1 TEXT1 is less than or equal to TEXT2.

2 TEXT1 is equal to TEXT2.

3 TEXT1 is greater than TEXT2.

4 TEXT1 is greater than or equal to TEXT2.

5 TEXT1 is not equal to TEXT2.

ORDTYP is a numeric field passed to the procedure. It indicates the type of comparison
to be performed by the procedure. The following are the valid values:

Valu Meaning
e

0 Perform a binary comparison.

1 Perform an equivalent comparison.

2 Perform a logical comparison.

RSLT is a numeric field returned as the procedure result. It indicates whether an error
occurred during the execution of the procedure.

8600 0544–103 5–87


Internationalization

The possible values for RSLT and their meanings are as follows:

Value Meaning

0 No error and the condition is FALSE

1 No error and the condition is TRUE

Other possible values returned by the VSNCOMPTXT procedure are as follows:

0 1000 3003

1 1001 3006

1002

The meanings of the error result values are explained under “Errors” at the end of this
section.

Output
Sample output from Example 5–22 follows:

RESULT = 0

See Also
For more information on the error result values, see Table 5–3 later in this section.

5–88 8600 0544–103


Internationalization

VSNESCAPE
This procedure takes the input text and rearranges it according to the escapement rules
of the ccsversion. Both the character advance direction and the character escapement
direction are used. If the character advance direction is positive, then the start of the text
is the leftmost position in the destination parameter. If the character advance direction is
negative, then the start of the text is the rightmost position in the destination parameter.
From that point on, the character advance direction value and the character escapement
direction values, in combination, control where each character should be placed in
relation to the previous character.

Example
Example 5–23 shows the parameter declarations and the specifications required to call
the VSNESCAPE library procedure. Each of the parameters is explained in the text
following the example.

This example takes the string ABCDEFG and rearranges it according to the escapement
rules of the ccsversion. Assume for this example a ccsversion number of 999 with a
character advance direction of plus (+, left to right) and with the following character
escapements:

Character Escapement Meaning

A + Left to right.

B -- Right to left.

C -- Right to left.

D -- Right to left.

E + Left to right.

F + Left to right.

G Blank Use character advance direction value.

8600 0544–103 5–89


Internationalization

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00200F* THIS PROGRAM TESTS THE VSNESCAPE PROCEDURE.
01000FFILE1 O DISK
01500A TITLE 'OUT/RPG/VSNESCAPE'
06000$$INCLUDE "SYMBOL/INTL/RPG/PROPERTIES"
08000C Z-ADD999 CCSVSN 110
09000C MOVEL'ABCDEFG' SOURCE 7
09200C Z-ADD0 SRCS 110 START, 0-RELA
09600C Z-ADD7 TRNLEN 110 TRANSLATION L
10000C*
12000C EEXSRVSNESCAPE RSLT 110
14000C PARAMCCSVSN
16000C PARAM SOURCE
17000C PARAMSRCS
18000C PARAM DEST 7
20000C PARAMTRNLEN
20500C*
21000C EXCPT
34000C*
36000C SETON LR
36200OFILE1 E
36400O 'RESULT = '
36600O RSLT 3
36800OFILE1 E
37000O 'DEST = '
37200O DEST 20

Example 5–23. Coding for the VSNESCAPE Procedure

Explanation
CCSVSN is a numeric field passed to the procedure. It enables you to specify the number
of the ccsversion that is used. The ccsversion number used in Example 5–23 is 75.
Ccsversion numbers can be obtained by calling the CENTSTATUS procedure or by
referring to the MLS Guide. The following values are allowed:

Value Meaning

Greater than or Specifies a ccsversion. The numbers of the ccsversions are listed in
equal to 0 the MLS Guide.

–2 Use the system default ccsversion. If the system default ccsversion is


not available, an error is returned.

SOURCE is an alphanumeric field passed to the procedure that contains the text for
which the escapement information is requested. The SOURCE for Example 5–23 is
“ABCDEFG”. The recommended array size for SOURCE is determined by the caller.

SRCS is a numeric field passed to the procedure. It contains the relative offset of the
location in SOURCE where the text rearranging is to begin.

5–90 8600 0544–103


Internationalization

DEST is a numeric field passed to the procedure. It contains the escapement information
for the input text. The recommended array size for DEST is the same as the size for
SOURCE.

TRNLEN is a numeric field passed to the procedure. It contains the length of the text that
is to be rearranged.

RSLT is a numeric field returned as the procedure result. It indicates whether an error
occurred during the execution of the procedure. Values other than 1 indicate an error. An
explanation of the error result values can be found under “Errors” at the end of this
section. You should check the value of the procedure result whenever you use this
procedure.

Possible values returned by the VSNESCAPE procedure are as follows:

1 1000 3000

1001 3002

1002 3003

Output
Sample output from Example 5–23 follows:

RESULT = 1
DEST = ADCBEFG

See Also
For more information on the error result values, see Table 5–3 later in this section.

8600 0544–103 5–91


Internationalization

VSNGETORD1
This procedure returns the ordering information for the input text. The ordering
information determines how the input text is collated. It includes the ordering and priority
sequence values of the characters and any substitution of characters to be made when
the input text is sorted. You can choose one of the following types of ordering
information:

• Equivalent ordering information, that comprises only the OSVs


• Logical ordering information, that comprises the OSVs followed by the PSVs
Example
Example 5–24 shows the parameter declarations and the specifications required to call
the VSNGETORD1 library procedure. Each of the parameters is explained in the text
following the example.

This example obtains the OSVs and PSVs for the input text string “ABC¯®.” The
ccsversion is CanadaEBCDIC. You can use the MLS Guide to determine that the
ccsversion for CanadaEBCDIC is 74. You can also retrieve this number by calling the
procedure CCSVSNNUM with the name CanadaEBCDIC. This example requests logical
ordering information, so both the OSVs and PSVs are returned. This example also allows
for maximum substitution, so the parameter max_osvs is equal to itext_len * 3 and the
parameter total_storage is equal to max_osvs + round(max_osvs/2.0).

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00200F* THIS PROGRAM TESTS THE VSNGETORD1 PROCEDURE.
01000FFILE1 O DISK
01500A TITLE 'OUT/RPG/VSNGETORD1'
06000$$INCLUDE "SYMBOL/INTL/RPG/PROPERTIES"
08000C Z-ADD74 CCSVSN 110
08500C MOVE 'ABC¯®' SOURCE 5
09200C Z-ADD0 SRCS 110 START, 0-RELA
09500C Z-ADD5 TLEN 110 TRANSLATION L
09600C Z-ADD0 DESTS 110 DEST OFFSET
09650C TLEN MULT 3 MAXOSV 110
09700C Z-ADD2 ORDTYP 110 LOGICAL COMPA
09750C*
09800C MAXOSV DIV 2 TOTSTG 110 MAX BYTES
09850C MVR DECMAL 112 REMAINDER
09900C DECMAL IFGE.5
09950C TOTSTG ADD 1 TOTSTG
09970C END END IF
09980C MAXOSV ADD TOTSTG TOTSTG
10000C*
12000C EEXSRVSNGETORD1RSLT 110
14000C PARAMCCSVSN
16000C PARAM SOURCE 5
17000C PARAMSRCS

Example 5–24. Coding for the VSNGETORD1 Procedure (cont.)

5–92 8600 0544–103


Internationalization

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
17500C PARAMTLEN
18000C PARAM DEST 25
18500C PARAMDESTS
19000C PARAMMAXOSV
20000C PARAMTOTSTG
20200C PARAMORDTYP
20500C*
21000C EXCPT
22000C RSLT IFEQ 1
26000C END
34000C*
36000C SETON LR
36200OFILE1 E
36400O 'RESULT = '
36600O RSLT 3

Example 5–24. Coding for the VSNGETORD1 Procedure

Explanation
VSNNUM is a numeric field passed to the procedure. It contains the number of the
ccsversion that is used. The number can be obtained by calling the CENTSTATUS
procedure or by referring to the MLS Guide. The following shows the allowed values:

Value Meaning

Greater than or Specifies a ccsversion. The numbers of the ccsversions are listed in
equal to 0 the MLS Guide.

–2 Use the system default ccsversion. If the system default ccsversion is


not available, an error is returned.

SOURCE is an alphanumeric field passed to the procedure that contains the text for
which the ordering information is requested. The recommended array size for SOURCE is
determined by the caller.

SRCEST is a numeric field passed to the procedure. It contains the offset of the location
in SOURCE where the translation is to begin.

TLEN is a numeric field passed to the procedure. It contains the length of the text that is
to be translated.

DEST is an alphanumeric field returned by the procedure. It contains the ordering


information for the input text. The recommended array size for DEST is the same as the
size for SOURCE.

DESTST is a numeric field returned by the procedure. It designates the starting offset in
DEST at which the result values are placed.

8600 0544–103 5–93


Internationalization

MAXOSV is a numeric field passed to the procedure. It designates the maximum number
of storage bytes to be used to store the ordering sequence values.

The value of MAXOSV should be at least the length of the input text, but it might need to
be more to allow for substitution. The maximum substitution length is 3; therefore, to
allow for substitution for every character, the value of MAXOSV is as follows:

(length of source text in bytes) * 3

If the number of ordering sequence values returned is less than MAXOSV, then the
destination is filled with the ordering sequence value for blank.

TOTSTG is a numeric field passed to the procedure. It defines the maximum number of
bytes needed to store the complete ordering information for the text. If you request
equivalent ordering information, TOTSTG is equal to MAXOSV. If you request logical
ordering information, you must provide space for the four-bit priority values in addition to
the space allowed for the OSVs. Each OSV has one PSV, and one byte can hold two
PSVs. Therefore, the space allowed for PSVs values is MAXOSV/2, and the value of
TOTSTG is as follows:

MAXOSV + (MAXOSV)/2

When the ordering information is returned by the procedure, all OSVs are listed first,
followed by all the PSVs.

ORDTYP is a numeric field passed to the procedure. It indicates the type of ordering
information you want, as follows:

Value Meaning

1 OSVs only

2 PSVs only

RSLT is a numeric field returned as the procedure result. It indicates whether an error
occurred during the execution of the procedure. Values other than 1 indicate an error. An
explanation of the error result values can be found under “Errors” at the end of this
section. You should check the value of the procedure result whenever you use this
procedure.

Possible values returned by the VSNGETORD1 procedure are as follows:

0 1001 3000 3003

1 1002 3001 3006

3002 3008

5–94 8600 0544–103


Internationalization

Output
Sample output from Example 5–24 is as follows:

RESULT = 1

In this sample, DEST contains the following hex data: 414243414541 454040404040
404040111221 111111111111.

See Also
For more information on the error result values, see Table 5–3 later in this section.

VSNINSPTXT
This procedure searches specified text for characters that are present or not present in a
requested truthset. The SCAND parameter is an integer that represents the number of
characters that were searched when the criteria specified in the FLAG parameter were
met. If SCAND is equal to INSLEN, then all the characters were searched, but none met
the criteria. Otherwise, adding the TEXTST value to the RSLT value gives the location of
the character, from the start of the array, that met the search criteria.

Example
Example 5–25 shows the parameter declarations and the specifications required to call
the VSNINSPTXT library procedure. Each of the parameters is explained in the text
following the example.

This example examines a record which contains two fields, a name and a phone number.
The name is verified to contain only alphabetic characters as defined by the France
ccsversion. You can use the MLS Guide to determine that the ccsversion number for
France is 35. You can also retrieve this number by calling the procedure CSSVSNNUM
with the name France.

8600 0544–103 5–95


Internationalization

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00200F* THIS PROGRAM TESTS THE VSNINSPTXT PROCEDURE.
01000FFILE1 O DISK
01500A TITLE 'OUT/RPG/VSNINSPTXT'
02000E TEXT 1 1 40
06000$$INCLUDE "SYMBOL/INTL/RPG/PROPERTIES"
06500C Z-ADD35 VSNNUM 110
08000C Z-ADD0 TEXTST 110 START TEXT
10000C Z-ADD40 INSLEN 110 INSPECT LEN
10400C Z-ADD13 TTYPE 110 SCAN NUMERIC
10800C Z-ADD0 FLAG 110 NOT IN TRUTHS
11000C*
12000C EEXSRVSNINSPTXTRSLT 110
14000C PARAMVSNNUM
15000C PARAM TEXT
16000C PARAMTEXTST
16200C PARAMINSLEN
16400C PARAMTTYPE
16600C PARAMFLAG
16800C PARAM SCAND 110
17000C*
17500C EXCPTHEAD
18000C*
20000C RSLT IFEQ 1
22000C EXCPT
24000C END
34000C*
36000C SETON LR
36020OFILE1 E HEAD
36040O 'RESULT = '
36060O RSLT 3
38000OFILE1 E
40000O 'SCANNED CHARACTERS = '
42000O SCAND 3
44000VVECTOR SEQ
460007775961089John Alan Smith

Example 5–25. Coding for the VSNINSPTXT Procedure

Explanation
VSNNUM is a numeric field passed to the procedure. It specifies the ccsversion to be
used. The ccsversion number used in Example 5–25 is 35. The following are the values
allowed for VSNNUM:

5–96 8600 0544–103


Internationalization

Value Meaning

Greater than Specifies a ccsversion. The numbers of the ccsversions are


or equal to 0 listed in the MLS Guide.

–2 Use the system default ccsversion. If the system default


ccsversion is not available, an error is returned.

TEXT is an alphanumeric field passed to the procedure. It is searched using the


requested truthset. The recommended array size for TEXT is determined by the caller.

TEXTST is a numeric field passed to the procedure. It contains the byte offset in TEXT,
relative to 0 (zero), at which the search begins.

INSLEN is a numeric field passed to the procedure. It specifies the number of characters
to be searched beginning at TEXTST. It specifies the maximum length of the search.

TTYPE is a numeric field passed to the procedure. It indicates the type of truthset to be
used for the search. The following are the values allowed for TTYPE and their meanings:

Value Meaning

12 Alphabetic truthset. It identifies the characters defined as alphabetic


in the specified ccsversion.

13 Numeric truthset. It identifies the characters defined as numeric in


the specified ccsversion.

14 Presentation truthset. It identifies the characters in the ccsversion


that can be represented on a presentation device, such as a printer.

15 Spaces truthset. It identifies the characters defined as spaces in the


specified ccsversion.

16 Lowercase truthset. It identifies the characters defined as lowercase


alphabetic in the specified ccsversion.

17 Uppercase truthset. It identifies the characters defined as uppercase


alphabetic in the specified ccsversion.

A ccsversion is not required to have a definition for each of these truthsets. Some of the
truthsets, such as 16 and 17, are optional. A result of 4002 might be returned if the
truthset was not defined for the ccsversion. The input text remains unchanged.

FLAG is a numeric field passed to the procedure. It indicates the type of search to be
performed. The values allowed for FLAG and their meanings are as follows:

Value Meaning

0 Search the text until a character is found that is not in the requested
truthset.

1 Search the text until a character is found that is in the requested


truthset.

8600 0544–103 5–97


Internationalization

SCAND is a numeric field returned by the procedure. It contains the number of


characters, relative to 0 (zero), that were scanned before the search criteria was met.

RSLT is a numeric field returned as the procedure result. It indicates whether an error
occurred during the execution of the procedure. Values other than 1 indicate an error. An
explanation of the error result values can be found under “Errors” at the end of this
section. You should check the value of the procedure result whenever you use this
procedure.

Possible values returned by the VSNINSPTXT procedure are as follows:

1 1000 3000 4002

1001 3001

1002 3003

3006

3007

Output
Sample output from Example 5–25 follows:

RESULT = 1
SCANNED CHARACTERS = 10

See Also
For more information on the error result values, see Table 5–3 later in this section.

VSNTRANTXT
This procedure applies a specified translate table to the source text and places the result
into the destination parameter. You can use the same alphanumeric field for both the
source and destination text.

You might use this procedure to translate alternate digits received as data into numerics
for arithmetic processing.

Example
Example 5–26 shows the parameter declarations and the specifications required to call
the VSNTRANTXT library procedure. Each of the parameters is explained in the text
following the example.

This example translates a string in lowercase letters to uppercase letters using the
CanadaEBCDIC ccsversion. The input string is “p¯an.” You can use the MLS Guide to
determine that the ccsversion number for CanadaEBCDIC is 74. You can also retrieve
this number by calling the procedure CCSVSNNUM with the name CanadaEBCDIC.

5–98 8600 0544–103


Internationalization

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
01000FPRINT O DISK
01500A TITLE 'OUT/RPG/VSNTRANTXT'
05000$$ INCLUDE "SYMBOL/INTL/RPG/PROPERTIES"
18000C MOVE 'p¯an' SOURCE 7
24000C Z-ADD74 VSNNUM 110
28000C Z-ADD4 TLEN 110
28500C Z-ADD0 STRTS 110 START SOURCE
29000C Z-ADD0 STRTD 110 START DEST
29500C Z-ADD7 TYP 110 LOW-TO-UPPER
30000C*
32000C EEXSRVSNTRANTXTRSLT 110
34000C PARAMVSNNUM
38000C PARAM SOURCE
40000C PARAMSTRTS
42000C PARAM DEST 10
44000C PARAMSTRTD
46000C PARAMTLEN
47000C PARAMTYP
48000C*
48500C EXCPTHEAD
48600C*
48700C RSLT IFEQ 1
48800C EXCPT
48900C END
49000C*
62000C SETON LR
64000OPRINT E HEAD
66000O 'RESULT = '
68000O RSLT 3
70000OPRINT E
72000O 'DEST = '
74000O DEST

Example 5–26. Coding for the VSNTRANTXT Procedure

8600 0544–103 5–99


Internationalization

Explanation
VSNNUM is a numeric field passed to the procedure. It contains the number of the
ccsversion to be used. The ccsversion contains the rules for translation of text. Refer to
the MLS Guide for a list of the ccsversion numbers. The values allowed for VSNNUM and
the meanings of the values are as follows:

Value Meaning

Greater than or equal Use the specified ccsversion number.


to 0

–2 Use the system default ccsversion. If the system default


ccsversion is not available, an error is returned.

SOURCE is an alphanumeric field passed to the procedure. It contains the data to


translate. The recommended array size for SOURCE is determined by the caller.

STRTS is a numeric field passed to the procedure It designates the byte offset, relative
to 0 (zero) in SOURCE at which translation is to begin.

DEST is an alphanumeric field returned by the procedure. It contains the translated text.
The recommended array size for DEST is the same as the size for SOURCE.

STRTD is a numeric field passed to the procedure. It indicates the starting offset location
in DEST where the translated text is to be placed.

TLEN is a numeric field passed to the procedure. It designates the number of characters
in SOURCE to translate, beginning at STRTS.

TTABLE is a numeric field passed to the procedure. It designates the type of translation
requested. The allowed values for TTABLE and their meanings are as follows:

Value Meaning

5 Translate numbers 0 through 9 to alternate digits specified in the


ccsversion.

6 Translate alternate digits to numbers 0 through 9.

7 Translate all characters from lowercase to uppercase.

8 Translate all character from uppercase to lowercase.

9 Translate a character to its escapement value.

A ccsversion is not required to have a definition for each of these tables. Some of the
tables, such as 5, 6, 7, and 8, are optional. A result of 4002 might be returned if the table
was not defined for the ccsversion. The input text remains unchanged.

RSLT is a numeric field returned by the procedure that indicates whether an error
occurred during the execution of the procedure. Values other than 1 indicate an error. An
explanation of the error result values can be found under “Errors” at the end of this
section. You should check the value of the procedure result whenever you use this
procedure.

5–100 8600 0544–103


Internationalization

Possible values returned by the VSNTRANTXT procedure are as follows:

1 1000 3000 3003 4002

1001 3001 3006

1002 3002

Output
Sample output from Example 5–26 follows:

RESULT = 1
DEST = P®AN

See Also
For more information on the error result values, see Table 5–3 later in this section.

8600 0544–103 5–101


Internationalization

Errors
All of the procedures in the CENTRALSUPPORT library return integer results to indicate
the success or failure of the procedure. Table 5–3 displays error codes associated with
internationalization. You can find a complete list of error codes and their explanations in
the CENTRALSUPPORT library file SYMBOL/INTL/RPG/PROPERTIES.

Explanation of Error Values


Values in the range 1000 through 1999 are error messages that report a Unisys software
error.

Values from 2000 through 2999 contain error messages in which the caller passed invalid
data to a procedure, but the CENTRALSUPPORT library was able to return some valid
data.

Values from 3000 through 3999 contain error messages in which the caller passed invalid
data to a CENTRALSUPPORT procedure, and the CENTRALSUPPORT library was unable
to return any valid data.

Table 5–3 lists the error values that can be returned for internationalization and the
specific description of each error message that you can have your program display.

Refer to the MLS Guide for a list of the complete error messages and for information
about the corrective actions to be taken if an error occurs.

Table 5–3. Specific Descriptions for Internationalization Error Values

Error Specific Description


Value

1000 An error occurred while accessing the SYSTEM/CCSFILE or the


SYSTEM/CONVENTIONS file.
1001 An unexpected fault occurred in CENTRALSUPPORT. Your request cannot be
processed at this time.
1002 A CENTRALSUPPORT software error was detected. Your request cannot be
processed at this time.
2001 The data is not in the requested language. It is in MYSELF.LANGUAGE or the
SYSTEM LANGUAGE or the first available LANGUAGE.
2002 The data is not in the requested convention; it is in MYSELF.CONVENTION or
the SYSTEM CONVENTION.
2004 Only partial data is being returned. There was insufficient space in the output
array.
3000 A parameter was incorrectly specified as less than or equal to 0.

5–102 8600 0544–103


Internationalization

Table 5–3. Specific Descriptions for Internationalization Error Values

Error Specific Description


Value

3001 The output array size is smaller than the length of the data it is supposed to
contain.
3002 At least one array length is invalid or the offset + length is greater than the size
of the array.
3003 The requested number was not found.
3004 The requested name was not found.
3005 The requested number was not found.
3006 The type code specified is out of the acceptable range.
3007 The flag specified is out of the acceptable range.
3008 The space for OSVs or total storage allocated in OUTPUT is not big enough for
OSVs and/or PSVs.
3011 An invalid control character was detected in the template.
3012 The input date contains illegal characters.
3013 The input time contains illegal characters.
3014 An attempt was made to add a new convention with the name of an existing
convention.
3015 The maximum digits value is either missing or out of range.
3016 The fractional digits value is either missing or out of range.
3017 The international fractional digits value is either missing or out of range.
3018 The long date template is either missing or contains invalid information.
3019 The short date template is either missing or it contains invalid information.
3020 The numeric date template is either missing or contains invalid information.
3021 The long time template is either missing or it contains invalid information.
3022 The numeric time template is either missing or contains invalid information.
3023 The monetary template is either missing or it contains invalid information.
3024 The numeric template is either missing or it contains invalid information.
3027 The lines per page value is either missing or it is out of range.
3028 The characters per line value is either missing or it is out of range.
3029 A required symbol in either the monetary or the numeric template is missing.
3030 An invalid template length value was encountered.

8600 0544–103 5–103


Internationalization

Table 5–3. Specific Descriptions for Internationalization Error Values

Error Specific Description


Value

3031 A mutually exclusive combination of control characters has been encountered in


a monetary or numeric template.
3032 The mindigits field in a “t” control character in a monetary or numeric template
is out of range.
3033 A right bracket “]” is required to terminate a “t” control character symbol
definition list.
3034 An expected colon “:” is missing from the “t” control character in a monetary
or numeric template.
3035 The input value did not contain digits or an expected symbol was missing.
3036 Specified convention does not exist and cannot be retrieved, modified, or
deleted.
3037 A convention definition cannot be added, modified, or deleted.
3038 The “PRECISION” parameter value is out of range.
3039 A required convention name was not provided.
3040 The named convention is a standard convention and cannot be modified or
deleted.
3041 A hexadecimal value representing a symbol in a monetary or numeric template
is missing a required delimiter.
3042 An invalid character was encountered in a hex value representing a symbol in a
monetary or numeric template.
3043 The international currency notation is missing a required terminating delimiter.
3044 The DATE components are separated by an invalid character.
3045 The year component exceeds 2 digits.
3046 A nonzero value is required for the year component.
3047 The month value is outside of the valid range. Acceptable values are in the
range 1 through 12.
3048 The day value is outside of the valid range. Acceptable values for months
January through December are:
1..31, 1..28 (1..29 in a leap year), 1..31, 1..30, 1..31,1..30,
1..31, 1..31, 1..30, 1..31, 1..30, and 1..31, respectively.
3049 An input date is required, but it is missing.
3050 Time components are separated by an invalid character.
3051 The hour value is outside of the valid range for the 24-hour clock. Acceptable
values are in the range 0 through 23.

5–104 8600 0544–103


Internationalization

Table 5–3. Specific Descriptions for Internationalization Error Values

Error Specific Description


Value

3052 The hour value is outside of the valid range for the 12-hour clock. Acceptable
values are in the range 1 through 12.
3053 The minute value is outside of the valid range. Acceptable values are in the
range 0 through 59.
3054 The second value is outside of the valid range. Acceptable values are in the
range 0 through 59.
3055 The partial second value contains invalid characters.
3056 An input time is required, but it is missing.
3057 The month value is required, but it is missing
3058 The day-of-year value is outside of the valid range. Acceptable values are in the
range 1 through 365 (1 through 366 for a leap year).
3059 The day-of-year value cannot be calculated because a date component (year,
month, or day) is missing.
4002 The requested data was not found.

8600 0544–103 5–105


Internationalization

5–106 8600 0544–103


Section 6
Indicator Summary Form

The RPG Indicator Summary form shown in Figure 6–1 is used for documentation
purposes to provide an accurate record of the indicators that are used and the function of
those indicators in the RPG source program.

Figure 6–1. Indicator Summary Coding Form

Table 6–1 summarizes the definitions in Figure 6--1.

Table 6–1. Field Definitions Summary (Indicator Summary Form)

Columns Description

1–5 Identifies the program sequence numbers unless the $UNSEQ compiler control option
is TRUE.
6 Contains any value as long as column 7 contains an asterisk (*).
7 Requires an asterisk (*); causes complete line to be considered a comment.
8–10 Contains record identifying indicators.
11–13 Contains input field indicators.
14–16 Contains resulting indicators from calculations.
17–19 Contains matching indicators.
20–22 Contains control level, overflow, halt, and user indicators.
23–74 Identifies functions of indicators listed in columns 8 through 22.
75–80 Contains the program identification. Any entry is valid.

8600 0544–103 6–1


Indicator Summary Form

6–2 8600 0544–103


Section 7
Control Specification

The Control Specification provides the RPG compiler with information about options such
as debugging, date formatting, and sign positioning. Only one Control Specification line
can appear in an RPG program. The use of the Control Specification is optional.

Control Specification Coding Form and Summary


The coding form provides one line for coding the proper control information (see
Figure 7–1).

Figure 7–1. Control Specification Coding Form

Table 7–1 summarizes the field definitions for the Control Specification.

Table 7–1. Field Definitions Summary (Control Specification)

Columns Description

1–5 Identifies the program sequence numbers unless the $UNSEQ compiler control
option is TRUE.
6 Identifies the type of specification for each line of code. This field must be coded
with the letter H.
7 Contains an asterisk if the line is a comment.

8600 0544–103 7–1


Control Specification

Table 7–1. Field Definitions Summary (Control Specification)

Columns Description

10 Determines whether warnings should be regarded as syntax errors. Acceptable


entries are blank or the letter D.
15 Designates whether the DEBUG operation is to be used during compilation.
Acceptable entries are the letters D and C, 1, or blank. The letters D and C are valid
when COMS is being used. For more information about using COMS, refer to
Volume 2 of this manual.
17 Determines the location of the sign in external numeric data items. Acceptable
entries are blank, or the letters L or R.
21 Specifies the punctuation and format of numeric and UDATE fields. Acceptable
entries are blank or the letters I, D, or J.
22 Defines the currency symbol that appears in the output when editing. Any character
is an acceptable entry.
23 Specifies the order of the system date (date format). Acceptable entries are blank or
the letters M, D, or Y.
24 Identifies the separator to be used in date editing. Any character is an acceptable
entry.
26 Specifies the collating sequence applied to alphanumeric data. Acceptable entries
are blank, or the letters E, A, S, or N.
40 Designates the way in which external signs are to be handled. Acceptable entries
are blank, or the letters S or O.
41 Causes output lines conditioned by the first page (1P) indicator to be printed more
than once. Acceptable entries are blank or 1.
42 Specifies the initialization and setting of zero/blank indicators. Acceptable entries are
blank or the letters R or S.
43 Determines if input, output, update, or combined files need to be translated.
Acceptable entries are blank or F.
46 Defines the line printer skipping method. Acceptable entries are blank, 1, or 2.
49 Specifies the handling of run-time errors. Acceptable entries are blank or the letters
S or G.
50 Determines program handling if a halt indicator is on. Acceptable entries are blank or
the letters S or G.
51 Names the RPG dialect to use (RPG I or RPG II). Acceptable entries are blank or 1.
52 Designates the point at which to open files. Acceptable entries are blank or the
letters N and S.
53 Specifies the point at which to close files. Acceptable entries are blank or the letters
N and S.
75–80 Contains program documentation. Any entry is valid.

7–2 8600 0544–103


Control Specification

Field Definitions
The fields for the Control Specification coding form are defined in the paragraphs that
follow.

An entry in a column that is not part of any of the defined fields in a specification might
cause warnings to be displayed.

Sequence Number (Columns 1–5)


The Sequence Number field contains a 5-digit sequence number (00000–99999) for an
RPG program source unless the $UNSEQ compiler control option is TRUE. Refer to
Section 21, “Control of the Compilation Process,” for information about the $UNSEQ
option.

Form Type (Column 6)


This field identifies the type of specification for each line of code. This field must be
coded with the letter H.

Comment (Column 7)
Explanatory statements can appear in the source if column 7 contains an asterisk (*). The
Comment entry enables the entire line to the right of the asterisk to appear as program
documentation on the program listing. Comments are not instructions to the RPG
program or compiler, but serve as program documentation. Any valid character can be
used in a comment line. An asterisk in column 7 overrides an entry in column 6.

Example
Example 7–1 shows comment line coding.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00105H*
00110H* This is an example of how comment lines are coded. All lines
00120H* with an asterisk in column 7 are ignored by the compiler.
00140H*
00150H* Control Specification
00170H*
00200H 1

Example 7–1. Coding a Control Specification Comment Line

8600 0544–103 7–3


Control Specification

Object Output (Column 10)


An entry in column 10 determines whether warnings should be regarded as syntax
errors.

Valid entries for the Object Output field (column 10) are

Entry Results

Blank Warnings are not treated as errors.

D Warnings are treated as syntax errors; no object code file is created by the
compiler if syntax errors are found.

Treating warnings as syntax errors has the same effect as setting the $WARNFATAL
compiler control option. If syntax errors are found or if warnings are found when
$WARNFATAL is TRUE, no object file is created by the compiler. By default, warnings do
not prevent the object code from being created.

Debug (Column 15)


Column 15 specifies whether the DEBUG operation is in effect during program
generation. This option is overridden by the $USERDEBUG compiler control option, if
specified.

The DEBUG operation is performed if the following are true:

• Column 15 of the Control Specification is coded with a 1.


• The DEBUG operation code appears in the Calculation Specifications. Refer to the
description of the DEBUG operation code in Section 16, “Operation Codes,” for
further information.
If this column contains an entry other than blank, 1, or a valid COMS entry, the entry is
treated as a blank and a warning message is displayed.

Refer to Volume 2 of this manual for information about valid entries used with COMS.

7–4 8600 0544–103


Control Specification

Sign Position (Column 17)


This field specifies the location of the sign in external numeric data items.

Valid entries for the Sign Position field (column 17) are

Entry Definition

Blank or L A sign is placed in the leftmost (high-order) character position.

R A sign is placed in the rightmost (low-order) character position.

A valid nonblank entry in this column overrides any previous assignment of the sign
position with the default value or the $RSIGN compiler control option. The sign position
specified by this field can be overridden by the $RSIGN compiler control option if
different sign positions are required in the program (refer to Section 21, “Control of the
Compilation Process”).

Any entry other than blank, L, or R is treated as an L, and a warning message is


displayed.

Inverted Print (Column 21)


This field specifies the punctuation used for numeric literals in the Calculation
Specifications and for edit codes in the Output Specifications, as well as the order and
punctuation of the system date field.

Valid entries for the Inverted Print field (column 21) are

Entry Definition

Blank Domestic format.

I International format.

J Similar to the international format except when a numeric field contains a


fraction. If a field containing fractions is written, the number 0 is written to the
left of the decimal comma.

D United Kingdom format.

An entry other than blank, I, J, or D is treated as a blank, and a warning message is


displayed.

This column might be partly overridden by entries in the Date Format and Date Edit fields
(columns 23 and 24).

8600 0544–103 7–5


Control Specification

The Inverted Print field values and resulting formats are shown in Table 7–2.

Table 7–2. Inverted Print Field Entries and Sample Results

Column Numeric Literal Edit Codes with Zero Suppress UDATE


21 Entry with a Comma or a Comma or a to the Left or with a
a Period as a Period as a Right of the Slash or a
Decimal Point Decimal Point Decimal Point Period

Blank 5678.90 7,654.32 .60 MM/DD/YY


D 5678.90 7,654.32 .60 DD/MM/YY
I 5678,90 or 7.654,32 ,60 DD.MM.YY
5678.90
J 5678,90 or 7.654,32 0,60 DD.MM.YY
5678.90

Currency Symbol (Column 22)


This field specifies the currency symbol. The character used to replace the currency
symbol in fields with either edit codes or edit words is specified. This character does not
appear in edit words, which continue to be coded with the dollar sign ($) in the usual
way. A blank entry in this field implies the use of the dollar sign as the currency symbol.

Date Format (Column 23)


This field specifies the date format. The column 23 entries designate the order of the
system date field (UDATE). The Inverted Print field (column 21) also affects the format of
the system date field.

Valid entries for the Date Format field (column 23) are

Entry Definition

Blank Use the format specified by the Inverted Print field (column 21).

M Use the MMDDYY format.

D Use the DDMMYY format.

Y Use the YYMMDD format.

7–6 8600 0544–103


Control Specification

Date Edit (Column 24)


This field is used for date editing. Column 24 specifies the character used as a separator
when a field is edited with a Y edit code. The entry in the Inverted Print field (column 21)
also affects the character used as the separator.

Valid entries for the Date Edit field (column 24) are

Entry Definition

Blank Character specified by the Inverted Print field (column 21) is used as the
separator.

& Blank is used as the separator.

Any Specified character is used as the separator.


other
character

Collating Sequence (Column 26)


This field specifies the collating sequence applied to alphanumeric data in the following
functions:

• Match field sequence checking


• Match field processing
• COMP operation code
• IFxx, DOUxx, DOWxx, and CASxx operation codes
• LOKUP operation code
• Preexecution-time vector loading
Valid entries for the Collating Sequence field (column 26) are

Entry Definition

E or EBCDIC collating sequence as defined by the standard mapping tables for


blank EBCDIC-to-ASCII and ASCII-to-EBCDIC translation.

A ASCII collating sequence as defined in the American National Standard:


Code for Information Interchange, X3.4–1977.

S Enables the use of Alternate Collating Sequence Specifications to explicitly


modify the EBCDIC collating sequence (refer to Section 18, “Alternate
Collating Sequence Specifications”).

N Enables the program to have automatic access to the system default


collating sequence. The N entry specifies that the system default
localization collating sequence should be applied to process alphanumeric
data.

8600 0544–103 7–7


Control Specification

The correspondence between characters of the ASCII character code and characters of
the EBCDIC character code is determined by standard mapping tables for EBCDIC-to-
ASCII and ASCII-to-EBCDIC translation (refer to Appendix B, “Reference Tables”).

External Sign Handling (Column 40)


This field provides programmatic control of external sign handling.

Valid entries for the External Sign Handling field (column 40) are

Entry Definition

S or All unpacked numeric input fields containing a negative zero (J through R) or an


blank alphanumeric minus sign (–) in the sign byte are converted to a negative sign
(binary 1101). Packed numeric input fields containing a negative sign (binary
1101) retain that sign. All other numeric input fields (packed or unpacked) are
converted to the system standard positive sign (binary 1100).

When positive, unpacked, unedited numeric data are written, the sign byte is
converted to alphanumeric 0 through 9. The positive sign (binary 1100) is
retained for positive, packed, unedited numeric output data. Retention of this
sign permits the writing of positive, unpacked numeric data, which cannot
otherwise be written as alphabetic characters even though no editing is done.

O Input fields are handled as described for the S option. For output fields, the
sign byte in positive, unpacked, unedited numeric output fields contains
positive zero (+0) or A through I. Positive, packed, unedited numeric output
fields retain the positive sign (binary 1100).

Any entry other than blank, S, or O is treated as a blank, and a warning message is
displayed.

7–8 8600 0544–103


Control Specification

Forms Position (Column 41)


Because special forms might need to be aligned in the line printer before a report can be
printed, the Forms Position field enables all heading/detail output lines conditioned by the
first page (1P) indicator to be printed more than once when the program is executed.

Valid entries for the Forms Position field are

Entry Definition

Blank The 1P indicator lines are printed only once.

1 Forms positions function is enabled.

After each time the lines are printed, the program pauses to enable the
operator to reposition the forms. The operator can print the lines as many
times as necessary to align the forms properly.

The 1P indicator can also be used to designate output to devices other than printers.

If this field contains an entry other than blank or 1, the entry is treated as a blank and a
warning message is displayed.

Zero/Blank Indicator Setting (Column 42)


This field specifies beginning of job (BOJ) initialization for indicators that test for zero or
blank conditions in the Input Specifications and Calculation Specifications. This field also
determines whether a Blank After field (column 39) in the Output Specifications affects
the setting of zero/blank indicators that have been applied to the same field. The Source
Input Dialect field (column 51) also affects the setting of zero/blank indicators. If a value
is entered in this field, it overrides the default zero/blank indicator setting specified by the
dialect named in the Source Input Dialect field.

Valid entries for the Zero/Blank Indicator Setting field (column 42) are

Entry Definition

Blank The default value is R for RPG II and S for RPG I dialect. Source input dialect is
determined by the Source Input Dialect field (column 51) in the Control
Specification.

R Zero/blank indicators are turned off at BOJ and are not affected by a Blank
After field specified for the associated field during output.

S Zero/blank indicators are turned on at BOJ. If a field with a zero/blank indicator


specified in either the Input Specifications or the Calculation Specifications is
also specified in Output Specifications with a Blank After field entry, the
zero/blank indicator is turned on when zeros or blanks are moved to the field.

Halt indicators are always turned off initially, even if the indicators are used to test for
zero or blanks, and are never turned on by a Blank After field entry. Any entry other than
blank, S, or R is treated as a blank, and a warning message is displayed.

8600 0544–103 7–9


Control Specification

File Translation (Column 43)


This field is used when information in input, output, update, or combined files is in a
character code that is different from the character code used by the system. Refer to
Section 19, “File Translation Specifications,” for more information on file translation.

Valid entries for the File Translation field (column 43) are

Entry Definition

Blank No file translation is needed.

F Input, output, update, or combined files are to be translated.

Line Printer Skipping (Column 46)


This field specifies the desired method of line printer skipping. The type of printer used
should be considered when this option is specified. The Source Input Dialect field
(column 51) also affects the method of line printer skipping. If a value is entered in this
column, it overrides the default line printer skipping specified by the dialect named in the
Source Input Dialect field.

Valid entries for the Line Printer Skipping field (column 46) are

Entry Definition

Blank The default value is 2 for RPG II and 1 for RPG I dialect. Source input dialect is
determined by the Source Input Dialect field (column 51) in the Control
Specification.

1 The line printer skipping method specified in columns 19 through 22 of Output


Specifications is determined by the channel number specified in those
columns.

2 The line printer skipping method specified in columns 19 through 22 of Output


Specifications is determined by the line number specified in those columns.

Any entry other than 1, 2, or blank is treated as a blank, and a warning message is
displayed.

7–10 8600 0544–103


Control Specification

Run-Time Error (Column 49)


This field specifies whether a run-time error (for example, RECORD IDENTIFICATION
ERROR or MATCH FIELD SEQUENCE ERROR) is handled automatically or through
operator intervention.

Valid entries for the Run-Time Error field (column 49) are

Entry Definition

Blank Operator intervention is required either to continue or to end the program.

S A run-time error causes the program to end in an orderly manner.

G The program continues processing as described in Appendix A, “System


Messages.”

Any entry other than S, G, or blank is treated as a blank, and a warning message is
displayed.

Halt Indicator (Column 50)


This field specifies whether operator intervention is required when a halt indicator is on
or whether the situation is to be handled automatically.

Valid entries for the Halt Indicator field (column 50) are

Entr Definition
y

Blank Operator intervention is required either to continue or to end the program.

S The program automatically ends in an orderly manner.

G The program continues processing as described in Appendix A, “System


Messages.”

Any entry other than S, G, or blank is treated as a blank, and a warning message is
displayed.

8600 0544–103 7–11


Control Specification

Source Input Dialect (Column 51)


RPG for MCP based systems supports two dialects: RPG I and RPG II. The RPG I dialect
is primarily compatible with the IBM 360/20 RPG. The RPG II dialect is compatible with
the IBM System/36 RPG II. Both dialects support MCP based extensions. If RPG I
features are needed, a 1 must be entered in column 51 of the Control Specification;
otherwise, this column should be blank. The source program is not checked against the
syntax of the chosen dialect; this option is used only to resolve conflicts between the
dialects. Provided that no conflict exists, RPG II features can be used when the RPG I
dialect is specified. Similarly, RPG I features can be used when the RPG II dialect is
specified.

Valid entries for the Source Input Dialect field (column 51) are

Entry Definition

Blank RPG II features are used.

1 RPG I features are used.

When this field contains a 1, the following actions occur:

• Printer output skipping refers to channel numbers. This option can be overridden.
Refer to “Line Printer Skipping (Column 46)” in this section.
• Zero/blank indicators (except the halt indicators) are turned on at the beginning of
program execution. This option can be overridden. Refer to “Zero/Blank Indicator
Setting (Column 42)” in this section.
If more than one zero/blank indicator is used for a given field, only the first zero/blank
indicator is the related zero/blank indicator of the field.
• When a field with a related zero/blank indicator becomes 0 (zero) or blank, the related
zero/blank indicator is turned on immediately. (Fields can become 0 or blank as a
result of a Blank After entry, move operations, or arithmetic operations.) This option
can be overridden. Refer to “Zero/Blank Indicator Setting (Column 42)” in this
section.
• The last record (LR) indicator test in the PLC is bypassed. Refer to step 4 in
Section 3, “RPG Program Logic Cycle (PLC).”
• An ampersand (&) appearing in the extension portion of an edit word is written as an
ampersand (unlike RPG II, in which the ampersand is written as a blank).
Any entry other than blank or 1 is treated as a blank, and a warning message is displayed.

7–12 8600 0544–103


Control Specification

Time of File Open (Column 52)


Normally, all files are opened at BOJ, as specified in the PLC. This option enables files to
be opened when they are first accessed.

Valid entries for the Time of File Open field (column 52) are

Entry Definition

Blank All files are opened at BOJ.

N All files are opened at BOJ. The $ACCESSOPEN compiler control option (if
specified) is ignored and a warning message is displayed.

S Each file is opened when it is first accessed.

Any entry other than blank or S is treated as a blank, and a warning message is
displayed.

Time of File Close (Column 53)


Normally, all files are closed at end of job (EOJ), as specified in the PLC. This option
enables serial input files to be closed at end of file (EOF).

Valid entries for the Time of File Close field (column 53) are

Entry Definition

Blank All open files are closed at EOJ.

N All open files are closed at EOF. The $EOFCLOSE compiler control option (if
specified) is ignored and a warning message is displayed.

S Consecutively processed input files, update files, and combined files are
closed at EOF. All other open files are closed at EOJ.

Any entry other than blank or S is treated as a blank, and a warning message is
displayed.

Program Identification (Columns 75–80)


This field is not used by the RPG compiler, but appears on the source program listing so
that the field can be used for documentation purposes to identify different portions of the
program. Any entry is valid for the Program Identification field (column 75–80).

The Program Identification field is used to identify any cross-reference listing that might
need to be created for the program. For more information about cross-reference listings,
see the descriptions of the $XREF and $XREFFILES compiler control options in
Section 21, “Control of the Compilation Process.”

8600 0544–103 7–13


Control Specification

7–14 8600 0544–103


Section 8
File Description Specifications

Every file used by an RPG program must be described through File Description
Specifications. These specifications provide information about the way the file is to be
used.

The name of this specification is shortened to File Specifications to increase readability.


The terms File Description Specifications and File Specifications are synonyms.

File Specifications are also required for data management files. Refer to Volume 2 of this
manual for more information.

File Specifications are also used to define key descriptions for indexed files.

Additional information about the file can be specified in the Attribute Specifications that
follow directly after the corresponding File Specifications. Refer to Section 9, “Attribute
Specifications,” for more information.

File Specifications Coding Form and Summary


The File Specifications form is used to code file description information (refer to
Figure 8–1). At least one file description line is required to describe each file.

Figure 8–1. File Specifications Coding Form

8600 0544–103 8–1


File Description Specifications

Table 8–1 summarizes the field definitions for the File Specifications form.

Table 8–1. Field Definitions Summary (File Specifications)

Columns Description

1–5 Identifies the program sequence numbers unless the $UNSEQ compiler
control option is TRUE.
6 Identifies the type of specification for each line of code. This field must be
coded with the letter F.
7 Contains an asterisk if the line is a comment.
7–14 Contains a unique name for every file used by the program.
15 Specifies the way in which each file is used. Acceptable entries are I, O, U,
C, or D.
16 Describes the use of input, update, and combined files. Acceptable entries
are blank, P, S, C, T, D, F, or R.
17 Specifies the files that are to be checked for EOF during multifile
processing. Acceptable entries are blank or E.
18 Specifies that matching fields are to be checked. Acceptable entries are
blank, A, or D.
19 Specifies whether the file contains fixed–length or variable–length records.
Acceptable entries are blank, F, or V.
20–23 Specifies the block size. Allowable entries are device dependent.
24–27 Specifies the record size. The entries are device dependent.
28 Specifies, for disk files, processing by an addrout file or sequentially within
limits. Acceptable entries are blank, L, or R.
29–30 Specifies the length of a key field. Acceptable entries are 1 through 99,
right-justified.
31 Describes the format of keys within the records. Acceptable entries are
blank, K, A, P, N, I, J, L, or R.
32 Identifies the way in which a file is to be accessed or if multiple buffers are
required. Acceptable entries are I, 1 through 9, T, or blank.
33–34 Specifies the overflow indicator used to condition records of a printer file.
Acceptable entries are blank, OA through OG, or OV.
35–38 Specifies the key field starting position in each record of an indexed file.
Acceptable entries are 1 through 9999, right-justified.
39 Indicates whether an output table, array file, or printer file is further
described in the Extension Specifications or Line Counter Specifications.
Acceptable entries are blank, E, or L.

8–2 8600 0544–103


File Description Specifications

Table 8–1. Field Definitions Summary (File Specifications)

Columns Description

40–46 Identifies the I/O device to which each file is assigned. Acceptable entries
are DATACOM, DISK, GCRTAPE, ODT, PACK, PETAPE, PORT, PRINTER,
PUNCH, READER, REMOTE, SPO, TAPE, TAPE7, and TAPE9.
47–52 Assigns a name to the key field of an indexed sequential file. Any valid field
name is an acceptable entry.
53 Performs a function that depends on the entry in this field and the Device
field (columns 40–46).Acceptable entries are blank, U (unlabeled file), F
(special forms), L (exclusive use), or K (continuation line).
54–65 Specifies a continuation line option for a DISK file. The valid entry is RECNO.
66 Specifies the addition to, or the deletion from, an existing file or that
unordered records are to be loaded for indexed files. Acceptable entries are
blank, A, U, B, or D.
67 Specifies whether the file is to be translated from ASCII to EBCDIC, from
EBCDIC to ASCII, or from a translation table specified by the user.
Acceptable entries are blank, E, A, or S.
68 Indicates a primary key or whether duplicates are allowed for indexed
sequential files. Acceptable entries are blank, D, or N.
69 Specifies whether a disk file being created is delete-capable.
70 Specifies the action to be taken during the closing of a tape or disk file.
Acceptable entries are blank, C, P, U, N, R, or K.
71–72 Indicates whether or not the file is conditioned by an external indicator.
Acceptable entries are blank or U1 through U8.
75–80 Contains the program identification. Any entry is valid.

An entry in a column that is not part of any of the defined fields might cause a warning
message to be displayed.

8600 0544–103 8–3


File Description Specifications

Field Definitions
Field definitions for the File Specifications are discussed in the following paragraphs.

Sequence Number (Columns 1–5)


The Sequence Number field contains a 5-digit sequence number (00000–99999) for an
RPG program source unless the $UNSEQ compiler control option is TRUE. Refer to
Section 21, “Control of the Compilation Process,” for information about the $UNSEQ
option.

Form Type (Column 6)


This field identifies the type of specification for each line of code. This field must be
coded with an F.

Comment (Column 7)
Explanatory statements can appear in the source if column 7 contains an asterisk (*). The
Comment entry enables the entire line to the right of the asterisk to appear as program
documentation on the program listing. Comments are not instructions to the RPG
program or compiler, but serve as program documentation. Any valid character can be
used in a comment line. An asterisk in column 7 overrides an entry in column 6.

Example
Example 8–1 shows comment line coding.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00105F*
00110F* This is an example of how comment lines are coded. All lines
00120F* with an asterisk in column 7 are ignored by the compiler.
00140F*
00250F* File Specifications
00270F*
00300FFILEIN IP 80 80 DISK
00400FFILEOUT O 132 132 PRINTER

Example 8–1. Coding a File Specifications Comment Line

Filename (Columns 7–14)


This field assigns a unique file name to every file used by the program according to the
rules for names described in Section 2, “RPG Language Elements.” The entry is left-
justified.

This field can be blank only for lines describing a key.

8–4 8600 0544–103


File Description Specifications

File Type (Column 15)


This field identifies the way in which the program uses the file.

Valid entries for the File Type field (column 15) are

Entry Definition

I Input file

O Output file

U Update file

C Combined file

D Display file

Input, output, update, combined, and display files can be specified in any order, provided
that the rules specified in the discussion of primary and secondary files later in this
section are followed.

Input Files
Input files contain records used as the source of data by a program. Records are read
from a file that is described as input. Input files should be further described in the Input
Specifications, with the exception of table files, which must be described in the
Extension Specifications.

Output Files
Output files contain records that are written, printed, displayed, or punched as output
from the program. Output files normally are described in the Output Specifications. If
Output Specifications are not provided for an output file, data records are not written to
the file. The file might still be opened and closed by the PLC. If EOJ vector output is
assigned to the file in the Extension Specifications, output data are written to the file
automatically.

The File Designation field (column 16) must be blank for all output files except when a
direct file is being created. For more information, refer to the discussion of direct files in
Section 4, “Disk Files.”

8600 0544–103 8–5


File Description Specifications

Update Files
An update disk file enables the program to read a record, make the information available
for processing, and write information back into the file. A primary or secondary update
file must be updated in the same cycle as the selection of the file.

All update files normally are described in the Output Specifications and must be further
described in the Input Specifications. If Output Specifications are not provided for an
update file, data records in the file are not updated.

When a record is read by the program, the record is placed in a buffer. The only fields
that can be altered in the record buffer are the ones specified in the Output
Specifications. All other data in the record buffer remain unchanged.

Combined Files
Combined files are files used for both input and output. These files consist of records
read by the program and written as output. The records that have been read are written.
The output is as specified in the Output Specifications. Output is retained in a holding
area until the next record is read from the file. This action ensures that only one record is
written for each record read and processed by the program. Combined files must be
further described in the Input Specifications and are normally described in the Output
Specifications. If Output Specifications are not provided for a combined file, records are
not written for that file.

Display Files
Display files print a field or record directly on the operator display terminal (ODT). The
DSPLY operation must be used in the Calculation Specifications to perform the print
operation. Display files are described only in the File Specifications; that is, they do not
need Input Specifications or Output Specifications.

8–6 8600 0544–103


File Description Specifications

File Designation (Column 16)


The File Designation field further describes the use of the file type. This field must be
blank for all output and display files except when a chained direct file is being created.

Valid entries for the File Designation field (column 16) are as follows:

Entry Definition

Blank Output or display file

P Primary file

S Secondary file

C Chained file

T Table or array file

D Demand file

F Full-procedural file

R Record-address file

Primary Files
A primary file is the principal file from which the program reads input records. The
primary file can be specified as input, update, or combined. An RPG program can have no
more than one primary file. If more than one primary file is defined in the File
Specifications, all primary files except the first named primary file are assumed to be
secondary files, and a warning is displayed.

If a P is not entered in any of the File Specifications, the first secondary file defined is the
primary file.

Secondary Files
A secondary file is specified for multifile processing and can be an input, update, or
combined file. Multifile processing occurs when the PLC is used to process more than
one file.

Note: Chained, table, demand, and full-procedural files do not use the PLC to process
records.

Secondary files are processed in the order in which they are entered in the File
Specifications.

8600 0544–103 8–7


File Description Specifications

Chained Files
A chained file can be an input, update, or output file. When the chained file is an input
file, it is accessed by the CHAIN operation code in the Calculation Specifications. Chained
files do not use the PLC for input.

The RPG compiler does not explicitly limit the number of chained files allowed in an RPG
program.

When the chained file is an output file, a direct file is created. Refer to the discussion of
direct files in Section 4, “Disk Files,” for more information.

Table or Array Files


A table or array file is a sequential file that contains vector entries that can be read into
the program during preexecution time. Preexecution-time vector files are described in the
File Specifications and must be further described in the Extension Specifications. A table
or array file must be specified as an input file in the File Type field (column 15) of the File
Specifications.

Table and array files are not involved in record-selection processing at execution time.
Vector files are read before data files at execution time.

Both compile-time and preexecution-time vectors can be changed at execution time.


Vector entries read during compilation can be permanently altered only by recompiling
the program.

A vector output file that is written or punched at EOJ is a normal output file. This file is
indicated by the letter O in the File Type field and requires no entry in the File
Designation field (column 16).

Demand Files
A demand file can be an input, update, or combined file. Demand files can be processed
consecutively or randomly. Demand files do not use the PLC for input. Records are read
through the use of the READ and CHAIN operation codes in the Calculation
Specifications.

The RPG compiler does not explicitly limit the number of demand files allowed in an RPG
program.

8–8 8600 0544–103


File Description Specifications

Full-Procedural Files
A full-procedural file can be either an input disk file or an update disk file. The file can be
accessed randomly or consecutively. Full-procedural files do not use the PLC for input.
The READ, CHAIN, READP, and READE operation codes in the Calculation Specifications
are used to read records from full-procedural files. The READP and READE operations
are available only for EFS files.

The RPG compiler does not explicitly limit the number of full-procedural files allowed in
an RPG program.

Record-Address Files
A record-address file must be an input file. The file is not described in the Input
Specifications, but must be described in the Extension Specifications.

The two types of record-address files are as follows:

File Type Definition

Limits file Contains record key limits

Addrout file Contains record addresses and relative record numbers

For a description of using limits files and addrout files, refer to Section 4, “Disk Files.”

File Type and File Designation Fields Summary


The File Type (column 15) and the File Designation (column 16) fields completely
describe the type of file.

Table 8–2 shows the relationship of the File Type (column 15) and File Designation
(column 16) fields for disk files.

Table 8–2. Summary of File Type and File Designations for Disk Files

File Type File Designation Column 15 Column 16

Input Primary, secondary, chained, full- I P, S, C, F, R, T, D


procedural, record-address, table, array,
or demand
Update Primary, secondary, chained, full- U P, S, C, F, D
procedural, demand
Output Blank, chained (creating a direct file) O Blank, C
Combined Primary, secondary, demand C P, S, D

8600 0544–103 8–9


File Description Specifications

End of File (Column 17)


This field indicates whether the program can end before all the records from all the files
are processed. An entry in this field can specify if files should be checked for EOF during
multifile processing. If no entry is specified, processing in the program continues until
EOF is reached for all primary, secondary, and cycle-driven record-address files. At this
point, the last record (LR) indicator turns on.

This field must be blank for all files except primary, secondary, and record-address files
and any file processed by a record-address file.

Valid entries for the End of File field (column 17) are

Entry Definition

Blank If this entry is blank for all files, all records are read from all primary,
secondary, and cycle-driven record address files before the program ends.

E All records in this file are read and processed before the program ends.

Note: If there is an E in column 17 for a file, the program ends when EOF is reached for
that file even if EOF was not reached for other files controlled by the PLC.

An E in this field signifies that processing ends after the last record is processed in each
file for which the E was specified, except in multifile processing. For multifile processing,
if the primary file is designated with an E in column 17, all associated secondary files
continue processing after the last record has been read in the primary file; processing
stops when an unmatched record appears in each secondary file not specified with an E
in column 17.

When a data file is processed using a record-address file, the data file itself never
reaches EOF. The use of column 17 enables the program to end when the record-
address file reaches EOF.

Key Description: Multiple Keys (Columns 15–17)


This field describes multiple keys of an indexed file.

For EFS files with multiple keys, each key is described as a separate file. For more
information, refer to the discussion of alternate index files in Section 4, “Disk Files.”

For BFS files, if more than one key is needed for an indexed file, the following rules must
be followed to describe the additional keys:

• All key descriptions pertaining to a given indexed file must follow directly after the
initial File Specifications.
• The word KEY must be entered in columns 15 through 17.

8–10 8600 0544–103


File Description Specifications

• Valid entries must be coded in the following fields:


− Record-Address Field Length field (columns 29–30)
− Record-Address Type field (column 31)
− Key Field Starting Location field (columns 35–38)
− Index Name field (columns 47–52)
− Duplicate Keys field (column 68)
• All other columns must be blank.
• All keys used on Calculations Specifications must be described in the File
Specifications.
• Each key description coded for a file must be unique among all keys defined for that
file. Each key is defined by the Key Field Starting Location field (columns 35–38), the
Record-Address Field Length field (columns 29–30), and the Record-Address Type
field (column 31).
• Keys must be specified only if they are used on Calculation Specifications.
• All keys and their descriptions must be specified when the file is created.
Example
Example 8–2 shows a BFS file with a primary key (PRIK) and two alternate keys (ALK1,
ALK2) with duplicates allowed.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
01700FFBFS UF F1350 270 8AI 2 DISK PRIK U
01720F KEY 4A 10 ALK1 D
01730F KEY 6A 14 ALK2 D

Example 8–2. BFS File with One Primary Key and Two Alternate Keys

Example
Example 8–3 shows an EFS file with a primary key (PRIK) and two alternate keys (ALK1,
ALK2) with duplicates allowed. Note that the KEYEDIOIISUPPORT library does not
create key files in the order in which you enter them.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
01700FFEFS UF F1350 270 8AI 2 DISK PRIK U
01720A TITLE 'FILE/INDEX/EFS'
01730FFEFS UF F1350 270 4AI 10 DISK ALK1 D
01740A TITLE 'FILE/INDEX/EFS/KEY02'
01750FFEFS3 UF F1350 270 6AI 14 DISK ALK2 D
'FILE/INDEX/EFS/KEY01'

Example 8–3. EFS File with One Primary Key and Two Alternate Keys

8600 0544–103 8–11


File Description Specifications

Sequence (Column 18)


The Sequence field indicates that matching fields in sequenced files are checked for
either ascending or descending order. This field must be blank for all files except primary
and secondary files. The field to be checked is specified in the Match Field (columns 61–
62) of the Input Specifications. The file can be an input, update, or combined file.

Valid entries for the Sequence field (column 18) are

Entry Definition

Blank or A Records with matching fields are checked for sequence in ascending order.

D Records with matching fields are checked for sequence in descending


order.

Sequence checking is performed according to the collating sequence specified in the


Collating Sequence field (column 26) of the Control Specification. All files with matching
fields must specify the same matching sequence(that is, ascending or descending order).

If a record from a matching file is out of sequence, a MATCH FIELD SEQUENCE ERROR
message is displayed. Refer to Appendix A, “System Messages,” for the list of error
messages.

This field must be blank for a key description.

File Format (Column 19)


This field specifies whether the file contains fixed-length or variable-length records.

Valid entries for the File Format field (column 19) are as follows:

Entry Definition

Blank or F Fixed record length.


V Variable record length. This entry is valid only for disk and tape files.

Record-address files and EFS disk files must always have a fixed format.

This field must be blank for a key description.

For files containing variable-length records, the beginning of each record must contain
the total size of the record. If the mnemonic value of the INTMODE attribute is EBCDIC
(the default) the size is stored in the first four characters of the record as a decimal
number. These first four characters indicate the total number of characters in the record.
If the INTMODE attribute is set to SINGLE, the size is stored in the first word of the
record in binary. The user program must maintain the total size field of the record. For
information on setting the length of variable-length records, see the discussions of the
INTMODE, SIZEVISIBLE, and BLOCKSTRUCTURE attributes in the File Attributes
Programming Reference Manual.

8–12 8600 0544–103


File Description Specifications

Example
Example 8–4 shows the specification of record lengths for variable-length records. The
INTMODE attribute has the default value of EBCDIC and the SIZEVISIBLE attribute has
the default value of TRUE. The program reads three input files, each of which has a
different record length. Each record is written to the output file. Because the output file
has variable-length records, the total size of each record is stored in the first 4 characters
of the record. The length of the first 4 characters is included in the value of the total size
of the record.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00100F*
00200F* Each input file has a different record length.
00300F*
00400FHEADER IP F 80 80 DISK
00500FRECORDS IS F 368 368 DISK
00600FTRAILER IS F 132 132 DISK
00700F*
00800F* The output file has variable-length records.
00900F*
01000FTAPE O V8000 372 DISK
01100IHEADER AA 01
01200I 1 80 REC1
01300IRECORDS BB 02
01400I 1 368 REC2
01500ITRAILER AA 03
01600I 1 132 REC3
01700O*
01800O* Write each record from the three input files to the output
01900O* file. Store the total size of the record in the first 4
02000O* characters. The size should include the 4 characters used
02100O* to store the size.
02200O*
02300O* REC1 is a 80 character record. The size is stored as 80+4.
02400O*
02500OTAPE D 01
02600O 4 '0084'
02700O REC1 84
02800O*
02900O* REC2 is a 368 character record. The size is stored as 368+4.
03000O*

Example 8–4. Specifying Record Lengths for Variable-Length Records


(cont.)

8600 0544–103 8–13


File Description Specifications

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
03100O D 02
03200O 4 '0372'
03300O REC2 372
03500O* REC3 is a 132 character record. The size is stored as 132+4.
03600O*
03700O D 03
03800O 4 '0136'
03900O REC3 136

Example 8–4. Specifying Record Lengths for Variable-Length Records

Block Length and Record Length (Columns 20–27)


The Block Length and Record Length fields specify the block and record length in
characters for the file. The minimum and maximum record and block lengths allowed
depend on the device assigned to the file.

These fields must be blank for a key description.

Table 8–3 gives the minimum and maximum block and record length in characters for
specific devices.

Table 8–3. Minimum and Maximum Block


and Record Length Values

Device (Columns 40–46) Minimum Maximum

DISK 1 9999
ODT 1 9999
PORT 1 9999
PRINTER 1 132
PUNCH (80 column) 1 80
READER (80 column) 1 80
REMOTE 1 9999
TAPE 1 9999

Note: For card and printer files, the block length must equal the length or be blank.

8–14 8600 0544–103


File Description Specifications

Table 8–4 gives the default block and record length values for specific devices.

Table 8–4. Default Block and Record


Length Values

Device Block and Record Length

DISK 180
PRINTER 132
All other devices 80

The block length and record length entries can be blank in certain cases.

The treatment of the various cases is shown in Table 8–5.

Table 8–5. Block and Record Lengths: Resulting Values

Block Record
Length Length Result

Entry Entry The values entered are used.


Blank Blank Block length and record length default to the same value.
Entry Blank Invalid.
Blank Entry Block length defaults to the value specified for record
length.

Entries in the Block Length (columns 20–23) and Record Length(columns 24–27) fields
must be right-justified. Leading zeros can be omitted.

When a disk or tape file is created, greater efficiency is achieved if the block length of
the file is set to a value between 3000 and 6000 bytes.

Fixed-Length Records
The length of one block and one record can be entered in the Block Length (columns 20–
23) and Record Length (columns 24–27) fields, respectively. The block length must be an
integer multiple of the record length. For unblocked files, the block length must equal the
record length (card and printer files are unblocked).

8600 0544–103 8–15


File Description Specifications

Variable-Length Records
The largest record length and the largest block length are specified in the Block Length
field (columns 20–23) and the Record Length field (columns 24–27), respectively. Control
characters are included in the record length. The block size must be greater than or equal
to the record length.

Variable-length data are written to the file in fixed-size blocks. Each block contains as
many whole records as can fit into the block.

Processing Mode (Column 28)


This field is used with the File Designation field (column 16), the Record-Address Type
field (column 31), and the File Organization Type field (column 32) to determine the
processing mode for disk files.

Valid entries for the Processing Mode field (column 28) are as follows:

Entry Definition

Blank Nondisk file or disk file not to be processed sequentially within limits or by an
addrout file

R Disk file to be processed by an addrout file or to be created as a direct file

L Indexed disk file to be processed sequentially within limits

This field must be blank for a key description.

Record-Address Field Length (Columns 29–30)


This field is used for limits files, record-address files, indexed files, and alternate index
files.

For a record-address file, this field specifies one of the following:

• The length in bytes of each record in an addrout file


• The length of each key in a file processed within limits
For an indexed file or an alternate index file, this field specifies the length in bytes of the
key field within the records of the file.

For an alternate index file with a noncontiguous key, this field specifies the total length in
bytes of all parts of the key field within the records of the file. The key defined by this
entry must be the same length in all records of the file.

The entry must be numeric and right-justified in the field. Leading zeros can be omitted.
The value must be the number of bytes occupied by the key field.

The key length plus the value in the Key Field Starting Location field (columns 35–38)
minus 1 must not exceed the value in the Record Length field (columns 24–27). The

8–16 8600 0544–103


File Description Specifications

maximum key field length is 99 bytes for limits files, indexed files, and alternate index
files. For more information, refer to the discussion of file processing in Section 4, “Disk
Files.”

The length is 6 bytes for addrout files except when the GSORT compiler control option is
used with the SORT compiler, in which case the length is 3 bytes.

Record-Address Type (Column 31)


This field must be blank except for indexed disk files, alternate index files, and record-
address files. The field then gives additional information about the format of the keys, the
processing mode, or both.

Valid entries for the Record-Address Type field (column 31) are as follows:

Entry Definition

Blank Sequential or direct file

K, A Indexed file, alternate index file, or limits file with alphanumeric or zoned-
decimal keys

P Indexed file, alternate index file, or limits file with signed, packed keys

N Indexed file, alternate index file, or limits file with numeric keys in
alphanumeric format

I Addrout file or a file processed by an addrout file

J Indexed file, alternate index file, or limits file with unsigned, packed keys

L Indexed file, alternate index file, or limits file with numeric keys in separate
leading sign format

R Indexed file, alternate index file, or limits file with numeric keys in separate
trailing sign format

The valid entries for a key description are K, A, P, N, J, L, and R.

If the file is an alternate index file with a noncontiguous key, the field must contain an A.

If the file is an addrout file, the Record-Address Type field (column 31) contains an I and
the File Designation field (column 16) contains an R. If the file is processed by an addrout
file, the File Designation field does not contain R.

A numeric key specified for a limits file can have a different data format than the numeric
key specified for the associated indexed file. For details of the data formats, refer to the
Packed field (column 43) in Section 14, “Input Specifications.”

If an indexed file with alternate keys is processed sequentially by key or sequentially


within limits with the use of a record-address file, the key used for processing is the one
defined in the File Specifications for that file.

8600 0544–103 8–17


File Description Specifications

File Organization Type (Column 32)


Column 32 identifies the file organization and specifies whether multiple buffers are
required. Refer to the discussion of file organization in Section 4, “Disk Files,” for more
information.

Valid entries for the File Organization Type field (column 32) are as follows:

Entry Definition

Blank Sequential, direct, or indexed file processed consecutively or randomly by


relative record number with the number of I/O buffers assigned by the system

I Indexed or alternate index file processed by key

1-9 Sequential or direct file with the number of I/O buffers as specified

T Addrout file

If column 32 contains a T (for an addrout file), the File Designation field (column 16) must
contain an R, and the file must be assigned to disk or tape.

A limits file is defined by entering an R in the File Designation field (column 16) and 1
through 9 or blank in the File Organization Type field (column 32). If an indexed file is
processed sequentially within limits using a record-address file, the key used for
processing is the key defined in the File Specifications. Any other keys that are defined
are checked for consistency at run time.

This field must be blank for a key description.

8–18 8600 0544–103


File Description Specifications

Valid Entries for File Processing, Type, and Organization


Table 8–6 summarizes the valid entries for the Processing Mode (column 28), Record-
Address Type (column 31), and File Organization Type (column 32) fields for different
combinations of file processing and file retrieval.

Table 8–6. Summary of Processing Mode, Record-Address Type, and


File Organization Column Entries

File Kind File Processing Column Column Column


28 31 32

Addrout Addrout file Blank Blank T


file
Sequential Consecutive Blank Blank Blank
Sequential Random by relative record R Blank Blank
numbers supplied with the
CHAIN operation
Sequential Random by using an addrout R I T
file to supply the addresses
Indexed Sequential by key Blank A or P I
Indexed Sequential within limits L A or P I
Indexed Random by key R A or P I
Indexed Random by using a record- R I T
address file to supply relative
record numbers.
Direct Consecutive Blank Blank Blank
Direct Random by relative record R Blank Blank
numbers supplied with
CHAIN operation

The following guidelines apply to buffer allocation:

• The use of buffers can increase the efficiency of the program when it is executed;
however, multiple I/O buffers also increase the size of the program.
• The program runs more efficiently if the number of I/O buffers is set by the system.
Leaving column 32 blank causes the system to determine the number of I/O buffers.
• Multiple I/O buffers cannot be used with table, combined, display, or indexed disk
files.

8600 0544–103 8–19


File Description Specifications

Overflow Indicator (Columns 33–34)


This field applies only to files with PRINTER specified in the Device field (columns 40–
46). This field specifies the overflow indicator that conditions overflow records printed to
this file. Overflow printing is the printing of special lines when the overflow area is
reached. A unique overflow indicator must be assigned to each printer file for which
overflow printing is desired.

Valid entries for the Overflow Indicator field (columns 33–34) are as follows:

Entry Definition

Blank Specifies automatic skipping. No default overflow indicator is assigned.

OA–OG, OV Specifies indicator used to condition overflow printing for the file.

If an overflow indicator is specified without output conditioned on that indicator, a


continuous listing is produced.

For more information, refer to the discussion of overflow and printer file handling in
Section 17, “Output-Format Specifications.”

This field must be blank for a key description.

Key Field Starting Location (Columns 35–38)


For an indexed or alternate index file, this field specifies the character position within
each record where the key field begins. The entry must be numeric and right-justified in
the field. Leading zeros can be omitted. The Record-Address Field Length (columns 29–
30) added to the Key Field Starting Location minus 1 must not exceed the Record Length
(columns 24–27). The Key Field Starting Location field must be blank except for indexed
and alternate index files.

8–20 8600 0544–103


File Description Specifications

Extension Code (Column 39)


The Extension Code field applies to input table or array files read during program
execution, to record-address files, and to printer output files. This field indicates whether
the file is further described in the Extension Specifications (table and array files or record-
address files) or the Line Counter Specifications (printer output files).

Valid entries for the Extension Code field (column 39) are as follows:

Entry Definition

Blank Line Counter Specifications or Extension Specifications are not required for
this file; however, these specifications can still appear.

E Extension Specifications further describe the file. This entry is allowed only for
input table and array files, and record-address files.

L Line Counter Specifications further describe the file. This entry is allowed only
for printer output files.

This field must be blank for a key description.

Device (Columns 40–46)


This field identifies the logical device to which the file is assigned. All entries must be
left-justified.

Valid entries for the Device field (columns 40–46) are as follows:

Entry Definition Entry Definition

DATACOM Remote file PUNCH 80-column card reader


DISK Disk file READER 80-column card reader
ODT Operator display REMOTE Remote file
terminal
PORT Port file TAPE Magnetic tape
PRINTER Line printer

8600 0544–103 8–21


File Description Specifications

Equivalent device names accepted by the compiler are

Equivalent Device Name Assumed Device Name

SPO ODT
TAPE7 TAPE
TAPE9 TAPE
PETAPE TAPE
GCRTAPE TAPE
PACK DISK

A warning message is displayed when an equivalent device name is used.

Only one ODT (SPO) file is allowed; this file must be a display file.

The RPG language makes no provision for accessing multifile tapes.

Limits files can be assigned to any input device. Addrout files can be assigned only to an
input medium that is available to the SORT compiler as output. Only disk files can be
processed sequentially within limits or by addrout files.

This field must be blank for a key description.

Index Name (Columns 47–52)


This field must be blank except for indexed or alternate index files processed randomly or
sequentially by key. The field assigns a name to be associated with the key defined on
this line. This name can be blank, but only one blank name can be present for each file.
The formation of the name follows the rules specified in the discussion about field
names in Section 2, “RPG Language Elements.” The name must be unique among key
names. If the name is used in the Result Field (columns 43–48) in the Calculation
Specifications with CHAIN, SETLL, or DELET operation codes, then the name refers to a
key name and not to a field name.

File Open or Continuation Line (Column 53)


Any entry is allowed here; however, only valid entries are recognized. An entry that is not
recognized is treated as a blank, and a warning message is displayed.

Valid entries for the File Open or Continuation Line field (column 53) are as follows:

Entry Definition

Blank Indicates that standard labels are expected or provided for the file. If the file is
an input or update file, or any type of disk file, then the file is not available to
other programs while this program has the file open.

8–22 8600 0544–103


File Description Specifications

Entry Definition

B Applies to printer and card files only. For printer files, this entry indicates that
the file is to be written to a printer backup file. For punch files, it indicates that
the file is to be written to a punch backup file.

F Applies to printer files and indicates that special forms are required.

K Designates a continuation line. Continuation lines are used to provide


additional information about an EFS disk file.

L Applies to disk files and indicates that the file is not available to other
programs while this program has the file open.

U Indicates that this file is expected to be provided or is provided as an unlabeled


file, except for disk files. If the file is a disk file, access to this file by other
programs is not restricted while this program has the file open.

By default, input and update disk files are unavailable to other programs while they are
opened by the program. Input and update files can be made available to other programs
by setting the EXCLUSIVE file attribute to FALSE for the file or by setting the
$KEYEDIOIIOUTPUT compiler control option to TRUE.

If this field contains a K, this line is a continuation line. A continuation line is used to
provide additional information about an EFS disk file. A continuation line must occur
immediately after the file description line and must come before Attribute Specifications
or another file description line. Continuation lines must contain blanks in columns 7
through 52, a K in column 53, RECNO in columns 54–59, and the name of the field the
RECNO option uses for the relative record number in columns 60 through 65.

Continuation lines are valid only on EFS disk files if the $KEYEDIOIIOUTPUT compiler
control option is TRUE.

This field must be blank for a key description.

8600 0544–103 8–23


File Description Specifications

Continuation Options (Columns 54–65)


This field is valid only for an EFS disk file. An entry is required in this field if this line is a
continuation line, that is, if the Continuation Line field (column 53) contains a K.

The RECNO option is used to load or randomly add records to an EFS disk file. This
option contains the relative record number of a 7–digit numeric field with zero decimal
positions. This field must be specified if records are to be added randomly to an EFS
direct or sequential file that is delete-capable. It is also required for loading an EFS direct
file that is delete-capable. columns 60 through 65 must contain the name of the field that
the RECNO option uses for the relative record number. The name must be left-justified in
the columns. The relative record number used must be that of a deleted record, that is,
one that is initialized to FF (hex). The compiler uses the relative record number in the
RECNO field to determine where a record is to be read or added.

Refer to Section 4, “Disk Files,” for examples of how to use the RECNO option.

This field must be blank for a key description.

File Addition/Unordered (Column 66)


This field specifies that records can be added to or deleted from a disk file, or that
records are loaded in unordered sequence when an indexed file is being created.

Valid entries for the File Addition/Unordered field (column 66) are as follows:

Entry Definition

A Records are to be added to an existing file.

B Records are to be added to an existing file, deleted from an existing file, or


both.

U Records are to be loaded in unordered sequence for an indexed file being


created.
D, Records cannot be added to an existing file. Records can be deleted from an
blank existing file. Records are to be loaded in ascending key sequence if an
indexed file is being created.

An entry of either A or B is required in this field if ADD is entered in columns 16 through


18 of the Output Specifications record description for the file.

For input and output files, if an A or B is entered in this field, an ADD entry is assumed
for all output records.

8–24 8600 0544–103


File Description Specifications

This field must be blank under the following conditions:

• The file is processed randomly by an addrout file.


• The file is processed sequentially within limits by an addrout file.
• The File Specification is a key description line.
• Records are to be loaded in ascending key sequence when an indexed file is to be
created.
If this field is blank when an indexed file is being created, the user must ensure that
records are loaded in ascending key sequence. A KEY OUT OF SEQUENCE error
message occurs if a record is found out of sequence. Refer to Appendix A, “System
Messages,” for the list of error messages. For any indexed file, an entry in this field
implies that the index is ordered by the key specified in the Record-Address Field Length
field (columns 29–30) and Record-Address Type field (column 31) and in the Key Field
Starting Location field (columns 35–38).

For indexed files, indexes must be maintained so that records can be accessed in
ascending sequence. A DUPLICATE KEY error message occurs if an attempt is made to
write a record with a key that already exists in the file.

A KEY NOT FOUND error occurs if an attempt is made to access a record by a key value
that does not exist in the file. Refer to Appendix A, “System Messages,” for information
about DUPLICATE KEY and KEY NOT FOUND errors.

The method of adding and deleting file records depends on the type of file. Refer to the
discussions of adding and deleting records in Section 4, “Disk Files,” for more
information.

This field must be blank for a key description.

8600 0544–103 8–25


File Description Specifications

File Translation (Column 67)


This field specifies that file translation is required for the file using the character code set
specified in this field. File translation can be specified only for files with sequential
organization. Combined and update files are translated when they are read and written.

Valid entries for the File Translation field (column 67) are as follows:

Entry Definition

Blank or File translation is not required for this file.


E

A This file is translated from the ASCII character code set to the EBCDIC
character code set on input, and from the EBCDIC character code set to the
ASCII character code set on output.

S A user-specified translation table is to be used. An S in column 67 of the File


Translation field implies that a File Translation Specifications is included later
in the program. This specification contains the translation table.

This field must be blank for a key description.

Duplicate Keys (Column 68)


This field describes indexed files that are processed randomly or sequentially by key. This
field specifies whether the key is a primary key and whether duplicates are allowed in the
key defined on this line.

Valid entries for the Duplicate Keys field (column 68) are as follows:

Entry Definition

Blank Not an indexed file or a primary key of an indexed file

D Alternate key with duplicates allowed


N Alternate key with no duplicates allowed

A valid entry is required in this column for all files processed using a key. One blank entry
is required for each file. When the file is created, a primary key must be defined. D and N
are not allowable entries for the primary key.

8–26 8600 0544–103


File Description Specifications

Delete-Capable File (Column 69)


This field is valid only if the compiler control option $KEYEDIOIIOUTPUT is TRUE.

This field specifies that records can be deleted from an EFS disk file. If a file is to be
delete-capable, this field must contain a D when the file is created.

Valid entries for the Delete-Capable File field (column 69) are as follows:

Entry Definition

Blank The disk file is not delete-capable.

D The disk file is delete-capable.

In addition, the following entries must be coded to create a delete-capable file:

• The File Type field (column 15) must contain the letter O.
• The File Addition/Unordered field (column 66) must be blank.
For more information, refer to the discussion of creating disk files in Section 4, “Disk
Files.”

This field must be blank for a key description.

File Close (Column 70)


This field specifies the action taken when the file is closed.

Valid entries for the File Close field (column 70) are as follows:

Entry Definition

Blank Default close


P Close with purge

U Close with unload

N Close with no rewind

R Close with remove

C Close with crunch

K Close with crunch and remove

A syntax error occurs if column 70 contains any other entry. The compiler displays a
warning message and ignores the close option specified in column 70 if it is inappropriate
for the device named in the Device field (columns 40–46).

This field must be blank for a key description.

8600 0544–103 8–27


File Description Specifications

To show the effects of the various close options, each type of file is discussed separately
in the paragraphs that follow.

Card Files
All close options are ignored for card files. A warning message is displayed for the
following entries: P, U, N, R, C, and K. Regardless of the specified option, the logical
connection between the program and the file is severed when the file is closed.

Tape Files
The results of the various options for tape files are described in Table 8–7.

Table 8–7. File Close Options for Tape Files

Option Result

Blank (default close) The tape is rewound, and the logical connection between the
program and the file is severed.
P (close with purge) The tape is rewound and marked as available for output, provided
that a write-enable ring is present. The logical connection
between the program and the file is severed.
U (close with The tape is rewound. The tape unit cannot be accessed again by
unload) this program or any other program, without operator intervention.
The logical connection between the program and the file is
severed.
N (close with no The file is positioned at its end, and the tape is not rewound. The
rewind) tape unit remains assigned to the program, and the logical
connection between the program and the file is not severed until
EOJ.
R (close with The compiler displays a warning message, and the default close
remove) option is used.
C (close with The compiler displays a warning message, and the default close
crunch) option is used.
K (close with crunch The compiler displays a warning message, and the default close
and remove) option is used.

Printer Files
All close options for printer files are ignored. A warning message is displayed for entries
P, U, N, R, C, or K. Regardless of the option specified, the logical connection between
the program and the file is severed.

8–28 8600 0544–103


File Description Specifications

Disk Files
The action taken on files assigned to disk is discussed in terms of old files and new files.
An old file already exists on disk and appears in the disk directory. A new file is created
by the program, can be referred to by the program, and does not appear in the directory.

The results of the various close options for disk files are described in Table 8–8.

Table 8–8. File Close Options for Disk Files

Option Result: Old Files Result: New Files

Blank The file remains in the directory. The file is entered into the
(default directory. The logical connection
close) between the program and the file
is severed.
P (close The file is deleted from the The file is removed from disk. The
with directory. logical connection between the
purge) program and the file is severed.
U (close The file remains in the directory. The file is entered into the
with directory. The logical connection
unload) between the program and the file
is severed.
N (close The compiler displays a warning The compiler displays a warning
with no message, and the default close message, and the default close
rewind) option is used. option is used.
R (close The file remains in the directory. The file is entered into the
with directory. If another file of the
remove) same name exists, it is deleted
from the directory. The logical
connection between the program
and the file is severed.
C (close The file remains in the directory. The file is entered into the
with directory. Any unused portions of
crunch) disk storage allocated for the file
are released as available to the
system. A file that is closed with a
crunch cannot subsequently be
extended. The logical connection
between the program and the file
is severed.

8600 0544–103 8–29


File Description Specifications

Table 8–8. File Close Options for Disk Files

Option Result: Old Files Result: New Files

K (close The file remains in the directory. The file is entered into the
with directory. If another file of the
crunch same name exists, it is deleted
and from the directory. Any unused
remove) portions of disk storage allocated
for the file are released as
available to the system. A file
closed with a crunch cannot
subsequently be extended. The
logical connection between the
program and the file is severed.

Abnormal End
If the program ends abnormally (that is, if the program is discontinued as a result of a
run-time error, operator intervention, or both), the close options described in the
preceding paragraphs do not apply. Instead, the following actions occur:

• For disk files, new files are purged and old files are closed as described for the U
(close with unload) entry.
• Nondisk files are closed as described for the U (close with unload) entry for the
appropriate device.

File Condition (Columns 71–72)


This field indicates whether the file is conditioned by an external indicator. Input (except
input table files), update, output, and combined files can be conditioned by external
indicators. If a file is conditioned by an external indicator, the file is used only when that
indicator is on. When the indicator is off, the file is not opened. The file is treated as
though EOF had been reached, and no records can be read from, or written to, the file.

Valid entries for the File Condition field (columns 71–72) are as follows:

Entry Definition

Blank The file is not conditioned by an external indicator.

U1–U8 The specified external indicator conditions the file.

External indicators can be used to condition operations to be performed only when the
specified indicator has been set at program execution.

8–30 8600 0544–103


File Description Specifications

The external indicators U1 through U8 receive the values of the Boolean task attributes
SW1 through SW8 at the start of program execution. For information about assigning
values to task attributes, refer to the description of the EXECUTE command in the
CANDE Operations Reference Manual and the discussion of initiating processes in the
Task Attributes Reference Manual.

If all primary and secondary files are conditioned by external indicators, a warning
message is displayed.

If a file is conditioned by an external indicator, records written to the file should also be
conditioned by that indicator in the Output Specifications. If an output file is conditioned
by an external indicator, every output record described in the Output Specifications for
the file should be conditioned by that external indicator; otherwise, the object program
builds the output record and performs any Blank After operations, but suppresses the
write operation. Any calculation operations that should not be performed (especially
CHAIN and READ operations) also can be conditioned by that indicator; otherwise, the
object program automatically conditions the operation on that external indicator.

If an external indicator is entered in the File Condition field for a record-address file, the
same indicator must be assigned to the associated data file.

This field must be blank for a key description.

Program Identification (Columns 75–80)


The Program Identification field entry is not used by the compiler but appears on the
source program listing so that the field can be used to document different portions of the
program.

8600 0544–103 8–31


File Description Specifications

8–32 8600 0544–103


Section 9
Attribute Specifications

Attribute Specifications are available for files, libraries, COMS, and DMSII.

• File Attribute Specifications immediately follow File Specifications.


• Library Attribute Specifications immediately follow Library Specifications. Restrictions
for Attribute Specifications for libraries are described in Section 13, “Library
Specifications.”
• For information about COMS and DMSII Attribute Specifications, refer to Volume 2
of this manual.
This section describes Attribute Specifications for files. Unless stated otherwise, the
rules that apply to Attribute Specifications for files also apply to Attribute Specifications
for COMS, DMSII, and libraries.

All Attribute Specifications for a file must immediately follow the specification for that
file. All Attribute Specifications for a particular library must immediately follow the
declaration of the library. Only one attribute for each Attribute Specification is allowed.

If an attribute is specified more than once, the last attribute setting overrides any
previous attribute setting. Attribute Specifications override attributes already specified in
the File Specifications. For example, if the Device field (columns 40–46) in the File
Specifications contains PRINTER and Attribute Specifications for that file declare the
attribute KIND to have a value of DISK, the attribute KIND is changed from PRINTER to
DISK. Refer to the File Attributes Reference Manual for more information about
attributes.

8600 0544–103 9–1


Attribute Specifications

Attribute Specifications Coding Form and Summary


The coding form for Attribute Specifications is illustrated in Figure 9–1.

Figure 9–1. Attribute Specifications Coding Form

Table 9–1 summarizes the field definitions for the Attribute Specifications form.

Table 9–1. Field Definitions Summary (Attribute Specifications)

Columns Description

1–5 Identifies the program sequence numbers unless the $UNSEQ compiler
control option is TRUE.
6 Identifies the type of specification for each line of code. This field must be
coded with an A.
7 Contains an asterisk (*) if the line is a comment.
7–8 Specifies whether this Attribute Specification is a continuation of the
Attribute Specifications on the preceding line. This field can contain the
entry AN or blanks.
9–65 Contains a file attribute and, optionally, an associated value.
66–71 Contains a field name for use in Calculation Specifications, or contains
blanks.
72–74 Specifies the length of the field name given in columns 66 through 71 or
contain blanks.
75–80 Contains the program identification. Any entry is valid.

An entry in a column that is not part of any of the defined fields in a specification might
cause a warning message to be displayed.

9–2 8600 0544–103


Attribute Specifications

Field Definitions
Field definitions for Attribute Specifications are described in the following paragraphs.

Sequence Number (Columns 1–5)


The Sequence Number field contains a 5-digit sequence number (00000–99999) for an
RPG program source unless the $UNSEQ compiler control option is TRUE. Refer to
Section 21, “Control of the Compilation Process,” for information about the $UNSEQ
option.

Form Type (Column 6)


This field contains the type of specification for each line of code. This field must contain
an A.

Comment (Column 7)
Explanatory statements can appear in the source if column 7 contains an asterisk (*). The
Comment entry enables the entire line to the right of the asterisk to appear as program
documentation on the program listing. Comments are not instructions to the RPG
program or compiler, but serve as program documentation. Any valid character can be
used in a comment line. An asterisk in column 7 overrides an entry in column 6.

Example
Example 9–1 shows comment line coding.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00105A*
00110A* This is an example of how comment lines are coded. All lines
00120A* with an asterisk in column 7 are treated as documentation, &
00130A* are ignored by the compiler.
00140A*

Example 9–1. Coding an Attribute Specifications Comment Line

8600 0544–103 9–3


Attribute Specifications

Specifications Continuation (Columns 7–8)


This field specifies an attribute continuation line.

Valid entries for the Specifications Continuation field are as follows:

Entry Definition

Blank Not a continuation line

AN Attribute continuation line

An entry of AN in columns 7 through 8 specifies that this Attribute Specification line is a


continuation of the preceding line if that immediately preceding line contains an A in
column 6. The contents of columns 9 through 65 of this line are then concatenated to the
end of the contents for the same columns of the preceding line for the Attribute
Designation field (columns 9–65).

Attribute Designation (Columns 9–65)


This field specifies a single attribute and, optionally, its associated value. The attribute
and value are entered in free format in this field (and, if necessary, in this field on any
continuation Attribute Specification lines). File attributes and values are defined in the File
Attributes Reference Manual.

An attribute must appear in this field, but the attribute value is optional. If no attribute
value is given, no initial declaration of a value is made other than the normal default. Only
one attribute is allowed per line (including continuation lines).

An attribute can be classified as belonging to one of three categories, depending on the


type of the attribute identifier: alphanumeric, numeric, or mnemonic. In RPG, type
Boolean is type mnemonic with the values TRUE and FALSE.

For alphanumeric attributes, the attribute value must be an alphanumeric literal enclosed
in apostrophes.

For numeric attributes, the attribute value must be a numeric literal with no decimal
places.

For mnemonic attributes, the attribute value must be enclosed in apostrophes.

9–4 8600 0544–103


Attribute Specifications

Example
Example 9–2 shows various ways of coding Attribute Specifications. Included are
Attribute Specifications with numeric and Boolean attribute designations.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00500F* File Attribute Specifications
00510F*
00600F* One attribute for a file
00900F*
02000FFILE1 IP 80 80 DISK
03000A TITLE 'INPUT'
03500F*
04120F* Multiple attributes for a file
04150F*
04200FFILE2 IS 80 80 DISK
04300A BUFFERS 2
04400A NEWFILE 'FALSE'
04450F*
04600F* Attribute continuation line
04650F*
05000FFILEOUT O 132 132 PRINTER
06000A TITLE
06500AAN 'OUTPUT'
10000IFILE1 AA 01
11000I 1 2 FILLER
11100IFILE2 BB 02
11200I 1 2 FILLER

Example 9–2. Coding Kinds of Attribute Specifications

Variable Name (Columns 66–71)


This field specifies a field name to be used when the attribute is to be changed or
interrogated in the Calculation Specifications. The field is declared as being of type
numeric for numeric attributes and of type alphanumeric for alphanumeric or mnemonic
attributes. The name in this field is referred to as an attribute identifier.

The field name can appear only in the Calculation Specifications for a MOVE, MOVEL,
COMP, or Z-ADD operation. This field name cannot name a vector and cannot appear
with any other operation in a Calculation Specifications or in any other specification
except for Attribute Specifications. In addition, the name in this field cannot appear as
the name of a data structure on Input Specifications.

This field must be blank if columns 7 and 8 contain the entry AN. If this field is blank and
an attribute value has not been specified, the compiler displays a warning message.

8600 0544–103 9–5


Attribute Specifications

Field Length (Columns 72–74)


This field defines the length of the entry in the Variable Name field (columns 66–71). If
the Variable Name field is not used, this field must be blank.

Zero decimal places are implied for numeric attributes.

If the field length of an alphanumeric or mnemonic attribute identifier is greater than the
length of the attribute value, then the value is filled with blanks on the right. If the field
length of an alphanumeric or mnemonic attribute identifier is less than the length of the
attribute value, then the value is truncated on the right.

If the field length of a numeric attribute identifier is greater than the length of the
numeric attribute value, then the value is filled with zeros on the left. If the field length of
a numeric attribute identifier is less than the length of the attribute value, then the value
is truncated on the left.

Program Identification (Columns 75–80)


The Program Identification field is not used by the compiler, but appears on the source
program listing so that the field can be used to document different portions of the
program.

9–6 8600 0544–103


Attribute Specifications

Example of Using Attribute Specifications


Example 9–3 shows the coding of field definitions in Attribute Specifications. The
program uses the RESIDENT attribute to determine whether the file with the specified
title is present on disk. The first time the program runs, the name of the file title is
assigned to a file that exists. The second time the program runs, the name of the file title
is assigned to a file that is not present. For example, during the first program run, the
assignment TITLE=FILE/THAT/IS/THERE is used; the second time, the assignment
TITLE=SOME/NONEXISTENT/FILE is used. To run this program, a 2-record input file
called INPUT is needed.

..*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...
000H S
000FINPUT IP F 80 80 DISK
100FTEST ID F 80 80 DISK
110A*
120A* Declare the field RESDNT to represent the RESIDENT attribute
140A* of the file TEST and TITLE to represent the TITLE attribute:
145A*
150A RESIDENT RESDNT 5
170A TITLE TITLE 75
200FREM O 80 80 REMOTE U
300FODT D 80 ODT
350E*
400E* Either a vector or a data structure can be used to contain the
500E* file title. This program uses a vector.
600E*
700E VEC 1 2 75
000IINPUT NS 01
000I 1 10 FLD1
100ITEST NS 02
200I 1 10 FLD1
210C*
220C* Test whether the file is resident:
225C*
230C N99 Z-ADD1 I 10
235C 99 ADD 1 I
240C MOVELVEC,I TITLE
250C RESDNT COMP 'TRUE' 50
300C EXCPTREM
320C MOVELTITLE STR 80
340C STR DSPLYODT
345C SETON 99
400OREM E
500O 50 24 'FILE IS RESIDENT'
000O N50 24 'FILE NOT RESIDENT'
000V*....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
000V* Note that this is a sequenced Vector Specification.
000V*
000VVECTOR SEQ
000FILE/THAT/IS/THERE.
000SOME/NONEXISTENT/FILE.

Example 9–3. Determining If a File Is Present on Disk

For a complete description of file attributes, refer to the File Attributes Reference
Manual.

8600 0544–103 9–7


Attribute Specifications

Attribute Modification
File attributes can be modified by the Calculation Specifications. However, to be
modified, a field name must be associated with the attribute.

If the Result Field (columns 43–48) in the Calculations Specifications is a field name
defined in the Attribute Specifications, the Factor 2 field is used to assign the associated
attribute. If Factor 2 is a field name defined in the Attribute Specifications, the Result
Field contains the associated value for this attribute at the end of the operation.

If a field name associated with an alphanumeric or mnemonic attribute is specified in the


Result Field, Factor 2 must be an alphanumeric literal, an alphanumeric variable name, or
an alphanumeric or mnemonic attribute identifier (named in columns 66–71 of the
Attribute Specifications).

If a field name associated with a numeric attribute is specified in the Result Field, then
Factor 2 must be either a numeric literal or a numeric variable name with zero decimal
positions.

If a field name associated with an alphanumeric or mnemonic attribute is specified in the


Factor 2 field, the Result Field must be an alphanumeric variable name or an
alphanumeric or mnemonic attribute identifier. If a field name associated with a numeric
attribute is specified in Factor 2, the Result Field must be a numeric variable name with
zero decimal positions.
For an attribute identifier in the Result Field, if the value of Factor 2 is not defined for the
attribute field name or if the attribute field name is defined as read-only, the attribute is
not assigned a value.

9–8 8600 0544–103


Attribute Specifications

Example
Example 9–4 shows a program that assigns and modifies file attributes.

...*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...
005F*
010F* This program assigns and modifies file attributes for the
012F* files INFIL and OUTFIL. The printer backup file
014F* is routed to "STATION LP2002A".
015F*
100FINFIL IP 180 180 DISK U
200A TITLE 'FILE1 ON DISK'
300FOUTFIL O 132 132 PRINTER
400A DESTINATION DESNAM 16
500IINFIL NS
520C*
525C* When a value is moved into a pointer-valued attribute such as
530C* DESTINATION, the value must be ended with a period (.).
535C*
550C MOVEL'STATION 'WA16 16
600C MOVE 'LP2002A.'WA16
620C MOVE WA16 DESNAM
700OOUTFIL H 1P
800O 5 'HELLO'

Example 9–4. Assigning and Modifying File Attributes

8600 0544–103 9–9


Attribute Specifications

9–10 8600 0544–103


Section 10
Extension Specifications

Extension Specifications follow Attribute Specifications for files. If no Attribute


Specifications occur for the last file coded, Extension Specifications follow the File
Specifications. Extension Specifications are used to describe vectors and record-address
files. For record-address files, entries are required in columns 11 through 26 of the
Extension Specifications. For vectors, the entries required depend on the type of vector
that is specified.

Extension Specifications Coding Form and


Summary
Figure 10–1 shows the Extension Specifications coding form.

Figure 10–1. Extension Specifications Coding Form

8600 0544–103 10–1


Extension Specifications

Table 10–1 summarizes the field definitions for the Extension Specifications coding form.

Table 10–1. Field Definitions Summary (Extension Specifications)

Columns Description

1–5 Identifies the program sequence numbers unless the $UNSEQ compiler
control option is TRUE.
6 Identifies the type of specification for each line of code. This field must be
coded with the letter E.
7 Contains an asterisk (*) if the line is a comment.
11–18 Contains the file name of a preexecution-time vector file or a record-
address file.
19–26 Contains the name of the file to which the vector is written or the file name
of the file to be processed by a record-address file.
27–32 Contains the name of the input vector. These columns are also used to
name the first of two alternating vectors.
33–35 Designates the number of entries contained in each vector input record.
36–39 Identifies the maximum number of items contained in the vector named in
columns 27 through 32. The entry must be right-justified. The maximum
entry is 9999.
40–42 Specifies the length (in bytes) of each element in the input vector named in
columns 27 through 32.
43 Designates the external vector format. Acceptable entries are the letters P,
J, L, R, B, or a blank.
44 Determines the number of decimal positions contained in each vector
element. Acceptable entries are 0 through 9 if the vector element is
numeric, or blank if the vector element is alphanumeric. Entries for
designator and COMS–time types are described in Volume 2 of this manual.
45 Specifies the sequence in which elements of the vector named in
columns 27 through 32 are loaded. Acceptable entries are the letters A and
D, or blank.
46–57 Describes the second of two alternating vectors. Entries are of the same
type as that specified for the first vector. The second vector is loaded in
alternating format with the first.
58–74 Contains comments.
75–80 Contains the program identification that appears on the source program
listing.

An entry in a column that is not part of any of the defined fields in a specification might
cause a warning message to be displayed.

10–2 8600 0544–103


Extension Specifications

Field Definitions
The field definitions for the Extension Specifications are described in the following
paragraphs.

Sequence Number (Columns 1–5)


The Sequence Number field contains a 5-digit sequence number (00000–99999) for an
RPG program source unless the $UNSEQ compiler control option is TRUE. Refer to
Section 21, “Control of the Compilation Process,” for information about the $UNSEQ
option.

Form Type (Column 6)


The Form Type field identifies the type of specification for each line of code. This field
must be coded with an E.

Comment (Column 7)
Explanatory statements can appear in the source if column 7 contains an asterisk (*). The
Comment entry enables the entire line to the right of the asterisk to appear as program
documentation on the program listing. Comments are not instructions to the RPG
program or compiler, but serve as program documentation. Any valid character can be
used in a comment line. An asterisk in column 7 overrides an entry in column 6.

Example
Example 10–1 shows comment line coding.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00105E*
00110E* This is an example of how comment lines are coded. All lines
00120E* with an asterisk in column 7 are ignored by the compiler.
00140E*

Example 10–1. Coding an Extension Specifications Comment Line

8600 0544–103 10–3


Extension Specifications

From Filename (Columns 11–18)


This field contains the file name of a preexecution-time vector file or the file name of a
record-address file. File names must be left-justified in the From Filename field.

Following is a description of the entries required for preexecution-time vectors and


record-address files:

Type of Description
Entry

Preexecution- The From Filename field is required for every preexecution-time vector
time vectors used by the program. A preexecution-time vector must be designated
as an input table file in the File Specifications.

If the vector is a compile-time vector or an execution-time vector


loaded by either Input Specifications or Calculation Specifications, this
field must be blank.

Vector files are processed in the order in which they appear in the
Extension Specifications. Thus, if more than one vector file is specified
for the program, the files are loaded in the order in which they appear.

Record- The From Filename field is required for every record-address file used
address files by the program. The record-address file must also be designated as an
input record-address file in the File Specifications.

The same record-address file must not be named in more than one
Extension Specifications. Fields that apply to vectors (columns 27–57)
must be blank for a record-address file.

10–4 8600 0544–103


Extension Specifications

To Filename (Columns 19–26)


This field contains the name of the file to which the vector is written or the file name of
the file to be processed by a record-address file. File names entered in the To Filename
field must be left-justified.

Following is a description of the entries required for output vector files and record-
address files:

Type of Description
Entry

Output vector To write any vector file, the name of the appropriate output file must
files be entered in this field. The designated output file must previously
have been described in the File Specifications as a sequential output
file. A vector can be written to only one output file and is automatically
written or punched at EOJ after all the other records have been
processed. More than one vector can be written to the same output
file.

Record-address This field must contain the name of the input or update file to be
files processed with the input record-address file specified in the From
Filename field. The input or update file name specified in this field
cannot appear in any other Extension Specification.

If an input file is specified in the File Specifications as being


processed through the use of an addrout or a limits file, the input file
specified must be named in this field and the record-address file (an
addrout or limits file) must be specified in the From Filename field.

Vector Name (Columns 27–32)


This field names vectors to be used by the program. Each vector name must be unique
and must not be specified more than once in the Extension Specifications. The rules for
the formation of vector names are described in “Vector Names” in Section 2, “RPG
Language Elements.”

Table names must begin with the letters TAB. (These letters can appear alone.) Any
name that appears in this field and that does not begin with TAB is considered an array
name.

If two related vectors are in alternating format in one vector file, the first vector must be
named in this field and the second vector in the Alternating Vector Format field
(columns 46–57). Any combination of tables and arrays is allowed in alternating format.

8600 0544–103 10–5


Extension Specifications

Entries per Record (Columns 33–35)


This field specifies the number of entries in each vector input record. Every record,
except the last, must contain the number of entries specified in this field; the last record
can contain fewer entries than the number specified.

Valid entries for the Entries per Record field are as follows:

Entry Definition

Blank Execution-time vector

1-999 Number of vector entries contained in each vector input record

Entries in this field must be numeric and right-justified; leading zeros can be omitted.
Corresponding items from alternating vectors must be on the same record and in
alternating format. Each pair of items is considered one entry. The number of entries
specified in this field must not exceed the number specified in the Entries Per Vector
field (columns 36–39).

The following equations can be used to determine the number of entries per record:

• (L1 + L2) x N <= R1


• (L1 + L2) x N <= R2
The variables used for the preceding equations are as follows:

Variable Definition

L1 Length entered in columns 40 through 42 unless the first vector is


packed; in this case

L1 = 1 + ((length in columns 40 through 42)/2)

L2 Length of the alternate vector as entered in columns 52 through


54 unless the alternate vector is packed; in this case

L2 = 1 + ((length in columns 52 through 54)/2)

N Number specified in the Entries per Record field

R1 Record length of the To Filename field

R2 Record length of the From Filename field

10–6 8600 0544–103


Extension Specifications

The following rules must be observed when a vector is loaded:

• To load a preexecution-time vector, entries are made in the Entries per Record field
and in the From Filename field (columns 11–18). Refer to the discussion of
preexecution-time vectors in this section for more information.
• To load a compile-time vector, an entry is made in the Entries per Record field and
the From Filename field (columns 11–18) is blank.
• If the From Filename (columns 11–18), To Filename (columns 19–26), and Entries per
Record (columns 33--35) fields are blank, vector loading is not implied. In this case,
vectors can be loaded by using either the Input Specifications or the Calculation
Specifications (an execution-time load). Preexecution-time and compile-time vectors
can be changed using Input Specifications or Calculation Specifications.
Table 10–2 shows the vector type resulting from the entries in the From Filename
(columns 11–18) and Entries per Record (columns 33--35) fields.

Table 10–2. Determining Vector Type

Vector Type From Filename Field Entries per Record Field

Compile-time Blank Entry


Preexecution-time Entry Entry
Execution-time Blank Blank

Entries per Vector (Columns 36–39)


This field contains a nonzero integer that specifies the maximum number of items that
can be contained in the vector named in the first Vector Name field (columns 27–32).
When vectors are loaded in alternating format, this number also includes the vector
named in the Alternating Vector Format field (columns 46–57). Entries in the Entries per
Vector field must be numeric and right-justified; leading zeros can be omitted. The
maximum allowable entry is 9999.

Length of Entry (Columns 40–42)


This field specifies the length of each element in the vector named in the first Vector
Name field (columns 27–32). When numeric vectors are in packed decimal format, the
number of digits (excluding the sign) is entered; otherwise, the number of bytes is
entered. When numeric vectors are in separate signed format, the length must include
the sign byte.

If the length of a numeric item in a vector data input record is less than the length
specified in this field, then leading zeros must be added. If the length of an alphanumeric
item in a vector data input record is less than the length specified in this field, then
leading or trailing blanks must be added.

8600 0544–103 10–7


Extension Specifications

The maximum length of a vector element is specified in the discussion of field lengths in
Section 2, “RPG Language Elements.” An element must be completely contained in one
record; therefore, input record sizes also limit the maximum size of a vector element.

For binary data, the number of decimal digits required for the element is designated in
this field. This number must be less than 9.

Entries in this field must be right-justified, and leading zeros can be omitted.

Packed (Column 43)


This field specifies the external format of the vector data. If the vector is part of a vector
file and that file is being translated from or to a non-EBCDIC character code set, the entry
in this field must not be P or J.

Valid entries for the Packed field are as follows:

Entry Definition

Blank Vector elements are in either unpacked decimal or alphanumeric


format.

P Vector elements are in signed, packed decimal format.

J Vector elements are in unsigned, packed decimal format.

L Vector elements are in separate leading signed, unpacked format.

R Vector elements are in separate trailing signed, unpacked format.

B Vector elements are in binary format.

Preexecution-time vectors can be packed, unless the To Filename field (columns 19–26)
indicates a printer file. Compile-time vectors must not be in packed or binary format.
When vectors are loaded or modified by the Input Specifications, the sign position and
format (packed or unpacked) described in the Input Specifications dictate the external
data format. The sign of compile-time and preexecution vectors is determined by the
Sign Position field (column 17) of the Control Specification, the $RSIGN compiler control
option, and the $FZONE compiler control option.

This field must be blank for execution-time vectors.

For details of the data formats of vectors with an entry in this field, refer to the Packed
field (column 43) in Section 14, “Input Specifications.”

10–8 8600 0544–103


Extension Specifications

Decimal Positions (Column 44)


This field specifies the number of decimal positions contained in each element of the
vector named in the first Vector Name field (columns 27–32).

This field cannot be blank for a numeric vector. If the numeric elements have no decimal
positions, a 0 (zero) must be entered.

The valid entries for the Decimal Positions field are as follows:

Entry Definition

Blank Alphanumeric vector

0–9 Number of positions to the right of an implied decimal point for


numeric vector elements

Sequence (Column 45)


This field specifies the sequence in which elements are loaded for the vector named in
the first Vector Name field (columns 27-32).

Valid entries for the Sequence field are as follows:

Entry Definition

Blank Unordered elements

A Elements arranged in ascending order

D Elements arranged in descending order

A compile-time vector, defined with an A or a D in the Sequence field must be loaded in


the appropriate sequence. A preexecution-time vector is checked for the specified
sequence. If a sequence error occurs, the compiler displays a VECTOR SEQUENCE
ERROR run-time error (refer to Appendix A, “System Messages”). The sequence check
enables two consecutive elements to be equal. Alternate vectors need not be in the
same sequence.

Column 45 should contain an entry if high- or low-resulting indicators are assigned when
a LOKUP operation is performed on the vector in the Calculation Specifications.

8600 0544–103 10–9


Extension Specifications

Alternating Vector Format (Columns 46–57)


These fields describe a second vector to be loaded in alternating format with the vector
named in the first Vector Name field (columns 27–32). These fields and the
corresponding fields in columns 27 through 45 require the same types of entries;
however, the entries in the Alternating Vector Format fields apply only to the second
vector. When a single vector description is required, these fields must be blank. Compile-
time, preexecution-time, and execution-time vectors can be specified as alternating
vectors.

Comments (Columns 58–74)


This field is available for comments and can contain any valid characters.

Program Identification (Columns 75–80)


The Program Identification field is not used by the compiler but appears on the source
program listing so that the field can be used to document different portions of the
program.

10–10 8600 0544–103


Extension Specifications

Using Vectors
Tables and arrays are logical configurations of data elements that have similar
characteristics. Because there are few differences between tables and arrays, both are
usually referred to as vectors. When differences exist in their characteristics, these
elements are referred to individually as either tables or arrays.

Vectors can be distinguished according to the time at which they are loaded with data.

Table 10–3 shows the three types of vectors and the times at which they are loaded.

Table 10–3. Types of Vectors

Vector Type Time Loaded

Compile-time During RPG program compilation


Preexecution-time At the beginning of RPG program execution
Execution-time During RPG program execution

Each element of a vector must have the same length and data type (numeric or
alphanumeric). All numeric elements must have the same number of decimal positions.

Every vector used by the program must have a name.

An index can be used to access a specific element in a vector.

For information on execution-time vectors of types designator and COMS-time, see the
discussion of COMS Extension Specifications in Volume 2 of this manual.

Understanding Array and Table Differences


Tables and arrays are the same except in the following areas.

The following differences apply to arrays:

• Array names are described in the discussion of vector names in Section 2, “RPG
Language Elements.”
• If an array name appears without an index, it refers to the entire array. Such a
reference specifies that the designated operation is to be performed repetitively,
once for each element of the array.
The following differences apply to tables:

• All table names must begin with the letters TAB.


• Each table maintains a hold pointer and a hold area equal in size to one element of
the table.

8600 0544–103 10–11


Extension Specifications

• If a table name appears without an index, it refers to the last item designated in the
table as stored in the hold area. When no index is used, the hold area can be affected
by the LOKUP operation or other calculation operations described in Section 16,
“Operation Codes,” or by the Blank After field (column 39) in the Output
Specifications.
• A LOKUP operation can be performed on a table. If the operation is successful, the
contents of the hold area are replaced by the value of the table element that satisfies
the search conditions, and the hold pointer is updated to point to this new element. If
the operation is unsuccessful, the contents of the hold area are not modified and the
hold pointer is set to point to the first element of the table.
• A table can be updated by specifying the table name in the Result Field (columns 43–
48) in the Calculation Specifications for a calculation operation other than the LOKUP
operation. Also, a table can be updated by specifying the Blank After field
(column 39) in the Output Specifications. Both of these methods cause the contents
of the hold area and the table element (the element referred to by the hold pointer) to
be changed.
• If a table element is updated by specifying the table name with an index, only the
indexed element of the table changes. The hold area and the hold pointer are not
modified.
• If a table name is used with no index in the Factor 1 (columns 18–27) or Factor 2
(columns 33--42) fields of the Calculation Specifications, the name refers to the value
currently in the hold area for that table.
• At BOJ, the hold pointer is initialized to 1. If the table is numeric, the hold area is
initialized to zeros. If the table is alphanumeric, the hold area is initialized to blanks.

Declaring Vectors
All vectors in a program must be described in the Extension Specifications.

The following Extension Specifications fields require entries for each type of vector,
regardless of the time at which the vector is loaded:

• The Vector Name field (columns 27–32). This field specifies the vector name.
• The Entries per Record field (columns 33–35). This field identifies the number of
vector elements in each input record.
• The Entries per Vector (columns 36–39) and Length of Entry (columns 40–42) fields.
These fields determine the size of the vector.
• The Packed field (column 43). This field specifies the input data format.
• The Decimal Positions field (column 44). This field specifies the number of decimal
positions in each entry.
• The Sequence field (column 45). This field determines the order of the elements.

10–12 8600 0544–103


Extension Specifications

If the vector is loaded in alternating format with another vector, the Alternating Vector
Format fields (columns 46–57) are also used.

If the vector is to be loaded at preexecution time from the file name specified in the
From Filename field (columns 11–18), the file description in the File Specifications for
that file must include an I in the File Type field (column 15), a T in the File Designation
field (column 16), and an E in the Extension Code field (column 39).

If the vector is to be written at EOJ to the output file named in the To Filename field
(columns 19–26), the output file must be described in the File Specifications.

For execution-time vectors, the From Filename (columns 11–18), To Filename


(columns 19–26), and Entries per Record (columns 33--35) fields must be blank.
Execution-time vectors cannot be written at EOJ.

All vectors can be altered during program execution, regardless of when they were
initially loaded. For this reason, all vectors can be considered to have dynamic
characteristics.

Using an Index with a Vector Name


An index can be used to refer to a vector element. An index name is specified by adding
a comma (,) and an index after the vector name. The index can be either the number of
the element to be used or the name of a field containing the number of the element to
be used. The following are the rules for creating a vector name that includes an index:

• The name, including the index, can be up to 6 characters long unless it is specified in
the Factor 1 or Factor 2 field in the Calculation Specifications. In that case, the vector
name and index can be up to 10 characters long.
• The name must be unique in the RPG program.
• The value of the index must not be 0 (zero), a negative value, or more than the
number of elements in the array.
Following are examples of valid vector names:

Vector Description
Name

SALE This vector has no index; therefore, the name refers to the entire vector.

SALE,N The index is a field called N that contains the number of the element to
be used. Notice that the entire name cannot have more than 6
characters, including the comma.

SALE,3 The index is 3. The index specifies the actual number of the element to
be used.

8600 0544–103 10–13


Extension Specifications

Loading Vectors
Preexecution-time, compile-time, and execution-time vectors are loaded differently. The
following text explains these differences.

Preexecution-Time Vectors
Each preexecution-time vector is loaded with data that was read into the program
storage area at the beginning of program execution, before normal operations in the PLC
begin. The storage area is reserved by entries in the Extension Specifications. The data
for each vector are taken from the files identified in the File Specifications.

More than one vector can be loaded from the same file. Short preexecution-time vector
loads are not allowed.

A preexecution-time vector is loaded from the file described in the From Filename field
(columns 11–18) in the Extension Specifications. The data are read in at the beginning of
program execution and placed in the preexecution-time vector until the vector is full (see
Example 10–2).

Vectors are loaded in the sequence in which they are specified in the Extension
Specifications; consequently, files are opened, read, and closed as each designated
vector is loaded. No separators are allowed between vector groups. If the number of
records in a vector file is not equal to the number expected, the compiler displays a
VECTOR LOAD ERROR message. Refer to Appendix A, “System Messages.”

Example
The program in Example 10–2 on the following page shows how to load preexecution-
time vectors. TABLE1, ARRAY2, ARRAY3, and TABLE2 are loaded from FILE1. TABLE1
contains 100 elements. Each element is 18 characters long, and there are three
elements on each record.

ARRAY2 and ARRAY3 are in alternating format. There are 15 elements in each array, and
5 elements of each array on each record. TABLE2 is also in FILE1. It contains 100
elements with 10 elements of each array per record.

ARRAY1 is loaded from FILE2. It has 80 elements; each element is 4 digits in length and
has two implied decimal positions. There are 20 elements per record.

10–14 8600 0544–103


Extension Specifications

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
01000F* This program shows how to load preexecution-time vectors.
01500F*
02000FFILEIN IP 80 80 DISK
02250FFILE1 IT 80 80 EREADER
02500FFILE2 IT 80 80 EREADER
03000FFILEOUT O 132 132 PRINTER
04000E FILE1 TABLE1 3 100 18
05000E FILE2 ARRAY1 20 80 4 2D
06000E FILE1 FILEOUT ARRAY2 5 15 10 AARRAY3 5 1A
06500E FILE1 TABLE2 10 100 6P1
07000IFILEIN AA 01
08000I 5 80 FILLER
09000OFILEOUT D 01
10000O FILLER 80

Example 10–2. Loading Preexecution-Time Vectors

Compile-Time Vectors
Compile-time vectors are loaded at compile time at the end of the source program and
after any alternate collating or file translation records. Compile-time vectors are described
further in Section 20, “Vector Data Specifications.”

If a compile-time vector does not have a vector data specification associated with it, the
vector entries are initialized to the default values. The default values are also described in
Section 20.

8600 0544–103 10–15


Extension Specifications

Execution-Time Vectors
Execution-time vectors are loaded during program execution through entries in either the
Input Specifications or the Calculation Specifications. Either certain fields of input records
or the results of calculation operations can be used to load the elements of an execution-
time vector. This loading, unlike the automatic loading of compile-time and preexecution-
time vectors, is completely under programmatic control.

Fields within input records might contain data for vector loading. In this case, loading is
done by assigning either a vector name with an index or an array name without an index
as a field name in an input record description (see Example 10–3). A table name without
an index is not allowed. If the field name contained in the Variable Name field
(columns 27–32) in the Extension Specifications designates a single element of a vector,
the input field is placed into the vector element when the record is selected. If the field
name designates an entire array (no index assigned), the input field length must be an
integer multiple of the element size contained in the Length of Entry field (columns 40–
42) in the Extension Specifications. It must also be less than or equal to the total size of
the array. If the input field is less than the size of the array, the elements not referred to
are not affected.

Example
Example 10–3 shows a load using Input Specifications. When a record from FILEIN with
a T in position 1 is read, the 01 indicator is turned on. The five characters beginning in
position 2 are loaded into the first element of the array AR1. The 60 characters beginning
in position 8 are loaded into the entire array AR2.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
02000FFILEIN IP 180 180 DISK
05000FFILEOUT O 132 132 PRINTER
06000E AR1 10 5 A
07000E AR2 20 3 A
10000IFILEIN AA 01 1 CT
11000I 2 6 AR1,1
11500I 8 67 AR2
12000OFILEOUT D 01
13000O AR1,1 6

Example 10–3. Loading Execution-Time Vectors with Input Specifications

A calculation operation that specifies a vector in the Result Field (columns 43–48) of the
Calculation Specifications causes the designated vector to be loaded with the result of
the operation. If an index is specified, a vector element is loaded. If no index is
designated, the entire vector is loaded.

10–16 8600 0544–103


Extension Specifications

Example
Example 10–4 shows the loading of execution-time vectors through the use of
Calculation Specifications.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
02000FFILEIN IP 80 80 DISK
03000FFILEOUT O 132 132 PRINTER
04000E AR1 10 5 0A
05000E AR2 50 6 0A
06000IFILEIN AA 01 1 CT
07000I 5 540AR1
07050C* Add the first element of AR1 to every element of AR2
07100C*
08000C 01 AR1,1 ADD AR2 AR2
08030C*
08050C* If IX > 10 turn indicator 02 ON
08070C*
08100C 01 Z-ADD0 IX 30
08200C LOOP TAG
08300C 01 1 ADD IX IX
08400C 01 10 COMP IX 02
08440C*
08450C* If the 02 indicator is OFF, divide 3.1415 into the element
08460C* of AR2 pointed to by IX
08470C*
08500C 01N02 AR2,IX DIV 3.1415 AR2,IX
08600C 01N02 GOTO LOOP
09000OFILEOUT D 01
10000O AR2,1 8
11000O AR2,2 16
12000O AR2,3 24

Example 10–4. Loading Execution-Time Vectors with Calculation


Specifications

Alternating Vector Format


Vectors specified as occurring in alternating format have related elements contained in
alternating format in each input record (see Examples 10–2 and 10--3). The two vectors
need not have the same size as that specified in the Length of Entry field (columns 40–
42), and need not have the same type (numeric or alphanumeric) or sequence order;
however, each vector must have the same number of elements contained in each input
record and the same number of elements as specified in the Entries per Vector field
(columns 36–39). Any combination of tables or arrays is allowed in alternating format.
Each pair of elements in the input record is considered one entry. The first element of
each pair belongs to the vector described in columns 27 through 45, and the second
element belongs to the vector described in columns 46 through 57.

8600 0544–103 10–17


Extension Specifications

Writing Vectors
Compile-time and preexecution-time vectors can be written to an output device at EOJ
by specifying an output file in the To Filename field (columns 19–26) of the Extension
Specifications. This vector output is performed automatically after all processing has
been completed. Vector records are in the format specified by the Extension
Specifications.

Execution-time vectors cannot specify a To Filename; therefore, they cannot be written


automatically at EOJ.

An entire array can also be written during output by specifying the array name without an
index in the Field Name field (columns 32–37) in the Output Specifications. If an entire
array is written in this manner, the end position specified must have sufficient space for
all elements of the array plus any editing. For editing whole arrays, refer to Section 17,
“Output-Format Specifications.”

10–18 8600 0544–103


Section 11
Line Counter Specifications

Line Counter Specifications are used only for printer files and indicate the form length,
the position of the last line to be printed on each page (overflow line), and the format of
the carriage control tape. If Line Counter Specifications are absent for a printer file, a
form length of 66 lines and an overflow line of 60 are assumed. For more information,
refer to the discussion of printing reports and overflow in Section 17, “Output-Format
Specifications.”

Line Counter Specifications Coding Form and


Summary
The coding form for Line Counter Specifications is illustrated in Figure 11–1.

Figure 11–1. Line Counter Specifications Coding Form

8600 0544–103 11–1


Line Counter Specifications

Table 11–1 summarizes the field definitions for the Line Counter Specifications coding
form.

Table 11–1. Field Definitions Summary (Line Counter Specifications)

Columns Description

1–5 Identifies the program sequence numbers unless the $UNSEQ compiler
control option is TRUE.
6 Identifies the type of specification for each line of code. This field must be
coded with the letter L.
7 Contains an asterisk (*) if the line is a comment.
7–14 Specifies the name of a printer file.
15–17 Specifies the length of the page or form if columns 18 through 19 contain
the letters FL. If columns 18 through 19 are numeric, this field specifies the
line number (counted from the top of the page) to associate with that
channel number. Acceptable entries are 1 through 112, right-justified.
18–19 Designates the use of the numeric entry in columns 15 through 17.
Acceptable entries are the letters FL and 1 through 12, right-justified.
20–22 Specifies the line number of the overflow line if columns 23 through 24
contain the letters OL. If columns 23 through 24 are numeric, this field
specifies the line number (counted from the top of the page) to associate
with that channel number. Acceptable entries are 1 through 112, right-
justified.
23–24 Designates the use of the numeric entry in columns 20 through 22.
Acceptable entries are the letters OL and 1 through 12, right-justified.
25–74 Specifies the channel number related to the preceding Line Number field
entry. Acceptable entries for the Channel Number fields are 1 through 12,
right-justified. The Line Number fields designate a particular line on each
page. Acceptable entries for the Line Number field are 1 through 112, right-
justified.
75–80 Contains the program identification. Any entry is valid.

11–2 8600 0544–103


Line Counter Specifications

Field Definitions
The field definitions for the Line Counter Specifications are defined in the following
paragraphs.

An entry in a column that is not part of any of the defined fields in a specification might
cause a warning message to be displayed.

Sequence Number (Columns 1–5)


The Sequence Number field contains a 5-digit sequence number (00000–99999) for an
RPG program source unless the $UNSEQ compiler control option is TRUE. Refer to
Section 21, “Control of the Compilation Process,” for information about the $UNSEQ
option.

Form Type (Column 6)


The Form Type field identifies the type of specification for each line of code. This field
must be coded with the letter L.

Comment (Column 7)
Explanatory statements can appear in the source if column 7 contains an asterisk (*). The
Comment entry enables the entire line to the right of the asterisk to appear as program
documentation on the program listing. Comments are not instructions to the RPG
program or compiler, but serve as program documentation. Any valid character can be
used in a comment line. An asterisk in column 7 overrides an entry in column 6.

Example
Example 11–1 shows comment line coding.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00105L*
00110L* This is an example of how comment lines are coded. All lines
00120L* with an asterisk in column 7 are ignored by the compiler.
00140L*

Example 11–1. Coding a Line Counter Specifications Comment Line

Filename (Columns 7–14)


The Filename field specifies the name of the printer file to which these Line Counter
Specifications apply. An entry in this field is required and must be left-justified. Also, in
the File Specifications, the file name must be named in the Filename field (columns 7–14)
and the designation PRINTER must be specified in the Device field (columns 40–46).

8600 0544–103 11–3


Line Counter Specifications

Line Number, FL, Channel Number (Columns 15–19)


Depending on the entry in columns 18 through 19, these fields have two possible
meanings.

If columns 18 through 19 contain the entry FL (form length), the entry in columns 15
through 17 specifies the length (in print lines) of each page.

If columns 18 through 19 contain a numeric entry identifying a channel number, the entry
in columns 15 through 17 specifies the number of the line (counted from the top of the
form) to be associated with that particular channel. The Channel Number field entry must
be in the range 1 through 12.

The Line Number field entry in columns 15 through 17 must be in the range 1 through
112. Entries must be right-justified in their fields, and leading zeros are optional.

Example
Example 11–2 shows how the Line Counter Specifications are used to set up the channel
line equations, form lengths, and overflow lines for four printer files. For the file PRINT1,
columns 15 through 19 specify that channel 1 is line 10, columns 20 through 24
designate that channel 12 is line 50, and columns 25 through 29 specify that channel 3 is
line 15.

For the file PRINT2, columns 15 through 19 specify that the form length is 50, and
columns 20 through 24 designate that the overflow line is 10.

PRINT3 sets up the form length, the overflow line, and the channel line equation. The
number must be the same for the overflow line and the channel line equation if both are
specified.

PRINT4 sets up the form length and the overflow line. The overflow line is less than the
form length.

11–4 8600 0544–103


Line Counter Specifications

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00300FFILEIN IP 80 80 DISK
00500FPRINT1 O 132 132 OA LPRINTER
00550FPRINT2 O 132 132 OB LPRINTER
00600FPRINT3 O 132 132 OC LPRINTER
00610FPRINT4 O 80 80 OD LPRINTER
00650LPRINT1 1001 5012 1503
00700LPRINT2 50FL 10OL
00750LPRINT3 80FL 60OL 0601 2003 6012
00800LPRINT4 60FL 55OL
00900IFILEIN AA 01
01000I 2 50FIELD1
01010I 7 10 FIELD2
01020I 12 15 FIELD3
01030I 22 272FIELD4
01100OPRINT1 D 01
01200O FIELD1 10
01300OPRINT2 D 01
01400O FIELD2 10
01500OPRINT3 D 01
01600O FIELD3 10
01700OPRINT4 D 01
01800O FIELD4 10

Example 11–2. Coding of Line Counter Specifications

Line Number and OL or Channel Number (Columns 20–24)


Depending upon the entry in columns 23 through 24, these fields have two possible
meanings.

If OL (overflow line) is entered in columns 23 through 24, the entry in columns 20


through 22 specifies the line number that is consideredthe overflow line. The overflow
line number must be less than or equal to the form length. When the destination of a
space, skip, or print operation is to a line beyond the overflow line, but before the end of
the page, the overflow indicator associated with the file is turned on to indicate that the
end of the page is near. If the destination is beyond the form length, the overflow
indicator does not turn on. This does not imply that the overflow indicator turns off if it is
already on.

When the overflow indicator is on, the following actions take place before the form is
advanced to the next page:

1. Detail lines still to be printed as part of the current program cycle are completed.
2. Total lines are printed.
3. Total lines conditioned by the overflow indicator for this file are printed.
4. Heading and detail lines conditioned by the overflow indicator for this file are printed.

8600 0544–103 11–5


Line Counter Specifications

Because these actions take place after the overflow line is reached, enough space must
be left between the overflow line and the bottom of the page to print all the lines. See
the discussion of overflow in Section 17, “Output-Format Specifications,” for more
information.

The Line Number field entry in columns 20 through 22 must be in the range from 1 to the
entry in the Line Number field (columns 15–17). The entry must be right-justified, and
leading zeros are optional.

If columns 23 through 24 contain a numeric entry identifying a channel number in the


range 1 through 12, then the entry in columns 20 through 22 specifies the number of
lines from the top of the form to be associated with the channel number.

The Line Number field entry in columns 20 through 22 must be in the range 1 through
112. Entries must be right-justified in the field, and leading zeros are optional.

Neither form length (FL) nor overflow line (OL) can be specified separately. If Line
Counter Specifications are not used, or if FL and OL are not specified, then the default
value for form length is 66 lines and the default value for overflow line is 60 lines.

Line Number and Channel Number (Columns 25–74)


Columns 25 through 74 of the Line Counter Specifications are divided into ten pairs of
fields. Each pair consists of a 3-character Line Number field and a 2-character Channel
Number field. All fields are optional and must be blank if they are not used.

The Channel Number field can contain an entry in the range 1 through 12. This Channel
Number entry is associated with a corresponding Line Number field entry in the range 1
through 112, and relates a channel number to a particular position on each page of the
output forms. The same channel number should not be specified more than once in the
same Line Counter Specifications.

All entries must be right-justified in their respective fields, and leading zeros are optional.

The Line Number entry must be less than or equal to the form length defined in
columns 15 through 17 if FL is entered in columns 18 through 19, or to the default
number of lines (66) if the form length is not specified.

If any channel specifications are made, channels 1 and 12 must be defined. If both the
overflow line and channel 12 are specified, they must be associated with the same line
number.

All channel numbers used in the Output Specifications must be defined in the Line
Counter Specifications. When channel numbers are used, it is the responsibility of the
user to ensure that the proper carriage control tape is in the printer.

11–6 8600 0544–103


Line Counter Specifications

Program Identification (Columns 75–80)


The Program Identification field is not used by the compiler but appears on the source
program listing so that the field can be used to document different portions of the
program.

8600 0544–103 11–7


Line Counter Specifications

11–8 8600 0544–103


Section 12
Telecommunications Specifications

This section explains how data communications can be controlled programmatically by


using RPG. The RPG data communications facility provides the ability to access, process,
and create messages, and to communicate with local and remote communications
devices through a message control system (MCS).

COMS is a fully featured MCS designed for high-volume transaction processing. This
MCS can be used with RPG programs. For information about COMS
Telecommunications Specifications, refer to Volume 2 of this manual.

Message Control System (MCS)


The implementation of the RPG data communications facility requires that an MCS be
present in the operating environment of the RPG program.

The MCS is the logical interface to the operating system under which the RPG program
operates. The primary functions of the MCS are as follows:

• To act as an interface between the RPG program and the network of communication
devices. This interface mechanism is similar to the way an operating system acts as
an interface between the RPG program and devices such as magnetic tape, mass-
storage devices, and printers.
• To perform line discipline, including such tasks as dial-up, polling, and
synchronization.
• To perform device-dependent tasks, such as character translation and insertion of
control characters, enabling the RPG program to be device-independent.

MCS Functions
The RPG program acts as an interface with the MCS when messages are sent or
received, or when the status of the various data communication files created and
maintained by the MCS are interrogated. The RPG program interface consists of

• The interface between the RPG program and the MCS


• The interface between the MCS and the data communications devices
Although the interfaces are implemented and controlled by the MCS, these interfaces
must be specified in the File Specifications and the associated Telecommunications
Specifications to establish the proper link between the RPG program and the MCS.

8600 0544–103 12–1


Telecommunications Specifications

Data communications files consist of one or more messages from, or to, one or more
data communications devices and, as such, form the data buffers between the RPG
program and the MCS. Input data communications files are logically separate from output
data communications files.

Telecommunications Specifications Coding Form


and Summary
The Telecommunications Specifications coding form (see Figure 12–1) shows the fields
that can be coded to establish and maintain the link between the RPG program and the
MCS. For each defined data communications file, a corresponding File Specification must
also be present.

Figure 12–1. Telecommunications Specifications Coding Form

12–2 8600 0544–103


Telecommunications Specifications

Table 12–1 summarizes the field definitions for the Telecommunications Specifications
coding form.

Table 12–1. Field Definitions Summary (Telecommunications


Specifications)

Columns Description

1–5 Identifies the program sequence numbers unless the $UNSEQ compiler
control option is TRUE.
6 Identifies the type of specification for each line of code. This field must be
coded with the letter T.
7 Contains an asterisk (*) if the line is a comment.
7–14 Specifies the name of the data communications file.
16 Specifies whether the file is to transmit or receive messages. Acceptable
entries are the letters T, R, I, and O. Entries for COMS headers (I and O) are
described in Volume 2 of this manual.
17–19 Specifies the communication type for COMS headers, which are discussed
in Volume 2 of this manual.
40 Designates the use of the entry in columns 41 through 47. Acceptable
entries are blank, or the letters S and E.
41–47 Contains a symbolic name referring to the remote station number if column
40 contains the letter S. This field contains the actual remote station number
if column 40 contains an E. This field must be blank if column 40 is blank. All
entries are left-justified.
53–54 Specifies an indicator to be turned on when certain errors occur. Acceptable
entries are blank, 01 through 99, L1 through L9, LR, and H0 through H9.
63 Designates the use of the entry in columns 64 through 70. Acceptable
entries are blank or the letters S and E.
64–70 Contains a symbolic name that refers to the location of the message length
if column 63 contains the letter S. This field contains the actual message
length if column 63 contains the letter E. This field must be blank if column
63 is blank. All entries must be left-justified.
75–80 Contains the program identification. Any entry is valid.

8600 0544–103 12–3


Telecommunications Specifications

Field Definitions for Telecommunications


Specifications
The following paragraphs define the fields in the Telecommunications Specifications.

An entry in a column that is not part of any of the defined fields in a specification might
cause a warning message to be displayed.

Sequence Number (Columns 1–5)


The Sequence Number field contains a 5-digit sequence number (00000–99999) for an
RPG program source unless the $UNSEQ compiler control option is TRUE. Refer to
Section 21, “Control of the Compilation Process,” for information about the $UNSEQ
option.

Form Type (Column 6)


The Form Type field identifies the type of specification for each line of code. This field
must contain the letter T.

Comment (Column 7)
This field can contain an asterisk (*).

Explanatory statements can appear in the source if column 7 contains an asterisk (*).The
Comment entry enables the entire line to the right of the asterisk to appear as program
documentation on the program listing. Comments are not instructions to the RPG
program or compiler, but serve as program documentation. Any valid character can be
used in a comment line. An asterisk in column 7 overrides an entry in column 6.

Example
Example 12–1 shows comment line coding.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00105T*
00110T* This is an example of how comment lines are coded. All lines
00120T* with an asterisk in column 7 are ignored by the compiler.
00140T*

Example 12–1. Coding a Telecommunications Specifications Comment Line

12–4 8600 0544–103


Telecommunications Specifications

Filename (Columns 7–14)


This field contains the file name of a data communications file described in the File
Specifications.

Station Type (Column 16)


This field specifies whether the file is to transmit or receive messages.

Valid entries for the Station Type field are as follows:

Entry Definition

T Transmit or transmit with reply. The file must be declared in the File
Specifications as a combined or output file (a C or an O, respectively) in the
File Type field (column 15). The file must be further described in the Output
Specifications. If the file is a combined file, it must also be defined in the Input
Specifications.

Messages are transmitted from a file declared as output.

If the file is a combined file, messages can be alternately transmitted and


received.

R Receive or receive with transmission of reply. The file must be further


described in the File Specifications as an input or combined file (I or C,
respectively) in the File Type field (column 15). The file must be further
described in the Input Specifications. If the file is a combined file, it must also
be defined in the Output Specifications.

Messages are received from a file declared as input.

If the file is a combined file, messages can be alternately received and


transmitted.

Remote Station Location Identification (Column 40)


This field contains information concerning the identification of a remote station.

Valid entries for the Remote Station Location Identification field are as follows:

Entry Definition

Blank Remote station identification is not given.

S The Remote Station Identification field (columns 41–47) contains the symbolic
name (field name) referring to the LASTSUBFILE attribute.

E The Remote Station Identification field contains the actual station number.
(This entry is not recommended.)

8600 0544–103 12–5


Telecommunications Specifications

The Remote Station Location Identification field (columns 41–47) indicates how the
LASTSUBFILE attribute of the data communications file is to be referred to in the
program. The LASTSUBFILE attribute indicates the relative station number (RSN) from
which the most recent READ or RECV operation was done, and is used by the system to
determine whereto send data generated for an EXCPT operation or a SEND operation.

Note: The RSN of the file is a numeric value with no decimal positions, is unique only in
the program, and is meaningful only after a file has been opened.

The RSN differs from the logical station number (LSN) that is assigned to each station in
a network. An RSN cannot be used to indicate stations to be opened by a data
communications file. Instead, the FILENAME attribute can be used on an Attribute
Specification following the File Specification of the data communications file to specify
the name of the station to be opened.

Remote Station Identification (Columns 41–47)


If the Remote Station Location Identification field (column 40) contains an S, the entry in
the Remote Station Identification field contains a field name (left justified), by which the
LASTSUBFILE attribute can be referred to in the program. When the symbolic name is a
table name, the remote station identification must be either the first or the only element
of the table. An array name cannot be specified in this field.

If the user specifies a field name, but does not define the format of the field in the
program, the compiler defines the format of the identifier as an 11-digit numeric field
with no decimal positions.

If the user specifies the length of the station identification to be longer than 11 digits and
then attempts to write to the data communications file, a REMOTE STATION
IDENTIFIER <name> SHOULD BE NUMERIC WITH A MAXIMUM OF 11 DIGITS error
message is displayed.

When the Remote Station Location Identification field (column 40) contains an E, the
entry in the Remote Station Identification field contains the actual RSN of the remote
station (left-justified). (This entry is not recommended.)

This field must be blank when the Remote Station Location Identification field
(column 40) contains a blank. If a blank entry is specified, messages are transmitted to
the station from which the last message was received.

12–6 8600 0544–103


Telecommunications Specifications

Error Indicator (Columns 53–54)


This field specifies an indicator to be turned on when certain communications errors
occur and to be turned off after valid communications. Valid entries for this field are 01
through 99, L1 through L9, LR, and H0 through H9.

An error indicator should be specified for each data communications file. I/O operations
should be conditioned based on the setting of the indicator.

The error indicator is turned on when a data communications error is detected by the
MCS. For example, an error such as INVALID KEY ON A TRANSMISSION, FILE
UNKNOWN ON A RECEIVE, or MESSAGE LENGTH EXCEEDS RECORD LENGTH ON A
TRANSMISSION would cause the MCS to turn on the error indicator.

If an error occurs, processing continues, ignoring the record that caused the error. An
appropriate program response, such as operator notification or the end of the program in
an orderly manner, can be conditioned based on the error indicator.

If an error occurs and an error indicator is not specified, a DATACOM READ ERROR or a
DATACOM WRITE ERROR message is returned. Refer to Appendix A, “System
Messages,” for the list of error messages.

Other errors, including transmission errors, are normally handled by the MCS and not by
the RPG program. Therefore, the RPG program might not be notified of an error
condition.

Note: H0 through H9 are valid entries; however, they should not be used as error
indicators because the program cycle in which the error occurred might not be
completed before the halt indicator is turned off. Also, a program halt might occur before
the controlled halt occurs.

Message Length Identification (Column 63)


This field contains information concerning the contents of the Message Length field
(columns 64–70).

Valid entries for the Message Length Identification field are as follows:

Entry Definition

Blank The Message Length field (columns 64–70) contains no specification for
message length. The default value is the record size.

S The Message Length field (columns 64–70) designates the symbolic name
(field name) containing the message length.

E The Message Length field (columns 64–70) contains the exact message
length.

8600 0544–103 12–7


Telecommunications Specifications

Message Length (Columns 64–70)


If the Message Length Identification field (column 63) contains an S, the entry in the
Message Length field contains the symbolic name (left-justified) referring to the location
of the message length. When the symbolic name is a table name, the message length
must be either the first or the only element in the table. An array name cannot be
specified. When data are transmitted, the value of the message length is used as the
transmission length. When data are received, the entry named in the Message Length
field is updated to correspond to the length of the data received.

If the user specifies a field name, but does not define the format of the identifier in the
program, the compiler defines the format of the field as an 11-digit numeric with no
decimal positions.

This field contains the actual message length (left-justified) when the Message Length
Identification field (column 63) contains an E. When a numeric entry is present in the
Message Length field, all messages have the same length. This entry must not exceed
the record length. If the message length is less than the record size, the rest of the
record is not filled with blanks.

This field must be blank when the Message Length Identification field (column 63)
contains a blank entry.

Program Identification (Columns 75–80)


The Program Identification field is not used by the compiler but appears on the source
program listing so that the field can be used to document different portions of the
program.

12–8 8600 0544–103


Telecommunications Specifications

Field Definitions for Telecommunications File


Specifications
The required entries for data communications files defined in the File Specifications are
described in the following paragraphs. Any columns not mentioned are used in the
manner described in Section 8, “File Description Specifications.”

Filename (Columns 7–14)


The file name specified in the File Specifications must be the same as the file name used
in the Telecommunications Specifications that further define the file.

File Type (Column 15)


This field identifies the way in which the program uses the data communications file.

Valid entries in the File Type field for data communications files are as follows:

Entry Definition

I The specified file is an input (receive) file.

O The specified file is an output (transmit) file.

C The specified file is a combined file that can receive or transmit with optional
reply.

8600 0544–103 12–9


Telecommunications Specifications

File Designation (Column 16)


This field further describes the use of input and combined files.

Valid entries in the File Designation field for data communications files are as follows:

Entry Definition

Blank Output file

P Primary sequential file

S Secondary sequential file

T Input table file or array file

D Demand file

Chained, full-procedural files and record-address files cannot be specified as data


communications files. A demand file is useful for applications that control the processing
of data communications files declared to transmit with reply. For this type of application,
a T must appear in the Station Type field (column 16) in the Telecommunications
Specifications.

End of File (Column 17)


An E is required in this field for data communications files. If an E is specified for any
other input file except the data communications file, the program might go to EOJ before
processing of the data communications file is complete.

File Format (Column 19)


A data communications file cannot have variable-format records; thus, a V entry in this
field is ignored for data communications files. However, the actual record length in the
file can vary based on the message length specified in the Message Length field
(columns 64–70) in the Telecommunications Specifications.

Block Length (Columns 20–23)


The specified block length must equal the record length if the file is declared as a
combined file in the File Specifications; that is, the File Type field (column 18)
contains a C.

12–10 8600 0544–103


Telecommunications Specifications

Record Length (Columns 24–27)


The record length of the largest record in the data communications file must be specified
and right-justified in this field. If the actual length of an input message exceeds the value
specified in the Record Length field, the rightmost characters of the message are
truncated.

If the value contained in the Message Length field (columns 64–70) in the
Telecommunications Specifications of an output message exceeds the value specified in
the Record Length field, the message is not transmitted and the indicator specified in the
Error Indicator field (columns 53–54) in the Telecommunications Specifications is turned
on.

If the actual message length is less than the record length, the contents of the remainder
of the record are undefined.

Processing Mode (Column 28)


This field must be blank for a data communications file.

Record-Address Field Length (Columns 29–30)


This field must be blank for a data communications file.

Record-Address Type (Column 31)


This field must be blank for a data communications file.

File Organization Type (Column 32)


This field defines the number of messages for which file space in memory should be
reserved. Valid entries are integer values in the range 1 through 9.

If no value is specified in this field, the default value is 2.

No other entries in this field are valid for data communications files.

Key Field Starting Location (Columns 35–38)


This field must be blank for a data communications file.

8600 0544–103 12–11


Telecommunications Specifications

Device (Columns 40–46)


Data communications files must specify either DATACOM or REMOTE as the device
type.

Columns 47 through 70
These columns must be blank for a data communications file.

File Condition (Columns 71–72)


A file-conditioning indicator can be specified in this field for data communications files.

Example
Example 12–2 shows the use of data communications files.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
01100F*
01200F* DESCRIPTION OF PROGRAM:
01300F* -----------------------
01400F*
01500F* This program executes a series of RECV operations from the
01600F* remote file REM1, and reports what happened by executing SEND
01700F* operations back to the station of REM1 from which the RECV
01750F* operation was done.
01800F*
01900F* INDICATORS USED:
02000F* ----------------
02100F*
02200F* 02 record identifying indicator for file REM1.
02300F* 05 Error indicator for REM1 (assigned on Telecommunication
02350F* Specifications).
02400F* 10 Turned on to invoke initial prompt record from SEND
02450F* operation.
02900F* 58 EOF indicator for RECV operation (columns 58–59).
03000F*
03100FDUMMY IP F 80 80 DISK
03200FCONSOLE D 80 80 ODT
03300F*
03400F* Declare a remote demand file:
03500F*
03600FREM1 CD F 80 80 DATACOM
03700A TITLE 'MARKS'
03800TREM1 R 05
03900IDUMMY NS 01
04000I 1 20 SNAM
04100I*

Example 12–2. Coding of Data Communications Files (cont.)

12–12 8600 0544–103


Telecommunications Specifications

04200I* Input Specifications for the demand remote file:


04300I*
04400IREM1 AA 02
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
04500I 1 80 REC1
04600C*
04700C* SEND an initial prompt message:
04800C*
04900C SETON 10
05000C SEND REM1
05100C SETOF 10
05200C*
05300C* Perform a series of RECV operations for the demand file:
05400C*
06000C LOOP TAG
09500C RECV REM1 58
09800C SEND REM1
09900C N58 GOTO LOOP
14900O*
15100O* Send initial prompt:
15200O*
15300OREM1 E 10
15400O 24 'Welcome to the RPG SEND/'
15500O 48 'RECV test. Please trans'
15600O 72 'mit a line: '
15700O*
15800O* Echo record from RECV operation.
15900O*
16000OREM1 E N10
16100O 24 'Record received was:'
16200O E N10
16300O REC1 80
16400O E N10
16500O 24 'Please transmit another '
16600O 48 'record, or "?EOF" '

Example 12–3. Coding of Data Communications Files

8600 0544–103 12–13


Telecommunications Specifications

12–14 8600 0544–103


Section 13
Library Specifications

A library program provides a set of procedural entry points that can be called by other
programs known as user programs. Refer to the Task Management Programming Guide
for a detailed discussion of libraries. Familiarity with this material is assumed in the
following discussion.

Subroutines written in other languages are often called procedures. RPG programs can
call library procedures written in other languages. These procedures can be written in any
programming language that enables library calls from other languages. Library
procedures are also called entry points. Parameters can be passed to the library either by
reference or by value.

The RPG calling mechanism enables both procedures and functions (typed procedures)
to be called as subroutines by the EEXSR and PARAM operations. Information about
these operations is provided in the discussion of library operations in Section 16,
“Operation Codes.”

Library Specifications consist of Library Name Specifications, Library Attribute


Specifications, Library Subroutine Specifications, and Library Parameter Specifications.
Library Name Specifications, if present, must occur between Telecommunications
Specifications and Input Specifications. Library Attribute Specifications can appear after
each Library Name Specifications. Library Subroutine Specifications occur after each
Library Name Specifications. Library Parameter Specifications occur after each Library
Subroutine Specifications.

A program that shows the extensive use of Library Specifications is provided in


Example 13–2 later in this section.

8600 0544–103 13–1


Library Specifications

Library Specifications Coding Form and Summary


Figure 13–1 shows the coding form for the Library Specifications.

Figure 13–1. Library Specifications Coding Form

Table 13–1 summarizes the field definitions for the Library Specifications coding form.

Table 13–1. Field Definitions Summary (Library Specifications)

Columns Description

1–5 Identifies the program sequence numbers unless the $UNSEQ compiler
control option is TRUE.
6–18 Specifies the form type of the Library Specifications. Acceptable entries are
LIBRARY NAME, LIBRARY SUBR, or LIBRARY PARAM.
19–28 Specifies the name of a library, library subroutine, or library parameter.
29–31 Designates the result length on a Library Subroutine Specifications or the
parameter length on a Library Parameter Specifications.
32 Specifies the library access attribute on a Library Name Specifications, the
Result Decimal Position on a Library Subroutine Specifications, or the
Parameter Decimal Positions on a Library Parameter Specifications.
Acceptable entries are 0 through 9, the letters D, F, I, or T, and blank.
33 Contains an entry only on the Library Parameter Specifications and specifies
whether the parameter is passed by value or by reference. Acceptable
entries are the letters V and R.
34 Contains an entry only on the Library Parameter Specifications and specifies
information about a vector parameter. Acceptable entries are blank, 0 (zero),
*, and the letters L and P.
35–74 Specifies the title or function name on a Library Name Specifications, or
specifies the actual name of the subroutine on a Library Subroutine
Specifications.

An entry in a column that is not part of any of the defined fields in a specification might
cause a warning message to be displayed.

13–2 8600 0544–103


Library Specifications

Field Definitions for Library Name Specifications


Library Name Specifications identify the names of libraries that contain entry points that
the program intends to call.

Field definitions for Library Name Specifications are discussed in the following
paragraphs.

Sequence Number (Columns 1–5)


The Sequence Number field contains a 5-digit sequence number (00000–99999) for an
RPG program source unless the $UNSEQ compiler control option is TRUE. Refer to
Section 21, “Control of the Compilation Process,” for information about the $UNSEQ
option.

Form Type (Columns 6–18)


This field must contain LIBRARY NAME.

Library Name (Columns 19–28)


This field specifies the name of the library. All Library Subroutine Specifications up to the
next Library Name Specifications or Input Specifications designate entries in this library.
Library names follow the rules for the definition of RPG names. A library name cannot
exceed 10 characters in length and must be unique among library names.

LIBACCESS (Column 32)


This column specifies the LIBACCESS library attribute. This attribute can be overridden
by Library Attribute Specifications.

Valid entries in the LIBACCESS field are as follows:

Entry Definition

T or Indicates the LIBACCESS library attribute is BYTITLE


blank

F Indicates the LIBACCESS library attribute is BYFUNCTION

Family substitution can occur when the object code specified is on DISK and the library is
linked by title. In this situation, it is desirable to link BYFUNCTION to an initialized library.
Refer to the System Software Utilities Manual for more information.

8600 0544–103 13–3


Library Specifications

Title or Function Name (Columns 35–74)


The name specified in this field depends on the entry in the LIBACCESS field
(column 32). If the LIBACCESS field contains a T or a blank, this field specifies the name
of the library. If the LIBACCESS field contains an F, this field designates the library
FUNCTIONNAME attribute.

If this field is blank, the TITLE or FUNCTIONNAME attribute defaults to the library name
in columns 19 through 28.

This field can be overridden by Library Attribute Specifications.

Field Definitions for Library Attribute


Specifications
Library Attribute Specifications are used with Library Name Specifications to further
define library attributes. All Attribute Specifications for a library that refer to a particular
library must immediately follow the declaration of that library. The entries on Attribute
Specifications for a library are restricted to the library attributes in the following list. In all
other respects, Attribute Specifications for a library are identical to Attribute
Specifications for a file. For more information on Attribute Specifications, refer to
Section 9, “Attribute Specifications.”

All library attributes except LIBPARAMETER can be specified on the Library Name
Specifications.

The allowable alphanumeric library attributes are

• FUNCTIONNAME
• INTNAME
• LIBPARAMETER
• TITLE
The allowable mnemonic library attribute is LIBACCESS. Its allowable values are BYTITLE
and BYFUNCTION.

There are no numeric library attributes.

13–4 8600 0544–103


Library Specifications

Field Definitions for Library Subroutine


Specifications
The Library Subroutine Specifications identify and describe the library subroutines that
the program intends to call.

Field definitions for the Library Subroutine Specifications are discussed in the following
paragraphs.

Sequence Number (Columns 1–5)


The Sequence Number field contains a 5-digit sequence number (00000–99999) for an
RPG program source unless the $UNSEQ compiler control option is TRUE. Refer to
Section 21, “Control of the Compilation Process,” for information about the $UNSEQ
option.

Form Type (Columns 6–18)


This field must contain LIBRARY SUBR.

Library Subroutine Name (Columns 19–28)


This field assigns a unique name to every library subroutine used by the program. The
rules for a library subroutine name follow the definition of RPG names. A library
subroutine name cannot exceed 10 characters in length and must be unique among
library subroutine names. Subroutine names beginning with a dollar sign ($) are reserved
for system subroutines defined in the system software. Refer to Section 2, “RPG
Language Elements,” for information about rules for names.

Result Length (Columns 29–31)


If column 32 is numeric, the field length of the result must be entered in this field.
Otherwise, this field is blank.

8600 0544–103 13–5


Library Specifications

Result Decimal Positions (Column 32)


If the subroutine is a function, that is, a typed procedure that returns a result, then the
result type is indicated in this field. Otherwise, this field is blank.

Only the following result types are allowed in the Result Decimal Positions field:

Entry Definition

0–9 Number of decimal positions in a numeric field

D Designator

I Indicator

T COMS-time

Designator and COMS-time result types are discussed in Volume 2 of this manual.

Actual Name (Columns 35–74)


This field contains the name by which this subroutine is called in the library. If these
columns are blank, the default is the subroutine name in columns 19 through 28.

13–6 8600 0544–103


Library Specifications

Field Definitions for Library Parameter


Specifications
The Library Parameter Specifications identify the parameters that are passed when the
library procedure is called.

The number of parameters described in the Library Parameter Specifications must equal
the number of formal parameters declared in the procedure entry point in the library.

Field definitions for Library Parameter Specifications are discussed in the following
paragraphs.

Sequence Number (Columns 1–5)


The Sequence Number field contains a 5-digit sequence number (00000–99999) for an
RPG program source unless the $UNSEQ compiler control option is TRUE. Refer to
Section 21, “Control of the Compilation Process,” for information about the $UNSEQ
option.

Form Type (Columns 6–18)


This field must contain LIBRARY PARAM.

Library Parameter Name (Columns 19–28)


This field can be used to describe the parameter and is interpreted as a comment.

Parameter Length (Columns 29–31)


This field defines the length of the field being passed. A value is required for numeric
parameters and is optional for alphanumeric parameters. If the length is specified for an
alphanumeric parameter, the actual parameter used with the PARAM operation must be
the same length. If the length is omitted, any size alphanumeric field can be passed. For
all other parameter types this field must be blank.

8600 0544–103 13–7


Library Specifications

Parameter Decimal Positions (Column 32)


This field specifies the type of field passed as a parameter.

Valid entries in the Parameter Decimal Positions field are as follows:

Entry Definition

Blank Alphanumeric

0–9 Number of decimal positions in a numeric field

D Designator

F File

I Indicator

T COMS-time

Designator and COMS-time fields are discussed in Volume 2 of this manual.

Value/Reference (Column 33)


This field is used to indicate whether the parameter is passed by reference or by value.
Either a blank or an R indicates that the parameter is passed by reference. The letter V in
this field indicates that a parameter is passed by value. Files can be passed only by
reference.

Vector Parameter (Column 34)


This field contains additional information about passing alphanumeric fields and vector
parameters.

For additional information about parameter matching, refer to the discussion of the
PARAM operation in Section 16, “Operation Codes.”

13–8 8600 0544–103


Library Specifications

Following are the valid entries for alphanumeric parameters:

Entry Definition

Blank or Unindexed vector passed as a zero-bounded ([0]) EBCDIC array.


0

* Alphanumeric field, literal, unindexed vector, or vector element passed as an


asterisk-bounded ([*]) EBCDIC array.

L Same as an asterisk (*) entry, followed by a length. Compatible with


FORTRAN77 character arrays and Pascal character array schemata.

P Alphanumeric field, literal, unindexed vector, or vector element passed as a


pointer.

Following are the valid entries for all other parameter types:

Entry Definition

Blank Single field, literal, or vector element. Unindexed vector passed as a zero-
bounded ([0]) array.

L Same as an asterisk (*) entry, followed by a length. Compatible with


Pascal integer array schemata.

* Unindexed vector passed as an asterisk-bounded ([*]) array.

Note: Pascal array schemata with multiple discriminants in which the base type is a
structured type have no corresponding parameter types in RPG.

Columns 35–74
These columns must be blank.

8600 0544–103 13–9


Library Specifications

Field Definitions for Library Linkage Subroutines


The system provides a number of predefined system subroutines that enable the RPG
program to control the library linkage. Next to each RPG name is the system software
utilities name. The system software utilities name is used in the discussion of libraries in
the System Software Utilities Manual, in which additional information on library linkage is
provided.

Following are the predefined system subroutines and their related utilities:

RPG Name Software Utilities Name

$SETNAME SETACTUALNAME

$LINKLIB LINKLIBRARY

$DELINKLIB DELINKLIBRARY

$CANCELLI CANCELLIBRARY
B

$SETNAME
The $SETNAME system subroutine changes the actual name of a subroutine to another
name. To use $SETNAME, the program must not be currently linked to the library. For
additional information, refer to the following discussion of $DELINKLIB. See Table 13–2
for the parameter specifications for this subroutine.

$LINKLIB
A program is usually linked to the library on the first call of any of its subroutines. If this
implicit link fails for any reason, the calling program is ended. The $LINKLIB system
subroutine enables the option of explicitly linking to the library and checking whether the
linkage was successful. Refer to Table 13–2 for parameter specifications.

$DELINKLIB
A program usually remains linked to the library until the end of the task. However,
$DELINKLIB can end the linkage before the task is complete. If $SETNAME is needed
after the library is linked, a typical usage of system subroutines might include
$DELINKLIB, followed by $SETNAME and $LINKLIB. Refer to Table 13–2 for the
parameter specifications for this subroutine.

$CANCELLIB
The $CANCELLIB system subroutine does not return a result. $CANCELLIB is a special
version of $DELINKLIB.

13–10 8600 0544–103


Library Specifications

Table 13–2 describes the result and parameter types for the library linkage subroutines.

Table 13–2. Library Linkage Subroutine Parameters

RPG Name Result Parameter 1 Parameter 2

$SETNAME Numeric field The Library Alphanumeric


length equals 11; Subroutine Name, literal, field, or array
decimal positions from columns 19 containing the new
equal 0. Values through 28 of the name, and ending
greater than or Library Subroutine with a space or a
equal to 0 indicate Specifications. period. Passed by
success. Values Passed by value value (coded in
less than 0 indicate (coded in the Factor Factor 2).
failure. 2 field).
$LINKLIB Numeric field The Library Name
length equals 11; from columns 19
decimal positions through 28 of the
equal 0. Values Library Name
greater than 0 Specifications.
indicate failure. Passed by value
(coded in Factor 2).
$DELINKLIB Numeric field The Library Name
length equals 11; from columns 19
decimal positions through 28 of the
equal 0. Values Library Name
greater than 0 Specifications.
indicate success. Passed by value
Values less than 0 (coded in Factor 2).
indicate failure.
$CANCELLIB The Library Name
from columns 19
through 28 of the
Library Name
Specifications.
Passed by value
(coded in Factor 2).

8600 0544–103 13–11


Library Specifications

Example of Using Library Specifications


Following are several examples of Library Specifications coding. The examples call library
procedures to manipulate dates.

Example 1
Example 13–1 contains a partial program sample that shows Library Specifications
coding. A complete programming example is provided in Figure 13–3.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00215E NAME 3 8
00220E*
00100LIBRARY NAME DATELIB T *SYSTEM/DATE/LIBRARY
00105L*
00110L* Library of date manipulation routines.
00115L*
00120LIBRARY SUBR DATEDIF 50 DATE_DIFFERENCE
00125L*
00130L* Returns the number of days between two Gregorian dates.
00135L*
00140LIBRARY PARAM<begin> 60V
00150LIBRARY PARAM<end> 60V
00160L*
00170L*
00180LIBRARY SUBR DATELIT DATE_LITERAL
00185L*
00190L* Turns Gregorian date into MMMMMMMMM DD, YYYY
00195L*
00200LIBRARY PARAMGREGORIAN 60V
00210LIBRARY PARAMLITDATE 18 *
05000C 27 MOVE 'DATE_LIT'NAME,1
05100C 27 MOVE 'ERAL_EUR'NAME,2
05200C 27 MOVEL'OPEAN ' NAME,3
05300C 27 EEXSR$SETNAME RSLT 110 88
05400C PARAMDATELIT
05500C PARAMNAME
05600C 27 88 GOTO ERROR

Example 13–1. Coding Library Specifications

13–12 8600 0544–103


Library Specifications

Example 2
Example 13–2 shows a complete RPG program that uses Library Specifications
extensively. Comments in the example provide an explanation of the code as it is
presented.

A copy of this program and its data file are on the release media under the node
EXAMPLE/RPG/LIBRARY/ACCESS. The library subroutines used by the program are also
on the release media (EXAMPLE/COBOL74/LIBRARY and EXAMPLE/PASCAL/LIBRARY).

..*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...
200F*
202F* DESCRIPTION OF PROGRAM:
204F* -----------------------
206F*
208F* This program illustrates how to declare and use subroutines
210F* from a library. The libraries are written in different
212F* languages. They export procedures for use by calling programs.
214F* Three libraries are invoked: DATELIB, which is written in
216F* Pascal; PRINTLIB, which is written in COBOL74; and GENSUP, the
218F* GENERALSUPPORT system library, which is written in NEWP.
220F*
222F* This program uses three input records: D-records,
224F* S-records, and T-records. In each D-record there are
226F* two dates. The DateLit subroutine of DATELIB is called
228F* to convert the dates from Gregorian format into display
230F* format, that is, from 122654 to December 26, 1954. DateDif is
232F* called to calculate the number of days between the two dates.
234F* The display format dates are then passed to CharCount, which
236F* tallies all the characters used in an array named CT.
238F* The display dates and the number of days between them are
240F* written to a file named MAINFILE.
242F*
244F* In an S-record there are two variables called ACTNAM
246F* and XFLAG. $SETNAME is called to change the actual name
248F* of DateLit to ACTNAM. The Options subroutine of DATELIB
250F* is called to set the DMY (Day-Month-Year) flag of DATELIB
252F* to TRUE if XFLAG is the letter D. Otherwise, DMY is
254F* set to FALSE (indicating Month-Day-Year).
256F*
258F* In each T-record there is file name that is translated
260F* from display format (the form that the user sees) to standard
262F* display format (the form in which file titles are stored) by
264F* the Disp2Std subroutine of GENSUP. The standard format name
266F* is also passed to CharCount to be tallied in the CT array.
268F*
270F* At LR, the Print-It subroutine is called from PRINTLIB.
272F* The parameters of the subroutine are CT and MAINFILE.

Example 13–2. Declaring and Using Subroutines from a Library (cont.)

8600 0544–103 13–13


Library Specifications

..*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...
274F* Print-It writes the contents of CT to MAINFILE.
276F* DICTIONARY OF PROGRAM IDENTIFIERS
280F* IN - Disk file containing program input. There are two record
282F* formats: D-records and T-records. D-records contain date
284F* pairs in the format D mmddyy mmddyy. T-records are in
286F* the format T <70 bytes of title>.
288F* MAINFILE - The file used to display results of Pascal library
290F* calls. This file is also passed as a parameter to
292F* the Print-It subroutine.
294F* OUTNEWP - The file containing the results of calling Disp2Std.
296F* DATELIB - Pascal Library accessed by this program. (Contains
298F* date manipulation routines.)
300F* DateDif - Library subroutine that returns the number of days
302F* between two Gregorian dates.
304F* DAYS - 5-digit numeric field representing the difference in
306F* days between FMDATE and TODATE.
308F* FMDATE - 6-digit integer (zero scale factor) having the
310F* form MMDDYY. FMDATE is read from the IN primary
312F* file. It is the first half of the date
314F* pair read from that file on each cycle.
316F* FMDLIT - 18-byte alphanumeric field used to hold the display
318F* form of FMDATE.
320F* TODATE - 6-digit integer (zero scale factor) having the
322F* form MMDDYY. TODATE is read from the IN primary
324F* file. It is the second half of the date
326F* pair read from that file on each cycle.
328F* TODLIT - 18-byte alphanumeric field used to hold the display
330F* form of TODATE.
332F* LTITLE - The TITLE attribute of the DATELIB library.
334F* LIBACC - The LIBACCESS attribute of the DATELIB library.
336F* VECTOR - A Preexecution vector containing long literals.
338F* ACTNAM - New actual name for DateLit.
340F* INDICATORS USED:
342F*
344F* 01 - record identifying indicator for D-records of the IN file.
346F* 02 - record identifying indicator for T-records of the IN file.
348F* 03 - record identifying indicator for S-records of the IN file.
350F* 10 - Plus field indicator for field FMDATE. It is turned on
352F* if FMDATE is a positive integer on each cycle. It is used
354F* to condition all operations using FMDATE.
356F* 11 - Plus field indicator for field TODATE. It is used to
358F* condition all operations using TODATE.
360F*20,21,22 - Plus, minus, and zero indicators for the field DAYS
362F* when it is set as the result of calling DateDif.
364F* 30 - Error indicator.
366F* 77 - XFLAG (= D ).
368F* 99 - First-control-cycle switch.

Example 13–2. Declaring and Using Subroutines from a Library (cont.)

13–14 8600 0544–103


Library Specifications

..*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...
370F*
372F*
374F*
376FIN IP F 80 80 DISK
378A TITLE 'EXAMPLE/RPG/LIBRARY/ACCESS/DATA'
380FODT D F 80 80 ODT
382FINVECT IT F 80 80 DISK
384A TITLE 'EXAMPLE/RPG/LIBRARY/ACCESS/VECTOR'
386FMAINFILEO F 80 80 REMOTE
388A TITLE 'EXAMPLE/RPG/LIBRARY/ACCESS/OUTPUT/PASCAL'
390FOUTNEWP O F 80 80 DISK
392A TITLE 'EXAMPLE/RPG/LIBRARY/ACCESS/OUTPUT/NEWP'
394E ACTNAM 1 70
396E STDNAM 70 1
398E FILNAM 70 1
400E CT 256 5 0
402E INVECT VECTOR 1 2 80
404L*
406L* Declare the DATELIB library. Attribute Specifications give an
408L* initial value for the FUNCTIONNAME attribute, and both initial
410L* values and field names for the TITLE and LIBACCESS attributes.
412L* If no attribute modification is used in the Calculation
414L* Specifications, LIBACCESS is BYFUNCTION with FUNCTIONNAME
416L* equal to GOODFUNCTION, and TITLE is ignored. LTITLE changes to
418L* OBJECT/EXAMPLE/PASCAL/LIBRARY and LIBACC is changed to BYTITLE
420L* at the beginning of the Calculation Specifications.
422L*
424LIBRARY NAME DATELIB T TITLE/OVERRIDDEN/BY/ATTRIBUTE/IMAGES
426A TITLE 'THIS/EXAMPLE/SHOWS/HOW/TO/SPECIFY/A/TITLE/ LTITLE 80
428AAN THATS/OVER/40/BYTES'
430A LIBACCESS BYFUNCTION LIBACC 10
432A
434AAN
436AANFUNCTIONNAME 'GOODFUNCTION'
438L*
440L* Declare the DateDif library subroutine. Two parameters are
442L* specified. They are both by-value integers, having a length of
444L* 6 and a scale factor of 0 (zero). The subroutine returns a
446L* result that is a 5-digit number, having a scale factor of 0
448L* (zero). The actual name of the procedure (the name by which the
450L* library exported it) is DATE_DIFFERENCE. The Pascal description
452L* of the subroutine is
454L*
456L* function date_difference ( from_date, to_date : integer )
458L* : integer;
460L*
462LIBRARY SUBR DATEDIF 50 DATE_DIFFERENCE

Example 13–2. Declaring and Using Subroutines from a Library (cont.)

8600 0544–103 13–15


Library Specifications

..*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...
464LIBRARY PARAM FROM_DATE 60V
466LIBRARY PARAM TO_DATE 60V
468L*
470L* Set the DMY (Day-Month-Year) flag. The Pascal description of
472L* the subroutine is
474L*
476L* procedure option ( new_dmy : Boolean );
480LIBRARY SUBR OPTION
482LIBRARY PARAM new_dmy IV
484L* Declare the DateLit library subroutine. Two parameters are
486L* specified. The first is a by-value 6-digit number with a scale
488L* factor of 0 (zero), which is interpreted as a Gregorian date.
490L* The second is a by-reference alphanumeric area, passed with
492L* asterisk bound in which DateLit writes the date as
494L* MMMMMMMMM DD, YYYY. The Pascal definition of this subroutine is
496L*
498L* ebcrange = 1..9999;
500L* ebcdic_schema (length : ebcrange)
502L* = packed array [1..length] of char;
504L* ebcdic18 = ebcdic_schema (18);
506L* procedure date_literal ( in_day : ext_date;
508L* var lit_date : ebcdic18 );
510L*
512L* Note that though the EBCDIC18 type is built from a schema, it
514L* is not a schema itself, so the parameter is passed asterisk
516L* bound.
518L*
520L* This program uses $SETNAME to change the ACTUALNAME of the
522L* subroutine to date_literal_european. The procedure is
524L*
526L* procedure date_literal_european ( in_day : ext_date;
528L* var lit_date : ebcdic18)
530L*
532LIBRARY SUBR DATELIT DATE_LITERAL
534LIBRARY PARAM_DAY 60V
536LIBRARY PARAMLIT_DATE *
538L*
540L* The following example demonstrates passing to a Pascal schema
542L* parameter. The Pascal declaration of this procedure is
544L*
546L* ebcrange = 1..9999;
548L* ebcdic_schema (length : ebcrange)
550L* = packed array [1..length] of char;
552L* char_of_int = array [char] of integer;
554L* procedure char_count ( var in_str :ebcdic_schema;
556L* var count : char_of_int );
558L*

Example 13–2. Declaring and Using Subroutines from a Library (cont.)

13–16 8600 0544–103


Library Specifications

..*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...
560L* The variable in_str is a schema type. To call this procedure
562L* from RPG, L is put (asterisk bound with length) in the Vector
564L* Parameter field (column 34).
566L*
568LIBRARY SUBR CHARCOUNT CHAR_COUNT
570LIBRARY PARAMINSTR L
572LIBRARY PARAMCOUNT 50 *
574L*
576L*
578L*
580LIBRARY NAME PRINTLIB OBJECT/EXAMPLE/COBOL74/LIBRARY
582LIBRARY SUBR PRINT-IT
584LIBRARY PARAMCOUNTS 50 0
586LIBRARY PARAMFYLE F
588L*
590LIBRARY NAME GENSUP
592A LIBACCESS BYFUNCTION
594A FUN
596AANCTIONNAME 'GENERALSU
598A************* Comment lines can be inserted anywhere.*************
600AANPPORT'
602A LIBPARAMETER PARAM 80
604AAN ' THIS IS MY LIBRARY PARAMETER VALUE '
606LIBRARY SUBR DISP2STD I DISPLAYTOSTANDARD
608LIBRARY PARAM <-from-> VP
610LIBRARY PARAM <-to-> VP
612L*
614I*
616IIN NS 01 1 CD
618I 3 80FMDATE 10
620I 10 150TODATE 11
622I NS 02 1 CT
624I 3 72 FILNAM
626I NS 03 1 CS
628I 3 3 XFLAG
630I 5 74 ACTNAM
632C*
634C* First Cycle Setup:
636C*
638C* Inquiring and modifying library attributes:
640C*
642C N99 MOVELPARAM TEMP 80
644C N99TEMP DSPLYODT
646C N99 MOVE LTITLE TEMP 80
648C N99TEMP DSPLYODT
650C N99 MOVE VECTOR,1 LTITLE
652C N99 MOVE LTITLE TEMP 80

Example 13–2. Declaring and Using Subroutines from a Library (cont.)

8600 0544–103 13–17


Library Specifications

..*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...
654C N99TEMP DSPLYODT
656C N99 MOVE LIBACC TEMP10 10
658C N99TEMP10 DSPLYODT
660C N99 MOVEL'BYTITLE 'LIBACC
662C N99 MOVE LIBACC TEMP10 10
664C N99TEMP10 DSPLYODT
666C N99 SETON 99
668C*
670C* HANDLE S-RECORDS:
672C*
674C* This section of the code changes the actual name of DateLit to
676C* the value of ACTNAM. If the library was linked during a
678C* previous cycle, it is delinked with $DELINKLIB. Then the
680C* actual name is changed with $SETNAME. Failure is indicated by
682C* a negative result, and a halt indicator is used in the
684C* Resulting Indicator field (column 56, the minus indicator).
688C*
690C 03 EEXSR$DELINKLIB H2
692C PARAMDATELIB
694C 03 EEXSR$SETNAME H3
696C PARAMDATELIT
698C PARAMACTNAM
700C*
702C* The DMY flag of DATELIB is set.
704C*
706C 03'D' COMP XFLAG 77
708C 03 EEXSROPTION
710C PARAM*IN77
712C* HANDLE D-RECORDS:
714C*
716C* Call external subroutine DateDif. The date difference is
718C* returned into the field DAYS; indicators 20, 21, and 22 are
720C* set to indicate if DAYS is positive, negative, or zero.
722C* FMDATE and TODATE are passed as by-value parameters.
724C*
726C 10 11 01 EEXSRDATEDIF DAYS 50 202122
728C PARAMFMDATE
730C PARAMTODATE
732C*
734C* External subroutine DateLit is called. FMDATE is passed as a
736C* by-value parameter. The alphanumeric field FMDLIT is passed as
738C* a by-reference parameter. The literal date is returned by
740C* storing it in FMDLIT.
742C*
744C 10 11 01 EEXSRDATELIT
746C PARAMFMDATE
748C PARAM FMDLIT 18
750C*

Example 13–2. Declaring and Using Subroutines from a Library (cont.)

13–18 8600 0544–103


Library Specifications

..*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...
752C 10 11 01 EEXSRDATELIT
754C PARAMTODATE
756C PARAM TODLIT 18
758C*
760C* FMDLIT and TODLIT are passed to CHARCOUNT. The character
762C* field is declared as passed by reference, CHARCOUNT does not
764C* update it, so it can be passed by value. The character counts
766C* are tallied in the array CT, which is passed by reference. If
768C* CT is passed by value, the routine runs correctly, but the
770C* CT vector in the calling program is never updated.
774C 10 11 01 EEXSRCHARCOUNT
776C PARAMFMDLIT
778C PARAM CT
780C 10 11 01 EEXSRCHARCOUNT
782C PARAM TODLIT
784C PARAM CT
786C* If FMDATE or TODATE is 0 (zero) set LR as follows:
788C*
790C N10 01
792CORN11 01 SETON LR
794C*
796C* HANDLE T-RECORDS:
798C*
800C* The Disp2std subroutine is called to translate the display
802C* format file name, FILNAM, to the standard format file name,
804C* STDNAM. If any errors occur, indicator 30 is on; otherwise,
806C* it is off.
808C*
810C 02 MOVE ' ' STDNAM
812C 02 EEXSRDISP2STD *IN30
814C PARAMFILNAM
816C PARAMSTDNAM
818C N30 02 EEXSRCHARCOUNT
820C PARAMSTDNAM
822C PARAM CT
824C*
826C* At LR, the Print-It subroutine writes the contents of CT
828C* to MAINFILE:
830C*
832CLR EEXSRPRINT-IT
834C PARAMCT
836C PARAM MAINFILE
838C*
840OMAINFILED 10 11 01
842O 4 'FROM'
844O FMDLIT 23
846O 26 'TO'

Example 13–2. Declaring and Using Subroutines from a Library (cont.)

8600 0544–103 13–19


Library Specifications

..*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...
848O TODLIT 45
850O 48 'IS'
852O 20 DAYS Z 54
854O 20 59 'DAYS'
856O 21 58 'BACKWARDS'
858O 22 56 'NOTHING'
862OOUTNEWP D 02
864O 6 'INPUT:'
866O FILNAM 80
868O D 30 02
870O 12 '--- NOT GOOD'
872O D N30 02
874O 9 'STANDARD:'
876O STDNAM 80

Example 13–2. Declaring and Using Subroutines from a Library

Example 3
The CURRENT_DATE procedure in the GENERALSUPPORT library returns a
21-character alphanumeric value that represents the calendar date, time of day, and local
time differential factor provided by the system on which the function is evaluated.

Example 13–3 shows the coding required to access a 4-digit year.

...*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...
2000FOUTPUT O REMOTE
2500LIBRARY NAME GENSUPP F GENERALSUPPORT
3000LIBRARY SUBR CURRDATE CURRENT_DATE
3500LIBRARY PARAMDATE *
3900C MOVE 'ABCDE' ALPHA 6
4000C EEXSRCURRDATE
5000C PARAM DATE 21
6000C EXCPTOUTPUT
8000C SETON LR
8111OOUTPUT E
9111O DATE 21

Example 13–3. Calling the CURRENT_DATE Procedure

13–20 8600 0544–103


Library Specifications

Returned Value
The character positions returned, numbered from left to right, appear as follows:

Table 13–3. Alphanumeric Value Returned by the CURRENT_DATE


Procedure

Character Contents
Positions

1 through 4 Four numeric digits for the year in the Gregorian calendar.
5 through 6 Two numeric digits for the month of the year, in the range 01
through 12.
7 through 8 Two numeric digits for the day of the month, in the range 01 through
31.
9 through 10 Two numeric digits for the hours past midnight, in the range 00
through 23.
11 through 12 Two numeric digits for the minutes past the hour, in the range 00
through 59.
13 through 14 Two numeric digits for the seconds past the minute, in the range 00
through 59.
15 through 16 Two numeric digits for the hundredths of a second past the second,
in the range 00 through 99.
17 See Table 13–4.

18 through 21 See Table 13–5.

Character position 17 can contain one of three characters as shown in Table 13–4.

Table 13–4. Meaning of Character in Position 17

IF character 17 is a . . . THEN . . .

Minus sign (–) The local time indicated in the previous character
positions is behind Greenwich Mean Time.
Plus sign (+) The local time indicated in the previous character
positions is the same as or ahead of Greenwich Mean
Time.
Zero (0) The system on which this value is evaluated does not
have the facility to provide the local time differential
factor.

Character positions 18 through 21 contain the time in hours and minutes relative to
Greenwich Mean Time. The meaning of the time value contained in these positions
depends upon the character in position 17 as shown in Table 13–5.

8600 0544–103 13–21


Library Specifications

Table 13–5. Meaning of Characters in Positions 18–21

IF character 17 is a . . . THEN . . .

Minus sign (–) Character positions 18 and 19 contain a numeric value in


the range 00 through 24. This value indicates the number
of hours that the reported time is behind Greenwich Mean
Time.
Character positions 20 and 21 contain a numeric value in
the range 00 through 59. This value indicates the number
of minutes that the reported time is behind Greenwich
Mean Time.
Plus sign (+) Character positions 18 and 19 contain a numeric value in
the range 00 through 24. This value indicates the number
of hours that the reported time is ahead of Greenwich
Mean Time.
Character positions 20 and 21 contain a numeric value in
the range 00 through 59. This value indicates the number
of minutes that the reported time is ahead of Greenwich
Mean Time.
Zero (0) Character positions 18 through 21 contain zeros.

Example of Output
The following is an example of a value returned by the CURRENT_DATE procedure.
Because character position 17 is a minus sign, the digits 0700 indicate the reported
time is 7 hours and 0 (zero) minutes behind Greenwich Mean Time.

1995062813195795-0700

13–22 8600 0544–103


Section 14
Input Specifications

The Input Specification describes the records in each file and the fields in each record to
be used as input data for the program.

For information about data management and COMS Input Specifications, refer to Volume
2 of this manual.

There are two types of Input Specifications: record-type descriptions (columns 7–42) and
field descriptions (columns 43–70). Field and record-type descriptions must not be
specified on the same line.

Record-type descriptions define the various input records and their relationship to other
records in the file. For record-type descriptions, the columns for field descriptions must
be blank.

Field descriptions define each field within a record. For field descriptions, the columns for
record-type descriptions must be blank. Field descriptions must start one line below the
associated record-type descriptions.

Data structures are also defined in the Input Specifications. Data structures enable the
user to control how fields are mapped in memory. Data structures are described later in
this section.

Input Specifications Coding Form and Summary


The coding form for the Input Specifications is illustrated in Figure 14–1.

Figure 14–1. Input Specifications Coding Form

8600 0544–103 14–1


Input Specifications

Table 14-1 summarizes the field definitions for the Input Specification form.

Table 14–1. Field Definitions Summary (Input Specifications)

Columns Description

1–5 Identifies the program sequence numbers unless the $UNSEQ


compiler control option is TRUE.
6 Identifies the type of specification for each line of code. This field must
be coded with the letter I.
7 Contains an asterisk (*) if the line is a comment.
7–14 Contains a file name that was specified in the File Specifications as an
input, update, or combined file, or specifies the name of a data
structure.
14–16 Places the Record Identification Codes (columns 21–41)in an AND or
OR relationship. Acceptable entries are AND or OR, left-justified.
15–16 Specifies whether records are to be processed in a predetermined
sequence. Acceptable entries are 01 through 99 or any pair of
alphabetic characters.
17 Indicates the number of records of each type in a sequence group if
sequencing is specified. Acceptable entries are blank, 1, or the letter N.
18 Specifies whether sequenced records must be present or that a data
structure is a local data area. Acceptable entries are blank or the letter
O.
19–20 Contains a record identifying indicator (01 through 99), a control level
indicator (L1 through L9), the last record indicator (LR), a halt indicator
(H0 through H9); or specifies a data structure (DS) or look-ahead fields
(**).
21–41 Record Identification Codes specify the following:
• Columns 21 through 24, 28 through 31, and 35 through 38 specify
the position within the record that contains a record identification
code. Acceptable entries are blank or 1 through n (where n equals
the record length).
• Columns 25, 32, and 39 indicate whether the characters in
columns 27, 34, and 41 are present in the specified position in the
record. Acceptable entries are blank or N.
• Columns 26, 33, and 40 specify the part of the character in
columns 27, 34, and 41 that is to be tested for record
identification. Acceptable entries are the letters C (the entire
character), Z (the zone portion), or D (the digit portion).
• columns 27, 34, and 41 contain the character. Any character is an
acceptable entry.
43 Specifies the format of numeric input. Acceptable entries are blank, or
the letters P, J, L, R, B, S, and D.
44–47 Designates the leftmost position of the input field. Acceptable entries
are numeric and must be right-justified.

14–2 8600 0544–103


Input Specifications

Table 14–1. Field Definitions Summary (Input Specifications)

Columns Description

48–51 Contains the rightmost position of the input field. Acceptable entries
are numeric and must be right-justified.
52 Specifies the number of decimal positions for numeric fields.
Acceptable entries are blank or 0 through 9.
53–58 Contains field names, whole arrays, indexed tables or arrays, or one of
the special names, PAGE through PAGEn (where n = 1 through 9).
Entries in this field are left-justified.
59–60 Designates a control level indicator. Acceptable entries are blank or L1
through L9.
61–62 Specifies sequence checking for a single input file or sequence
checking with matching records for two or more input files. Acceptable
entries are blank or M1 through M9.
63–64 Contains one of the following field record relations indicators: 01
through 99 (record identifying indicator), L1 through L9 (control level
indicator that has been previously defined), MR (matching record
indicator), U1 through U8 (external indicator), or H0 through H9 (halt
indicator), or blank.
65–66 Contains an indicator that designates if the specified field is greater
than blank or positive. Acceptable entries are blank, 01 through 99, or
H0 through H9.
67–68 Contains an indicator that designates if the specified field is less than
blank or negative. Acceptable entries are blank, 01 through 99, or H0
through H9.
69–70 Contains an indicator that designates if the specified field is blank (or
zero). Acceptable entries are blank, 1 through 99, or H0 through H9.
75–80 Contains the program identification. Any entry is valid.

8600 0544–103 14–3


Input Specifications

Field Definitions
The fields for the Input Specifications are discussed in the following paragraphs.

An entry in a column that is not part of any of the defined fields in a specification might
cause warning messages to be displayed.

Sequence Number (Columns 1–5)


The Sequence Number field contains a 5-digit sequence number (00000-99999) for an
RPG program source unless the $UNSEQ compiler control option is TRUE. Refer to
Section 21, “Control of the Compilation Process,” for information about the $UNSEQ
option.

Form Type (Column 6)


The Form Type field identifies the type of specification for each line of code. This field
must contain the letter I.

Comment (Column 7)
Explanatory statements can appear in the source if column 7 contains an asterisk (*). The
Comment entry enables the entire line to the right of the asterisk to appear as program
documentation on the program listing. Comments are not instructions to the RPG
program or compiler, but serve as program documentation. Any valid character can be
used in a comment line. An asterisk in column 7 overrides an entry in column 6.

This field identifies the file to which the record-type and subsequent field descriptions
belong or the data structure to be used. If a data structure is specified, the name can be
only 6 characters in length. For additional information, see the discussion of data
structures in this section.

Every input, update, and combined file (except input table files and record-address files)
described in the File Specifications must be described in the Input Specifications. No
other files can be described in the Input Specifications.

The Filename entry must be the same as the one used in the File Specifications. The
entry must appear on the first line containing information about the records in the file. If
the entry is blank, the last file name entered is associated with the record being
described. The first record-type description must not have a blank Filename entry.

Primary and secondary files are processed in the order in which they are described in the
File Specifications, not in the order in which they are specified in the Input Specifications.

All record-type and field descriptions for a particular file must be grouped together in the
Input Specifications. Descriptions of records from different files must not be
interspersed.

14–4 8600 0544–103


Input Specifications

AND and OR Lines (Columns 14–16)


If more than three entries need to be specified in the Record Identification Codes
(columns 21–41) to identify a record type, an AND line can be used. The word AND is
entered in columns 14 through 16, and at least one additional entry must be placed in the
Record Identification Codes field (columns 21–41).

When the same record type is identified in more than one way, OR lines can be specified
by entering OR in columns 14 through 15 and leaving column 16 blank. Any additional
record identification codes must be entered in columns 21 through 41.

Columns 7 through 14 must be blank when the AND and OR Lines field contains an
entry. For further details, see the discussion of the Record Identification Codes field
(columns 21–41) in this section.

Sequence (Columns 15–16)


This field specifies a special sequence of different record types. An alphabetic or blank
entry specifies that the record types need not be in any special order.

Valid entries for the Sequence field are as follows:

Entry Definition

Blank Record types are not sequenced, and a warning message is displayed.

Two Record types are not sequenced.


alphabetic
characters

Two numeric Record types are sequenced.


digits (01–99)

All chained and demand files must have an alphabetic entry in this field. Within each file,
all record types that have alphabetic entries in the Sequence field must be specified
before record types with numeric entries.

Example
Example 14–1 shows how to code the Sequence field when both alphabetic and numeric
entries are desired.

8600 0544–103 14–5


Input Specifications

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00300FFILEIN IP 80 80 DISK
00500FFILEOUT O 132 132 PRINTER
00900IFILEIN AA 05 15 D5
01000I 7 13 FIELD1
01010I 011 05 11 CA
01020I 4 9 FIELD2
01030I 021O05 17NCA
01040I 4 9 FIELD3
01100OFILEOUT D 05
01200O FIELD1 15
01250O FIELD2 25
01300O FIELD3 35

Example 14–1. Coding for Sequence Checking

If the Sequence field contains a numeric entry, the compiler assigns sequence numbers
to the different record types in the file. These sequence numbers enable the programmer
to specify that one record type is to appear before another record type within a
sequenced group. The program automatically checks the designated order as the records
are read.

The first sequenced record type specified should have an entry of 01 in this field; the
next record type should be given a higher number, and so forth. Gaps in sequence
numbers are allowed, but the numbers must be in ascending order.

If a record is encountered that is out of sequence, an INPUT RECORD SEQUENCE


ERROR message occurs. Refer to Appendix A, “System Messages,” for information on
the INPUT RECORD SEQUENCE error message.

AND and OR records can be specified within a sequence-checked file. However, the
AND and OR line must not have a sequence field; all sequencing specifications are taken
from the preceding line.

Number (Column 17)


This field is used only if sequence checking is to be done, that is, when the Sequence
field (columns 15–16) contains a numeric entry and indicates whether more than one
record of the designated type can appear in each group of a sequenced input file.

14–6 8600 0544–103


Input Specifications

Valid entries for the Number field are as follows:

Entry Definition

Blank Record types are not to be checked for sequence. The Sequence field
(columns 15–16) contains an alphabetic entry.

1 Only one record is present in each sequence group.

N One or more records of the designated type are present in each sequence
group.

Records in an AND and OR Lines field must not have a Number field entry. The
specifications from the preceding line apply to the AND and OR Lines field
(columns 14–16).

Option (Column 18)


The Option field is used only if the Sequence field (columns 15–16) specifies that
sequence checking is to be done. This field specifies whether certain record types are
optional or indicates that the data structure defined in columns 7 through 12 is a local
data area for a terminal.

Valid entries for the Option field are as follows:

Entry Definition

Blank Record types must be present in each group.

O Record type is optional for each group.

U Data structure is a local data area.

If the letter O is entered in this field, a record of the designated type can be optionally
present in each group of a sequenced file. If this field is blank, the Number field
(column 17) contains an entry that indicates one or more records are specified for this
record type; record types must be present for each group. If the letter U is entered, the
data structure defined in columns 7 through 12 of this specification is used as a local data
area.

If all record types in a file are designated as optional, no sequence errors are detected.

Records in an AND and OR Lines field (columns 14–16) must not have an Option field
entry. The specifications from the preceding line also apply to the AND and OR Lines
field.

8600 0544–103 14–7


Input Specifications

Record Identifying Indicator (Columns 19–20)


This field can be used for one of the following purposes:

• To assign an indicator to each record type


• To specify look-ahead fields
• To identify header-trailer records
• To define a data structure
Valid entries for the Record Identifying Indicator field are as follows:

Entry Definition

01–99 Record identifying indicator

L1–L9 Control level indicator

LR Last record indicator

H0–H9 Halt indicator

TR Header-trailer specification

DS Data structure

** Look-ahead field

If the entry is blank, a warning message is displayed. The various entries have special
meanings, as defined in the following paragraphs.

Record Identifying Indicators (01–99)


Each input file can contain different groups of records that require different types of
processing. Unique record identifying indicators can be used for each group of records.

When a group of records is selected for processing, its corresponding identifying


indicator is turned on. This indicator remains on for the rest of the current program cycle
and can be used to condition various calculation and output operations. All record
identifying indicators are turned off at the same point in the program cycle. Refer to
Section 3, “RPG Program Logic Cycle (PLC),” for more information.

For any one primary or secondary file, only one record identifying indicator can be on. For
any one chained or demand file, more than one record identifying indicator can be on.
However, this situation occurs only if two or more records are read from the same file
during one program cycle through the use of CHAIN or READ operations.

Record identifying indicators can be assigned in any order. If the same operations are to
be performed on different groups of records, the same indicator can be assigned to more
than one group of records. Refer to the discussion of the OR line in the Record
Identification Codes field (columns 21–41) in this section.

14–8 8600 0544–103


Input Specifications

Different indicators can be specified for each group of records that requires special
processing in an OR relationship; however, record identifying indicators are not allowed
in an AND line. If the record identifying indicator is not specified on an OR line, the
default value is the value of the last previously specified record identifying indicator for
that record. If no value has been specified for that record, no record identifying indicator
is used. Refer to the discussion of the AND line in the Record Identification Codes field
(columns 21–41) and to the discussion of the OR relationship in the Field Name field
(columns 53–58) in this section.

Control Level Indicators (L1–L9)


A control level indicator is used instead of a record identifying indicator when a record
type (rather than a control field) signals the start of a new control group. This use of the
control level indicator does not cause the lower control levels to be turned on. Refer to
the discussion of the Control Level field (columns 59–60) in this section for a complete
description of control level indicators.

Last Record (LR) Indicator


The last record indicator is used instead of a record identifying indicator when a record
type (rather than automatic EOF) signals the end of processing. Final total operations
should be conditioned by this indicator.

The use of the LR indicator as a record identifying indicator for a file that is read during
detail calculations does not cause the LR indicator to be turned off. This is because all
indicators used as record identifiers are turned off at the indicator initialization step of the
program logic cycle (PLC). During the indicator initialization step, the record is read during
detail calculations and before a test for the LR indicator occurs.

Halt Indicators (H0–H9)


A halt indicator is used instead of a record identifying indicator when the occurrence of a
specific record type denotes an error condition requiring a program halt.

Header-Trailer Specifications
A header-trailer, or spread-record, enables an individual record to be processed as if it
were actually several records. The record is composed of a portion of data that are
common to the entire record (the header) and is followed by one or more occurrences of
the remaining fields of the record (the trailer). The header is used with each occurrence
of the trailer.

8600 0544–103 14–9


Input Specifications

Data Structure
A data structure can be used to define an area of memory in several ways and reorganize
fields for easier reference. A data structure is an area in memory composed of one or
more subfields. Columns 19 through 20 contain DS to indicate that a data structure is
used. Refer to the discussion of data structures in this section.

Look-Ahead Field (**)


A pair of asterisks (**) indicates that the fields named in the Field Name field
(columns 53–58) of subsequent lines are look-ahead fields.

By using look-ahead fields, the program can extend the use of the matching record
function or determine when the last record of a control group is being processed.
Matching records are described later in this section. The rules for processing the last
record of a control group are as follows:

• Look-ahead fields can be specified only for input, update, or combined files that are
either primary files or secondary files.
• One set of look-ahead fields can be specified for each file; the description applies to
all records in that file.
• A look-ahead field is read-only and must not be used as the Result Field for
calculation operations (except for the DEBUG, TESTB, TESTN, and TESTZ
operations).
• The name given to a look-ahead field must not occur in any other Input or Extension
Specifications and must not be a special word (except PAGE through PAGEn).
• If the look-ahead field occurs in Output Specifications, the Blank After field
(column 39) must not be used.
• To access information both before and after the record is selected for processing,
the field must be described twice using different names; it must be described once
as a look-ahead field and once in the normal manner.
• The look-ahead field must not follow a record-type description that has a numeric
Sequence field (columns 15–16) entry.
• Columns 17, 18, and 21 through 74 must be blank.
• Columns 14 through 16 must contain blanks or alphabetic characters, but not AND or
OR on the lines following the line containing the pair of asterisks (**).
• On the look-ahead field description lines, columns 7through 42 and 59 through 74
must be blank.
• When the last record of a file is being processed, any look-ahead fields for that file
contain all nines (signed numeric or alphanumeric according to the field type).
For input files, a look-ahead field enables the program to access information in fields of
the next record that becomes available for processing. Thus, the program can use
information from the look-ahead fields to condition certain operations before the record is
available for processing.

14–10 8600 0544–103


Input Specifications

Look-ahead fields are not allowed for data communications files.

Figure 14–2 shows the processing of two input files. (See Example 14–2 later in this
section for coding examples of look-ahead fields.)

Figure 14–2. Records Available for Look-Ahead: Two Input Files

For combined and update files, the look-ahead fields apply to the next record in the file
only if the current record was read from some other file. When the current record is read
from a combined or update file, the look-ahead fields apply to the current record.

8600 0544–103 14–11


Input Specifications

Figure 14–3 shows processing records from an update file and a secondary input file.

Figure 14–3. Records Available for Look-Ahead Fields: One Update File and One
Input File

14–12 8600 0544–103


Input Specifications

Example
Example 14–2 shows coding for look-ahead fields.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00300FFILE1 IP 180 90 DISK
00325FFILE2 IS 180 90 DISK
00350FFILE3 US 180 90 DISK
00400FPRINTER O 132 132 PRINTER
00500IFILE1 AA 01 1 C2
00600I 1 11 CTL L1M1
00700I 12 162AMT
00800I **
00850I 1 11 NXTCTA
00900IFILE2 BB 02 1 C3
01000I 22 32 CTL L1M1
01020I 12 162AMT
01040I **
01050I 22 32 NXTCTB
01060IFILE3 CC 03 1 C2
01070I 02 12 CTL L1M1
01080I 16 202AMT
01090I **
01100I 02 12 NXTCTC
01110C*
01120C* Accumulate totals.
01130C*
01140C AMTL1 ADD AMT AMTL1 82
01150C AMTLR ADD AMT AMTLR 102
01160C*
01170C* FILE1 or FILE2 next?
01180C*
01190C 03 NXTCTA COMP NXTCTB 20
01200C N03N02 SETOF 20
01210O*
01220O* When FILE2 is processed next, flag this FILE3 record.
01230O*
01240OFILE3 D 03 20
01250O 60 '9'
01260OPRINTER D 1 02 20
01270O CTL 32
01280O AMT A 20
01290O T 12 L1
01300O CTL 32
01310O AMTL1 AB 20
01400O LR AMTLR A 50

Example 14–2. Coding Look-Ahead Fields

8600 0544–103 14–13


Input Specifications

Record Identification Codes (Columns 21–41)


This field is used when more than one record type is contained in the file. It specifies
which record identifying indicator remains turned on during the program cycle and detail
output. Each record type is identified by a unique character or a combination of
characters that occur in a designated position in the record. Record identifying indicators
can also be turned on when records are read from demand, chained, or full-procedural
files in detail and total calculations.

If record identification codes have been specified, other codes can be designated with
the AND and OR Lines field (AND or OR in columns 14 through 16). As many lines as
necessary can be used to describe these continuation codes. Example 14–3 shows AND
and OR relationships.

At least one Record Identification Codes field entry must be present on each AND line
and on the preceding line. Record identification codes are not required on an OR line.

AND Line
An AND line is used to describe record identification codes that consists of more than 3
characters. Each new line enables three more record identification codes to be specified.

An AND line is identified by coding the word AND in columns 14 through 16. The record
selected must contain all the characters specified in the record identification codes to
turn on the corresponding record identifying indicator (columns 19–20).

OR Line
Sometimes a particular record type can be identified by two or more different record
identification codes. For this condition, an OR line is used to indicate that only one of the
codes specified must be present to identify the record type.

An OR line is identified by coding the word OR in columns 14 through 15.

Example

Example 14–3 shows AND and OR coding.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00300FFILEIN IP 80 80 DISK
00400FFILEOUT O 132 132 PRINTER
00405I*
00410I* The lines below describe a record type that can be
00415I* identified by the code DEPT appearing in positions
00420I* 67-70 of the input record. The AND line is used in
00425I* order to specify additional characters as part of the
00430I* record identification code.

Example 14–3. Coding AND and OR Relationships (cont.)

14–14 8600 0544–103


Input Specifications

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
0435I*
00440I* The OR line enables an alternate code to be specified.
00445I* Thus, a 9 in the first position also serves to
00450I* identify the record type even if the code DEPT does
00455I* not appear in positions 67 through 70 of the input record.
00460I*
00465I* For the record type below, either the word DEPT in
00470I* positions 67-70 or a 9 in position 1 (or both)
00475I* causes the L1 indicator to turn on.
00480I*
00500IFILEIN 011 L1 67 CD 68 CE 69 CP
00510I AND 70 CT
00520I OR 1 D9
00600I 7 13 FIELD1
01100OFILEOUT D L1
01200O FIELD1 15

Example 14–3. Coding AND and OR Relationships

Position (Columns 21–24, 28–31, and 35–38)


These fields give the location in the record of each character specified in the Record
Identification Codes field. Entries must be numeric, and can range between 1 and the
value specified in the Record Length field (columns 24–27) in the File Specifications.
Entries must be right-justified.

Not (Columns 25, 32, and 39)


These fields indicate either the presence or absence of the specified character at the
designated location.

Valid entries for the Not field are as follows:

Entry Definition

Blank Character must be present in the location specified by the Position field entry.

N Character must not be present in the location specified by the Position field
entry.

8600 0544–103 14–15


Input Specifications

C/Z/D (Columns 26, 33, and 40)


These fields indicate whether the character, its zone portion, or its digit portion should be
used for comparison.

Valid entries for the C/Z/D fields are as follows:

Entry Definition

C Entire character

Z Zone portion

D Numeric (digit) portion

If the zone of the plus sign (+) is specified, the record identification code is treated as the
positive zone (that is, a zone of A through I). If the zone of the minus sign (–) is specified,
the record identification code is treated as the negative zone (that is, a zone of J through
R).

Character (Columns 27, 34, and 41)


Any valid EBCDIC character can identify the record type. These fields specify the
character to be used for comparison as part of the record identification codes.

If no record identification codes are found in a record, a RECORD IDENTIFICATION


ERROR message is returned. Refer to Appendix A, “System Messages,” for more
information on this message.

Packed (Column 43)


The Packed field specifies the external format of an input field. The entry in this field
must not be P or J if the file for which this input field is defined is being translated from
an EBCDIC character code set, that is, if the File Translation field (column 67) in the File
Specifications does not contain a blank or E.

Valid entries for the Packed field are as follows:

Entry Definition

Blank Alphanumeric or unpacked decimal format

P Signed packed decimal format

J Unsigned packed decimal format

L Separate leading signed unpacked format

R Separate trailing signed unpacked format

B Binary data in two's complement format

S Single-precision numeric format

D Double-precision numeric format

14–16 8600 0544–103


Input Specifications

Data defined with either a blank or a P can be specified as left- or right-signed in either
the Sign Position field (column 17) in the Control Specification or the $RSIGN compiler
control option (refer to Section 21, “Control of the Compilation Process.” )

The various external formats specified in the Packed field are described in the following
paragraphs.

Alphanumeric or Unpacked Decimal Format


In alphanumeric or unpacked decimal format, each byte can contain one character. Each
byte is divided into a 4-bit zone portion and a 4-bit digit portion. This format is illustrated
in Figure 14–4.

Figure 14–4. Alphanumeric or Unpacked Decimal Format

Each digit portion holds one digit of the number; the zone portions (except for the sign
position) are dropped.

Signed Packed Decimal Format


In signed packed decimal format, each byte can contain two decimal numbers. Each byte
is divided into two 4-bit portions. Each 4-bit portion holds one digit, except for one portion
that holds the sign position. This format is illustrated in Figures 14–5 and 14--6.

Figure 14–5. Left-Signed Packed Decimal Format

Figure 14–6. Right-Signed Packed Decimal Format

8600 0544–103 14–17


Input Specifications

Unsigned Packed Decimal Format


In unsigned packed decimal format, each byte can contain two decimal digits. Each byte
is divided into two 4-bit portions. Each 4-bit portion holds one digit. This format is
illustrated in Figure 14–7.

Figure 14–7. Unsigned Packed Decimal Format

An input field defined with unsigned packed decimal format is converted to signed
internal format automatically by the RPG program when the field is moved from the input
buffer to the work area. After conversion, the data field contains a positive sign (binary
1100). The sign can be altered by performing calculation operations on the data field.

Separate Signed Decimal Format


In separate signed decimal format, each byte (except the leading or trailing sign byte)
represents one digit of the numeric field, as in the unpacked decimal format. For input
data, the field is negative if the sign position contains an alphanumeric minus sign (–);
otherwise, the field is positive. This format is illustrated in Figures 14–8 and 14--9.

Figure 14–8. Separate Leading Signed Decimal Format

Figure 14–9. Separate Trailing Signed Decimal Format

14–18 8600 0544–103


Input Specifications

Binary Format
In binary format, the field length must be either 2 bytes or 4 bytes. A 2-byte field implies
a 4-digit numeric field, unless the field is otherwise defined. A 4-byte field implies a 9-
digit numeric field, unless the field is otherwise defined. This format is illustrated in
Figures 14–10 and 14–11.

Figure 14–10. Binary Data Format (2 Bytes Long)

Figure 14–11. Binary Data Format (4 Bytes Long)

The numeric value of a positive number is obtained by summing the values associated
with the bit positions where the bit value equals 1. The value of a negative number is
obtained by summing the values associated with the bit positions where the bit value
equals 0 and then adding 1. The sign bit is not included in these calculations.

Single-Precision Numeric Format


A single-precision numeric format is denoted by an S in the Packed field. When an input
value is entered as a single-precision integer, the field length must be 6 bytes. The 6-byte
field implies an 11-digit numeric field.

In single-precision numeric format, the field must be 6 bytes long. The value itself is
represented in a sign-magnitude binary format, as shown in the following diagram. In
Figure 14–12, the 6 bytes (which make one word) are shown as a grid of bits, numbered
from top to bottom and from left to right, with the top left bit being number 47, and the
bottom right bit being number 0.

8600 0544–103 14–19


Input Specifications

Figure 14–12. Single-Precision Numeric Format (1 Word Long)

Key Field Contents


\\\ 47: 1 Not used

sm 46: 1 Sign bit for mantissa:

1 = negative

0 = positive

se 45: 1 Sign bit for exponent (always 0 in


RPG)

e 44: 6 Exponent (always 0 in RPG)

mantissa 38: 39 Mantissa

Double-Precision Numeric Format


A double-precision numeric format is denoted by a D in the Packed field. When an input
value is entered as a double-precision integer, the field must be 12 bytes long. The 12-
byte field implies a 23-digit field.

For double-precision numeric format, the field must be 12 bytes (two words) long. The
value itself is represented in a sign-magnitude binary format, as shown in Figures 14–13
and 14--14. For this diagram, each word is shown as a grid of bits, numbered from top to
bottom and from left to right, with the top left bit being number 47, and the bottom right
bit being number 0.

14–20 8600 0544–103


Input Specifications

Figure 14–13. Double-Precision Numeric Format (Word 1)

Key Field Contents

\\\ 47: 1 Not used


sm 46: 1 Sign bit for mantissa:
1 = negative
0 = positive
se 45: 1 Sign bit for exponent (always 0 in RPG)
e 44: 6 Least significant portion of exponent (always 13 in
RPG)
mantissa 38: 39 Most significant portion of mantissa

Figure 14–14. Double-Precision Numeric Format (Word 2)

Key Field Contents

E 47: 9 Most significant portion of exponent (always 0 in RPG)


mantissa 38: 39 Least significant portion of mantissa

8600 0544–103 14–21


Input Specifications

Field Location (Columns 44–51)


This field describes the location of data fields within a record and is divided into two
subfields. The first subfield (columns 44–47) specifies the beginning of each field
(FROM), and the second subfield (columns 48–51) specifies the ending of each field (TO).
A field that is 1 character in length would have the same number entered in both
subfields. Both entries must be in the range from 1 to the value specified in the Record
Length field (columns 24–27) in the File Specifications. The TO entry must be greater
than or equal to the FROM entry. The resulting field length must be 2 or 4 bytes for
binary fields, 6 bytes for single-precision numeric fields, and 12 bytes for double-precision
numeric fields.

If the Field Name (columns 53–58) entry is a field name or a vector element, the length of
the field is determined by the following rules, where n is the difference between the TO
location and the FROM location plus 1.

Field Format Field Length

Alphanumeric n
Unpacked numeric n
Packed signed numeric 2n –1
Packed unsigned 2n
numeric
Separate leading sign n –1
Separate trailing sign n –1
Binary [(n + 2) * (n + 2)] div 4
Single-precision n
Double-precision n

The value of n must not exceed the field-size limits as described in the discussion of field
lengths in Section 2, “RPG Language Elements.”

If the Field Name entry (columns 53–58) specifies an array without an index, the FROM
and TO entries need not provide sufficient space for the whole array (as long as the Field
Location entry provides for an integer number of array elements). The actual length, in
bytes, needed for each array element can be calculated as follows, where t is the value
specified in the Length of Entry field (columns 40–42) in the Extension Specifications:

Field Format Field Length

Alphanumeric t
Unpacked numeric t
Packed signed numeric (t/2) + 1 (integer portion)
Packed unsigned numeric (t + 1)/2 (integer portion)
Separate leading sign t

14–22 8600 0544–103


Input Specifications

Field Format Field Length

Separate trailing sign t


Binary 2 + [2 * (integer portion of
t/5)]

Entries in the FROM and TO subfields must be right-justified, and leading zeros can be
omitted.

Decimal Positions (Column 52)


This field specifies the number of positions to the right of the implied decimal point in a
numeric field. The entry in this field must not be blank for a numeric field; if the data field
contains only integers, a 0 (zero) should be entered to indicate no decimal positions.

Valid entries in the Decimal Positions field are as follows:

Entry Definition

Blank Alphanumeric field

0–9 Number of decimal positions in a numeric field

D COMS-designator subfields (Refer to Volume 2 of this manual.)

T COMS-time subfields (Refer to Volume 2 of this manual.)

Any field to be edited or used for arithmetic operations must be numeric. The number of
decimal positions specified cannot exceed the length of the field, as specified in the Field
Location field (columns 44–51).

Field Name (Variable Name) (Columns 53–58)


This field assigns an identifier (name) to an input data field. All fields referred to by the
program must be named. Names must be assigned according to the rules for forming
field names which are discussed in Section 2, “RPG Language Elements.” A previously
defined vector name (but not an unindexed table name) can be used to load a previously
defined vector during input. (Refer to Section 10, “Extension Specifications,” for a
complete discussion of execution-time vectors.) A separate line must be used for each
field description.

All fields within one record type should have unique names. If two or more fields within
the same record have identical names, only the last one defined is used unless field
record relation indicators are used. Refer to the discussion of the Field Record Relations
field (columns 63–64) in this section. Fields within a record are processed in the order in
which they appear in the program (subject to the state of the field record relation
indicator). Fields from different record types can have the same name; however, names
not uniquely defined must have the same length and decimal positions. These fields
need not occur in the same location in each record.

8600 0544–103 14–23


Input Specifications

OR Relationship
To eliminate duplicate coding of identical fields in different record types, the OR
relationship can be used. OR lines can be used when either of the following situations
occurs:

• Two or more record types are specified as identical.


• Two or more record types have some fields that are identical and some fields that
are different. Refer to the discussion of the Field Record Relations field (columns 63–
64) in this section.
Example
Figure 14–4 shows an example of duplicate coding. Figure 14–5 shows how the duplicate
coding can be eliminated by using the OR relationship.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00100H* The following program shows identical fields defined
00150H* within two different record types.
00200H*
00300FFILEIN IP 80 80 DISK
00400FFILEOUT O 132 132 PRINTER
00500IFILEIN AA 01 70 CA
00600I 1 5 FIELD1
00700I 10 25 FIELD2
00800I 41 472FIELD3
00810I 60 69 FIELD4
00900I BB 02 70 CB

Example 14–4. Using Duplicate Coding (cont.)

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
01000I 1 5 FIELD1
01010I 10 25 FIELD2
01020I 41 472FIELD3
01030I 60 69 FIELD4
01100OFILEOUT D 01
01200O FIELD1 5
01300O FIELD2 25
01400O FIELD3 47
01500O FIELD4 69

Example 14–4. Using Duplicate Coding

14–24 8600 0544–103


Input Specifications

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00100H* This program shows identical fields defined within two
00150H* different record types using an OR line.
00200H*
00300FFILEIN IP 80 80 DISK
00400FFILEOUT O 132 132 PRINTER
00500IFILEIN AA 01 70 CA
00550I OR 02 70 CB
00600I 1 5 FIELD1
00700I 10 25 FIELD2
00800I 41 472FIELD3
00810I 60 69 FIELD4
01100OFILEOUT D 01
01200O FIELD1 5
01300O FIELD2 25
01400O FIELD3 47
01500O FIELD4 69

Example 14–5. Using an OR Relationship to Eliminate Duplicate Coding

Special Words
The special words PAGE and PAGEn (where n is in the range 1 through 9) can be used in
the Field Name field.

Refer to the discussion of special words in Section 2, “RPG Language Elements,” for a
complete description of the use of these words.

Control Level (Columns 59–60)


This field assigns control level indicators to fields in primary or secondary files. Any field
other than a whole array or a look-ahead field can be assigned a control level indicator. A
field that is assigned a control level indicator is known as a control field. A group of
records with identical data in the control field is known as a control group.

Valid entries in the Control Level field are as follows:

Entry Definition

Blank This data field is not a control field.

L1–L9 This data field is a control field.

A control break occurs when a record containing a control field is read and the data in
that control field are different from the data in the same control field of the previous
record. When a control break occurs, the designated control level indicator is turned on
(along with all lower control level indicators). For example, if control level indicator L5 is
turned on, then indicators L4, L3, L2, and L1 are also automatically turned on. Control
level indicator L0 cannot be assigned to a control field because it is always on.

8600 0544–103 14–25


Input Specifications

A control level indicator either can be turned on or can be turned off by specifying it as a
resulting indicator (in columns 54–59 in the Calculation Specifications). A control level
indicator can also be used as a record identifying indicator; however, in this case, control
level indicators lower than the one specified are not automatically turned on or off.

For a detailed description of the treatment of control breaks, refer to the description of
step 7, Control Fields and Record Identification, in Section 3, “RPG Program Logic Cycle
(PLC).”

Assignment of Control Level Indicators


Control level indicators are used to condition operations such as the following:

• Calculations to be performed when a control group (such as totals) changes


• Operations to be performed on the first record of a new control group
• Summary record output to be performed for each control group
The following rules must be observed when control level indicators are assigned:

• The same control level indicator can be used for different record types or files;
however, the control fields associated with that indicator must have the same length.
(See Example 14–6.)
• Field names have no effect on the control level indicator; thus, control fields in
different record types can have the same name and indicator.
• The maximum cumulative size of control fields within one record type is 255
characters.
• Control fields can overlap within a record type.
• For control break purposes, numeric control fields are treated as though they had no
decimal positions.
• For numeric control fields, only the absolute value of the field is compared. The sign
is ignored.
• All control fields with the same control level indicator are considered numeric, if any
of those fields are described as numeric.
• Control levels can be written in any sequence, and gaps are permitted in the control
levels assigned.
• For each control level used in a program, a control break occurs the first time a
control field is encountered if there is no previous control field to compare with the
current control field.
• During the PLC, total calculations and total output are processed in the cycle after
the control field is selected.
• Different record types in a file do not need to have the same number of control
fields. However, the user must ensure that unwanted control breaks do not occur.

14–26 8600 0544–103


Input Specifications

Example
Example 14–6 shows the coding of control fields.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00300FFILEIN IP 80 80 DISK
00400FFILEOUT O 132 132 PRINTER
00600IFILEIN AA 01 2 CQ
00700I 1 6 MINOR L1
00800I 10 21 NAME
00900I 25 330MAJOR L2
00910I 35 452TOTAL L3
00920I BB 02 2NCQ
00930I 1 90MAJOR L2
00940I 11 202AMT
00950I 21 26 MINOR L1
00960I 30 402TOTAL L3
01000CL1 AMT ADD TOTAL TOTAL
01100OFILEOUT D L1 L2
01200O MINOR B 10
01300O MAJOR B 30
01400O TOTAL 50
01500O NAME B 65

Example 14–6. Using Control Fields in Two Record TypesSplit Control


Fields

If the same control level indicator is assigned to more than one field within the same
record type, the control field created is known as a split control field. All designated fields
(those having the same control level within the same record type) are combined by the
program in the order in which they are specified in the Input Specifications and are
treated as one control field.

8600 0544–103 14–27


Input Specifications

Example
Split control fields are shown in Example 14–7.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00300FFILEIN IP 80 80 DISK
00400FFILEOUT O 132 132 PRINTER
00500IFILEIN AA 01 1 D1
00600I 13 16 TYPE01L3
00700I 19 25 TYPE03L3
00800I 10 12 TYPE02L3
00900I 26 28 TYPE10
00910I 29 29 TYPE11L5
00920I 30 31 TYPE12L5
01000I BB 02 1ND1
01100I 2 4 PART01L5
01200I 5 10 DEPT01L3
01300I 11 18 DEPT02L3
01310I*
01320I* The lines above describe split control fields in two record
01330I* types. The L3 control field is split in both record types;
01340I* however, the total length of all L3 fields in the first
01345I* record is the same as in the second record. The L5 control
01350I* field is split in the first record type. The total length
01360I* of all L5 control fields in that record type is equal to
01370I* the length of the single L5 field in the other record type.
01380I*
01500C TYPE01 COMP 'AAAA' 03
01510C TYPE02 COMP 'BBB' 04
01520C TYPE03 COMP 'CCCCCCC' 05
01530C TYPE11 COMP 'Y' 06
01540C TYPE12 COMP 'XX' 07
01600OFILEOUT D L3
01700O 03 TYPE01 10
01800O 04 TYPE02 13
01900O 05 TYPE03 20
01910O DEPT01 30
01920O DEPT02 40
01930O D L5
01940O 06 TYPE11 10
01950O 07 TYPE12 15
01960O PART01 20

Example 14–7. Using Split Control Fields

14–28 8600 0544–103


Input Specifications

The following special rules must be observed for split control fields:
• The same control level indicator can be used for split control fields in different record
types if the field names used are different. The length of various portions of a split
control field in one record type can differ from the corresponding portions in another
record type. However, the total length of the control fields (whether split or not)
must be the same in both record types. For further information, refer to the
discussion of the Field Record Relations field (columns 63–64) in this section.
• If one portion of a split control field is numeric, the entire field is considered numeric.
• No portion of a numeric split control field can exceed the maximum size for numeric
fields (as given in the discussion of field length in Section 2, “RPG Language
Elements” ). However, the total length of all fields assigned to one control level
indicator (within each record type) can be 255 characters.
• A mixture of packed and unpacked control fields is allowed.
• Split control field lines must be contiguous.

Match Field (Columns 61–62)


This field designates match fields for both multifile processing and sequence checking.

Valid entries in the Match Field are as follows:

Entry Definition

Blank No matching record input control or sequence checking is to be


performed.

M1-M9 Matching record input control and sequence checking are to be


performed when two or more primary or secondary files are specified
as having match fields. Only sequence checking is performed when
either one primary or one secondary file is specified as having match
fields.

This field must be blank for chained, demand, display, output, record-address, and vector
files.

For multifile processing, the use of match fields enables the compiler to dynamically
determine the absolute value of the data in the specified match fields and to select which
record to process next. This process is known as matching record input control. For the
matching record (MR) indicator to be turned on, one of the multiple files must be
designated as primary, and all others to be used in matching record input control must be
specified as secondary.

If matching records are specified for two or more secondary files and are not specified
for the primary file, matching record processing is performed, but the MR indicator is
never turned on.

8600 0544–103 14–29


Input Specifications

For both multifile and single-file processing, the use of match fields specifies that the
sequence of the absolute value of the data in the match field must be in agreement with
the collating sequence specified in the Collating Sequence field (column 26) in the
Control Specification.

Match Fields
Match fields enable the comparison of records from primary and secondary files to
determine when the records match. A maximum of nine different fields can be
designated as match fields (M1 through M9).

The matching record (MR) indicator is turned on whenever the match fields from a
primary file are exactly the same as the match fields from any secondary file. The MR
indicator is turned on or off after overflow output, but before detail calculations, during
the PLC. Additional information on the matching record (MR) indicator is provided in
Section 3, “RPG Program Logic Cycle (PLC).” The entries M1 through M9 specify the
fields in each record are to be matched and cause the MR indicator to be turned on when
a match condition occurs. M1 through M9 are not indicators; the MR indicator conditions
the operations that should be performed when records match.

Assignment of Match Fields

The following rules must be observed when match fields are assigned:

• All match fields must be in the same sequence during input. Refer to the discussion
of the Sequence field (column 18) in Section 8, “File Description Specifications,”
because sequence checking is automatically performed on all fields designated as
match fields. A sequence error in any field causes a MATCH FIELD SEQUENCE
ERROR message to be displayed. (Refer to the list of error messages in Appendix A,
“System Messages.”)
• If matching is used, not all the primary and secondary files are required to have
match fields. In addition, not all record types within a file are required to have match
fields. However, to achieve a matched condition, at least one record type from the
primary file and at least one record type from a secondary file must have match
fields.
• All fields given the same match field (M1-M9) must be the same length.
• Overlapping of different match fields within a record type is allowed.
• The cumulative size of all match fields cannot exceed 255 characters.
• All records to be matched must contain the same match fields (M1-M9); otherwise, a
match cannot occur, and a warning message is displayed.
• When more than one match field is designated for a record type, all fields to be
matched are combined in descending match field order and are treated as one
contiguous match field. The highest match field is M9.
• Split match fields are not allowed; thus, the same match field cannot be used more
than once for each record type unless field record relation indicators are used.
• Numeric match fields are treated as though they had no decimal positions.

14–30 8600 0544–103


Input Specifications

• For numeric match fields, the absolute value of the data are compared.
• If one field within a particular match field is defined to be numeric, then for purposes
of determining a match condition, the rest of the match fields are treated as numeric
values.
• The MR indicator is turned on in multifile processing if the absolute value of the data
in the match fields of a secondary file and the primary file are equal.
• Field names have no effect on the match fields assigned; therefore, match fields in
different record types can have both the same name and the same match field
assigned.
• Whole arrays must not be designated as match fields.
• Records in primary and secondary files without match fields specified are processed
before records in primary and secondary files with match fields specified.

File Processing with Match Fields

The following rules apply to file processing when match fields are used:

• If a match field condition occurs, the primary file record is processed first.
• When records do not match, the record with the lowest (for ascending files) or
highest (for descending files) match field value is processed first.
• For purposes of record selection, records without match fields are considered to
match the last preceding record with match fields specified and are selected next.
However, because no match occurs, the MR indicator is turned off. If the next record
matches the preceding record with match fields specified, the MR indicator is again
turned on.
• Since matched primary records are selected and processed before matched
secondary records, it is always possible to change the secondary record based on
the contents of the primary record. To change the primary record based on the data
in the secondary record, look-ahead fields must be specified for the secondary
record.
• The MR indicator is turned off while a record selected by the FORCE operation is
processed. If the next nonforced record matches the last record with match fields
specified, the MR indicator is turned on again.

Multifile Processing with Matching Records


At the beginning of RPG program execution, one record is read into the input buffer of
each primary and secondary file. One of these records is selected for processing
according to the rules in the following paragraphs. After the selected record is
processed, the next record is automatically read from the same file. During the next
program cycle, the new record is compared with the records remaining from the
previous cycle to select the next record.

8600 0544–103 14–31


Input Specifications

During each program cycle, the program selects a record for processing by inspecting
the record in the input buffer of each primary and secondary file. The following rules
apply to multifile processing when matching records are used:

• If the next record from any primary or secondary file has no match fields, that record
is selected.
• If records are in ascending sequence, the record with the lowest match field is
selected. If records are in descending sequence, the record with the highest match
field is selected.
• If more than one record satisfies either of the preceding rules, the record from the
highest-priority file is selected. The primary file has the highest priority, followed by
the secondary files in the order in which they are specified in the File Specifications.
• If the primary file has an E in the End of File field (column 17) in the File
Specifications, but the secondary files do not, any secondary file records that match
the previous primary record are processed before the LR indicator is turned on. Any
interspersed secondary file records without match fields also are processed before
the LR indicator is turned on.
• The MR indicator is turned on during the processing of any record that contains a
match field, provided that the current match field value originally occurred in a record
from the primary file. Otherwise, the MR indicator is turned off.
Example
An example of multifile processing with match fields is shown in Example 14–8. If
records from the primary and secondary files (EMPLYCRD and TIMECDS) have matching
values for EMPLNO and DEPTNO, the MR indicator is turned on, and records from the
primary file are processed first. If the primary file no longer matches, records from the
secondary file that match the previous primary file are processed.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.

00300FEMPLYCRDIP A 96 96 DISK
00400FTIMECDS ISEA 96 96 DISK
00410FPAYROLL O 96 96 PRINTER
00500IEMPLYCRDAA 10 1 CN 2 CA
00600I 3 15 NAME L1
00700I 16 180DEPTNO M2
00800I 19 220EMPLNO M1
00900I 23 292PAYRAT
01000ITIMECDS BB 20 1 CR 2 CC
01100I 3 15 NAME L1
01200I 16 180DEPTNO M2
01300I 19 220EMPLNO M1
01400I 40 462HRSWRK

Example 14–8. Using Match Fields to Process Multiple Files (cont.)

14–32 8600 0544–103


Input Specifications

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.0201
500C MR520 HRSWRK MULT PAYRAT PAY 164
01600C MR 20 TOTPAY ADD PAY TOTPAY 164
01700C MR 20 TOTHRS ADD HRSWRK TOTHRS 82
100OPAYROLL D L1
02200O NAME 15
02300O EMPLNO 25
02400O DEPTNO 30
02500O TOTHRS B 40
02600O TOTPAY B 60

Example 14–8. Using Match Fields to Process Multiple Files

Sequence Checking
Sequence checking of records within a file is performed whenever match fields (M1-M9)
are assigned. This sequence checking is performed with matching records if the primary
file and any secondary files have match fields specified. A maximum of nine fields (M1-
M9) in a record can be used for sequence checking. When a record is encountered that
has match field values out of sequence, a MATCH FIELD SEQUENCE ERROR error
message is displayed (refer to Appendix A, “System Messages”).

The following rules apply when match fields are assigned for sequence checking:

• The contents of the fields designated for sequence checking must be in the same
order, either ascending or descending.
• When more than one field is designated for sequence checking, all fields specified
are combined in order by descending sequence of matching fields (M9–M1) and are
treated as one contiguous field.
• Split sequence fields are not allowed; therefore, the same match field cannot be
used more than once in the record unless field record relation indicators are used.
• Numeric fields are treated as if they had no decimal positions.
• For numeric fields, only the digit portion of each character is compared.
• All sequence fields are considered numeric if any of the fields are numeric.
Example
Example 14–9 shows sequence checking with matching records.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00300FVOTERLSTIP 180 180 TAPE
00500FREPUBLSTO 132 132 PRINTER

Example 14–9. Using Match Records for Sequence Checking (cont.)

8600 0544–103 14–33


Input Specifications

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00510FDEMOCLSTO 132 132 PRINTER
00520FOTHERLSTO 132 132 PRINTER
00600IVOTERLSTNS 01 80 CX
00700I 4 8 STATE M4
00800I 10 15 COUNTY M3
00900I 20 30 CITY M2
01000I 33 35 PRECNT M1
01010I 40 44 PARTY
01020C 01 PARTY COMP 'REPUB' 10
01030C 01 PARTY COMP 'DEMOC' 20
01040C 01 PARTY COMP 'INDEP' 30
01700OREPUBLSTD 10
01800O STATE 8
01900O COUNTY 15
02000O CITY 30
02010O PRECNT 35
02020ODEMOCLSTD 20
02030O STATE 8
02040O COUNTY 15
02050O CITY 30
02060O PRECNT 35
02070OOTHERLSTD 30
02080O STATE 8
02090O COUNTY 15
02100O CITY 30
02110O PRECNT 35

Example 14–9. Using Match Records for Sequence Checking

Field Record Relations (Columns 63–64)


The assignment of a field record relation indicator in these columns permits data to be
made available for processing only if the indicator specified in the field is on. That is, if
the indicator is on, the data are made available just before detail calculations; if the
indicator is off, the field remains in its previous condition.

The following rules apply when field record relation indicators are assigned:

• The field record relation indicator does not need to be the same as any record
identifying indicator specified for the file.
• Fields within a record type that specify the same field record relation indicator can be
entered in any order.
• Split control fields must all have the same entry in the Field Record Relations field.{

14–34 8600 0544–103


Input Specifications

Valid entries in the Field Record Relations field are as follows:

Entry Definition

Blank No field record relation

01–99 Record identifying indicator defined elsewhere

L1–L9 Control level indicator defined elsewhere

MR Matching record (MR) indicator

U1–U8 External indicator

H0–H9 Halt indicator defined elsewhere

Example
Example 14–10 shows the use of field record relation indicators. Fields FIELD2 and
FIELD3 of the current record are available only if indicator 02 is on, and the FIELD6 field
is available only if indicator 03 is on. Fields FIELD4, FIELD5, FIELD7, FIELD8, and FIELD9
are available only if indicator 04 is on.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00300FFILEIN IP 180 180 DISK
00400FFILEOUT O 132 132 PRINTER
00700IFILEIN AA 01 80 CA
00800I 1 51FIELD0L2
00900I 71 752FIELD1L2
01000I 61 64 FIELD2L3 02
01100I 65 70 FIELD3L3 02
01200I 7 12 FIELD4L4 04
01210I 13 22 FIELD5L4 04
01220I 41 514FIELD6 03
01230I 10 13 FIELD7L4 04
01240I 14 20 FIELD8L4 04
01250I 21 25 FIELD9L4 04
01300C 01 FIELD0 COMP FIELD1 020304
01600OFILEOUT D 01
01700O FIELD0 5
01800O FIELD1 75
01900O 02 FIELD2 64
02000O 02 FIELD3 70
02010O 04 FIELD4 12
02020O 04 FIELD5 22
02030O 03 FIELD6 51
02040O 04 FIELD7 13
02050O 04 FIELD8 20
02060O 04 FIELD9 25

Example 14–10. Using Field Record Relation Indicators

8600 0544–103 14–35


Input Specifications

Record Identifying Indicators (01–99)


When several record types have been defined in an OR relationship, all fields defined
apply to all record types. However, in many cases, not all the record types defined have
exactly the same fields. The Field Record Relations field is used to specify that some
fields apply only to certain record types and not to others. If the Field Record Relations
field is blank, the associated field applies to all record types to which it is subordinate.
However, if the same entry found in the Record Identifying Indicator field of one record
type is placed in the Field Record Relations field, the field is identified as applying only to
the corresponding record type.

Control Level (L1–L9) and Matching Record (MR) Indicators


The use of either control level or matching record indicators signifies that the data from
the Field Record Relations field are to be made available only if a control break or
matching record condition has occurred for the designated record.

The following restrictions apply to control level and matching record indicators:

• A control level indicator cannot be used with a field that is part, or all, of a control
group.
• The matching record indicator should not be used with a field that is part, or all, of a
matching record input control group.
To overcome these restrictions, the fields can be defined twice: once to specify the
control fields, matching fields, or both, and again on another specification line with a
different entry in the Field Name field (columns 53–58) to specify the desired field record
relation.

External Indicators (U1–U8)


Using an external indicator to show a field record relationship indicates that the data are
to be made available only when the given external indicator is on.

Halt Indicators (H0–H9)


The halt indicators specify that the data are to be made available only when the given halt
indicator is on. A halt indicator usually is used when a record is specified with the halt
indicator in the Record Identifying Indicator field (columns 19–20) to signal the reason for
or conditions of the halt operation.

When two or more control fields, or two or more match fields, have the same control
level indicator or match field indicator, respectively, one of these sets of fields cannot
have a field record relation indicator assigned. If a split control field is specified, this
restriction applies to the group of specifications that forms the split control field. Thus,
specifications with field record relation indicators are used if that indicator is on. When
field record relation indicators are on, the specification without any field record relation
indicator is used.

14–36 8600 0544–103


Input Specifications

Field Indicators (Columns 65–70)


This field is composed of three subfields that enable the data of the input field to be
tested as follows:
• If the input field is numeric, it is tested for a plus (positive), minus (negative), or zero
condition.
• If the input field is alphanumeric, it is tested for a greater-than-blank, less-than-blank,
or equal-to-blank condition, according to the specified collating sequence.
These field indicators are assigned after overflow output to reflect the values of the fields
being tested.
Valid entries for the Field Indicators field are as follows:
Entry Definition

Blank No field indicators are used.

01–99 A field indicator is used.

H0–H9 A halt indicator is used.

The Field Indicators field is subdivided as follows:

Colum Name Description


n

65–66 Plus Any valid indicator specified in this field is turned on if the
corresponding data field is greater than 0 (for a numeric field)
or greater than blank (for an alphanumeric field).
67–68 Minus Any valid indicator specified in this field is turned on if the
corresponding data field is less than 0 (for a numeric field) or
less than blank (for an alphanumeric field).
69–70 Zero or Any valid indicator specified in this field is turned on if the
blank corresponding data field is 0 (for a numeric field) or blank (for
an alphanumeric field).

The following rules must be observed when field indicators are assigned and used:

• If the Zero/Blank Indicator Setting field (column 42) in the Control Specification is
blank, all field indicators are off at the beginning of the program and remain off until
the condition being tested is satisfied by the input record just read.
If the Zero/Blank Indicator Setting field contains an S, the indicators 01 through 99,
which are used as zero/blank indicators, are turned on at the beginning of the
program execution (unless the indicators are also used as record identifying
indicators). All other field indicators are off at the beginning of the program. Field
indicators are turned on if the condition being tested is satisfied by the input record
just read. In the case of zero/blank indicators that might have been turned on during
the previous output cycle, if the condition being tested is not satisfied, then the
indicator is turned off.
• A field can be assigned more than one field indicator; however, only the indicator
specified for the condition with a TRUE result is turned on. All other indicators
assigned to the field are turned off.

8600 0544–103 14–37


Input Specifications

• The state of a field indicator assigned to fields in different record types is determined
by the last record selected.
• The state of a field indicator assigned to more than one field within a record type is
determined by the last field to which the indicator is assigned.
• If a field indicator is not used elsewhere in the program, it remains on (or off) until
another record of the same type is selected.
• Indicators specified in the Field Indicators field can be altered by using them as
resulting indicators in the Resulting Indicators field (columns 54–59) in the Calculation
Specifications.
• If a halt indicator specified in the Field Indicators field is turned on as a result of the
corresponding condition being TRUE, the program halts after the input record that
caused the halt indicator to turn on has been completely processed.
• Field indicators cannot be assigned to whole arrays.

Program Identification (Columns 75–80)


The Program Identification field is not used by the compiler but appears on the source
program listing so that the field can be used to document different portions of the
program.

Header-Trailer or Spread-Record Specifications


A header-trailer, or spread-record, enables an individual record to be processed as if it
were actually several records. The record is composed of a portion of data that is
common to the entire record (the header) and is followed by one or more occurrences of
the remaining fields of the record (the trailer). The header is used with each occurrence
of the trailer.

Specifications of Data Records


Following are two ways to specify data records with a header (which can be optional) and
multiples of identical trailers:

• Define each field in the record with unique field names, such as ITEMA, ITEMB,
ITEMC, and ITEMD. Assuming that each ITEM field is the same length and data
format, the program then handles each individual field in one program cycle.
• Define the control fields, called the header, followed by the entry TR in columns 19
through 20 of the Input Specifications, and the first set of ITEM fields, called the
trailer. This method of specifying data records enables the compiler to assume that
the columns to the right of the record contain more sets of ITEM fields with the
same length and format. One trailer after another is processed, with one program
cycle for each trailer, until the end of the record or a trailer containing all blanks is
reached. Each trailer is processed with the header as one logical record.

14–38 8600 0544–103


Input Specifications

Header-Trailer Definition Requirements and Restrictions


The following must be observed when Header-Trailer Specifications are defined:

• The file must be defined as either input primary or input secondary.


• The record must be designed so that the record header precedes the record trailers.
• The header portion of the record must be specified on the Input Specifications lines
that immediately precede a line containing the entry TR in columns 19 through 20.
• A line in columns 19 through 20 containing the entry TR must precede the
specifications for the trailers.
• Columns 7 through 18 and 21 through 74 of the TR Input Specifications line must be
blank.
• A TR Input Specifications line can follow a record description entry without an
intervening header.
• Valid entries must be made in the FROM and TO fields for header and trailer field
specifications.
• Columns 7 through 42, 55 through 62, and 71 through 74 of the trailer field
specifications must be blank.
• Trailers cannot be extended onto the following data record.
• Field record relation indicators and field indicators are allowed for trailer field
specifications.
• Look-ahead fields must not be specified.
Example
Example 14–11 shows header and trailer specification coding.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00100F*
00200F* This program demonstrates the header-trailer, or spread
00300F* record, feature.
00400F*
00500F* The program reads a file of customer orders and prints them.
00600F*
00700F* The input file named SPREAD uses header-trailer formatting
00800F* for its input records. Each record has a customer number
00900F* in byte positions 1 through 5, and has between 1 and 4 order
01000F* descriptions following it on the same record. Here the
01100F* CUSTNO field is in the header portion of the input records,
01200F* and ITMNO, SIZE, and QTY are in the trailer portion.
01400F*
01500F* One program cycle is executed for each trailer portion of a
01600F* record, so that between 1 and 4 cycles are executed for each
01700F* input record.
01800F*
01900FSPREAD IP 80 80 DISK

Example 14–11. Using Header-Trailer Specifications (cont.)

8600 0544–103 14–39


Input Specifications

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
02000FPRINT O 120 120 DISK
02100I*
02200ISPREAD AA 01
02300I 1 50CUSTNO
02400I TR
02500I 6 130ITMNO
02600I 14 150SIZE
02700I 16 210QTY
02800O*
02900OPRINT H 1P
03000O 'CUSTOMER NUMBER '
03100O 'ITEM NUMBER '
03200O 'SIZE '
03300O 'QUANTITY '
03400O H 1P
03500O '--------------- '
03600O '----------- '
03700O '---- '
03800O '---------- '
03900O D 01
04000O CUSTNOX 15
04100O ITMNO X 29
04200O SIZE X 40
04300O QTY 1 62

Example 14–11. Using Header-Trailer Specifications

Data Structures
A data structure is an area in memory composed of one or more fields called subfields.
Ordinarily every field and array, whether defined on the Input Specifications or Calculation
Specifications, is assigned its own unique location in memory these fields do not overlap.
The Input Specifications that overlaps redefines locations in the buffer for the input file,
not in the storage location for variables.

A data structure can be used to define an area of memory in several ways and to
reorganize fields for easier reference. One data structure within a program can be
designated as a local data area for the program. Additional information on this type of
data structure is provided within this section. A data structure can also be used to
subdivide an input field into subfields that can be referred to in the program.

A data structure is coded on the Input Specifications. This is done because a data
structure maps an area in memory in a manner very similar to the way the Input
Specifications for a file map the input buffer. However, data structures do not specify
input.

Data structures must be the last entries on the Input Specifications, following all Input
Specifications for files. A data structure entry is specified in two parts: the data structure
name description and the data structure subfield description.

14–40 8600 0544–103


Input Specifications

Data Structure Name Descriptions


Fields for data structure name descriptions are discussed in Table 14–2.

Table 14–2. Fields for Data Structure Name Descriptions

Columns Name Description

7–12 Data Structure Contains blanks or the name of the data structure.
Name Note that unlike the Input Specifications for files, the
name can be only 6 characters long. The following
conditions apply to the data structure name:
• Must meet the requirements of a field name.
• Can be a name previously referred to in the Field
Name field (columns 53–58) of the Input
Specifications.
• Can be a name previously referred to in the
Variable Name field (columns 66–77) of the
Attribute Specifications.
18 Option Must have a U if the data structure is the local data
area for a terminal; otherwise, it is blank. Refer to the
discussion of the data structure for a local data area
later in this section.
19–20 Record Contains the letters DS.
Identifying
Indicator
21–70 Must be blank.

8600 0544–103 14–41


Input Specifications

Data Structure Subfield Descriptions


Table 14–3 describes field definitions for data structure subfields.

Table 14–3. Fields for Data Structure Subfield Descriptions

Columns Name Description

7–42 Must be blank for subfield descriptions.


43 Packed Contains the format of a subfield within the data
structure. Any entry allowed on the Input
Specifications for fields of files is also allowed for
subfields.
44–47 From Field Contains the 1-relative byte position where the
Location subfield begins. This position is relative to the
beginning of the data structure.
48–51 To Field Contains the 1-relative byte position where the
Location subfield ends. This position is relative to the beginning
of the data structure.
52 Decimal Contains the number of decimal positions for a
Positions numeric subfield. This field is blank for an
alphanumeric subfield. This field contains a D for
COMS–designator subfields and contains a T for
COMS–time subfields. Refer to Volume 2 of this
manual for information about COMS coding.
53–58 Field Name Indicates the subfield name.
59–70 Must be blank.

Following are the rules for subfield names:

• Subfield names must be unique within data structures, but the same names can be
repeated in the From, To, Packed, and Decimal Positions fields to enable the user to
repeat fields in varying forms of output.
• The same subfield name cannot be used in more than one data structure.
• A data structure name cannot be used as a subfield name.
• A subfield name can be an array name, but not a table name. The array named is
allocated at the specified location in the data structure. The correct number of bytes
must be designated to accommodate the array as declared in the Extension
Specifications. Note that the Packed field (column 43) can be used to specify the way
in which numeric array elements are to be stored.
Field record relation indicators, control level indicators, match field values, and field
indicators are not allowed in the data structure subfields.

14–42 8600 0544–103


Input Specifications

Coding of Data Structures


The following rules apply to data structures:

• A data structure is alphanumeric and is initialized to blanks, except for subfields that
are names of compile-time arrays, preexecution-time arrays, or the local data area for
a terminal. The initial value for numeric subfields in display format is 0 (zero); the
value is blank for Packed fields (column 43). For any other numeric format, the initial
value is unpredictable.
• A data structure name can be specified anywhere an alphanumeric field name is
allowed.
• Subfields can be referred to as ordinary variables.
• The maximum length for a data structure is 9999 characters, except for the local data
area, which has a maximum of 512 characters.
• The maximum length for an alphanumeric subfield is 9999 characters. A numeric
subfield has a maximum length of 23 digits.
• An array can be specified as a subfield; however, the length of the subfield must be
the entire length of the array. A table name or an array element cannot be used as a
subfield name.
• When a field appears as a data structure or a subfield, the entire data structure or the
specified location within a data structure is the space reserved for the field.
• A look-ahead field cannot be used as a data structure name or a subfield.
A data structure name must not be the same as any of the following names:
− Another data structure name in the program
− Array name
− Look-ahead field name
− Output group name
− Table name
− Subfield name
• A subfield name must not be the same as any of the following names:
− Array element name
− Data structure name
− Look-ahead field name
− Output group name
− Table name

8600 0544–103 14–43


Input Specifications

Example
Example 14–12 shows that subfields can be defined to overlap. In this program example,
the subfield NAME is 60 characters long in positions 1 through 60. The subfield is
redefined in the following two ways:

• The subfield is subdivided into the three subfields FNAME (first name), MNAME
(middle name), and LNAME (last name).
• The entire subfield is redefined by the array N (name). This redefinition is useful
because it enables individual characters of the name to be accessed. For example,
N,5 is the fifth character of NAME. In addition, the array N can be used in the LOKUP
operation code. For example, N can be used to find the first blank character in
NAME, or in any of the subfields NAME, FNAME, MNAME, or LNAME.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
01000E N 60 1
02000I DS
03000I 1 60 NAME
04000I 1 20 FNAME
05000I 21 40 MNAME
06000I 41 60 LNAME
07000I 1 60 N

Example 14–12. Defining Subfields to Overlap

Example
Example 14–13 shows the use of repeating subfields for a sporting event and a concert.

The data structure defined is named EVENT. There are two formats for EVENT. The
format used with sporting events has subfields for the event number, date, time, price,
the names of both teams, and the stadium where the game is to be played. The format
used with a concert has subfields for the event number, date, time, price, the name of
the band, and the name of the concert hall at which the performance is to occur.

Note that both formats have subfields for event number, date, time, and price, that the
definition is repeated for each, and the definitions are identical each time they are
repeated.

Note also that the subfield PRICE has a J in column 43. PRICE is to be stored in unsigned
packed format.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
02000I*
04000I* Definition of a data structure named EVENT:
06000I*
18800IEVENT DS
18900I*

Example 14–13. Using a Data Structure Format with Repeating Subfields


(cont,)

14–44 8600 0544–103


Input Specifications

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
19000I* The EVENT data structure can have several formats, depending on
19100I* the event type (E-TYPE), which will be S for sporting event and
19200I* C for concert:
19300I*
19800I 1 1 E-TYPE
19850I*
19900I* Layout of EVENT data structure for a sports event:
19950I*
20000I 2 70EVENTNO
20050I 8 130E-DATE
20100I 14 190E-TIME
20150I J 21 232PRICE
20200I 31 50 TEAM1
20400I 51 70 TEAM2
20600I 71 90 STADM
22000I*
24000I* Layout of EVENT data structure for a concert:
26000I*
28000I 2 70EVENTNO
30000I 8 130E-DATE
32000I 14 190E-TIME
34000I J 21 232PRICE
36000I 31 50 BAND
38000I 51 70 HALL

Example 14–13. Using a Data Structure Format with Repeating Subfields

8600 0544–103 14–45


Input Specifications

Description of the Data Structure for a Local Data Area


One data structure can be designated as the local data area for the program. The local
data area is used to obtain data at the start of program execution. Coding is similar to any
data structure, except that a U must be entered in the Option field (column 18) of the
field definition.

Example
An example of a data structure for a local data area is shown in Example 14–14. LOCAL
is a data structure with one 80-byte alphanumeric field called TEXT. The data structure
LOCAL is the local data area for the program.

When the program is started, the TASKSTRING task attribute is placed into the local data
area. This value can then be referred to with the use of the data structure designated by
the program to be the local data area. In the example of coding for a local data area data
structure, either TEXT or LOCAL can be used.

For instance, the following CANDE command places the alphanumeric value MONDAY at
the beginning of TEXT, with the rest of the local data area, LOCAL, containing blanks:

RUN TEST/RPG/LOCALDS; TASKSTRING = "MONDAY"

Because TASKSTRING is a read-only attribute, the value of the local data area is not
written back to TASKSTRING when the program ends.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
01000I*
02000ILOCAL UDS
03000I 1 80 TEXT

Example 14–14. Coding a Data Structure for a Local Data Area

14–46 8600 0544–103


Section 15
Calculation Specifications

The Calculation Specifications indicate the sequence and timing of the following two
types of data manipulation:

• Arithmetic, logical, and manipulative operations on defined data elements (fields)


• I/O control of certain files
These specifications describe the operations to be performed on the data and specify the
order in which the operations are to be performed. Calculation Specifications are optional;
however, if they appear in a program, they must appear in the following sequence:

• Detail calculations
• Total calculations
• Subroutines
Note: Subroutines cannot be the only Calculation Specifications entries because
subroutines can be accessed only from detail or total calculations; however, all three
types of Calculation Specifications need not occur.

Calculations Specifications Coding Form and


Summary
The coding form for the Calculation Specifications is illustrated in Figure 15–1.

Figure 15–1. Calculation Specifications Coding Form

8600 0544–103 15–1


Calculation Specifications

Each specification line describes one operation and has three functional parts:

• Conditions under which the operation is to be performed (columns 7–17)


• Type of operation and data on which the operation is to be performed
(columns 18–53)
• Tests for the results of the operation (columns 54–59)
Table 15–1 summarizes the field definitions for the Calculation Specifications form.

Table 15–1. Field Definitions Summary (Calculation Specifications)

Columns Description

1–5 Identifies the program sequence numbers unless the $UNSEQ compiler
control option is TRUE.
6 Identifies the type of specification for each line of code. This field must be
coded with the letter C.
7 Contains an asterisk (*) if the line is a comment.
7–8 Contains one of the control level indicators, an indication of a subroutine, or
an indication of an AND and OR relationship. Acceptable entries are L0
through L9, LR, SR, AN, OR, or blanks.
9–17 Contains indicators divided as follows:
• Columns 9, 12, and 15 are Not subfields that designate that the
associated indicator is to be off. Acceptable entries are N or blank.
• Columns 10 through 11, 13 through 14, and 16 through 17 can contain
indicators to condition a calculation operation. Acceptable entries are 01
through 99, L0 through L9, LR, MR, H0 through H9, U1 through U8, OA
through OG, OV, or blank.
18–27 Contains a field name, a special word, an alphanumeric or numeric literal, a
subroutine name, a label, a vector name, a vector element, or blank. The
entry must be left-justified.
28–32 Names the type of operation to be performed. Acceptable entries are listed
at the beginning of Section 16, “Operation Codes.” The entry must be left-
justified.
33–42 Contains a field name, a special word, an alphanumeric or numeric literal, a
subroutine name, a vector name, a vector element, a label, a file name, or
blank. The entry must be left-justified.
43–48 Identifies the name of the field, vector, or vector element that is used to
store the results of the operation. The entry must be left-justified.
49–51 Designates the length of the Result Field. Acceptable entries are 1 through
999 or blank. The entry must be right-justified.
52 Designates the number of decimal positions. If this field is blank, the entry is
alphanumeric. Acceptable entries are blank, D, T, or the numbers 0 through
9. COMS entries (D and T) are described in Volume 2 of this manual.

15–2 8600 0544–103


Calculation Specifications

Table 15–1. Field Definitions Summary (Calculation Specifications)

Columns Description

53 Defines whether or not the contents of the Result Field (columns 43–48) are
to be rounded. Acceptable entries are blank or H.
54–55 Specifies an indicator that turns on if one of the following conditions is true:
the Result Field (columns 43–48) is positive, Factor 1 (columns 18--27) is the
highest in a compare or LOKUP operation, or a tested zone (TESTZ
operation) is a plus zone. Acceptable entries are 01 through 99, L1 through
L9, LR, H0 through H9, OA through OG, OV, or blank.
56–57 Specifies an indicator that turns on if one of the following conditions is true:
the Result Field (columns 43–48) is negative, Factor 1 (columns 18--27) is
the lowest in a compare or LOKUP operation, or a tested zone (TESTZ
operation) is a minus zone. Acceptable entries are 01 through 99, L1 through
L9, LR, H0 through H9, OA through OG, OV, or blank.
58–59 Specifies an indicator that turns on if one of the following conditions is true:
the Result Field (columns 43–48) is 0 (zero) or blank, Factor 1 (columns 18--
27) is equal to Factor 2 (columns 33–42) in a compare or LOKUP operation,
or a tested zone (TESTZ operation) is neither a plus nor minus zone.
Acceptable entries are 01 through 99, L1 through L9, LR, H0 through H9,
OA through OG, OV, or blank.
60–74 Contains comments and documentary remarks.
75–80 Contains the program identification. Any entry is valid.

For information about data management and COMS Calculation Specifications, refer to
Volume 2 of this manual.

An entry in a column that is not part of any of the defined fields in a specification might
cause a warning message to be displayed.

8600 0544–103 15–3


Calculation Specifications

Field Definitions
The fields for the Calculation Specifications form are defined in the following paragraphs.

Sequence Number (Columns 1–5)


The Sequence Number field contains a 5-digit sequence number (00000–99999) for the
RPG source program unless the $UNSEQ compiler control option is TRUE. Refer to
Section 21, “Control of the Compilation Process,” for information about the $UNSEQ
option.

Form Type (Column 6)


The Form Type field identifies the type of specification for each line of code. This field
must contain the letter C.

Comment (Column 7)
Explanatory statements can appear in the source if column 7 contains an asterisk (*). The
Comment entry enables the entire line to the right of the asterisk to appear as program
documentation on the program listing. Comments are not instructions to the RPG
program or compiler, but serve as program documentation. Any valid character can be
used in a comment line. An asterisk in column 7 overrides an entry in column 6.

Example
Example 15–1 shows comment line coding.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00105C*
00110C* This is an example of how comment lines are coded. All
00120C* lines with an asterisk in column 7 are ignored by compiler.
00140C*

Example 15–1. Coding a Calculation Specifications Comment Line

15–4 8600 0544–103


Calculation Specifications

Control Level (Columns 7–8)


This field is used to do the following:

• Specify total calculations when an appropriate control break occurs.


• Designate calculations to be performed after the last record is read.
• Indicate that a calculation is part of a subroutine.
• Specify an AND or OR relationship for particular indicators.
The valid entries for the Control Level field are as follows:

Entry Definition

Blank The calculation operation is either part of detail calculations or part of a


subroutine.

L0–L9 The calculation operation is performed during total calculations only if the
designated control level indicator is on. L0 is always on.

LR The calculation operation is performed if the last record (LR) indicator is on.

SR The calculation operation is part of a subroutine.

AN, OR The calculation operation has AND or OR relationships among lines of


indicators.

An entry of either L0 through L9 or LR indicates that the operation is performed during


total calculations when the specified control level indicator is on. The first entry of L0
through L9 or LR in columns 7 and 8 determines the start of total calculations. All detail
calculations (if specified) must precede any total calculations. Operations that have
blanks in columns 7 and 8 and that occur before any total calculations or a BEGSR
operation are treated as detail calculations. These operations are performed during detail
calculations, depending on the conditions specified in columns 9 through 17.

L0 through L9
A control level indicator specified on the Input Specifications can be used to condition
operations that are to occur at a control break. The operation described on this
specification line of the Calculation Specifications is performed only when the designated
indicator is on. Information about the time when control level indicators can be turned on
is provided in the discussion of control level indicators in Section 14, “Input
Specifications.” Control level indicators need not be specified in a particular order.
Operations are executed in the order in which the operations are specified.

The L0 indicator is turned on after detail output during every cycle of the program. If no
other control level indicator is assigned, but total calculations are desired, the L0 indicator
can be used to condition those operations.

8600 0544–103 15–5


Calculation Specifications

Example
The L0 indicator is used to condition the total calculation because total calculations are
desired and the program has no control level indicators assigned on the Input
Specifications.

Example 15–2 shows L0 indicator coding.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
01000F*
02000FFILEIN IP 80 80 DISK
03000FFILEOUT O 132 132 PRINTER
04000I*
05000IFILEIN AA 01
06000I 5 132WAGE1
07000I BB 02
08000I 5 132WAGE2
09000C*
10000C 01 WAGE1 ADD TOTWAG TOTWAG 102
11000C 02 WAGE2 ADD TOTWAG TOTWAG 102
12000CL0 01 02 TOTWAG ADD TOTAL TOTAL 122
13000CLR TOTWAG ADD TOTAL TOTAL
14000O*
15000OFILEOUT T 1 L0
16000O TOTWAGJ 20

Example 15–2. Coding an L0 Indicator

LR
The LR indicator is used to condition operations to be performed at EOF. This indicator is
automatically turned on when the last record has been read and processed. Control level
indicators L1 through L9 are also turned on. The LR indicator can also be turned on if it is
specified as a resulting indicator of a Calculation Specification. A calculation operation
that turns on the LR indicator does not cause the other control level indicators to be
turned on.

SR
The subroutine (SR) entry is not an indicator; rather, it is used to indicate that the
specification on a particular line is part of a subroutine. Subroutines must be specified
after all detail and total calculation lines are specified. A subroutine specification line can
contain SR, OR, AN, or blanks in columns 7 through 8. The first BEGSR operation
determines the start of subroutines.

15–6 8600 0544–103


Calculation Specifications

AND, OR (AND and OR Lines)


The Control Level field is also used to specify that calculation lines have the Indicators
field (columns 9–17) in an AND or OR relationship. AN is the mnemonic identified in this
field to refer to the AND relationship among lines of indicators for calculation operations.
Any number of AND or OR lines can be specified for each operation. The last line of a
group in an AND or OR relationship contains the operation code and all operands. All
previous lines in the group must contain blanks in columns 18 through 59. If a control
level indicator conditions an entire group, the first line of that group must contain a
control level indicator or LR. If the group is part of a subroutine, the first line can contain
an SR entry. Each AND and OR line and the previous line must contain at least one
indicator in columns 9 through 17.
Example
Example 15–3 shows the relationship of AND and OR.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
01000F*
02000FFILEIN IP 80 80 DISK
03000FFILEOUT O 132 132 PRINTER
04000I*
05000IFILEIN AA 02 1 CA
06000I 5 132WAGE
07000I 2 42AMT1
08000I BB 03 1 CB
09000I 15 232WAGE
10000I 2 42AMT2
11000I CC 04 1 CC
12000I 25 332WAGE
13000I 2 42AMT3
14000C*
15000C 02 WAGE COMP AMT2 050603
16000C 03 WAGE COMP AMT3 050604
17000C 04 WAGE COMP AMT1 050602
18000C 02 03 04
19000C*
20000C* Example of OR coding
21000C*
22000COR 02 03
23000COR 02 04
24000COR 03 04
25000C*
26000C* Example of AND coding
27000C*
28000CANN05N06 WAGE ADD TOTAL TOTAL 122
29000O*
30000OFILEOUT T 1 LR
31000O TOTAL J 20

Example 15–3. Coding AND and OR Relationships

8600 0544–103 15–7


Calculation Specifications

Indicators (Columns 9–17)


This field consists of three subfields so that up to three indicators on each line can be
specified in an AND relationship to condition a calculation operation.

Each subfield is divided into the following two parts:

• Not (columns 9, 12, and 15)


• Indicator (columns 10–11, 13–14, and 16--17)
The Not subfields determine that the associated indicator must be off if the operation is
to occur. If this condition is desired, an N must be entered in the Not subfield; otherwise,
this subfield must be blank.

The Indicator subfields designate the indicator to be tested. If the immediately preceding
Not subfield is blank, the indicator is tested to determine if it is on. If the subfield
contains an N, the indicator is tested to determine if it is off.

Only the following entries are allowed in the Indicator subfield:

Entry Definition

Blank The operation is not conditioned by any indicators. In this case, the Not
subfield must also be blank.

01–99 The operation is conditioned by a numeric indicator defined elsewhere in the


program.

L0–L9 The operation is conditioned by a control level indicator defined in the Input
or Calculation Specifications.

LR The operation is conditioned by the last record (LR) indicator.

MR The operation is conditioned by the matching record (MR) indicator.

H0–H9 The operation is conditioned by a halt indicator defined elsewhere in the


program.

U1–U8 The operation is conditioned by an external indicator.

OA–OG, The operation is conditioned by an overflow indicator defined in the File


OV Specifications.

All the indicators specified on one line are in an AND relationship. These indicator
conditions, plus any others associated in an AND relationship (AN in columns 7–8), must
be satisfied if the operation is to be performed. Each of the indicators is discussed in the
following paragraphs.

15–8 8600 0544–103


Calculation Specifications

Numeric Indicators (01–99)


The indicators 01 through 99 do the following:

• Condition calculation operations to be performed only for specific input record types
if the indicator was designated in the Record Identifying Indicators field
(columns 19–20) in the Input Specifications
• Condition calculation operations to be performed only when an input field meets
certain conditions if the indicator was identified in the Field Indicators field
(columns 65–70) in the Input Specifications
• Condition calculation operations according to the results of previous operations if the
indicator was specified in the Resulting Indicators field (columns 54–59) in the
Calculation Specifications

Control Level Indicators (L0–L9)


The control level indicators are normally defined in the Control Level field
(columns 59–60) of the Input Specifications; however, these indicators can also be used
as in the Resulting Indicators field (columns 54–59) in the Calculation Specifications. For
either usage, the control level indicators entered in columns 9 through 17 signify an
operation to be performed only on the first cycle after a control break.

The following conditions apply when control level indicators are used in the Indicators
field:

• An operation to be performed during detail calculations occurs only while the first
record of the new control group is being processed.
• An operation to be performed during total calculations occurs when both the control
break specified in columns 7 through 8 and the control break specified in the
Indicators field are satisfied. Both control breaks can be satisfied when the last
record of a control group has been processed.
• An operation that is part of a subroutine and that is called from detail calculations
occurs only while the first record of the new control group is being processed.
• An operation that is part of a subroutine and that is called from total calculations
occurs only if the EXSR operation is at an equal or higher control level.

Last Record (LR) Indicator


The LR indicator is used to condition operations performed after the last record has been
processed.

8600 0544–103 15–9


Calculation Specifications

Matching Record (MR) Indicator


The MR indicator is used to condition operations performed when records match.

During detail calculations or a subroutine called from detail calculations, the MR indicator
refers to the status of the match fields of the record last selected.

During total calculations or a subroutine called from total calculations, the MR indicator
refers to the status of the match fields for the record before the record last selected.

Halt Indicators (H0–H9)


Halt indicators assigned in either the Record Identifying Indicator field (columns 19–20) in
the Input Specifications or the Resulting Indicators field (columns 54–59) in the
Calculation Specifications can be used to condition operations only when an error
condition occurs.

Because the program does not halt until the record in error has completely processed,
action must be taken to prevent reporting of erroneous results. The halt indicators can be
used with an N in the Not subfields of the Indicators field to inhibit an operation when the
specified halt indicator is on.

External Indicators (U1–U8)


External indicators can be used when the specified indicator is on at program execution
time. A complete description of external indicators is provided in the discussion of the
File Condition field in Section 8, “File Description Specifications.”

Overflow Indicators (OA–OG, OV)


Overflow indicators that have been previously assigned in the File Specifications can be
used when the overflow area of a printer file has been reached.

15–10 8600 0544–103


Calculation Specifications

Factor 1 (Columns 18–27)


This field supplies the data to be used as an operand by the operation identified in the
Operation field (columns 28–32).

Valid entries for the Factor 1 field are

• The name of any field defined elsewhere in the program


• A literal (alphanumeric or numeric)
• The name of a subroutine
• A vector name or a vector element
• The special words JDATE, UDATE, UDAY, UDAYNM, UMONTH, UTIME, UYEAR,
and PAGE through PAGEn
• A label
• A figurative constant
Entries in this field must be left-justified.

Operation (Columns 28–32)


This field specifies the operation code for the operation to be performed using Factor 1
(columns 18–27) and Factor 2 (columns 33–42). The operation code must be left-justified
in the field.

The program performs operations in the order in which they appear in the Calculation
Specifications; however, all operations conditioned by control level indicators designated
in the Control Level field (columns 7–8) must appear after operations not conditioned by
control level indicators and before all subroutines.

8600 0544–103 15–11


Calculation Specifications

Factor 2 (Columns 33–42)


This field supplies the data to be used as an operand by the operation specified in the
Operation field (columns 28–32).

Valid entries for the Factor 2 field are

• The name of any field defined elsewhere in the program


• A literal (alphanumeric or numeric)
• The name of a subroutine (EXSR operation only)
• A vector name or an element of a vector
• The special words JDATE, UDATE, UDAY, UDAYNM, UMONTH, UTIME, UYEAR,
and PAGE through PAGEn
• A label (GOTO operation only)
• A file name (CHAIN, CLOSE, DEBUG, DELET, DUMP, DSPLY, EXCPT, FORCE,
READ, READE, READP, RECV, SEND, or SETLL operation only)
Entries in the field must be left-justified.

Result Field (Columns 43–48)


This field names the field, vector, or vector element to be used to store the results of the
operation specified on this line.

All entries in the Result Field must be left-justified. Special words, except those in the
following list, can also be entered here.

The following items must not be used in the Result Field:

• Literals
• JDATE
• UDATE
• UMONTH
• UDAY
• UYEAR
• UTIME
• UDAYNM
A new field can be defined by entering the new field name as the Result Field, along with
the Field Length (columns 49–51) and Decimal Positions (column 52) field entries. A
complete description of field names is provided in Section 2, “RPG Language Elements.”

15–12 8600 0544–103


Calculation Specifications

Field Length (Columns 49–51)


This field defines the length of a Result Field (columns 43–48) that has not previously
been defined. The use of this field is optional.

If this field is blank, the field length must be defined elsewhere in the program (in the
Input or Extension Specifications or on a different line in the Calculation Specifications).
This field must be blank if the Result Field (columns 43–48) is blank.

The length of a field, vector, or vector element that has been previously defined can be
entered in this field; however, the length and number of decimal positions specified must
be the same as those previously defined.

Entries in this field must be numeric and right-justified; leading zeros can be omitted.

Decimal Positions (Column 52)


This field defines the number of positions to the right of the implied decimal point of a
value in a Result Field.

If the Result Field (columns 43–48) is either alphanumeric or blank, or if the Field Length
field (columns 49–51) is blank, this field must be blank.

If the Result Field is numeric and the Field Length field is specified, the Decimal Positions
field must contain an entry in the range 0 through 9; however, if a numeric vector or
vector element is assigned as the Result Field and the Field Length field is specified, the
Decimal Positions field can contain an entry or can be blank. If an entry is made, it must
agree with any previous entry specified for the field.

Valid entries for the Decimal Positions field are as follows:

Entry Definition

Blank Alphanumeric or blank field


0–9 Number of decimal positions in a numeric field

D COMS-designator subfields (Refer to Volume 2 of this manual.)

T COMS-time subfields (Refer to Volume 2 of this manual.)

The number of decimal positions specified must not exceed the length of the Result
Field. If the Result Field contains only integer values, the value of the Decimal Positions
field must be 0 to indicate that the Result field is numeric with no implied decimal
positions.

8600 0544–103 15–13


Calculation Specifications

Half Adjust (Column 53)


This field indicates whether or not the contents of the Result Field (columns 43–48) are
to be rounded. Rounding is accomplished by selecting the digit to the right of the least
significant decimal digit of the Result Field and either adding 5 to positive values or
subtracting 5 from negative values. All digits to the right of the last decimal position are
then dropped. Entries in this field are allowed for all arithmetic operations except MVR
and SQRT.

Valid entries for the Half Adjust field are as follows:

Entry Definition

Blank Do not half adjust.

H Half adjust.

Resulting Indicators (Columns 54–59)


This field can be used in the following ways:

• To test the value of the Result Field (columns 43–48)


• To name the indicators turned on or off by the SETON and SETOF operations
The resulting indicators are turned off before an operation is performed. After the
operation is performed, these indicators are set to indicate the result.

Three fields (columns 54–55, 56–57, and 58–59) can be used to test for different
conditions at the same time.

Valid entries for the Resulting Indicators field are as follows:

Entry Definition

Blank No resulting indicators

01–99 Numeric indicator

L0–L9 Control level indicator

LR Last record (LR) indicator

H0–H9 Halt indicator

OA– Overflow indicator previously defined in the File Specifications


OG, OV

15–14 8600 0544–103


Calculation Specifications

The resulting indicator turns on if the Result Field contains the appropriate result. The
Result Field can contain the result of an arithmetic operation or the results of one of the
following operation codes:

• CAS
• CHAIN
• COMP
• LOKUP
• READ
• READE
• READP
• TESTB
• TESTZ
Resulting indicators must not be specified when the Result Field (columns 43–48) is an
unsubscripted array name.
A discussion of operation codes and indicators is provided in Section 16, “Operation
Codes.” When a control level indicator is used as a resulting indicator, lower control level
indicators are not turned on.
Example
Example 15–4 shows the use of resulting indicators.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00100F*
00200FFILEIN IP 80 80 DISK
00300FFILE1 IT 80 80 DISK
00400FFILE2 ID 80 80 DISK
00500FDISKIN IC 180 180 4AI DISK
00600FFILEOUT O 132 132 PRINTER
00700E*
00800E FILE1 TABLES 3 100 6 0
00900I*
01000IFILEIN AA 01
01200I 5 100FIELD1
01300I 15 200FIELD2
01400I 25 300FIELD3
01500I 32 350KEY
01600I 40 40 ALPHA
01700IFILE2 AA 02
01800I 1 1 DUMMY1
01900IDISKIN AA 03
02000I 1 1 DUMMY2

Example 15–4. Coding Resulting Indicators (cont.)

8600 0544–103 15–15


Calculation Specifications

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
02100C*
02200C* Arithmetic operation:
02300C*
02400C 01 FIELD2 SUB FIELD1 FIELD3 22
02500C*
02600C* Compare operation:
02700C*
02800C FIELD2 COMP 124 234567
02900C*
03000C* Lookup operation:
03100C*
03200C FIELD3 LOKUPTABLES 89
03300C*
03400C* Chain operation:
03500C*
03600C KEY CHAINDISKIN 99
03700C*
03800C* Indicator operation:
03900C*
04100C SETON 5152
04200C SETOF 535155
04300C*
04400C* Read operation:
04500C READ FILE2 H8
04600C*
04700C* Test zone operation:
04800C*
04900C TESTZ ALPHA 010203
05000O*
05100OFILEOUT D 1 01
05200O FIELD1 10
05300O FIELD2 20
05400O FIELD3 30

Example 15–4. Coding Resulting Indicators

Comments (Columns 60–74)


This field is used for comments and documentary remarks.

Program Identification (Columns 75–80)


The Program Identification field is not used by the compiler but appears on the source
program listing so that the field can be used to document different portions of the
program.

15–16 8600 0544–103


Section 16
Operation Codes

RPG provides various categories of operation codes to enable data manipulation.


Operation codes are entered only in the Operation field (columns 28–32) in the
Calculation Specifications. The codes specify the type of arithmetic, logical, or I/O
operation to be performed on the associated operands.

Organization of Operation Codes


The information presented in this section is organized by groups of operation codes that
perform a similar function.

Table 16–1 outlines the organization of operation code definitions in this section.

Table 16–1. Operation Codes

Kind of Operation Name of Operation

Arithmetic operations ADD (Add)


DIV (Divide)
MULT (Multiply)
MVR (Move remainder)
SQRT (Perform square root)
SUB (Subtract)
XFOOT (Sum elements of numeric array)
Z-ADD (Zero then add)
Z-SUB (Zero then subtract)
Comparison operations COMP (Compare)
TESTN (Test for numeric)
TESTZ (Test zone)

8600 0544–103 16–1


Operation Codes

Table 16–1. Operation Codes

Kind of Operation Name of Operation

Move operations MOVE (Move rightmost)


MOVEA (Move array)
MOVEL (Move leftmost)
Move zone operations MHHZO (Move high to high zone)
MHLZO (Move high to low zone)
MLHZO (Move low to high zone)
MLLZO (Move low to low zone)
Binary field operations BITOF (Set bit off)
BITON (Set bit on)
TESTB (Test bits)
Indicator operations SETOF (Set off)
SETON (Set on)
Program branching GOTO (Branch to instruction)
operations
TAG (Identify entry point from GOTO)
Structured programming ANDxx (Perform conditional AND)
operations
CAS (Select case unconditional)
CASxx (Select case conditional)
CASE (Select case)
DO (Do)
DOUxx (Do until)
DOWxx (Do while)
IFxx (Execute if–then)
IFxx/ELSE (Execute if–then--else)
ORxx (Perform conditional OR)
Subroutine operations BEGSR (Begin subroutine)
ENDSR (End subroutine)
EXSR (Execute subroutine)
Library operations EEXSR (Execute external subroutine)
PARAM (Specify parameters for EEXSR)

16–2 8600 0544–103


Operation Codes

Table 16–1. Operation Codes

Kind of Operation Name of Operation

I/O operations CHAIN (Access data file)


CLOSE (Close file for processing)
DELET (Delete a record)
DSPLY (Display data)
EXCPT (Write exception output)
FORCE (Select record)
READ (Read sequentially)
READE (Read equal key)
READP (Read previous record)
RECV (Read remote file record)
SEND (Send remote file record)
SETLL (Set lower limit)
Other operations DEBUG (Debug program)
DEFN (Define a new field)
DUMP (Perform symbolic dump)
LOKUP (Look up vector entry)
SORTA (Sort array)
TIME (Provide current time)
ZIP (Activate WFL statement)
COMS operations Refer to Volume 2 of this manual.
DMSII operations Refer to Volume 2 of this manual.

8600 0544–103 16–3


Operation Codes

Arithmetic Operations
In the following paragraphs, a vector element is valid anywhere a field name is valid,
except as noted. Arithmetic operations are allowed only on numerically defined data
items. If the Factor 1 field (columns 18–27) is not specified for an ADD, a SUB, a MULT,
or a DIV operation, the default is the field indicated by the Result Field (columns 43–48).
This feature enables a shorthand specification of the operation. The Factor 1 field
(columns 18–27) and the Factor 2 field (columns 33–42) must either name numeric fields
or contain numeric literals. The Result Field must also be numeric.

All results are signed, and decimal alignment is performed. If the Result Field is not large
enough to hold the result, that result is truncated at one or both ends after decimal
alignment. If the Result Field is too large, leading and trailing zeros are inserted after
decimal alignment. Refer to Table 16–2 for an example of the importance of designating
a correct amount of space for the result.

Factor 1, Factor 2, and the Result Field can have identical or different field names. The
Half Adjust field (column 53) can be specified for all arithmetic operations except SQRT
and MVR. The Resulting Indicators field (columns 54–59) can be specified for all
operations, provided that the Result Field is not a whole array.

A whole array can be entered in the Factor 1 or the Factor 2 field if the Result Field is
also a whole array. In this case, the designated arithmetic operation is performed on each
element of the array or arrays designated as factors. The result is indicated in the
corresponding elements of the array in the Result Field. The operation ends when it
reaches the end of the shortest array. If the Result Field is an array but Factor 1 and
Factor 2 are not, the result of the operation performed on Factor 1 and Factor 2 is placed
in each element of the Result Field array.

If the field name associated with an attribute declared in an Attribute Specification


appears as Factor 1, Factor 2, or the Result Field of an arithmetic operation, then the field
must be numeric. The attribute is not assigned a value when the Result Field contains an
attribute identifier if one of the following is true:

• The numeric value of the arithmetic operation is not defined for the attribute field
name.
• The field name is defined as read-only.
The meanings of resulting indicators for arithmetic operations are as follows:

• The plus indicator (columns 54–55) is turned on if the Result Field is greater than 0.
• The minus indicator (columns 56–57) is turned on if the Result Field is less than 0.
• The zero indicator (columns 58–59) is turned on if the Result Field is 0.

16–4 8600 0544–103


Operation Codes

Compile-Time Warning Messages with Arithmetic Operations


When the compiler displays a high-order truncation or low-order truncation warning
message, the result produced can be inaccurate. This section describes these types of
warning messages because of the possibly severe effect on the data.

The following abbreviations are used in the discussion of the truncation warning
messages:

Abbreviation Definition

L1 Length of the Factor 1 field (columns 18–27)


L2 Length of the Factor 2 field (columns 33–42)
LR Length of the Result Field (columns 43–48)
D1 Decimal positions in the Factor 1 field
D2 Decimal positions in the Factor 2 field
DR Decimal positions in the Result Field

High-Order Truncation Warning Messages


The compiler displays a warning message to indicate that high-order truncation can occur
when the ADD, SUB, MULT, and DIV operation codes are used. Following is a list of
those operation codes and the conditions that cause warning messages to be displayed:

• ADD, SUB
A warning is issued if one of the following is true:
(L1 - D1) > (LR - DR)
(L2 - D2) > (LR - DR)

• MULT
A warning is issued if the following is true:
(L1 - D1) + (L2 - D2) > (LR - DR)

• DIV
A warning is issued if the following is true:
(L1 - D1) > (LR - DR)

8600 0544–103 16–5


Operation Codes

Low-Order Truncation Warning Messages


The compiler displays a warning message to indicate that low-order truncation can occur
when the ADD, SUB, and MULT operation codes are used. Following is a list of those
operation codes and the conditions that cause warning messages to be displayed when
they are used:

• ADD, SUB
A warning is issued if either of the following is true:
D1 > DR

D2 > DR

• MULT
A warning is issued if the following is true:
(D1 + D2) > DR

ADD (Add)
This operation adds the contents of the Factor 2 field (columns 33–42) to the contents of
the Factor 1 field (columns 18–27) and stores the sum in the Result Field (columns 43–
48). Additional information on the ADD operation is provided in the discussion of
arithmetic operations in this section.

This operation does not affect the Factor 1 and Factor 2 fields unless one of them is also
named in the Result Field. The Factor 1 field can be blank if the field to be used is the
same field as the Result Field. Example 16–1 shows the use of shorthand specifications.

Example
Example 16–1 shows shorthand forms of arithmetic operation coding for the ADD, SUB,
MULT, and DIV operation codes.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...00
100F*
00200FFILEIN IP 80 80 DISK
00300FFILEOUT O 132 132 PRINTER
00400I*
00500IFILEIN AA 01
00600I 5 100AMT1
00700I 15 200AMT2
00800C*
00900C* The following two lines have the same meaning.
01000C*
01100C AMT2 ADD AMT1 AMT2
01200C ADD AMT1 AMT2

Example 16–1. Arithmetic Operations (cont.)

16–6 8600 0544–103


Operation Codes

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...
01300C*
01400C* The following two lines have the same meaning.
01500C*
01600C AMT2 SUB AMT1 AMT2
01700C SUB AMT1 AMT2
01800C*
01900C* The following two lines have the same meaning.
02000C*
02100C AMT2 MULT AMT1 AMT2
02200C MULT AMT1 AMT2
02300C*
02400C* The following two lines have the same meaning.
02500C*
02600C AMT2 DIV AMT1 AMT2
02700C DIV AMT1 AMT2
02800OFILEOUT D 1 01
02900O AMT1 20
03000O AMT2 30

Example 16–1. Arithmetic Operations

DIV (Divide)
This operation divides the contents of the Factor 1 field (columns 18–27) by the contents
of the Factor 2 field (columns 33–42) and places the quotient in the Result Field
(columns 43–48). Additional information on the DIV operation is provided in the
discussion of arithmetic operations in this section.

This operation does not affect the Factor 1 and Factor 2 fields unless one of them is also
designated as the Result Field. Factor 1 can be blank if the Factor 1 field and the Result
Field have the same field name.

Any remainder resulting from the DIV operation is lost unless the next operation
specified is the MVR operation. The Result Field cannot be a whole array if the next
operation is an MVR operation.

If Factor 2 is equal to 0 (zero), a DIVIDE BY ZERO error message is displayed.


Example 16–1 shows abbreviated specifications for the DIV operation.

8600 0544–103 16–7


Operation Codes

MULT (Multiply)
This operation multiplies the contents of the Factor 1 field (columns 18–27) by the
contents of the Factor 2 field (columns 33–42) and stores the product in the Result Field
(columns 43–48). Additional information on the MULT operation is provided in the
discussion of arithmetic operations in this section.

This operation does not affect the Factor 1 and Factor 2 fields unless one of them is also
designated as the Result Field. Factor 1 can be blank if the Factor 1 field and the Result
Field have the same name.

Table 16–2 shows the importance of allowing a correct amount of space and number of
decimal places for the result of an operation. Two decimal numbers (89.67 and 2.148) are
multiplied. Allowing too many positions to the left or right of the decimal place causes
many leading or trailing zeros to appear. These zeros are unnecessary and can lead to an
inaccurate interpretation. Inaccuracies can also occur if there are too few leading zeros.
For example, the first result shown in each row of the table is completely inaccurate
because not enough space was provided to contain the result. The result that has 4
decimal positions and a field length of 7 numbers (192.6111) has no leading or trailing
zeros. The result is accurate and easy to read.

Table 16–2 shows the Result Field with varying entries in the Decimal Positions field
(column 52) and the Field Length field (columns 49–51).

Table 16–2. Result Field Contents after Multiplication of 89.67 and


2.148

Field Length

Decimal Position 1 3 5 7 9

0 2 192 00192 0000192 000000192


2 2.61 192.61 00192.61 0000192.61
4 2.6111 192.6111 00192.6111
6 2.611160 192.611160
8 2.61116000

MVR (Move Remainder)


This operation moves the remainder from a DIV operation to the designated Result Field
(columns 43–48).

The MVR operation must immediately follow the DIV operation. The MVR and DIV
operations should be conditioned by the same indicators to avoid unpredictable results.
Additional information on the MVR operation is provided in the discussion of arithmetic
operations in this section.

16–8 8600 0544–103


Operation Codes

The following items should be considered when the size of the Result Field is specified:

• The number of decimal positions should be as follows:


− Greater than or equal to the number of decimal positions in the Factor 1 field
(columns 18–27) of the previous DIV operation.
− Greater than or equal to the sum of the decimal positions in the Factor 2 field
(columns 33–42) and the Result Field of the previous DIV operation.
When these conditions are not met, a warning message is displayed.
• The number of integer positions should be greater than or equal to the number of
positions in the Factor 2 field of the previous DIV operation. When this condition is
not met, a warning is displayed.
• The Factor 1 field, the Factor 2 field, and the Half Adjust field (column 53) must be
blank.
• The Result Field cannot be an entire array.

SQRT (Perform Square Root)


This operation determines the square root of the contents of the Factor 2 field
(columns 33–42) and places the result in the Result Field (columns 43–48). The Factor 1
field (columns 18–27) must be blank. Additional information on the SQRT operation is
provided in the discussion of arithmetic operations in this section.

Obtaining reasonable precision from the SQRT operation requires that there be at least
half as many integer positions and implied decimal positions in the Result Field as there
are in the Factor 2 field.

The result of the SQRT operation is automatically adjusted; therefore, a Half Adjust field
(column 53) entry is not allowed.

If Factor 2 is negative, the program displays a SQRT OPERATION ERROR error message.

If processing is allowed to continue, the Result Field is set to 0.

8600 0544–103 16–9


Operation Codes

Table 16–3 shows possible results of the SQRT operation performed on the decimal
number 2994.42. Note the importance of allowing sufficient spaces to the left and right
of the decimal place. In addition, the presence of leading and trailing zeros can lead to an
inaccurate reading of the result. The result that has 3 decimal positions and a field length
of 5 numbers (54.721) has no leading or trailing zeros. The result is accurate and easy to
read.

Table 16–3. Result Field Contents after SQRT Operation on 2994.42

Field Length

Decimal Position 1 2 3 4 5 6

0 5 55 055 0055 00055 000055


1 .7 4.7 54.7 054.7 0054.7 00054.7
2 .72 4.72 54.72 054.72 0054.72
3 .721 4.721 54.721 054.721
4 .7213 4.7213 54.7213
5 .72129 4.72129

SUB (Subtract)
This operation subtracts the contents of the Factor 2 field (columns 33–42) from the
contents of the Factor 1 field (columns 18–27) and places the difference in the Result
Field (columns 43–48). Additional information on the SUB operation is provided in the
discussion of arithmetic operations in this section.

This operation does not affect the Factor 1 and Factor 2 fields unless one of them is also
designated as the Result Field. The Factor 1 field can be blank if the Factor 1 field and the
Result Field have the same name. See Example 16–1 earlier in this section for examples
of abbreviated specifications.

When two identical fields are subtracted, the result is the same as it is when 0 (zero) is
assigned to the Result Field.

XFOOT (Sum Elements of Numeric Array)


This operation sums the elements of a numeric array. Additional information on the
XFOOT operation is provided in the discussion of arithmetic operations in this section.

All elements of the array specified by the Factor 2 field (columns 33–42) are added, and
the total is placed in the Result Field (columns 43–48). The Factor 1 field (columns 18–27)
must be blank, and the Result Field cannot be a whole array.

If the Result Field is an element of the array named in the Factor 2 field, the value of that
element before the XFOOT operation is the one used in obtaining the total.

16–10 8600 0544–103


Operation Codes

Z-ADD (Zero Then Add)


This operation assigns zero to the Result Field (columns 43–48) and then adds the
contents of the Factor 2 field (columns 33–42) to the Result Field. Additional information
on the Z-ADD operation is provided in the discussion of arithmetic operations in this
section.

Factor 2 is not affected unless it is named in the Result Field. The Factor 1 field
(columns 18–27) must be blank.

Z-SUB (Zero Then Subtract)


This operation assigns zero to the Result Field (columns 43–48) and then subtracts the
contents of the Factor 2 field (columns 33–42) from the Result Field. Additional
information on the Z-SUB operation is provided in the discussion of arithmetic operations
in this section.

The Factor 1 field (columns 18–27) must be blank. Factor 2 is not affected unless it is
named in the Result Field.

This operation changes the sign of the field designated by Factor 2.

8600 0544–103 16–11


Operation Codes

Comparison Operations
The comparison operations test the specified fields for certain conditions. The results are
shown in the specified Resulting Indicators field (columns 54–59), which must be set.
Field values are not affected. At least one resulting indicator must be specified. The
TESTZ operation uses the Result Field (columns 43–48); however, the Result Field and
the Half Adjust field (column 53) must be blank for all other operations. Neither the Factor
1 field (columns 18–27) nor the Factor 2 field (columns 33–42) can name a whole array.

COMP (Compare)
This operation compares the Factor 1 field (columns 18–27) with the Factor 2 field
(columns 33–42) and sets the Resulting Indicators field (columns 54–59).

Settings for the resulting indicators are as follows:

Setting Comparison

High (columns 54–55) Factor 1 > Factor 2


Low (columns 56–57) Factor 1 < Factor 2
Equal (columns 58–59) Factor 1 = Factor 2

Factor 1 and Factor 2 must be the same data type.

If the Factor 1 field designates a field name associated with an alphanumeric or


mnemonic attribute, then Factor 2 must be an alphanumeric literal, an alphanumeric
variable name, or an alphanumeric or mnemonic attribute identifier. If the Factor 1 field
specifies a field name associated with a numeric attribute, Factor 2 must be a numeric
literal, a numeric variable name with zero decimal positions, or a numeric attribute
identifier.

The previously described conditions are also true if Factor 2 specifies a field name
associated with an alphanumeric, mnemonic, or numeric attribute.

Comparison of Numeric Fields


The comparison of numeric fields is based on their respective values considered as
signed numeric quantities. The length of the fields, in terms of digits, is not significant.
Both fields are automatically aligned by decimal point, and leading or trailing zeros are
supplied to make the lengths identical.

Comparison of Alphanumeric Fields


Alphanumeric fields are compared by left-justifying the Factor 1 (columns 18–27) and
Factor 2 (columns 33–42) fields in work areas of equal length and filling the rightmost
positions of the shorter field with blanks. A character-to-character comparison begins at
the leftmost position of each field. Moving right, the comparison continues until the

16–12 8600 0544–103


Operation Codes

program finds an unequal condition between corresponding characters, or until it reaches


the end of the fields.

If the program reaches the end of the fields, an equal condition exists. The equal
indicator (columns 58–59) turns on if the characters are equal in the collating sequence.

If the program finds an unequal condition, one of the following occurs:

• The high indicator (columns 54–55) turns on if the Factor 1 field contains the
character higher in the collating sequence.
• The low indicator (columns 56–57) turns on if the higher character is in the Factor 2
field.

TESTN (Test for Numeric)


The TESTN operation tests for numeric characters or blanks in the contents of an
alphanumeric field, indexed vector, or unindexed table specified in the Result Field
(columns 43–48). A whole array must not be specified. If all characters in the
alphanumeric field are numeric, the high indicator (columns 54–55) turns on.

Each character in the field must be unsigned except for the low-order character, which
must contain one of the following to be considered numeric:

• The positive (binary 1100) or negative (binary 1101) sign


• No sign
• A valid plus (+) or minus (–) character
If the alphanumeric field specified contains numeric characters and leading blanks, the
low indicator (columns 56–57) turns on. This test cannot be made for alphanumeric fields
with a length of 1 numeric character. The equal indicator (columns 58–59) turns on if the
field contains all blanks. The same indicator can be specified for more than one condition.
In that case, the indicator turns on if any of the conditions are satisfied.

The TESTN operation determines the sign of the low-order (rightmost) character within
an alphanumeric field as follows:

Character Sign Character Being Tested

Plus A through I, + 0, +
Negative J through R, – 0, --
Unsigned 0 through 9

Note: Because the tested field is alphanumeric, the contents of this field must be
moved to a numeric field if an arithmetic operation is to be performed.

8600 0544–103 16–13


Operation Codes

TESTZ (Test Zone)


The TESTZ operation tests the zone portion of the leftmost position of an alphanumeric
field or the sign position of a numeric field. The operation sets the Resulting Indicators
field (columns 54–59) accordingly. The Result Field (columns 43–48) names the field to
be tested. The field must not be an entire array.

The following fields must be blank:

• Factor 1 (columns 18–27)


• Factor 2 (columns 33–42)
• Field Length (columns 49–51)
• Decimal Positions (column 52)
• Half Adjust (column 53)
TESTZ operation results are summarized as follows:

Character under Test Resulting Indicators Set

A through I, &, +0 Plus (columns 54–55)


J through R, –, --0 Minus (columns 56–57)
All others Zero (columns 58–59)

If the field under test is numeric, no resulting indicator can be specified in columns 58
and 59. With that exception, the Resulting Indicators field is set according to the
character under test.

Move Operations
Move operations transfer the contents of the Factor 2 field (columns 33–42) to the Result
Field (columns 43–48). These operations do not affect the Factor 2 field. The Factor 1
field (columns 18–27) must be blank.

The operation code, the Factor 2 field, and the Result Field must contain entries. The
Control Level field (columns 7–8), the Indicators field (columns 9–17), and the Field
Length field (columns 49–51) can contain valid entries. The remainder of the specification
line must be blank.

The Resulting Indicators field (columns 54–59) can indicate the status (plus, minus, or
zero/blank) of the Result Field in the same manner as for arithmetic operations. If both
the Factor 2 field and the Result Field have the same length, the MOVE and MOVEL
operations give identical results. Factor 2 can be a field, vector, vector element, or literal;
however, the Result Field can only be a field, vector, or vector element.

An array name can be entered in the Factor 2 field if the Result Field also names an array.
In this case, the designated move operation is performed on each element of the array
named in the Factor 2 field. The result is placed in the corresponding elements of the

16–14 8600 0544–103


Operation Codes

array specified in the Result Field. The operation ends when it reaches the end of the
shorter array. If the Result Field is an array but Factor 2 is not, the designated move
operation is performed on Factor 2, and the result is placed in all elements of the Result
Field array.

For MOVE and MOVEL operations, the sign of a numeric variable is the algebraic sign;
the sign of an alphanumeric variable is the low-order zone.

Numeric fields that are the result of a MOVE or MOVEL operation contain a negative sign
(binary 1101) if the zone of the low-order byte of the alphanumeric field is negative
(binary 1101); otherwise, the field is positive.

For any move operations that affect the sign position, the following rules apply:

• When a positive numeric field is moved to an alphanumeric field, the sign byte of the
Result Field is alphanumeric 0 through 9.
• When a negative numeric field is moved to an alphanumeric field, the sign of the
Result Field is the negative sign (binary 1101).
Move operations can be specified between fields of different data types. Doing so
converts an alphanumeric field to numeric or a numeric field to alphanumeric. The
position of the decimal point is ignored for numeric fields.

MOVE (Move Rightmost)


The MOVE operation moves characters from the Factor 2 field (columns 33–42) to the
Result Field (columns 43–48). This operation begins with the rightmost character and
continues until either the source field is exhausted or the destination field is filled. The
sign of the Factor 2 field is moved to the sign position of the Result Field. The Half Adjust
field (column 53) must be blank.

When an alphanumeric-to-numeric move is specified, the digit portion of each character


in the Factor 2 field is moved to the Result Field. A programmatic error exists if the digit
is not a decimal digit (0 through 9). The result value for such a digit is undefined. Blanks
are transferred as zeros. The zone portion of the rightmost alphanumeric character is
used as the sign of the Result Field.

When a numeric-to-alphanumeric move is specified, each digit is converted to its


corresponding internal character code as it is moved to the Result Field.

If the sign is to be transferred, the following rules apply:

• If the numeric field is positive, the rightmost character contains alphanumeric 0


through 9.
• If the numeric field is negative, the zone of the rightmost character contains the
negative sign (binary 1101).

8600 0544–103 16–15


Operation Codes

If the Result Field is a field name defined in the Attribute Specifications, the contents of
the Factor 2 field assign a value to the associated attribute. If Factor 2 is a field name
defined in the Attribute Specifications, the Result Field contains the associated value for
this attribute at the end of the operation.

If the Result Field designates a field name associated with an alphanumeric or mnemonic
attribute, Factor 2 must be one of the following:

• An alphanumeric literal
• An alphanumeric variable name
• An alphanumeric attribute identifier
• A mnemonic attribute identifier
If the Result Field specifies a field name associated with a numeric attribute, Factor 2
must be a numeric literal, a numeric variable name with zero decimal positions, or a
numeric attribute identifier.

If the Factor 2 field designates a field name associated with either an alphanumeric or
mnemonic attribute, the Result Field must be an alphanumeric variable name or an
alphanumeric or mnemonic attribute identifier. If the Factor 2 field specifies a field name
associated with a numeric attribute, the Result Field must be a numeric variable name
with zero decimal positions or a numeric attribute identifier.

For an attribute identifier in the Result Field, if the value of Factor 2 is not defined for the
attribute field name or if the attribute field name is defined as read-only, the attribute is
not assigned a value.

Tables 16–4 through 16–6 show the results of the MOVE operation with Result Fields
that are larger, smaller, and equal in length to Factor 2.

Table 16–4. Results of MOVE Operations: Result Field Larger Than


Factor 2 Field

Factor 2 Factor 2 Result Result Field Result Field


Type Contents Field before MOVE after MOVE
Type

Alpha AB4SK Alpha 123456789 1234AB4SK


Alpha AB4SK Numeric +123456789 –123412422
Numeric –9876543 Numeric +123456789 –129876543
Numeric +9876543 Alpha ABCDEFGHI AB9876543

Legend
Alpha Alphanumeric
K –2

16–16 8600 0544–103


Operation Codes

Table 16–5. Results of MOVE Operations: Result Field Smaller Than


Factor 2 Field

Factor 2 Factor 2 Result Result Field Result Field after


Type Contents Field before MOVE MOVE
Type

Alpha GEBKLM4 Alpha 56784 LM4SK


SK
Alpha GEBKLM4 Numeric +56784 –34422
SK
Numeric –9876543 Numeric +56789 –76543
Numeric –9876543 Alpha ABCDE 7654L

Legend
Alpha Alphanumeric
K –2
L –3
M –4

Table 16–6. Results of MOVE Operations: Factor 2 and Result Field


of Same Length

Factor 2 Field Result Field

Type Contents Type Contents before Contents after


MOVE MOVE

Alpha AB4SK Alpha 56789 AB4SK


Alpha AB4SK Numeric +56789 –12422
Numeric –98765 Numeric +12345 –98765
Numeric –87654 Alpha ABSDE 8765M

Legend
Alpha Alphanumeric
K –2
M –4

8600 0544–103 16–17


Operation Codes

MOVEA (Move Array)


The MOVEA operation enables adjacent elements of numeric or alphanumeric arrays to
be moved or modified in one operation. In contrast, the MOVE and MOVEL operations
permit only single fields or individual vector elements to be moved or modified.

The data are moved from the leftmost position of the Factor 2 field (columns 33–42) to
the leftmost position of the Result Field (columns 43–48). If an array is named but not
indexed, the MOVEA operation begins with the first element of the array. If the array is
indexed, the operation begins with the element referred to.

As the transfer of data continues, successive array elements are moved, modified, or
both, until the end of either the Factor 2 field or the Result Field is reached. This action
can cause the MOVEA operation to end in the middle of an array element. If the Result
Field is longer than the Factor 2 field, the remaining data are unchanged. Regardless of
the field lengths, Factor 2 is never changed.

The following requirements apply to a MOVEA operation:

• Either the Factor 2 field or the Result Field must contain an array name.
• Neither the Factor 2 field nor the Result Field can refer to a table name or table
element.
• The Result Field cannot contain a literal.
The following items can be moved by the MOVEA operation:

• Adjacent array elements moved into a field


• A field moved into adjacent array elements
• Adjacent array elements in one array moved to the corresponding array elements of
either the same array or a different array
The array in the Factor 2 field or the Result Field, or both arrays, can be indexed. Indexing
has the following effects:

• For the Factor 2 field, the data transfer begins at the element indicated by the value
of the index.
• For the Result Field, the data reception begins at the element indicated by the value
of the index.
When the same array name is used in both the Factor 2 field and the Result Field, the
data transfer moves the original values of the array named in the Factor 2 field. The index
can be either a literal or a variable.

When a numeric Factor 2 field (source) or Result Field (destination) is used in a MOVEA
operation, the numeric value has a right f-zone format. A numeric value in right f-zone
format has the sign of the numeric value placed in the zone section of the rightmost
character, with 1111 (binary) representing a positive sign and 1101 (binary) a negative
sign. (For example, the numeric value +123 has the EBCDIC representation 123, and the
numeric value –123 has the EBCDIC representation 12L.)

16–18 8600 0544–103


Operation Codes

Following is a list of results when a numeric Factor 2 field or Result Field is used for a
MOVEA operation:

• A numeric Factor 2 field is used with an alphanumeric result.


The source numeric value is converted into right f-zone format before being
transferred.
• An alphanumeric Factor 2 field is used with a numeric result.
The alphanumeric source is interpreted as numeric data with right f-zone format. If
the source length is shorter than the destination length, resulting in the modification
of a partial element in the result, the result is converted into right f-zone format
before the transfer. The transfer is completed, and the result is then converted again
to its original format. This sequence enables the partial element modification to work
as though the result were always in right f-zone format.
The conversion sequence is somewhat inefficient and is unnecessary if the element
sizes of the Factor 2 field and the Result Field are equal or if the Result Field is
already in right f-zone format.
• A numeric Factor 2 field is used with a numeric result.
If the lengths of the Factor 2 field and result elements are equal, the source
elements are moved to the destination elements. This process is comparable to
using the Z-ADD operation to add elements to the Result Field one element at a
time.
If the lengths of the Factor 2 field and result elements are not equal, both the Factor
2 field and the result are converted to right f-zone format in temporary areas. A
transfer then occurs between the temporary areas. The converted, temporary result
is converted again to a numeric value and placed in the Result Field.
The conversion sequence is somewhat inefficient and is unnecessary if the Result
Field and the Factor 2 field are already in right f-zone format. It is recommended that
the MOVEA operation be restricted to arrays having the same element length.
Example
Example 16–2 shows coding for the MOVEA operation.

The initial data values before the start of the program are the following:

Field Value

FIELD1 (an alphanumeric field) 12345678


ARY1 (an alphanumeric array containing 3 elements of 3 characters ABC DEF
each) GHI
ARY2 (a numeric array containing 2 elements of 3 digits each) 123 –456
ARY3 (an alphanumeric array containing 4 elements of 2 characters 12 34 56 78
each)
ARY4 (a numeric array containing 3 elements of 3 digits each) 001 002 003

8600 0544–103 16–19


Operation Codes

Table 16–7 shows the results of an execution of the program in the example.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...02
100F*
00300FFILEIN IP 80 80 DISK
00400FFILE1 IT 80 80 DISK
00500FFILE2 IT 80 80 DISK
00600FFILE3 IT 80 80 DISK
00650FFILE4 IT 80 80 DISK
00700FFILEOUT O 132 132 PRINTER
00800E FILE1 ARY1 1 3 3
00900E FILE2 ARY2 1 2 3 0
01000E FILE3 ARY3 1 4 2
01050E FILE4 ARY4 1 3 3 0
01100IFILEIN AA 01
01200I 5 12 FIELD1
01300C*
01400C* Alphanumeric field to alphanumeric array move Πno indexing
01500C*
01600C 01 MOVEAFIELD1 ARY1
01700C*
01800C* Alphanumeric array to alphanumeric field move Πarray indexed
01900C*
02000C 01 MOVEAARY1,2 FIELD1
02100C*
02200C* Numeric array to alphanumeric array move Πno indexing
02300C*
02400C 01 MOVEAARY2 ARY1
02500C*
02600C* Alphanumeric array to alphanumeric array move --
02650C* Factor 2 indexed
02700C*
02800C 01 MOVEAARY3,4 ARY1
02900C*
03000C* Numeric array to alphanumeric array move ΠResult Field indexed
03100C*
03200C 01 MOVEAARY2 ARY1,3
03300C*
03400C* Alphanumeric array to alphanumeric array move --
03450C* both arrays indexed
03500C*
03600C 01 MOVEAARY1,3 ARY3,4
03700C*
03800C* Alphanumeric literal to array move Πno indexing
03900C*
04000C 01 MOVEA'ABC' ARY2
04010C*

Example 16–2. MOVEA Operations (cont.)

16–20 8600 0544–103


Operation Codes

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...
04020C* Numeric array to numeric array move ΠFactor 2 indexed
04030C*
04040C 01 MOVEAARY4,1 ARY2
04100OFILEOUT D 01
04200O FIELD1 B 10
04300O ARY1,1 B 15
04400O ARY1,2 B 20
04500O ARY1,3 B 25
04600O ARY2,1 B 30
04700O ARY2,2 B 35
04800O ARY3,1 B 40
04900O ARY3,2 B 45
05000O ARY3,3 B 50
05100O ARY3,4 B 55
05200O ARY4,1 B 60
05300O ARY4,2 B 65
05400O ARY4,3 B 70

Example 16–2. MOVEA Operations

Table 16–7 shows the contents of data items after the execution of a MOVEA operation.
The values for the field named in the Result Field are shown in the MOVEA result
column.

Table 16–7. Results of MOVEA Operations

Factor 2 Field Result Field MOVEA Operation Result

FIELD1 ARY1 123 456 78I


ARY1,2 FIELD1 DEFGHI78
ARY2 ARY1 123 45P GHI
ARY3,4 ARY1 78C DEF GHI
ARY2 ARY1,3 ABC DEF 123
ARY1,3 ARY3,4 12 34 56 GH
'ABC' ARY2 123 –456
ARY4,1 ARY2 001 002

Legend
P –6

8600 0544–103 16–21


Operation Codes

MOVEL (Move Leftmost)


This operation moves data from the Factor 2 field (columns 33–42) to the Result Field
(columns 43–48), starting with the leftmost position and continuing until either the source
field is exhausted or the destination field is filled. The Half Adjust field (column 53) must
be blank.

When an alphanumeric-to-numeric move is specified, the digit portion of each character


is transferred, and all blanks in the Factor 2 field are converted to zeros in the Result
Field.

When a numeric-to-alphanumeric move is specified, each digit is converted to its


corresponding internal character code as it is moved to the Result Field.

The sign is transferred only if the Result Field is one of the following:

• Numeric and not longer than the Factor 2 field


• Alphanumeric and not shorter than the Factor 2 field
If the sign is to be transferred, the following rules apply:

• If the numeric field is positive, the rightmost character contains alphanumeric 0


through 9.
• If the numeric field is negative, the zone of the rightmost character contains the
negative sign (binary 1101).
If the Result Field is a field name defined in the Attribute Specifications, the contents of
the Factor 2 field assigns a value to the associated attribute. If Factor 2 is a field name
defined in the Attribute Specifications, the Result Field contains the associated value for
this attribute at the end of the operation.

If the Result Field designates a field name associated with an alphanumeric or mnemonic
attribute, Factor 2 must be one of the following:

• An alphanumeric literal
• An alphanumeric variable name
• An alphanumeric attribute identifier
• A mnemonic attribute identifier
If the Result Field specifies a field name associated with a numeric attribute, Factor 2
must be either a numeric literal, a numeric variable name with 0 (zero) decimal positions,
or a numeric attribute identifier.

If the Factor 2 field designates a field name associated with either an alphanumeric or
mnemonic attribute, the Result Field must be an alphanumeric variable name or an
alphanumeric or mnemonic attribute identifier. If the Factor 2 field specifies a field name
associated with a numeric attribute, the Result Field must be a numeric variable name
with 0 (zero) decimal positions, or a numeric attribute identifier.

16–22 8600 0544–103


Operation Codes

For an attribute identifier in the Result Field, if the value of Factor 2 is not defined for the
attribute field name or if the attribute field name is defined as read-only, the attribute is
not assigned a value.

Table 16–8 provides examples of the MOVEL operation with the EBCDIC character code.

Table 16–8. Results of MOVEL Operations

Factor 2 Field Result Field

Type Length Type Length Characters Position of Sign


Transferred If Transferred

N Equal N Equal Digits Sign position


N Shorter N Longer Digits No transfer
N Longer N Shorter Digits Sign position
N Equal A Equal Digits Zone of rightmost
digit transferred
N Shorter A Longer Digits Zone of rightmost
digit transferred
N Longer A Shorter Digits No transfer
A Equal N Equal Digits Sign position
A Shorter N Longer Digits No transfer
A Longer N Shorter Digits Sign position
A Equal A Equal Bytes Not applicable
A Shorter A Longer Bytes Not applicable
A Longer A Shorter Bytes Not applicable

Legend
N Numeric
A Alphanumeric

8600 0544–103 16–23


Operation Codes

Move Zone Operations


These operations move the zone portion of one character. These operations do not affect
the Factor 2 field (columns 33–42). They affect only the zone portion of one character of
the Result Field (columns 43–48). The Factor 1 field (columns 18–27), the Half Adjust field
(column 53), and the Resulting Indicators field (columns 54–59) must be blank.

An array name can be entered in the Factor 2 field if the Result Field also specifies an
array. In this case, the designated move zone operation is performed on each array
element designated in the Factor 2 field. The result is placed in the corresponding array
element designated in the Result Field. The operation ends when the end of the shorter
array is reached.

If the Result Field is an array but the Factor 2 field is not, the zone from the Factor 2 field
is moved into the appropriate position in all elements of the array.

Each of the move zone operations is discussed in the following paragraphs.

MHHZO (Move High to High Zone)


This operation moves the zone from the high-order (leftmost) position of the Factor 2
field to the high-order (leftmost) position of the Result Field. Both the Factor 2 field and
the Result Field must be alphanumeric.

MHLZO (Move High to Low Zone)


If both the Factor 2 field and the Result Field are alphanumeric, this operation moves the
zone from the high-order (leftmost) position of the Factor 2 field to the low-order
(rightmost) position of the Result Field.

If the Factor 2 field is alphanumeric and the Result Field is numeric, this operation moves
the high-order (leftmost) position of the Factor 2 field to the sign position of the Result
Field. Factor 2 must be alphanumeric.

MLHZO (Move Low to High Zone)


If both the Factor 2 field and the Result Field are alphanumeric, this operation moves the
zone from the low-order (rightmost) position of the Factor 2 field to the high-order
(leftmost) position of the Result Field.

If Factor 2 is numeric and the Result Field is alphanumeric, this operation moves the zone
from the sign position of the Factor 2 field to the high-order (leftmost) position of the
Result Field. The Result Field must be alphanumeric.

16–24 8600 0544–103


Operation Codes

MLLZO (Move Low to Low Zone)


If both the Factor 2 field and the Result Field are alphanumeric, this operation moves the
zone from the low-order (rightmost) position of the Factor 2 field to the low-order
(rightmost) position of the Result Field.

If Factor 2 is alphanumeric and the Result Field is numeric, this operation moves the zone
from the low-order (rightmost) position of the Factor 2 field to the sign position of the
Result Field.

If Factor 2 is numeric and the Result Field is alphanumeric, this operation moves the zone
from the sign position of the Factor 2 field to the low-order (rightmost) position of the
Result Field.

If both Factor 2 and the Result Field are numeric, this operation moves the zone from the
sign position of the Factor 2 field to the sign position of the Result Field.

Summary of Move Zone Operations


Table 16–9 summarizes the move zone operations. In this table, alpha means
alphanumeric.

Table 16–9. Move Zone Operations

Move Result Definition


Zone Factor 2 Field
Operation Field Type Type

MHHZO Alpha Alpha Moves high-order zone of Factor 2 to


high-order zone of Result Field
MHLZO Alpha Alpha Moves high-order zone of Factor 2 to
low-order zone of Result Field
Alpha Numeric Moves high-order zone of Factor 2 to
sign position of Result Field
MLHZO Alpha Alpha Moves low-order zone of Factor 2 to
high-order zone of Result Field
Numeric Alpha Moves sign position of Factor 2 to
high-order zone of Result Field
MLLZO Alpha Alpha Moves low-order zone of Factor 2 to
low-order zone of Result Field
Alpha Numeric Moves low-order zone of Factor 2 to
sign position of Result Field
Numeric Alpha Moves sign position of Factor 2 to
low-order zone of Result Field
Numeric Numeric Moves sign position of Factor 2 to
sign position of Result Field

8600 0544–103 16–25


Operation Codes

If the variable is numeric, the low-order zone of a variable is defined as the algebraic sign.

A high-order zone must refer only to an alphanumeric field. Only the low-order zone can
be referred to when a numeric field is used.
The positive sign (binary 1100) is forced on all positive numeric fields that result from
move zone operations. When the zone of a positive numeric field is moved to that of an
alphanumeric field by a move zone operation, the sign byte of the Result Field
(columns 43–48) contains alphanumeric 0 through 9. When the zone of a negative
numeric field is moved to that of an alphanumeric field by a move zone operation, the
sign of the Result Field contains the negative sign (binary 1101).

Binary Field Operations


The binary field operations enable the use of bits as signals that give information about
the results of prior operations.

The Factor 2 field (columns 33–42) can contain either of the following:
• A 1-byte, alphanumeric field name.
• A series of numeric entries enclosed in apostrophes ('), ranging from 0 through 7.
These numbers indicate which bits to use from the Factor 2 field with the specified
binary field operation. Bits are numbered from left to right in the Factor 2 field. For
example, '017' in the Factor 2 field represents bits 0, 1, and 7.
The Result Field (columns 43–48) can contain only a 1-byte, alphanumeric field.

The Control Level (columns 7–8) and Indicators (columns 9–17) fields can contain entries.
The rest of the Calculation Specifications line must be blank.

The bit field operations are described in the following paragraphs.

Example
Example 16–3 shows binary field operation coding.

16–26 8600 0544–103


Operation Codes

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...
00100F*
00200FFILEIN IP 80 80 DISK
00300FFILEOUT O 132 132 PRINTER
00400I*
00500IFILEIN AA 01
00600I 10 10 FIELD2
00700I 15 15 FIELD3
00800I 20 20 FIELD4
00900I 25 25 FIELD5
01000C*
01100C BITON'
01234567'FIELD201200C BITOF'45670123'FIELD3
01300C TESTB'234' FIELD4 101020
01400C TESTB'4567' FIELD5 303040
01500O*
01600OFILEOUT D 01
01700O 10 30 35 'UNEQUAL CONDITION'

Example 16–3. Binary Field Operations

BITOF (Set Bit Off)


The bits that are on in the Factor 2 field designate the bits to turn off in the field named
as the Result Field (columns 43–48).

BITON (Set Bit On)


The bits that are on in the Factor 2 field designate the bits to turn on in the field named
as the Result Field (columns 43–48).

TESTB (Test Bits)


If the bits that are on in the Factor 2 field are off in the Result Field (columns 43–48), the
indicator specified in columns 54 through 55 is turned on.

If only some of the bits that are on in the Factor 2 field are on in the Result Field, then
the indicator in columns 56 through 57 is turned on. In this case, it is the responsibility of
the programmer to ensure that at least two bits are on in the data supplied from the
Factor 2 field. If only one bit is on, the indicator in columns 56 through 57 is never turned
on.

If the bits that are on in the Factor 2 field are on in the Result Field, the indicator
specified in columns 58 through 59 is turned on.

The same indicator, or two or three different indicators, can be used for one TESTB
operation.

8600 0544–103 16–27


Operation Codes

Indicator Operations
When an indicator operation is used, at least one indicator named in the Resulting
Indicators field (columns 54–59) turns on or off.

The Factor 1 field (columns 18–27), the Factor 2 field (columns 33–42), the Result Field
(columns 43–48), and the Half Adjust field (column 53) must be blank.

The following rules apply for the indicator operations:

• The following indicators cannot be turned on or off: first page (1P), matching record
(MR), and overflow indicators not used in the File Specifications.
• A control level indicator (L1–L9) turned on or off does not affect any other control
level indicator.
• All control level and record identifying indicators except L0 are automatically turned
off after the program completes detail output operations regardless of any previous
indicator operation.
• Halt indicators that are on at the conclusion of detail output cause the program to
halt.
• The program goes to EOJ after it completes total output operations if the SETON
operation turned on the LR indicator during either detail or total calculations.
The operations discussed in the following paragraphs explicitly affect the setting of
indicators.

SETOF (Set Off)


This operation turns off the indicators entered in the Resulting Indicators field
(columns 54–59).

SETON (Set On)


This operation turns on the indicators entered in the Resulting Indicators field
(columns 54–59).

16–28 8600 0544–103


Operation Codes

Program Branching Operations


Operations in the Calculation Specifications are usually performed in sequential order.
Branching operations enable the order of operations to be varied dynamically. Both
conditional branching and repetitive operations are possible. These operations are
described in the following paragraphs.

GOTO (Branch to Instruction)


This operation causes the program to branch to an instruction other than the next
sequential operation.

Branching can be either forward or backward and can occur within subroutines.
Branching is allowed between total and detail calculations. Also, a branch can be
performed from a subroutine to a label in detail or total calculations.

The Factor 2 field (columns 33–42) must contain a label that follows the rules for forming
labels described in Section 2, “RPG Language Elements.” This label is entered
elsewhere in the Calculation Specifications with the TAG operation. columns 18 through
27 and 39 through 59 must be blank.

Example
Example 16–4 shows how the subroutine GOEXIT executes a GOTO operation to the tag
EXIT in detail calculations.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...
00100C*
00200C EXSR GOEXIT
00300C EXIT TAG
00400CSR GOEXIT BEGSR
00500CSR GOTO EXIT
00600CSR ENDSR

Example 16–4. GOTO Program Branching Operation

TAG (Identify Entry Point from GOTO)


This operation identifies the entry point from a GOTO operation.

The Factor 1 field (columns 18–27) must contain a unique label (tag) that follows the rules
for forming labels described in Section 2, “RPG Language Elements.”

Conditioning by a control level indicator (columns 7–8) is allowed if the TAG operation is
part of total calculations. columns 9 through 17, 24 through 27, and 33 through 59 must
be blank.

Example 16–4 shows TAG operation coding.

8600 0544–103 16–29


Operation Codes

Structured Programming Operations


Structured programming operations direct control of the program to applicable units of
the code. This capability is essential to the structured programming method. Subdividing
programs into units makes them easier to write, debug, test, and modify. Structured
programming operations test for a specific condition to determine if an operation or a
group of operations is to be performed.

Structured programming operations include three types of cases, three kinds of DO


loops, and two varieties of an IF branching facility.

Operations are listed in the Table 16–10. The xx specifies the particular Boolean condition
to be met. A discussion of Boolean operators follows the table.

Table 16–10. Structured Programming Operations

Structured Programming Description


Operation

ANDxx AND (conditional Boolean operation)


CAS Execute case unconditional
CASxx Execute case conditional
CASE Select case
DO Do
DOUxx Do until
DOWxx Do while
IFxx Execute if-then
IFxx/ELSE Execute if-then-else
END End
ORxx OR (conditional Boolean operation)

The nonexecutable END operation specifies the end of a structured programming


operation, except for the ANDxx and ORxx operations, which have no associated END
operation.

Structured programming operations must be completely contained in either detail or total


calculations. Similarly, a structured programming operation must be completely
contained within subroutines.

Structured programming operations can be nested up to 100 levels. Additional


information on nesting levels is provided in the discussion of nesting structured
programming operations in this section.

16–30 8600 0544–103


Operation Codes

Boolean Operators
Boolean operators are used with the structured programming operations ANDxx, CASxx,
DOUxx, DOWxx, IFxx, and ORxx to compare a value in the Factor 1 field to a value in the
Factor 2 field.

Table 16–11 contains the Boolean operators and their definitions.

Table 16–11. Boolean Operators and Definitions

Boolean Operator Definition

EQ Factor 1 field equal to Factor 2 field


GE Factor 1 field greater than or equal to Factor 2 field
GT Factor 1 field greater than Factor 2 field
LE Factor 1 field less than or equal to Factor 2 field
LT Factor 1 field less than Factor 2 field
NE Factor 1 field not equal to Factor 2 field

Nesting Structured Programming Operations


Structured programming operations can be contained within one another (nested).
Nesting can occur to 100 levels. Any type and combination of structured programming
operation can be nested within another, with the exception of CASxx and CAS. See the
discussion of the CASxx and CAS structured programming operations for more
information. The CASxx and CAS structured programming operations do not have other
structured programming operations nested within them because they are used only to
call subroutines. The CAS and CASxx structured programming operations, however, can
be nested within other structured programming operations.

The ANDxx and ORxx operations do not cause additional levels of nesting. When
determining the nesting level of a structured construct, do not include the ANDxx and
ORxx operations.

Most structured programming operations are defined by a name, which is a reserved


word, and the position of a corresponding END operation. The exceptions to this
definition of scope are the ANDxx and ORxx operations, which have no END operations.
Note that branching into a structured programming operation from elsewhere in the
program might yield unpredictable results.

Figure 16–1 illustrates the way structured programming operations can be nested.

8600 0544–103 16–31


Operation Codes

Figure 16–1. Nested Structured Programming Operations

ANDxx (Perform Conditional AND)


The ANDxx structured programming operation can be used to specify a complex set of
conditions to be met before a section of code can be executed. An ANDxx operation can
be used with the DOUxx, DOWxx, IFxx, or IFxx/ELSE structured programming operations
to construct a compound conditional expression.

The ANDxx operation must be preceded by a DOUxx, DOWxx, or IFxx operation;


additionally, it can be preceded by either an ORxx or another ANDxx operation that is
subordinate to a DOUxx, DOWxx, or IFxx operation. The nonexecutable END operation is
not used with the ANDxx structured programming operation.

The compiler generates code to branch out of remaining comparisons as soon as a


condition is found to be FALSE. To take advantage of this immediate branching, place the
conditions that are likely to be FALSE before those that are likely to be TRUE.

The condition specified by the structured programming operation preceding the ANDxx
operation determines whether the ANDxx condition is evaluated or another action is
taken. Table 16–12 summarizes the actions taken when the condition of the preceding
operation has been determined.

16–32 8600 0544–103


Operation Codes

Table 16–12. Effects of Operations Preceding ANDxx

Preceding Operation Result Action Taken


Operation

DOUxx TRUE Evaluate ANDxx condition.


FALSE Branch to the top of DOUxx loop.
DOWxx TRUE Evaluate ANDxx condition.
FALSE Branch to the operation following END
(exit loop).
IFxx TRUE Evaluate ANDxx condition.
FALSE Branch to the operation following END.
IFxx/ELSE TRUE Evaluate ANDxx condition.
FALSE Branch to the operation following ELSE.

Field definitions for the ANDxx structured programming operation are as follows:

• The Indicators field (columns 9–17) must be blank.


• The Factor 1 field (columns 18–27) must contain one of the following: a numeric or
alphanumeric literal; a field name or vector element of type numeric, alphanumeric,
COMS-designator, or COMS-time. COMS-designators, however, can be compared
using only the EQ and NE Boolean operators. More information about COMS is
provided in Volume 2 of this manual.
Factor 1 must be the same type as Factor 2.
• The Operation field (columns 28–32) must contain the operation ANDxx, where xx
specifies a condition that is tested. Valid entries are ANDEQ, ANDNE, ANDLT,
ANDLE, ANDGT, and ANDGE. Boolean operators are described in a separate
discussion earlier in this section.
• The Factor 2 field (columns 33–42) must contain one of the following: a numeric or
alphanumeric literal; a field name or vector element of type numeric, alphanumeric,
COMS-designator, or COMS-time. COMS designators, however, can be compared
using only the EQ and NE Boolean operators.
Factor 2 must be the same type as Factor 1.
• The Result Field (columns 43–48) must be blank.
• The Resulting Indicators field (columns 54–59) must be blank.
Example
Example 16–5 shows the ANDxx operation used with the DOUxx, DOWxx, IFxx, and
IFxx/ELSE structured programming operations.

Indicator 10 is tested to determine if the DOUxx structured programming operation


should be started. If indicator 10 is off, the DOUxx structured programming operation is
not entered, and the program branches to the operation immediately following the END
operation (at sequence line number 10090).

8600 0544–103 16–33


Operation Codes

If the loop is initiated, the operations within the loop are executed. If indicator 11 is on at
the END operation, FAC1A is compared to FAC2A and the following occurs:

• If FAC1A is less than or equal to FAC2A, then FAC1B is compared to FAC2B. If


FAC1B is less than or equal to FAC2B, then the loop ends, and control of the
program passes to the operation following the END operation.
• If FAC1A is greater than FAC2A, the comparison between FAC1B and FAC2B is
skipped, and the loop is repeated until one of the following is true:
− FAC1A is less than or equal to FAC2A, and FAC1B is less than or equal to
FAC2B.
− Indicator 11 is turned off.
If indicator 11 is off at the END operation, the loop is exited and processing resumes at
the operation following the END operation (at sequence line number 10090).

Indicator 20 is tested to determine if the DOWxx structured programming operation


should be started. If indicator 20 is off, the DOWxx structured programming operation is
not entered, and the program branches to the operation immediately following the END
operation (at sequence line number 10170).

If the loop is initiated, FAC1C is compared to FAC2C and the following occurs:

• If FAC1C is less than FAC2C, then FAC1D is compared to FAC2D. If FAC1D is less
than FAC2D, the operations within the loop are executed. If indicator 21 is on, the
comparison with the DOWxx operation is made again; otherwise, the program
continues at the operation following the END operation (at sequence line number
10170).
• If FAC1C is greater than or equal to FAC2C, the comparison between FAC1D and
FAC2D is skipped, the loop ends, and the program continues at the operation
following the END operation.
Indicator 30 is tested to determine if the IFxx structured programming operation should
be started. If indicator 30 is off, the IFxx structured programming operation is not
entered, and the program branches to the operation following the END operation (at
sequence line number 10250).

If the operation is initiated, FAC1E is compared to FAC2E and the following occurs:

• If FAC1E is equal to FAC2E, then FAC1F is compared to FAC2F. If FAC1F is equal to


FAC2F, the operations between the ANDEQ, and END operations are executed and
control of the program passes to the operation following the END operation (at
sequence line number 10250).
• If FAC1E is not equal to FAC2E, the comparison between FAC1F and FAC2F is
skipped, and control of the program passes to the operation following the END
operation.
Indicator 40 is tested to determine if the IFxx structured programming operation should
be started. If indicator 40 is off, the IFxx structured programming operation is not
entered, and the program branches to the operation immediately following the END
operation (after sequence line number 10330).

16–34 8600 0544–103


Operation Codes

If the operation is initiated, FAC1G is compared to FAC2G and the following occurs:

• If FAC1G is greater than FAC2G, then FAC1H is compared to FAC2H. If FAC1H is


greater than FAC2H, the group of operations between the ANDGT and ELSE
operations is executed and control passes to the operation following the END
operation (after sequence number 10330). If FAC1H is less than or equal to FAC2H,
the group of operations between the ELSE and END operations is executed. Control
then passes to the operation following the END operation.
• If FAC1G is less than or equal to FAC2G, the comparison between FAC1H and
FAC2H is skipped, and the group of operations between the ELSE and END
operations is executed. Control then passes to the operation following the END
operation.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...10
010C 10 FAC1A DOULEFAC2A
10020C FAC1B ANDLEFAC2B
10030C FAC1A SUB 1 FAC1A
10040C FAC1B SUB 1 FAC1B
10050C* .
10060C* .
10070C 11 END
10080C*
10090C 20 FAC1C DOWLTFAC2C
10100C FAC1D ANDLTFAC2D
10110C FAC1C ADD 1 FAC1C
10120C FAC1D ADD 1 FAC1D
10130C* .
10140C* .
10150C 21 END
10160C*
10170C 30 FAC1E IFEQ FAC2E
10180C FAC1F ANDEQFAC2F
10190C FAC1E SUB 1 FAC1E
10200C FAC1F ADD 1 FAC1F
10210C* .
10220C* .
10230C END
10240C*
10250C 40 FAC1G IFGT FAC2G
10260C FAC1H ANDGTFAC2H
10270C SETON 01
10280C* .
10290C* .
10300C ELSE
10310C SETON 02
10320C END
10330C* .

Example 16–5. ANDxx Structured Programming Operations

8600 0544–103 16–35


Operation Codes

CASxx and CAS (Select Case Conditional/Unconditional)


This structured programming operation has two forms: CASxx and CAS. The CASxx
structured programming operation executes a subroutine call when the condition
specified by xx is met. The CAS structured programming operation executes a
subroutine call unconditionally.

Several CASxx operations can be grouped together with one END operation, or with one
CAS operation and one END operation. The Indicators field (columns 9–17) can be used
to condition the CASxx operations, but must be blank for the END operation. If a
condition associated with the indicator is not met, control passes to the next operation,
not to the operation following the END operation.

The Resulting Indicators field (columns 54–59) can be specified to indicate the
relationship between Factor 1 and Factor 2. This function is similar to that of the COMP
operation. If resulting indicators are specified, the relationship between Factor 1 and
Factor 2 is tested, and the appropriate indicators are turned on accordingly.

When the CASxx structured programming operation is invoked, the Factor 1 and Factor 2
fields are compared to determine if the condition specified by xx has been met, and
resulting indicators are set to indicate the result of the comparison. If the condition is not
met, the next executable calculation (a CASxx operation, a CAS operation, or the
operation following the END operation) is performed. If the condition has been met, the
subroutine specified in the Result Field is called. When the subroutine is completed, the
CASxx or CAS structured programming operation is ended, and the program passes
control to the operation following the END operation.

All CASxx operations should be placed before the CAS operation so that they can be
evaluated first. This arrangement is necessary because the CAS structured programming
operation executes a subroutine unconditionally; once a subroutine is called, the CASxx
structured programming operation ends.

The CAS and CASxx structured programming operations can be nested within DO,
DOUxx, DOWxx, CASE, and IFxx structured programming operations.

The CAS structured programming operation, which does not use the Factor 1 and Factor
2 fields, has a function that is similar to the EXSR operation. Additional information on the
EXSR operation is provided in this section.

The CASxx and CAS structured programming operations cannot be used within
subroutines or exception routines.

Field definitions for the CASxx and CAS operations are the following:

• The Factor 1 field (columns 18–27) must be blank when the CAS structured
programming operation is used.
When the CASxx structured programming operation is used, columns 18 through 27
must contain one of the following: a numeric or alphanumeric literal; a field name or
vector element of type numeric, alphanumeric, COMS designator, or COMS-time.
COMS designators, however, can be compared using only the EQ and NE Boolean
operators. Factor 1 must be the same type as Factor 2.

16–36 8600 0544–103


Operation Codes

• The Operation field (columns 28–32) must contain the CAS or CASxx operation,
where xx represents a condition to be tested. Valid entries are CAS, CASEQ, CASNE,
CASLT, CASLE, CASGT, and CASGE. Boolean operators EQ, NE, LT, LE, GT, and GE
are described in Table 16–11.
• The Factor 2 field (columns 33–42) must be blank when the CAS structured
programming operation is used.
When the CASxx structured programming operation is used, these columns must
contain one of the following: a numeric or alphanumeric literal; a field name or vector
element of type numeric, alphanumeric, COMS designator, or COMS-time. COMS
designators, however, can be compared using only the EQ and NE Boolean
operators. Factor 2 must have the same type as Factor 1 has.
• The Result Field (columns 43–48) must contain the name of the subroutine to be
called.
• Entries in the Resulting Indicators field (columns 54–59) are optional.
Example
Example 16–6 compares two values (FAC1 and FAC2) to determine which subroutine
should be called. Indicator 10 is tested to determine whether if the CASxx structured
programming operation should be started. If indicator 10 is off, the CASxx structured
programming operation on that line is not executed, and the program branches to the
next operation (the CASLT operation on line 10020).

If the CASGT structured programming operation is started, FAC1 is compared to 0 (zero).


If FAC1 is greater than 0, indicator 22 is turned on, SUBR1 is called, and, after returning
from the subroutine call, control of the program passes to the operation following the
END operation. If FAC1 is less than FAC2, resulting indicator 33 is turned on, and control
of the program passes to the CASLT operation at line 10020, where SUBR2 is called. If
FAC1 equals FAC2, indicator 44 is turned on, and control of the program passes to the
CASEQ operation at line 10030.

As each CASxx condition is tested, the first one that is met assigns an appropriate value
to a resulting indicator, calls a subroutine, and ends the CASxx structured programming
operation. If no CASxx condition is met, the unconditional CAS operation calls SUBR4.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...
10010C 10 FAC1 CASGT0 SUBR1 223344
10020C FAC1 CASLTFAC2 SUBR2 223344
10030C FAC1 CASEQFAC2 SUBR3 223344
10040C CAS SUBR4
10050C END
10060C

Example 16–6. CASxx and CAS Structured Programming Operations

8600 0544–103 16–37


Operation Codes

CASE (Select Case)


The CASE structured programming operation provides a convenient means of
dynamically selecting one of many possible actions at a particular point in the program.
The choice of alternative sets of operations is based upon the value of the CASE
selection variable.

The CASE structured programming operation consists of the following elements:

• CASE operation. This operation indicates the start of the CASE structured
programming operation.
• CASE selection variable. Specified in Factor 2 of the CASE operation, this variable is
compared to each CASE label to determine the set of operations to execute.
• CASE labels. These labels are numeric or alphanumeric constants to which the
selection variable is compared. When the selection variable is equal to a certain label
or falls within a specified CASE label range, the set of operations at that label is
executed. Once a match occurs, the rest of the labels are ignored and control passes
to the operation immediately following the END operation.
• END operation. This operation indicates the end of the CASE structured
programming operation.
The CASE structured programming operation might begin by testing a conditioning
indicator to determine if the CASE structured programming operation should be started.
If not, processing continues at the operation following the END operation. The Indicators
field (columns 9–17) on the CASE labels and END operations must be blank. Control level
indicators can be used on the lines containing the CASE and *ELSE labels and the END
operation, but these indicators are not evaluated.

When the CASE structured programming operation is started, a match is sought


between the CASE selection variable (Factor 2 of the CASE operation) and one of the
CASE labels. If a match is made, the set of operations immediately following the CASE
label is executed. If no match is made, the set of operations at *ELSE is executed, if the
*ELSE label is present. If the *ELSE label is not present and no match occurs, a run-time
error occurs.

CASE labels can specify complex selection criteria by defining a range of values or a
choice between two or more alternatives. A range can be specified with the use of THRU
in the Operation field of the CASE label operation. CASE labels must be in pairs and in
ascending order when a CASE range is specified; for example, acceptable CASE labels
are AA THRU CC, and 55 THRU 99. A range must not overlap another range nor include a
value that has already been declared by an individual CASE label. Duplicate labels are also
disallowed.

A choice between two or more CASE labels can be made by using OR in the Operation
field of the CASE label operation. The programming example in this section contains the
use of OR in a CASE label. The OR and THRU operations can be combined to create a
more complex CASE label.

If none of the CASE labels match a CASE selection variable. Consequently, an *ELSE
label can be used. *ELSE can be used anyplace in the CASE group; however, logically,

16–38 8600 0544–103


Operation Codes

the best position for the *ELSE label and its related set of operations is immediately
before the END operation, after an attempt has been made to match all CASE labels.
Although a program compiles and executes without the *ELSE label, it should always be
specified. If the *ELSE label is not present and none of the CASE labels match, then an
error message is displayed.

After the set of operations at a CASE label has been executed, control is then passed to
the operation immediately following the associated END operation. The CASE structured
programming operation can be exited by using a GOTO operation out of the set of
operations at a CASE label. A GOTO to a tag within another set of operations is not
prohibited, but it is not recommended.

Any RPG operation can be specified in CASE labels, including other CASE structured
programming operations. Nesting cannot exceed 100 levels. As with other nested
operations, CASE structured programming operations must be wholly contained within
detail or total calculations, subroutines, and DMSII exception routines.

Following are field definitions for the CASE operation:

• The Factor 1 field (columns 18–27) must be blank.


• The Operation field (columns 28–32) must contain the CASE operation.
• The Factor 2 field (columns 33–42) must contain one of the following: a numeric or
alphanumeric literal; a numeric or alphanumeric field name or vector element. The
type of this field must match the type of every CASE label, and the scale factor of
the CASE labels and this field must be the same; however, the lengths are not
required to match.
• Columns 43 through 59 must be blank.
Following are field definitions for CASE labels:

• The Factor 1 field (columns 18–27) must contain a numeric or alphanumeric literal, or
a figurative constant. The type and scale factor must be the same as the type and
scale factor of Factor 2 of the CASE operation. The type and scale factor must also
be consistent with all the labels in this CASE structured programming operation.
If *ELSE is used, it appears within this field.
• The Operation field (columns 28–32) contains a colon (:) to designate the end of a
CASE label. The operation THRU specifies a label range. The OR operation permits
alternative CASE labels to be used.
• Columns 33 through 59 must be blank.
Example
Example 16–7 shows the use of the CASE structured programming operation to obtain
marketing and advertising information for a large hotel. The information sought is the
state of origin for previous guests.

The selection variable STATE is alphanumeric. Presumably, before the start of this CASE
structured programming operation, some alphanumeric value was transferred to STATE
either by the MOVE operation or in the Input Specifications.

8600 0544–103 16–39


Operation Codes

The THRU operation on line 600 specifies a range. The value of the alphanumeric
constant CA is less than the value of FL, illustrating that label ranges are always specified
in pairs, with the lower value specified first.

The operators THRU and OR can be combined to create more complex CASE label
specifications. An example of the use of OR appears on lines 1200 and 1300.

Line 1700 provides an example when nothing is done at a particular CASE label. If STATE
equals WY, the test for that label is satisfied; however, control immediately passes to the
operation following the END operation.

If the value of STATE does not match any of the CASE labels, the *ELSE label at line
1800 and its related operations are executed. As is the case when any of the CASE
labels are satisfied, the operations specified below the *ELSE label are performed, and
control then passes to the operations following the END operation on line 2200.

The RPG compiler invokes the searching algorithm most efficient for each CASE
structured programming operation. Many factors are considered in determining the
algorithm, including the number of labels and the size and complexity of the operations
between the labels. As a result, the average execution speed for any CASE structured
programming operation is faster than it is if a linear search is used.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...
00100C CASE STATE
00200C 'MD' :
00300C*
00400C* Operations for Maryland
00500C*
00600C 'CA' THRU
00700C 'FL' :
00800C*
00900C* Operations for states that are alphabetically
01000C* between California and Florida.
01100C*
01200C 'NJ' OR
01300C 'NY' :
01400C*
01500C* Operations that process New York or New Jersey
01600C*
01700C 'WY' :
01800C *ELSE :
01900C*
02000C* Operations following *ELSE
02100C*
02200C END

Example 16–7. CASE Structured Programming Operation

16–40 8600 0544–103


Operation Codes

DO, DOUxx, and DOWxx


The DO, DOUxx, and DOWxx structured programming operations execute a group of
operations repeatedly until a specified condition that causes the loop to end is met.

The DO structured programming operation executes a group of operations a specified


number of times. The DOUxx structured programming operation executes a group of
operations repeatedly until a condition specified by xx is met. The DOWxx structured
programming operation executes a group of operations repeatedly while or as long as the
condition specified by xx is met. A conditioning indicator at the start of the loop
determines if the loop is to be executed. An indicator at the end of the loop determines if
the loop is repeated.

Each DO, DOUxx, and DOWxx structured programming operation must have a matching
END operation.

The DOUxx and DOWxx structured programming operations can be used with the
ANDxx and ORxx structured programming operations to form complex conditions.
Discussions of the ANDxx and ORxx structured programming operations are provided in
this section. The DO, DOUxx, and DOWxx structured programming operations are
further described under separate headings.

DO (Do)
Additional information on the DO structured programming operation is provided in the
previous discussion of DO, DOUxx, and DOWxx structured programming operations.

The DO structured programming operation executes a group of operations a specific


number of times in a loop.

The loop is controlled by the following four values:

• Starting value (Factor 1)


• Limit value (Factor 2)
• Current index value field (Result Field)
• Increment value (Factor 2 of the associated END operation)
The starting value and limit value can be specified to determine the number of times the
DO structured programming operation is executed. A positive, negative, or zero value
can be used as the starting value. If a starting value or limit value is not specified, the
default value of 1 is assigned.

The increment value is a constant added to the index value during each loop cycle. The
index value then becomes the new starting value for the next loop. For the first iteration,
the current index contains the starting value. If the Result Field is blank, the compiler
generates an internal index that is not accessible by the user.

8600 0544–103 16–41


Operation Codes

When the DO structured programming operation is executed, the index value is


compared with the limit value. If the index value is less than or equal to the limit value,
operations within the DO structured programming operation are performed, and the
increment value is added to the index value. The DO structured programming operation
is executed repeatedly until the index value becomes greater than the limit value. Then
the loop ends and control passes to the next executable calculation after the matching
END operation.

Following are field definitions for the DO structured programming operation:

• The Factor 1 field (columns 18–27) can be blank or can contain a starting value. The
starting value must be a numeric literal or a numeric field name or vector element
with no decimal positions. Factor 1 must have the same type as Factor 2 has. The
value used can be positive, zero, or negative. The default value is 1.
• The Operation field (columns 28–32) must contain the operation DO.
• The Factor 2 field (columns 33–42) can be blank or can contain a limit value. The limit
value must be a numeric literal or a numeric field name or vector element with no
decimal positions. Factor 2 must have the same type as Factor 1 has.
The limit value can be positive, zero or negative. The default value is 1.
• The Result Field (columns 43–48) can be blank or can contain a numeric field or
vector element to be used as the current index value. If the columns are blank, the
compiler generates a field that is used as an index value. The compiler-generated
index is not accessible by the user; however, if the current index value is specified by
the user, that value can be altered within the DO loop to affect the control flow.
• Factor 2 of the END operation (columns 33–42) can be blank or can contain an
increment value. The increment value must be a numeric literal or a numeric field
name or vector element with zero decimal positions.
The increment value can be positive, zero, or negative. Extreme care is needed when
using zero or a negative number to avoid an infinite loop. The default value is 1.
Example 1
Example 16–8 shows the use of a DO structured programming operation to perform a
group of operations 10 times. Indicator 98 is tested to determine if the DO structured
programming operation should be started. If the DO structured programming operation is
initiated, the index value, INDX, is tested. If INDX is less than or equal to 10, the group of
operations between the DO and END operations is performed.

The DO structured programming operation is executed repeatedly until INDX becomes


greater than 10. Then the loop ends, and control of the program passes to the operation
following the END operation. Because a starting value and an increment value were not
specified, the default value of 1 is assigned to each field.

16–42 8600 0544–103


Operation Codes

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...
10020C 98 DO 10 INDX
10030C* .
10040C* .
10050C END
10060C* .

Example 16–8. DO Structured Programming Operation

Example 2
Example 16–9 shows how to use a DO structured programming operation to perform a
group of calculations six times with specified starting and increment values. The DO
structured programming operation is performed in the same way as that shown in the
preceding example. There are, however, two differences. The starting value is 0 and the
increment value is 2. When the DO structured programming operation is initiated, INDX
is given the starting value, which is 0. Thereafter, each time the DO structured
programming operation is performed, the index value increases by 2.

During the DO structured programming operation in this example, INDX receives six
values before the loop ends:0, 2, 4, 6, 8, and 10. Then the loop ends, and control of the
program passes to the operation following the END operation.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...
10020C 98 0 DO 10 INDX
10030C* .
10040C* .
10050C END 2
10060C* .

Example 16–9. DO Structured Programming Operation with Increment Values

DOUxx (Do Until)


The DOUxx structured programming operation executes a group of operations repeatedly
in a loop until the condition specified by xx is met. After each loop is performed, Factor 1
and Factor 2 are compared to determine if the condition specified by xx has been met.
An ANDxx or ORxx operation can follow the DOUxx operation to form a compound
conditional expression. Discussions of the ANDxx and ORxx structured programming
operations are provided in this section. If the condition or compound condition has not
been met, the operations within the DOUxx structured programming operation are
performed, and the comparison is repeated. If the condition or compound condition has
been met, the next executable operation after the matching END operation is performed.

An indicator often is used to determine if the DOUxx structured programming operation


should be started. If the indicator is on, at least one iteration of the loop is performed
because the comparison between Factor 1 and Factor 2 occurs after the loop is
executed. The comparison between Factor 1 and Factor 2 can occur for an ANDxx or
ORxx structured programming operation, if either of those operations follows the DOUxx
operation.

8600 0544–103 16–43


Operation Codes

Following are field definitions for the DOUxx structured programming operation:

• The Factor 1 field (columns 18–27) must contain one of the following: a numeric or
alphanumeric literal; or a field name or vector element of type numeric,
alphanumeric, COMS designator, or COMS-time. COMS designators, however, can
be compared using only the EQ and NE Boolean operators. For more information
about COMS, see Volume 2 of this manual. Factor 1 must be the same type as
Factor 2.
• The Operation field (columns 28–32) must contain the operation DOUxx, where xx
specifies a condition that is tested. Valid entries are DOUEQ, DOUNE, DOULT,
DOULE, DOUGT, and DOUGE. The Boolean operators EQ, NE, LT, LE, GT, and GE
are described in Table 16–11.
• The Factor 2 field (columns 33–42) must contain one of the following: a numeric or
alphanumeric literal; or a field name or vector element of type numeric,
alphanumeric, COMS designator, or COMS-time. COMS designators, however, can
be compared using only the EQ and NE Booleans. Factor 2 must be the same type
as Factor 1.
• The Result Field (columns 43–48) must be blank.
Additional information on the DOUxx operation is provided in the discussion of the DO,
DOUxx, and DOWxx structured programming operations earlier in this section.

Example
Example 16–10 performs DOUxx operations until Factor 1 and Factor 2 are equal.
Indicator 10 is tested to determine if the DOUxx structured programming operation
should be started. If indicator 10 is off, the DOUxx structured programming operation is
not executed, and the program branches to the operation immediately following the END
operation.

If the loop is initiated, the operations within the loop are executed. If indicator 20 is on at
the END operation, FAC1 is compared to FAC2. If indicator 20 is not on, the program
branches to the operation after the END operation. If FAC1 is not equal to FAC2, the loop
is repeated until FAC1 equals FAC2 or indicator 20 is turned off. Then the loop ends, and
control of the program passes to the operation following the END operation.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...
10010C 10 FAC1 DOUEQFAC2
10020C FAC1 SUB 1 FAC1
10030C* .
10040C* .
10050C 20 END
10060C* .

Example 16–10. DOUxx Structured Programming Operation

16–44 8600 0544–103


Operation Codes

DOWxx (Do While)


The DOWxx structured programming operation executes a group of operations
repeatedly while the condition specified by xx is met. Each time the loop is performed,
Factor 1 and Factor 2 are compared to determine if the condition has been met. If so, the
group of operations is performed, and the DOWxx structured programming operation is
repeated. If not, the next executable calculation after the matching END operation is
performed. An ANDxx or ORxx operation can follow the DOWxx operation to form a
compound conditional expression. Because the comparison occurs before the set of
operations within the loop are performed, the loop is not entered if the comparison
between Factor 1 and Factor 2 of the DOWxx operation fails or if a compound conditional
expression exists and fails.

Discussions of the use of the DOWxx structured programming operation with ANDxx
and ORxx operations to form compound conditional expressions are provided earlier in
this section.

Field definitions for the DOWxx structured programming operation are described in the
following list:

• The Factor 1 field (columns 18–27) must contain one of the following: a numeric or
alphanumeric literal; or a field name or vector element of type numeric,
alphanumeric, COMS designator, or COMS-time. COMS designators, however, can
be compared using only the EQ and NE Boolean operations. Factor 1 must be the
same type as Factor 2.
• The Operation field (columns 28–32) must contain the operation DOWxx, where xx
specifies the condition that is tested. Valid entries are DOWEQ, DOWNE, DOWLT,
DOWLE, DOWGT, and DOWGE. Boolean operations EQ, NE, LT, LE, GT, and GE are
described in Table 16–11.
• The Factor 2 field (columns 33–42) must contain one of the following: a numeric or
alphanumeric literal; or a field name or vector element of type numeric,
alphanumeric, COMS designator, or COMS-time. COMS designators, however, can
be compared, using the EQ and NE Boolean operations only. Factor 2 must be the
same type as Factor 1.
• The Result Field (columns 43–48) must be blank.
Additional information about the DOWxx operation is provided in the discussion of the
DO, DOUxx, and DOWxx structured programming operations.

Example
Example 16–11 performs DOWxx operations until Factor 1 is greater than or equal to
Factor 2. Indicator 10 is tested to determine if the DOWxx structured programming
operation should be initiated. If indicator 10 is off, the DOWxx structured programming
operation is not executed, and the program branches to the operation immediately
following the END operation.

If indicator 10 is on, FAC1 is compared to FAC2. If FAC1 is less than FAC2, the
operations within the loop are executed: 5.25 is added to the value in Factor 1 and the
total is moved into the Result Field, calculations that are unrelated to the ADD operation
are performed, and the DOWLT operation is repeated.

8600 0544–103 16–45


Operation Codes

If indicator 20 is on at the END operation, FAC1 is compared to FAC2. If indicator 20 is


not on, the program branches to the operation after the END operation. When FAC1
becomes greater than or equal to FAC2, the loop ends and the program branches to the
operation following the END operation.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...
10010C 10 FAC1 DOWLTFAC2
10020C FAC1 ADD 5.25 FAC1
10030C* .
10040C* .
10050C 20 END
10060C* .

Example 16–11. DOWxx Structured Programming Operation

IFxx (Execute If–Then)


The IFxx structured programming operation executes a group of operations if the
condition specified by xx has been met. Each IFxx structured programming operation
must have a matching END operation. The Indicators field (columns 9–17) on the END
operation must be blank.

When the IFxx structured programming operation is invoked, Factor 1 and Factor 2 are
compared to determine if the condition specified by xx has been met. If so, a group of
operations is executed. If not, the next operation after the matching END operation is
performed. If an ANDxx or ORxx operation follows the IFxx operation, the condition for
either of those operations is checked immediately after Factor 1 and Factor 2 of the IFxx
operation are checked. Discussions of the use of the IFxx structured programming
operation with the ANDxx and ORxx operations to form compound conditional
expressions are provided in this section.

The IFxx operation can also be used with the ELSE operation. A discussion of that topic
is provided under the next heading.

Field definitions for the IFxx structured programming operation are described in the
following list:

• The Factor 1 field (columns 18–27)must contain one of the following: a numeric or
alphanumeric literal; or a field name or vector element of type numeric,
alphanumeric, COMS designator, or COMS-time. COMS designators, however, can
be compared using only the EQ and NE Boolean operations. Factor 1 must be the
same type as Factor 2.
• The Operation field (columns 28–32) must contain the operation IFxx, where xx
specifies a condition that is tested. Valid entries are IFEQ, IFNE, IFLT, IFLE, IFGT,
and IFGE. Boolean operators EQ, NE, LT, LE, GT, and GE are described in Table 16–
11 earlier in this section.
• The Factor 2 field (columns 33–42) must contain one of the following: a numeric or
alphanumeric literal; or a field name or vector element of type numeric,
alphanumeric, COMS designator, or COMS-time. COMS designators, however, can

16–46 8600 0544–103


Operation Codes

be compared using only the EQ and NE Boolean operations. Factor 1 must be the
same type as Factor 2.
• The Result Field (columns 43–48) must be blank.
Example
Example 16–12 performs the group of operations between the IFEQ and the END
operations if Factor 1 equals Factor 2. Indicator 10 is tested to determine if the IFxx
structured programming operation should be initiated. If indicator 10 is off, the IFxx
structured programming operation is not entered, and the program branches to the
operation immediately following the END operation.

If the IFxx operation is started, FAC1 is compared to FAC2. If FAC1 equals FAC2, a group
of operations is performed. If FAC1 is not equal to FAC2, the program branches to the
operation following the END operation.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...
10010C 10 FAC1 IFEQ FAC2
10020C* .
10030C* .
10040C END
10050C* .

Example 16–12. IFxx Structured Programming Operation

IFxx/ELSE (Execute If–Then–Else)


The IFxx structured programming operation can be used with the ELSE operation, a
nonexecutable operation that performs an alternative group of operations if the condition
specified by the IFxx operation is not met, or if the condition specified by a combination
of xx and the structured programming operations ANDxx and ORxx is not met. The
Indicators field (columns 9–17) on the END operation must be blank.

Additional information about the IFxx structured programming operation is provided in the
discussion of that topic under the preceding heading. Discussions of the use of IFxx
structured programming operation with the ANDxx and ORxx operations to form
compound conditional expressions are provided in this section.

Field definitions for the ELSE operation are described in the following list:

• The Factor 1 field (columns 18–27) must be blank.


• The Operation field (columns 28–32) must contain the ELSE operation.
• The Factor 2 field (columns 33–42) must be blank.
• The Result Field (columns 43–48) must be blank.

8600 0544–103 16–47


Operation Codes

Example
Example 16–13 performs the IFxx structured programming operation with the ELSE
operation. Indicator 10 is tested to determine if the IFxx structured programming
operation should be started. If indicator 10 is off, the IFxx structured programming
operation is not entered, and the program branches to the operation immediately
following the END operation.

If the IFxx structured programming operation is initiated, FAC1 is compared to FAC2. If


FAC1 equals FAC2, the group of operations between IFEQ and ELSE is executed. Then
control passes to the operation after the matching END operation.

If FAC1 does not equal FAC2, control passes to the ELSE operation. The group of
operations between the ELSE and END operations is executed. Control then passes to
the operation after the END operation.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...
10010C 10 FAC1 IFEQ FAC2
10020C* .
10030C* .
10040C ELSE
10050C* .
10060C* .
10070C END
10080C* .

Example 16–13. IFxx/ELSE Structured Programming Operations

ORxx (Perform Conditional OR)


The ORxx structured programming operation can be used to specify a complex set of
conditions to be met before a section of code can be executed. An ORxx operation can
be used with the DOUxx, DOWxx, IFxx, or IFxx/ELSE structured programming operations
to form a compound conditional expression.

The ORxx operation must be preceded by a DOUxx, DOWxx, IFxx, or IFxx/ELSE


operation; additionally, it can be preceded by either an ANDxx or another ORxx operation
that is subordinate to a DOUxx, DOWxx, or IFxx operation. The nonexecutable END
operation is not used with the ORxx structured programming operation.

The compiler generates code to branch around remaining comparisons as soon as a


condition is found to be TRUE. To take advantage of this immediate branching, place the
conditions that are the most likely to be TRUE before those that are likely to be FALSE.

The condition specified by the structured programming operation preceding the ORxx
operation determines whether the ORxx condition is evaluated or another action is taken.
Table 16–13 summarizes the actions taken when the condition of the preceding
operation has been determined.

16–48 8600 0544–103


Operation Codes

Table 16–13. Effects of Operations Preceding ORxx Operation

Preceding Operation Action Taken


Operation Result

DOUxx TRUE Branch to the operation following END (exit loop).


FALSE Evaluate ORxx condition.
DOWxx TRUE Branch to the operation following the DOWxx
conditions.
FALSE Evaluate ORxx condition.
IFxx TRUE Branch to the operation following the IFxx conditions.
FALSE Evaluate ORxx condition.
IFxx/ELSE TRUE Branch to the operation following the IFxx conditions.
FALSE Evaluate ORxx condition.

Field definitions for the ORxx structured programming operation are as follows:

• The Indicators field (columns 9–17) must be blank.


• The Factor 1 field (columns 18–27) must contain one of the following: a numeric or
alphanumeric literal; a field name or vector element of type numeric, alphanumeric,
COMS designator, or COMS-time. COMS designators, however, can be compared
using only the EQ and NE Boolean operators. More information about COMS is
provided in Volume 2 of this manual.
Factor 1 must be the same type as Factor 2.
• The Operation field (columns 28–32) must contain the operation ORxx, where xx
specifies a condition that is tested. Valid entries are OREQ, ORNE, ORLT, ORLE,
ORGT, and ORGE. Boolean operators are described in a separate discussion earlier in
this section.
• The Factor 2 field (columns 33–42) must contain one of the following: a numeric or
alphanumeric literal; a field name or vector element of type numeric, alphanumeric,
COMS designator, or COMS-time. COMS designators, however, can be compared
using only the EQ and NE Boolean operators.
Factor 2 must be the same type as Factor 1.
• The Result Field (columns 43–48) must be blank.
• The Resulting Indicators field (columns 54–59) must be blank.

8600 0544–103 16–49


Operation Codes

Example
Example 16–14 shows the ORxx operation used with the DOUxx, DOWxx, IFxx, and
IFxx/ELSE structured programming operations.

Indicator 10 is tested to determine if the DOUxx structured programming operation


should be started. If indicator 10 is off, the DOUxx structured programming operation is
not entered, and the program branches to the operation immediately following the END
operation (at sequence line number 10090).

If the loop is initiated, the operations within the loop are executed. If indicator 11 is on at
the END operation, FAC1A is compared to FAC2A and the following occurs:

• If FAC1A is less than or equal to FAC2A, then the comparison between FAC1B and
FAC2B is skipped, and control of the program passes to the operation following the
END operation.
• If FAC1A is greater than FAC2A, then FAC1B and FAC2B are compared. If FAC1B is
greater than FAC2B, the loop is repeated until one of the following occurs:
− FAC1A is less than or equal to FAC2A.
− FAC1B is less than or equal to FAC2B.
− Indicator 11 is turned off.
If indicator 11 is off at the END operation, the loop is exited and processing resumes at
the operation following the END operation (at sequence line number 10090).

Indicator 20 is tested to determine if the DOWxx structured programming operation


should be started. If indicator 20 is off, the DOWxx structured programming operation is
not entered, and the program branches to the operation immediately following the END
operation (at sequence line number 10170).

If the loop is initiated, FAC1C is compared to FAC2C and the following occurs:

• If FAC1C is less than FAC2C, the comparison between FAC1D and FAC2D is
skipped, and the operations within the loop are executed. If indicator 21 is on, the
comparison with the DOWxx operation is made again; otherwise, the program
continues at the operation following the END operation (at sequence line number
10170).
• If FAC1C is greater than or equal to FAC2C, then FAC1D and FAC2D are compared. If
FAC1D is less than FAC2D, the operations within the loop are executed. If indicator
21 is on, the comparison is made again; otherwise, the program continues at the
operation following the END operation.
Indicator 30 is tested to determine if the IFxx structured programming operation should
be started. If indicator 30 is off, the IFxx structured programming operation is not
entered, and the program branches to the operation following the END operation (at
sequence line number 10250).

16–50 8600 0544–103


Operation Codes

If the operation is initiated, FAC1E is compared to FAC2E and the following occurs:

• If FAC1E is equal to FAC2E, a comparison between FAC1F and FAC2F is skipped,


the operations between the OREQ and END operations are executed, and control of
the program passes to the operation following the END operation (at sequence line
number 10250).
• If FAC1E is not equal to FAC2E, then FAC1F is compared to FAC2F. If FAC1F is equal
to FAC2F, the operations between the OREQ and END operations are executed.
Control of the program then passes to the operation following the END operation (at
sequence line number 10250).
Indicator 40 is tested to determine if the IFxx structured programming operation should
be started. If indicator 40 is off, the IFxx structured programming operation is not
entered, and the program branches to the operation immediately following the END
operation (after sequence line number 10330).

If the operation is initiated, FAC1G is compared to FAC2G and the following occurs:

• If FAC1G is greater than FAC2G, the comparison between FAC1H and FAC2H is
skipped, and the group of operations between the ORGT and ELSE operations is
executed. Control then passes to the operation following the END operation (after
sequence line 10330).
• If FAC1G is less than or equal to FAC2G, then FAC1H is compared to FAC2H. If
FAC1H is greater than FAC2H, the group of operations between the ORGT and ELSE
operations is executed, and control passes to the operation following the END
operation (after sequence line 10330). If FAC1H is less than or equal to FAC2H, the
group of operations between the ELSE and END operations is executed, and control
passes to the operation following the END operation (after sequence line 10330).

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...
10010C 10 FAC1A DOULEFAC2A
10020C FAC1B ORLE FAC2B
10030C FAC1A SUB 1 FAC1A
10040C FAC1B SUB 1 FAC1B
10050C* .
10060C* .
10070C 11 END
10080C*
10090C 20 FAC1C DOWLTFAC2C
10100C FAC1D ORLT FAC2D
10110C FAC1C ADD 1 FAC1C
10120C FAC1D ADD 1 FAC1D
10130C* .
10140C* .
10150C 21 END

Example 16–14. ANDxx Structured Programming Operations (cont.)

8600 0544–103 16–51


Operation Codes

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...
10160C*
10170C 30 FAC1E IFEQ FAC2E
10180C FAC1F OREQ FAC2F
10190C FAC1E SUB 1 FAC1E
10200C FAC1F ADD 1 FAC1F
10210C* .
10220C* .
10230C END
10240C*
10250C 40 FAC1G IFGT FAC2G
10260C FAC1H ORGT FAC2H
10270C SETON 01
10280C* .
10290C* .
10300C ELSE
10310C SETON 02
10320C END
10330C* .

Example 16–14. ANDxx Structured Programming Operations

Subroutine Operations
Subroutine operation codes delimit the beginning and end of a subroutine, or call a
subroutine for execution.

Specification lines within a subroutine must contain SR, OR, AN, or blank in the Control
Level field (columns 7–8). Subroutines are specified after all detail and total Calculation
Specifications. Subroutine operations cannot be nested in a subroutine, and a subroutine
cannot call itself. Subroutine operation codes are discussed in the following paragraphs.

16–52 8600 0544–103


Operation Codes

Example
Example 16–15 shows subroutine operation coding.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...
10160C*
10170C 30 FAC1E IFEQ FAC2E
10180C FAC1F OREQ FAC2F
10190C FAC1E SUB 1 FAC1E
10200C FAC1F ADD 1 FAC1F
10210C* .
10220C* .
10230C END
10240C*
10250C 40 FAC1G IFGT FAC2G
10260C FAC1H ORGT FAC2H
10270C SETON 01
10280C* .
10290C* .
10300C ELSE
10310C SETON 02
10320C END
10330C* .
01000I 65 670EMPLNOL1
01100C*
01200C 01 EMPLNO COMP '000000' 102020
01300C 01 EMPLNO COMP '999999' 201010
01400CL1 10 EXSR SUB1
01500CSR SUB1 BEGSR0
1600CSR HRSWK ADD TOTHRS TOTHRS 102
01700CSR HRSWK MULT RATE PAY 152
01800CSR PAY ADD TOTPAY TOTPAY 122
01900CSR EXSR SUB2
02000CSR MOVE EMPLNO EMPLID 100
02100CSR ENDSR
02200CSR SUB2 BEGSR
02300CSR TOTHRS SUB 40.00 OVTHR 102
02400CSR RATE MULT 1.5 OVTRT 102
02500CSR OVTRT MULT OVTHR OVTPAY 152
02600CSR ENDSR
02700O*
02800OFILEOUT D 01
02900O NAME 15
03000O ADDR 30
03100O EMPLID 45
03200O TOTHRS 55
03300O TOTPAY 70
03400O OVTHR 80
03500O OVTPAY 95

Example 16–15. Subroutine Operation

8600 0544–103 16–53


Operation Codes

BEGSR (Begin Subroutine)


This operation code indicates the start of a subroutine.

The Factor 1 field (columns 18–27) contains the name of the subroutine, which must
follow the rules for forming labels as described in Section 2, “RPG Language Elements.”
Columns 9 through 17 and 33 through 59 must be blank.

ENDSR (End Subroutine)


This operation code indicates the end of a subroutine.

The Factor 1 field (columns 18–27) can contain a label. This label is used, like a tag, as a
point to which a GOTO operation branches within the subroutine, thereby allowing exits
from different points within the subroutine. Columns 9 through 17 and 33 through 59
must be blank.

EXSR (Execute Subroutine)


This operation code calls the subroutine named in the Factor 2 field (columns 33–42) for
execution.

After the subroutine is executed, the instruction following the EXSR operation is
executed. EXSR can appear anywhere in the Calculation Specifications.

Indicators can condition the EXSR operation, allowing the subroutine to be called only
when certain conditions are satisfied. The Factor 2 field contains the name of the
subroutine being called, which must be the same name as that entered in the Factor 1
field (columns 18–27) of a BEGSR operation. The Factor 1 field and columns 43 through
59 must be blank.

One subroutine cannot contain another subroutine; however, an EXSR operation can be
contained within a subroutine.

Library Operations
The EEXSR and PARAM operations enable a program to call an external subroutine. An
external subroutine can be either a system software procedure known to the compiler or
a library procedure defined on the Library Subroutine Specifications.

EEXSR (Execute External Subroutine)


The EEXSR operation in the Operation field (columns 28–32) requires an external
subroutine name in the Factor 2 field (columns 33–42).

Columns 43–59 must be blank if the external subroutine is not a function (that is, if it is
not a typed procedure).

16–54 8600 0544–103


Operation Codes

An external subroutine that returns a result is often referred to as a function or a typed


procedure. Columns 43 through 59 in the Calculation Specifications can be used with the
following restrictions:

• The type of the field named in the Result Field must match the type of the
procedure, as defined in Table 16–14 later in this section. Information about field
types is provided in the discussion of the PARAM operation in this section. The
Result Field cannot be alphanumeric.
• When a COMS-time or designator type is named as the Result Field, the Resulting
Indicators and Half Adjust fields must be blank. (Refer to Volume 2 for additional
information.)
If the result specified for the EEXSR operation does not have the same length or decimal
positions as specified on the Library Subroutine Specifications, the result is moved
according to the rules for the Z-ADD operation described earlier in this section.

If the subroutine returns a result and columns 43–59 are blank, the result is ignored.

PARAM (Specify Parameters for EEXSR)


The PARAM operation provides a method for specifying the parameters for the preceding
EEXSR operation.

The parameters must be listed in either the order specified in the external system
procedure or the order specified in the Library Subroutine Specifications for the library
subroutine.

Parameters can be passed either by value or by reference. The external subroutine


cannot update by-value parameters, but it can update by-reference parameters. Files can
be passed only by reference.

The PARAM operation in columns 28–32 requires an entry in either the Factor 2 field
(columns 33–42) or the Result Field (columns 43–48), but not both.

If an entry is made in the Factor 2 field, the parameter is considered to be passed by


value even if the external system procedure or Library Parameter specifications specify
by reference. Factor 2 can be a field name, a vector name, a vector element, a literal, or
an indicator. Indicators are coded as *INxx, where xx is the indicator number or name.
For example, indicator L2 would be encoded as *INL2. The parameter type must match
that defined in Table 16–14. Columns 7 through 27 and 43 through 59 must be blank. For
more information, refer to the discussion of alphanumeric aliases for indicators in
Section 2, “RPG Language Elements.”

Table 16–14 shows corresponding type matches between RPG and ALGOL. See the
discussion of the Vector Parameters field (column 34) in Section 13, “Library
Specifications,” for additional information on arrays. Designator and COMS-time types
are discussed in Volume 2 of this manual.

8600 0544–103 16–55


Operation Codes

Table 16–14. Parameter Matching

RPG Type ALGOL Type

File File
Numeric literal Integer
Numeric field (length less than 12)
Numeric vector element (length less than 12)
Numeric field (length more than 11) Double integer
Numeric vector element (length more than 11)
COMS-time field Real
COMS-time vector element
Designator
Designator vector element
Alphanumeric literal EBCDIC array or pointer
Alphanumeric field
Alphanumeric vector element
Unindexed alphanumeric vector
Unindexed numeric vector (item length less than 12) Integer array
Unindexed numeric vector (item length greater than 11) Double integer array
Unindexed COMS-time vector Real array
Unindexed designator vector

If an entry is named in the Result Field, the parameter is considered to be passed by


reference. The Result Field can be a field name, a vector name, a vector element, a file,
or an indicator, and must be defined as a by-reference parameter in the external system
procedure or the Library Parameter Specifications. For files, the file name is in
columns 43 through 50,and columns 51 through 59 are blank. Otherwise, columns 49
through 59 can also be used as specified for the EEXSR operation, with the exception of
the Half Adjust field (column 53).

Note: If an input file is passed to a library subroutine and the library reads a record or
changes the logical state of the file, unpredictable errors such as duplicated records,
missing records, or misidentified matching records might occur. It is suggested that only
an output file or a demand file be passed.

When a numeric field is passed by reference, the field length and decimal positions must
match those specified on the Library Parameter Specifications. When a numeric field or
literal is passed by value, the value is scaled to match the Library Parameter
Specifications.

When an alphanumeric field is passed by reference and a length is specified, the field
length of the actual parameter must match the length in the Library Parameter
Specifications.

16–56 8600 0544–103


Operation Codes

Example
Example 16–16 shows the PARAM operation used in conjunction with the EEXSR
operation.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...
00100L*
00200LIBRARY NAME DATELIB T *SYSTEM/DATE/LIBRARY
00300L*
00400L* Library of date manipulation routine
00500L*
00600LIBRARY SUBR DATEDIF 50 DATE_DIFFERENCE
00700L*
00800L* Returns the number of days between two Gregorian dates
00900L*
01000LIBRARY PARAM<begin> 60V
01100LIBRARY PARAM<end> 60V
01200L*
01300L*
01400LIBRARY SUBR DATELIT DATE_LITERAL
01500L*
01600L* Turns Gregorian date into "MMMMMMMMM DD, YYYY"
01700L*
01800LIBRARY PARAMGREGORIAN 60V
01900LIBRARY PARAM LITDATE 18 *
02000C*
02100C 10 EEXSRDATEDIF DAYS 50 202122
02200C PARAMFMDATE
02300C PARAMTODATE
02350C*
02400C* Additional Calculation Specifications coding
02450C*
02500C 10 EEXSRDATELIT
02600C PARAMFMDATE
02700C PARAM FMDLIT 1802750C*
02800C* Additional Calculation Specifications coding
02850C*
02900C 10 EEXSRDATELIT
03000C PARAMTODATE
03100C PARAM TODLIT 18
04000O*
04100OPRINTOUTD 1 10
04200O 4 'FROM'
04300O FMDLIT 23
04400O 26 'TO'
04500O TODLIT 45
04600O 48 'IS'
04700O 20 DAYS Z 54
04800O 20 59 'DAYS'
04900O 21 58 'BACKWARDS'
05000O 22 56 'NOTHING'

Example 16–16. PARAM Operation

8600 0544–103 16–57


Operation Codes

I/O Operations
Within the normal PLC, a record is read, calculations are performed (using the data from
the input record just read), and an output record is written. The CHAIN, DELET, DSPLY,
EXCPT, READ, RECV, SEND, READE, and READP operation codes enable greater control
over I/O by providing the capability to read and write records at times other than those
normally available as part of the RPG program cycle. The CLOSE operation code ends
processing of a file. The FORCE and SETLL operation codes permit some programmatic
control over the selection of records for processing. These operations are described in
the following paragraphs.

CHAIN (Access Data File)


The CHAIN operation provides a way to read

• A sequential or direct disk file, randomly by relative number


• An indexed disk file, randomly by key
The CHAIN operation can be used on any disk file designated in the File Specifications as
a demand, chained, or full-procedural file. The CHAIN operation can be specified
anywhere in the Calculation Specifications.

The CHAIN operation in columns 28–32 requires the following:

• The Factor 1 field (columns 18–27) must contain a relative record number or a key
field that is used to select the desired record.
• The Factor 2 field (columns 33–42) must contain the name of the disk file.
When the CHAIN operation is used with an indexed file and the length of Factor 1 is less
than the length of the key, the system pads Factor 1 with zeros or blanks. This padding
can cause found conditions to occur unexpectedly.

When the CHAIN operation is used with an alternate index file that has a noncontiguous
key, the entire key must be specified in Factor 1. It is recommended that a data structure
be used to specify the key. Refer to Section 4, “Disk Files,” for more information.

When the CHAIN operation is specified, the following fields must be blank:

• Field Length (columns 49–51)


• Decimal Positions (column 52)
• Half Adjust (column 53)
• Equal Resulting Indicator (columns 58–59)

16–58 8600 0544–103


Operation Codes

When the CHAIN operation is specified, optional entries are allowed in the following
fields:

• Control Level (columns 7–8)


• Indicators (columns 9–17)
• Result Field (columns 43–48)
When the CHAIN operation is used with an indexed file, a name in this field specifies
the name of the key through which the CHAIN operation is performed. The name
must be defined in the Index Name field (columns 47–52) in the File Specifications
for this file. A blank entry implies that the key, which is not necessarily the primary
key, is specified on the first File Specifications for this file.
• High Resulting Indicator (columns 54–55)
If no record is found, an indicator in columns 54 through 55 is turned on. If
columns 54 and 55 are blank, a KEY NOT FOUND error message is displayed. Refer
to the list of error messages in Appendix A, “System Messages.” The record area
and current record pointer remain unchanged when there is an error.
• Low Resulting Indicator (columns 56–57)
If no record is found, an indicator in columns 56 through 57 is turned on. If
columns 56 and 57 are blank, a KEY NOT FOUND error message is displayed. Refer
to the list of error messages in Appendix A, “System Messages.” The record area
and current record pointer remain unchanged when there is an error.
If an entry is present in this field, this indicator must be the same as the high
resulting indicator. If the low resulting indicator is not the same as the high resulting
indicator, a warning is issued, and the low resulting indicator field is assumed to be
blank.
If the chained file is conditioned by an external indicator, the CHAIN operation should be
conditioned by the same external indicator.

The CHAIN operation can be performed on an output file when a direct file is created.
Additional information on processing disk files and using the CHAIN operation is provided
in Section 4, “Disk Files.”

Indexed Files
When an indexed file is processed with the CHAIN operation, the value of the data
specified in the Factor 1 field is compared against the index to locate the data record for
which the key field contains the same value as does Factor 1. Record identifying
indicators and field indicators are assigned appropriate values.

If the key field of the data record available for processing does not equal the key value
specified in the Factor 1 field, a RECORD KEY MISMATCH error message is displayed. If
an equal condition is not found, the high indicator (columns 54–55) is turned on. If no high
resulting indicator is specified, a KEY NOT FOUND error message occurs. Refer to the
list of error messages in Appendix A, “System Messages,” for more information.

8600 0544–103 16–59


Operation Codes

If the indexed or alternate index file named in the Factor 2 field was defined in the File
Specifications with the letter P, N, or J in the Record-Address Type field (column 31),
then Factor 1 must be numeric. If the file was described by an A or a K in the Record-
Address Type field, then Factor 1 can be either alphanumeric or numeric. Even if Factor 1
is numeric, the comparison is done in alphanumeric mode.

Signs are never ignored. Conversion of a numeric field to an alphanumeric key causes
the sign to be stored by default in the leftmost zone of the key. Refer to Section 21,
“Control of the Compilation Process,” for information about using the $RSIGN compiler
control option to change the default location where the sign is stored. Positive and
negative signs are represented by F (hex) and D (hex), respectively.

Example
Example 16–17 shows coding for chained indexed files.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...
00200F*
00300FINPUT IPE 80 80 DISK
00400FINDEXED IC 80 80 4AI 5 DISK
00700FFILEOUT O 132 132 PRINTER
01100IINPUT AA 01
01200I 1 50INXKEY
01300IINDEXED BB 02
01400I 5 90IKEY
01500I 15 240FIELD1
01600C INXKEY CHAININDEXED 99
01900OFILEOUT D 01 02
02000O FIELD1 20

Example 16–17. Chained Indexed Files

Direct and Sequential Files


When the CHAIN operation is used with direct and sequential files, the value of the data
specified in the Factor 1 field must be a numeric integer (literal or field name) between 1
and n, where n is less than or equal to the total number of records in the file. This
numeric integer is used as a relative record number to select the desired record.

If the key (numeric integer) is within the bounds of the file, the record is found. If the key
is beyond the bounds of the file, the high resulting indicator specified in columns 54
through 55 is turned on; if no such indicator is specified, a KEY NOT FOUND error
message is displayed and the record area and current record pointer are unchanged.
Refer to Appendix A, “System Messages,” for more information.

16–60 8600 0544–103


Operation Codes

Example
Example 16–18 provides an example of using the CHAIN operation with sequential files.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...
00200F*
00300FINPUT IPE 80 80 DISK
00400FSEQ IC 80 80 DISK
00500FFILEOUT O 132 132 PRINTER
00600IINPUT AA 01
00700I 1 50RCDNUM
00800ISEQ BB 02
00900I 5 90DKEY
01000I 15 240FIELD1
01100C RCDNUM CHAINSEQ
01200OFILEOUT D 02
01300O FIELD1 20

Example 16–18. Chained Sequential Files

CLOSE (Close File for Processing)


The CLOSE operation ends processing of the file specified in the Factor 2 field
(columns 33–42). The close disposition of the file can be specified.

The Factor 1 field (columns 18–27) must be blank. The Factor 2 field requires a file name,
and the Result Field (columns 43–48) can be blank or can contain a CLOSE option value.

The Result Field can contain one of the following CLOSE option values:

CLOSE Description
Option

CRUNCH Used for disk files only. The option returns the unused portion of the
last row of disk space (beyond the end of file indicator) to the system.
The file cannot be expanded but can be written inside the end of file
limit.
NOWAIT Used for files in which the Device field (columns 40–46) of the File
Specifications contains the entry PORT. For additional information
about the PORT entry, refer to the File Attributes Reference Manual.
Used on tape files or disk files.
LOCK This option rewinds tape files. The system displays a message as a
reminder that the reel must be saved. The tape unit remains locked
until it is readied manually.
The LOCK option retains a disk file as a permanent file on disk, and the
program returns the buffer storage to the system.
continued

8600 0544–103 16–61


Operation Codes

CLOSE Description
Option

PURGE Removes the file name from the directory, and the program returns the
space occupied by the file to the system.
REEL Used for multireel tape files, primarily direct tape files, for which the
system does not automatically perform reel switching. After the current
reel is closed, the next reel is opened.
REWIND Used on tape files or disk files.
When a tape file is used, the file is rewound.
The REWIND option resets the record pointer of a disk file to the first
record of the file. The buffer storage is returned to the system. The I/O
unit remains under program control.
NORWND Used with tape files. It prevents the tape from rewinding during the
CLOSE operation.

When no CLOSE option is specified, the CLOSE operation closes the file according to the
type of file.

Following is a list of file types and the means by which they are closed when no CLOSE
option is specified:

• Card output file. A card containing an ending label is punched. The file must be
labeled.
• Line printer file. The printer is skipped to channel 1, an ending label is printed, and
the printer is again skipped to channel 1. The file must be labeled.
• Unlabeled tape output file. A double tape mark is written after the last block on the
tape, and the tape is rewound.
• Disk file. If the file is a temporary file, the disk space is returned to the system.
An error indicator can be specified in columns 58 through 59. If this indicator is specified
and an error occurs in the operation, the indicator turns on and the program retains
programmatic control. If the indicator is not specified and an error occurs, the operating
system discontinues the program.

Example
Example 16–19 shows the CLOSE operation. It is assumed that the file MYFILE has
been declared in the program as a disk file and is open when the CLOSE operation is
executed.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...
00100C*
00200C CLOSEMYFILE CRUNCH
00300C CLOSEMYFILE
00400C CLOSEMYFILE REWIND

Example 16–19. CLOSE Operation

16–62 8600 0544–103


Operation Codes

DELET (Delete a Record)


The DELET operation deletes a record from an indexed file. When a record is deleted
from a file, the contents of the record cannot be read.

The Factor 1 field (columns 18–27) can contain a field name, a vector element, a table
name, or a literal representing the value of the key of the record to be deleted. If the
Factor 1 field is blank, the current record of the file named in the Factor 2 field
(columns 33–42) is deleted from the file. If the Factor 1 field is blank and no current
record is present, or if the key value specified does not exist in the file, a DELETE
ERROR message is displayed. Refer to Appendix A, “System Messages,” for a list of
error messages.

If the length of Factor 1 is less than the length of the key, the system pads Factor 1 with
zeros or blanks. This padding can cause found conditions to occur unexpectedly.

The Operation field (columns 28–32) must contain a DELET operation. The Factor 2 field
(columns 33–42) must contain the name of a file designated as a chained, demand, or
full-procedural disk file. This file must be an indexed file, as indicated by the letter I in the
File Organization Type field (column 32) of the File Specifications. The file must not be an
output file, and it cannot be processed by record address. The file does not need to be
specified as delete-capable in the File Addition/Unordered field (column 66) of the File
Specifications.

The Result Field (columns 43–48) can contain the name of the key as defined in the File
Specifications for the file named in the Factor 2 field. If the Result Field is blank, the
default key is the key specified in the File Specifications. The Result Field must be blank
to delete a record from an alternate index file. Additional information on alternate index
files is provided in Section 4, “Disk Files.” If the key is one for which duplicates are
allowed, the first entry encountered is deleted. The Result Field can contain an entry only
when the Factor 1 field (columns 18–27) contains an entry.

Columns 54 and 55 of the Resulting Indicators field (columns 54–59) can contain an
indicator that is turned on if the record deletion cannot be performed or turned off if the
record deletion was successful. If no indicator is specified and no key match is found, a
DELETE ERROR message is displayed. Additional information is provided in Appendix A,
“System Messages.”

If the key named in the Result Field was defined in the File Specifications with the letters
P, N, or J in column 31, then Factor 1 must be numeric. If the key was defined by an A or
a K in column 31, then Factor 1 can be either alphanumeric or numeric. Even if Factor 1 is
numeric, the comparison is done in alphanumeric mode.

If an external indicator conditions the file from which a record is to be deleted, that
indicator should also condition the DELET operation.

The DELET operation does not affect the current record pointer. Refer to Section 4,
“Disk Files,” for more information on deleting records from a file.

8600 0544–103 16–63


Operation Codes

DSPLY (Display Data)


This operation causes data to be displayed.

The file name must be entered in the Factor 2 field (columns 33–42). The Half Adjust
(column 53) and Resulting Indicators (columns 54–59) fields must be blank. The Control
Level (columns 7–8) and Indicators (columns 9–17) fields can be assigned.

The Factor 1 field (columns 18–27) is optional and can be used either to name a data item
or to specify a numeric or alphanumeric literal. A data item can be a field name, a vector
element, or an unindexed array. An unindexed table name cannot be used.

The Result Field (columns 43–48) is optional. It is used to specify the name of a data item
(a field name, a vector element, or an unindexed array). If both the Factor 1 field and the
Result Field are blank, a syntax error message is generated. The record length of Factor 1
and the Result Field must not exceed the record length of the file named in Factor 2. The
record length is entered in the Record Length field (columns 24–27) of the File
Specifications.

The DSPLY operation functions in the following manner:

• Any data item or literal specified by the Factor 1 field is displayed.


• If the Result Field is blank, the program continues with the next operation; otherwise,
both of the following occur:
− The data item specified by the Result Field is displayed.
− The program waits for input from the operator.
• If an array is specified without an index in the Factor 1 field or the Result Field, every
element of the array is displayed with one element on each line. If the Result Field
contains an unindexed array, the program waits for input between each array
element.
Data being entered must be in 8-bit character fields and left-justified. Any excess
characters on the right side are truncated. Plus (+) and minus (–) signs are allowed.

16–64 8600 0544–103


Operation Codes

Example
Example 16–20 shows the coding for the DSPLY operation.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...
00100F*
00200FFILEIN IP 80 80 DISK
00300FSCT D 80 80 ODT
00400FFILEOUT O 132 132 PRINTER
00500I*
00600IFILEIN AA 01
00700I 5 100FIELD1
00800I 22 292FIELD2
00900I 35 442FIELD3
01000C*
01100C 01 FIELD1 ADD FIELD2 TOTAL 102
01200C 01 TOTAL COMP FIELD3 102030
01300C 10 'HIGH' DSPLYSCT
01400C 20 'LOW' DSPLYSCT
01500C 30 TOTAL DSPLYSCT FIELD3
01600O*
01700OFILEOUT D 01
01800O TOTAL 20

Example 16–20. DSPLY Operations

EXCPT (Write Exception Output)


This operation enables exception records to be written during calculations.

The Operation field (columns 28–32) must contain the entry EXCPT. Factor 1
(columns 18–27), the Result Field (columns 43–48), the Result Length field
(columns 49–51), and the Decimal Positions field (column 52) must be blank.

The Factor 2 field (columns 33–42) can be blank or can contain an entry for the file name
or output group name. If Factor 2 is blank, all lines in the Output Specifications with an E
entry in the Type field (column 15) but no entry in the Field Name field (columns 32–37)
are processed every time the EXCPT operation is executed, depending on output
conditioning indicators.

If Factor 2 contains a file name, only the exception output for that file is processed. The
exception records, however, are not produced for Output Specifications record
description lines that contain an output group name. The file must have output
capabilities.

If Factor 2 contains an output group name, all exception records on the Output
Specifications with this output group name in the Field Name field (columns 32–37) in the
Output Specifications are processed, depending on output conditioning indicators.
Example 16–19 shows a program that contains all three types of exception output.

8600 0544–103 16–65


Operation Codes

Resulting indicators can be specified only for data communications and port files. The
indicator meanings are as follows:

• The high resulting indicator (columns 54–55) is turned on when a transmission error
occurs. If no indicator is specified and a transmission error occurs, the program ends
abnormally.
• The low resulting indicator (columns 56–57) is turned on when a file full condition
occurs. If no indicator is specified, the program waits until the message is accepted.
• The equal resulting indicator (columns 58–59) is turned on when an EOF condition
occurs.
Example
Example 16–21 writes to two files, RMT and PRINT. The program writes FIRST LINE OF
REMOTE and SECOND LINE OF REMOTE to RMT. The program writes FIRST LINE OF
PRINT, SECOND LINE OF PRINT, and THIRD LINE OF PRINT to the file named PRINT.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...
00100F*
00200FDUMMY IP DISK
00300FPRINT O PRINTER
00400FRMT O REMOTE0
0050I*
00600I*
00700IDUMMY AA 01
00800I*
00900C*
01000C* Perform exception output to a printer file.
01100C*
01200C EXCPTPRINT
01300C*
01400C* Perform exception output using output group names.
01500C*
01600C EXCPTNAME2
01700C EXCPTWORD
01800C*
01900C* Output using SEND and output group names.
02000C*
02100C SEND REMOTE
02200C*
02300O*
02400O* Exception output to a file.
02500O*
02600OPRINT E
02700O 19 'FIRST LINE OF PRINT'
02800O*
02900O* Exception output with output group names.
03000O*

Example 16–21. EXCPT Operation (cont.)

16–66 8600 0544–103


Operation Codes

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...
03100OPRINT E WORD
03200O 19 'THIRD LINE OF PRINT'
03300ORMT E REMOTE
03400O 21 'SECOND LINE OF REMOTE'
03500OPRINT E NAME2
03600O 20 'SECOND LINE OF PRINT'
03700ORMT E NAME2
03800O 20 'FIRST LINE OF REMOTE'
03900O*

Example 16–21. EXCPT Operation

FORCE (Select Record)


This operation enables programmatic selection of the file from which the next record is
taken for processing and overrides the normal record-selection process that occurs
during input. The FORCE operation selects the file that supplies the next record for
processing. No records are actually read during these calculations.

This operation can apply only to input, update, or combined files designated as primary or
secondary. The Factor 2 field (columns 33–42) contains the name of the file to be forced;
all other fields except the Indicators field (columns 9–17) must be blank. This operation
cannot occur during total calculations and should not occur within a subroutine called
from total calculations.

The MR indicator is always off while a forced record is being processed, and the program
treats the record as if it had no match fields specified.

Care should be taken in specifying more than one FORCE operation during the same
program cycle. If more than one FORCE operation occurs, only the last one affects
record selection, and all others are ignored. If the forced file has an EOF condition,
normal record selection determines the next record to be processed.

READ (Read Sequentially)


This operation retrieves the next record from a file. The file must be designated in the
File Specifications as a demand, chained, or full-procedural file. This operation differs
from the CHAIN operation in that the CHAIN operation enables random access, while the
READ operation processes consecutively. The READ operation differs from the FORCE
operation in that the FORCE operation selects the record to be accessed during the next
cycle, while the READ operation selects a record to be accessed during the current
cycle.

The Factor 2 field (columns 33–42) contains the name of the file to be read. The READ
operation can be conditioned by the Control Level (columns 7–8) and Indicators
(columns 9–17) fields. Factor 1 (columns 18–27) and columns 43 through 53 must be
blank. An indicator should be specified in columns 58 and 59; if not, an EOF condition on
the READ operation causes a READ AT END OF FILE error message to be displayed.

8600 0544–103 16–67


Operation Codes

Refer to the list of error messages in Appendix A, “System Messages.” If EOF is


reached and an indicator is specified, that indicator is turned on. Any subsequent
attempts to use the READ operation for the same file cause that indicator to turn on.

When the READ operation is used to read an indexed file, the key used to define the
sequence of records to be followed is the key used by the previous successful READ or
CHAIN operation. If no successful READ or CHAIN operation has been performed, the
key used is the one defined in the File Specifications. The READ operation provides the
next record in sequence, using that key.

The following rules must be observed when the READ operation is used:

• Only demand and full-procedural files designated as input, update, or combined, or


chained indexed files designated as input or update can be read by the READ
operation.
• Sequence checking in the Input Specifications is not allowed.
• Control levels, matching fields, and look-ahead fields are not allowed.
• If the file is conditioned by an external indicator (U1–U8) that is not turned on, the
READ operation is ignored; the EOF indicator in columns 58 and 59 does not turn on.
• An indicator can be specified in columns 54 and 55 for a data communications file.
When specified, this indicator overrides the use of the Error Indicator field
(columns 53–54) of the Telecommunications Specifications.

READE (Read Equal Key)


The READE operation returns the next sequential record from an EFS disk file if the
record key is equal to the key specified in the operation. The file must be an EFS
indexed, full-procedural disk file.

The READE operation is typically used to read the duplicate records of an indexed file
after the initial record has been accessed. For example, if a CHAIN or READ operation
accesses the first in a series of duplicate records, the READE operation can then be used
to determine if duplicates exist and, if so, retrieve them.

If a READE operation is unsuccessful, the file must be repositioned with a CHAIN or


SETLL operation. If the file is not repositioned, all subsequent READ, READE, and
READP operations fail.

The Factor 1 field (columns 18–27) specifies the key of the record to be retrieved. Factor
1 must be the same type and length as the key specified for the file in the File
Specifications. Factor 1 can be a field name, a vector element, or a literal.

The Factor 2 field (columns 33–42) contains the name of the indexed full-procedural file
that is to be read.

Columns 58 and 59 must contain an indicator. The specified indicator is turned on if the
next record key is not equivalent to the key in Factor 1 or if an EOF condition is reached.

16–68 8600 0544–103


Operation Codes

READP (Read Previous Record)


The READP operation reads the previous record from an EFS file. The READP operation
performs the inverse of the READ operation. If, for example, record N was just read from
a file, the READP operation reads the record before record N.

If the file is delete-capable, the READP operation skips all deleted records until a
nondeleted record is found or the beginning of the file is encountered.

If a READP operation is unsuccessful, the file must be repositioned with a CHAIN or


SETLL operation. If the file is not repositioned, all subsequent READ, READE, and
READP operations will fail.

The Factor 2 field (columns 33–42) must specify the name of the file to be read. This file
must be a full-procedural file, as indicated by an F in the File Designation field (column 16)
of the File Specifications.

Columns 58 and 59 must contain an indicator. The specified indicator is cleared before
each READP operation and is turned on when the beginning of the file has been reached.

RECV (Read Remote File Record)


The RECV operation on a remote file causes the next record in the file to be read
immediately. The remote file must be a demand file.

The Factor 2 field (columns 33–42) contains the name of the remote file to be read. The
RECV operation can be conditioned by the Control Level (columns 7–8) and Indicators
(columns 9–17) fields. The Factor 1 (columns 18–27), Result Field (columns 43–48), Field
Length (columns 49–51), and Decimal Positions (column 52) fields must be blank.

An indicator in columns 54–55 overrides the Error Indicator field (columns 53–54) of the
Telecommunications Specifications.

An indicator in columns 58–59 is turned on when an EOF condition occurs. If no indicator


is specified, a READ AT END OF FILE error message is displayed. Refer to Appendix A,
“System Messages,” for additional information.

The RECV operation is also used to receive messages through COMS. Refer to the
discussion of COMS in Volume 2 of this manual for more information.

SEND (Send Remote File Record)


The SEND operation writes records or messages to a remote file during calculations.

The Operation field (columns 28–32) must contain SEND as an entry. The Factor 1
(columns 18–27), Result Field (columns 43–48), Field Length (columns 49–51), and
Decimal Positions (column 52) fields must be blank.

8600 0544–103 16–69


Operation Codes

Factor 2 (columns 33–42) can contain either an output group name or the name of the
remote file to which the message is sent. If Factor 2 contains a remote file name, the
output for that file is processed. Records are not processed for record description lines in
the Output Specifications that contain an output group name. If Factor 2 is an output
group name, all Output Specifications records with the specified output group name are
processed, depending on output conditioning indicators.

The SEND operation is similar to the EXCPT operation. It enables the same indicators in
columns 54 through 59.

Indicators are allowed as follows:

• The high resulting indicator (columns 54–55) is turned on when a transmission error
occurs. If no indicator is specified and a transmission error occurs, the program ends
abnormally.
• The low resulting indicator (columns 56–57) is turned on when a file-full condition
occurs. If no indicator is specified, the program waits until the message is accepted.
• The low resulting indicator (columns 58–59) is turned on when an EOF condition
occurs.
The Remote Station Identification field (columns 41–47) of the Telecommunications
Specifications is used to identify the location of the remote file. Additional information on
this specification is provided in Section 12, “Telecommunications Specifications.”

The length of a message sent to a remote file is specified by using the Message Length
field (columns 64–70) of the Telecommunications Specifications. Additional information
on this specification is provided in Section 12, “Telecommunications Specifications.”

The SEND operation is also used to send messages through COMS. Refer to the
discussion of COMS in Volume 2 of this manual.

SETLL (Set Lower Limit)


The SETLL operation sets the lower key limit for an indexed file processed consecutively
using the READ operation. The next record read has a key equal to the lower key limit or,
if a match does not exist, has a key next in sequence. Successive records are read in
ascending key sequence until either an EOF condition or another SETLL operation
occurs.

The Factor 1 field (columns 18–27) must contain a field name, a vector element, a table
name, or a literal representing the value of the lower limit being set. A whole array is not
allowed. The type (alphanumeric or numeric) of Factor 1 must be the same as the type of
the key for the file named as Factor 2.

If the length of Factor 1 is less than the length of the key, the system pads Factor 1 with
zeros or blanks. This padding can cause found conditions to occur unexpectedly.

The Factor 2 field (columns 33–42) contains the name of the file for which the lower limit
is specified. This file must be specified in the File Specifications as an indexed, demand,
or full-procedural file processed within limits either as a chained, indexed input, or update

16–70 8600 0544–103


Operation Codes

file. The file must not occur in the Extension Specifications; that is, no record-address file
can be associated with this file. The Result Field (columns 43–48) can contain the name
of the key field to which the SETLL operation pertains. This name must have been
defined in the File Specifications of the file named in the Factor 2 field. If this entry is
blank, the key used is the key defined on the first File Specifications for this file, which is
not necessarily the primary key.

Columns 49 through 59 must be blank. The SETLL operation can be conditioned by the
Control Level (columns 7–8) and Indicators (columns 9–17) fields.

Additional information on the SETLL operation is provided in Section 4, “Disk Files.”

Other Operations
The operations that follow do not share a function similar to that of another operation.
Included are the DEBUG, DEFN, DUMP, LOKUP, SORTA, TIME, and ZIP operations.

DEBUG (Debug Program)


DEBUG is a special-purpose operation that simplifies the location and correction of errors
in an RPG program.

The DEBUG operation can be used at any point in the Calculation Specifications to aid the
programmer in finding errors in program logic. Records containing information about the
status of indicators and field contents are written to an assigned output device.

DEBUG operations are compiled into the object program if the Debug field (column 15) in
the Control Specification contains the value 1, or if the $USERDEBUG compiler control
option is TRUE. All DEBUG operations are checked for syntax during compilation.

A file name must be specified in the Factor 2 field (columns 33–42). All DEBUG output
must go to the same file. The file named must be defined as a sequential output file in
the File Specifications.

The Factor 1 field (columns 18–27) is optional and can contain a literal or a field name that
identifies the particular DEBUG operation being executed. Factor 1 must not be an entire
array, and the size of the field must not exceed 8 characters or digits. The literal or the
value of the designated field is written as part of the output records. DEBUG can be
conditioned by indicators in the Control Level field (columns 7–8) and Indicators field
(columns 9–17). Columns 49 through 59 must be blank.

The Result Field (columns 43–48) is optional; however, if specified, it must be a field, a
vector, or a vector element.

One or more records are written as output from every DEBUG operation. The first record
is always written; the second and subsequent records are written only if the Result Field
(columns 43–48) contains an entry.

8600 0544–103 16–71


Operation Codes

The first output record contains the DEBUG followed by

• The contents of the Factor 1 field, if specified


• The words INDICATORS ON and a list of all indicators that are currently on in the
program
This record can extend to as many subsequent records as needed to list all indicators.
Following this output, subsequent records appear if the Result Field contains an entry.
These records contain the name of the item referred to in the Result Field, followed by
the entire contents of the record. This list of contents takes up as many records as
necessary.

If a vector element is referred to in the Result Field, the DEBUG output lists the vector
name, its subscript, and its contents. If the Result Field contains an unsubscripted array
name, each element of the array is listed, with each array element and its subscript
beginning a new record. If the Result Field contains an unsubscripted table name, the
contents of the hold area of the table are listed.

Example
Example 16–22 shows DEBUG operation coding.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...
00100H*
00200H 1
00300FFILEIN IP 80 80 DISK
00400FPRINT1 O 132 132 PRINTER
00600IFILEIN AA 01
00700I 5 100FIELD1
00800I 22 292FIELD2
00900I 35 442FIELD3
01000C 01 FIELD1 ADD FIELD2 TOTAL 102
01100C 01 TOTAL COMP FIELD3 101020
01200C 01 '1' DEBUGPRINT1 FIELD3
01500OPRINT1 D 20
01600O TOTAL 20

Example 16–22. DEBUG Operation

DEFN (Define a New Field)


The DEFN operation defines a new field based on an existing field. The new field is
assigned the same type (alphanumeric or numeric) and format as the existing field. The
length of the new field defaults to the length of the existing field, but can be altered with
an entry in the Field Length field (columns 49–51).

16–72 8600 0544–103


Operation Codes

Field definitions for the DEFN operation are defined in the following list:

• The Control Level field (columns 7–8) contains L0 through L9, LR, or SR.
• The Indicators field (columns 9–17) must be blank.
• The Factor 1 field (columns 18–27) contains the optional prefix *LIKE.
• The Operation field (columns 28–32) contains the operation code DEFN.
• The Factor 2 field (columns 33–42) contains the name of a field, a vector, or a vector
element. The characteristics of this field determine the characteristics of the field
defined in the Result Field. If the entries of this field and the Result Field have
already been defined, they must match. If the fields are not identical, an error
message is displayed.
• The Result Field (columns 43–48) can contain the name of a field, a data structure, or
a data structure subfield. It cannot contain a vector or vector element. The Result
Field is defined by the field named in Factor 2. If Factor 2 has type alphanumeric or
numeric, the Result Field has the same type. If Factor 2 is a vector or vector
element, the Result Field has the characteristics of the vector or vector element.
• The Field Length field (columns 49–51) can contain a plus sign (+) in column 49 to
indicate that the new entry is longer than the entry in the Factor 2 field. A minus
sign (–) in column 49 indicates that the entry in the new field is shorter than the entry
in the Factor 2 field. Columns 50 and 51 contain a numeric value that indicates the
amount of increase or decrease in the length of the new field. Single-digit numbers
must be right-justified.
If columns 49 through 51 are blank, the entry in the Result Field is defined with the
same length as that of the entry in the Factor 2 field.
• The Decimal Positions field (column 52) must be blank. The number of decimal
positions is taken from the identifier in the Factor 2 field.
• The Half Adjust field (column 53) must be blank.
• The Resulting Indicators field (columns 54–59) must be blank.

Example
Example 16–23 shows the DEFN operation. ALPH1 is a 10-character alphanumeric field,
NUM1 is a 6-digit numeric field with 3 decimal places, and ARY1 is a 10-element
alphanumeric array with elements that are 5 characters in length.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...
00100C*
00200C* FD1 is defined as a 12-digit alphanumeric field.
00300C*
00400C *LIKE DEFN ALPH1 FD1 + 2
00500C*
00600C* FD2 is defined as a 16-digit numeric field with

Example 16–23. DEFN Operation (cont.)

8600 0544–103 16–73


Operation Codes

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...
00700C* 3 decimal positions.
00800C*
00900C *LIKE DEFN NUM1 FD2 +10
01000C*
01100C* FD3 is defined as a 2-character alphanumeric field.
01200C*
01300C *LIKE DEFN ARY1,2 FD3 - 3
01400C*
01500C* FD4 is defined as a 12-digit numeric field with
01600C* 3 decimal positions.
01700C*
01800C DEFN FD2 FD4 - 4
01900C*
02000C* FD5 is defined as a 25-character alphanumeric field.
02100C*
02200C *LIKE DEFN ARY1 FD5 +20
02300C*
02400C* FD6 is defined as a 6-digit numeric field with
02500C* 3 decimal positions.
02600C*
02800C *LIKE DEFN NUM1 FD6

Example 16–23. DEFN Operation

DUMP (Perform Symbolic Dump)


A symbolic dump is a shorter and simpler version of a program dump.

The following information is contained in a symbolic dump:

• The machine type on which the program was running.


• The name of the program.
• The program history, including the sequence number of the record at which the
dump occurred and the sequence numbers of calling subroutines.
• A list of program indicators that are on.
• The fields, vectors, and files of the program, listed in alphabetical order. Also included
are descriptions and values for each of those program elements, in readable format.
There are three ways of producing a symbolic dump: using the DUMP operation,
responding to a halt, and compiling with OPTIONS assigned.

A symbolic dump is produced when the code file accesses the RPGSUPPORT library. A
symbolic dump is not produced if the RPGSUPPORT library has not been initialized at the
point the dump is requested. The two most likely causes for the library not to be ready
are

16–74 8600 0544–103


Operation Codes

• The symbolic dump is requested during the typically short interval after a new
RPGSUPPORT library is established with the Support Library (SL) system command.
• The symbolic dump is requested during a time that an RPG program is using a
function from the RPGSUPPORT library.
If the RPGSUPPORT library cannot be used, the following message is displayed and the
program is ended:

CANNOT LINK TO RPGSUPPORT LIBRARY

DUMP Operation
The DUMP operation produces a symbolic dump at a given point in the execution of the
program.

Field definitions for the DUMP operation are defined as follows:

• The Factor 1 field (columns 18–27), the Result Field (columns 43–48), and
columns 49 through 59 must be blank.
• The Operation field must contain DUMP as an entry.
• The Factor 2 field (columns 33–42) can be blank or can contain the name of an output
file. If an output file name is specified in Factor 2, the file must have a record size of
at least 80 bytes. If Factor 2 is blank, the dump writes to the TASKFILE of the
program. The TASKFILE is a printer file associated with every program. The system
also uses the TASKFILE to write nonsymbolic dump data.

Symbolic Dump after a Program Halt


When a program halt takes place, the user can choose one of several options. Choosing
the DUMP operation causes a symbolic dump to occur. For example, if the program halts
because the user attempts to divide by zero, the following message is displayed:

#<mix no>DIVIDE BY ZERO: <seq no>: AX GO OR STOP OR DUMP

If the user enters the following, a symbolic dump occurs:

?<mix no> AX DUMP

Then the following message appears:

#<mix no> (DUMP DONE) : AX GO OR STOP

Symbolic dumps produced as a result of program halts are written to the TASKFILE. The
TASKFILE is a printer file associated with every program.

8600 0544–103 16–75


Operation Codes

Symbolic Dump during a Compilation or Program Run


If a program ends abnormally, the OPTIONS task attribute indicates whether a program
dump is to be produced and, if so, the information to be included in the dump.

A program dump and an RPG symbolic dump are made available by setting the OPTIONS
attribute. Additional information on program dumps is provided in the Task Attributes
Reference Manual.

A symbolic dump is produced if the OPTIONS task attribute is specified and if either of
the following occurs:

• The DSED option is TRUE and the program ends abnormally because the operator
ends the program.
• The FAULT option is TRUE and the program ends abnormally for any reason other
than operator termination. For example, the program can be ended by the hardware,
system software, or application software. This situation does not include halt
conditions.
Data contained in the symbolic dump appear after program dump information is
presented.

Example 1
The following statement runs a program from CANDE, assigning both the DSED and
FAULT options. A symbolic dump is produced if the program ends abnormally or the
program is ended by the operator.

RUN TESTDUMP;OPTIONS = FAULT,DSED

Example 2
The following statement runs a program from CANDE, assigning only the FAULT option.
A symbolic dump is produced if the program ends abnormally, but is not produced if the
program is ended by the operator.

RUN TESTDUMP;OPTIONS = FAULT

LOKUP (Look Up Vector Entry)


This operation searches a vector for a particular data item. The vector name is entered in
the Factor 2 field (columns 33–42), and the data item sought (the search word) is entered
in the Factor 1 field (columns 18–27).

The search word is the data item for which a match is sought in the vector named in the
Factor 2 field. The search word can be an alphanumeric or numeric literal, a field name, a
vector element, or a table name. If the search word is a table name, it refers to only the
current contents of the hold area for that table. The search word must be the same
length and type as the length and type of the vector being searched. No decimal
alignment is performed.

16–76 8600 0544–103


Operation Codes

The Result Field (columns 43–48) is used only if two vectors are specified in the LOKUP.
When used, the Result Field must contain a table name. (Refer to the discussion of a
two-vector LOKUP operation later in this section.)

The Resulting Indicators field (columns 54–59) must be used with the LOKUP operation
to specify the type of search to be performed.

Resulting indicators are used in the following ways:

• When a high resulting indicator (columns 54–55) is specified, the vector is searched
for the item immediately higher than the search word.
• When a low resulting indicator (columns 56–57) is specified, the vector is searched
for the item immediately lower than the search word.
• When an equal resulting indicator (columns 58–59) is specified, the vector is
searched, starting from the first entry for an item equal to the search word.
Example
Example 16–24 shows LOKUP operations. ARY1 is searched for an element with a value
equal to the contents of FIELD1. Indicator 10 turns on if the LOKUP operation is
successful.

The second LOKUP operation is a two-vector LOKUP operation. ARY2 is searched for an
element with a value immediately higher than the value of FIELD2. If the LOKUP
operation is successful, indicator 20 is turned on and the hold pointer for the table is set
to be the corresponding element from TABLE.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...
00200F*
00300FFILEIN IP 80 80 DISK
00400FFILE1 IT 80 80 DISK
00500FFILE2 IT 80 80 DISK
00600FFILE3 IT 80 80 DISK
00700FFILEOUT O 132 132 PRINTER
00800E FILE1 ARY1 1 5 5 0
00900E FILE2 ARY2 1 4 5 0A
01000E FILE3 TABLE 1 4 3 00
1100IFILEIN AA 01 1 CA
01200I 6 100FIELD1
01300I 16 200FIELD2
01400C*
01500C* LOOKUP OPERATION:
01600C*
01700C FIELD1 LOKUPARY1 10
01800C FIELD2 LOKUPARY2 TABLE 20
01900OFILEOUT D 01
02000O FIELD1 10
02100O FIELD2 20

Example 16–24. LOKUP Operations

8600 0544–103 16–77


Operation Codes

Rules for LOKUP Operation


The following rules must be observed when resulting indicators are assigned to a LOKUP
operation:

• Only two conditions can be tested, but at least one is required.


• If two resulting indicators are assigned, one must be assigned to EQUAL. The
program then searches for an item that satisfies either condition. The equal condition
is given precedence; the nearest lower or higher entry satisfies the search only if no
EQUAL entry is found.
• Any search for a condition other than equal (low, high, low and equal, or high and
equal) is allowed only if the vector was specified in the Extension Specifications as
having ascending or descending sequence. The search algorithm assumes that the
elements of the vector are in the specified sequence; if the elements of the vector
get out of sequence, unpredictable results can occur.
• If the search is successful, the resulting indicator that reflects the relation of the item
found to the search word is turned on. If two indicators are assigned, only the one
indicating the comparison of the search word and the vector element is turned on.
• If no element of the vector being searched satisfies the condition, no resulting
indicator is turned on.
The LOKUP operation can begin searching a vector at an element other than the first
with a numeric literal or a data item with the vector as an index. The search starts at the
designated element and continues until either the desired item is found or the end of the
vector is reached. If the search is unsuccessful and the index is a data item rather than a
literal, the index is set to 1. If the search is successful, the index contains the number of
the element that satisfied the condition. If a literal is used as an index, it is not changed.
The value of the index must be an integer not less than 1 nor greater than the number of
elements in the vector. If the value of a data item index violates these rules, a
SUBSCRIPT ERROR message is displayed at run time. Refer to the list of error
messages in Appendix A, “System Messages.”

One-Vector LOKUP
When the search involves one vector, Factor 1 (the search word), Factor 2 (the vector to
be searched), and one or two resulting indicators must be specified. The Control Level
field (columns 7–8) and the Indicators field (columns 9–17) can also be used. The Result
Field (columns 43–48) and the Half Adjust field (column 53) must be blank.

If the search is successful, the proper resulting indicator is turned on to indicate the
comparison that caused the search to end. The hold pointer for a table is set to point to
the element that satisfied the condition, and the contents of that element are moved into
the hold area. If a data item is assigned to the vector as an index, the data item contains
the index of the element that satisfied the condition. The element for an array is not
saved in a hold area; the index only points to the location of the element.

16–78 8600 0544–103


Operation Codes

If the search is not successful, no resulting indicators are turned on. If Factor 2 is a table
name, the hold area is not affected, but the hold pointer is set to point to the first
element of the table. If Factor 2 is a vector with a data item assigned as index, the index
is set to 1.

Example 16–23 shows the one-vector LOKUP operation.

Two-Vector LOKUP
When the search involves two vectors, Factor 1 (the search word), Factor 2 (the vector
to be searched), the Result Field (a corresponding or related table name that contains
available data), and one or two resulting indicators must be specified. The Control Level
field (columns 7–8) and the Indicators field (columns 9–17) can also be used.

When two vectors are specified with the LOKUP operation, only the vector named in the
Factor 2 field (columns 33–42) is actually searched. If the search is successful, the proper
resulting indicator is turned on to indicate the comparison that caused the search to end.
When tables have no index (in both the Factor 2 field and the Result Field), the hold
pointers for the tables are set to point to the corresponding elements from the tables,
and the contents of those elements are moved to the hold areas. If a data item is used
as a vector index in the Factor 2 field, the data item contains the number of the element
that satisfied the condition. No hold areas or hold pointers exist for arrays; the indexes
point to the locations of the elements in each array.

If the search is unsuccessful, no resulting indicators are turned on, and the hold area for
tables is unchanged. For tables (in both the Factor 2 field and the Result Field) with no
index assigned, the hold pointers are set to point to the first elements of the tables. The
index is set to 1 for vectors with a data item assigned as an index.

The vectors specified for LOKUP need not be the same type; however, the Result Field
(columns 43–48) can contain only a table name.

If the vector being searched is longer than its related vector, the search stops at the end
of the shorter vector. If the vector searched has a literal index, that index must be less
than or equal to the number of elements in either vector. If the vector searched has a
variable index, at run time its value is checked to verify that it is within the range of
elements of the related vector. If not, a SUBSCRIPT ERROR message is displayed at run
time. Refer to the list of error messages in Appendix A, “System Messages.”

Example 16–24 shows the two-vector LOKUP.

8600 0544–103 16–79


Operation Codes

SORTA (Sort Array)


The SORTA operation sorts a numeric or alphanumeric array into ascending or
descending order. Numeric array elements are ordered by their numeric value.
Alphanumeric array elements are ordered by the collating sequence of the EBCDIC
character code or be the system default collating sequence. Alternate collating
sequences are ignored.

The order in which to sort the array is specified by an entry in the Sequence field
(column 45) of the Extension Specifications. If the array is to be sorted in ascending
order, the Sequence field is coded with an A or a blank. If the array is to be sorted in
descending order, a D is entered in the Sequence field.

Following are the required entries for the SORTA operation:

• The Factor 2 field (columns 33–42) must be coded with the name of the array to be
sorted.
• The Factor 1 (columns 18–27), Result Field (columns 43–48), and Resulting Indicators
(columns 54–59) fields must be blank.
• The Decimal Position field (column 52) indicates the use of a different collating
sequence. Specifying a C in this column indicates that the collating sequence
specified in the Collating Sequence field (column 26) of the Control Specification is
used instead of the collating sequence of the EBCDIC character code.
• The Half Adjust field (column 53) selects the sort method by specifying a value: a
blank or an H specifies heap sort; a B specifies a bubble sort; and a Q specifies a
quick sort.
If performance is critical in an application, the type of sort chosen is important. Quick sort
is generally the fastest method when sorting a completely unsorted array of more than
10 elements. For sorting in descending order, heap sort is often faster than quick sort. If
the array is very small (10 elements or less) or almost entirely sorted, bubble sort is
recommended. Bubble sort is not an efficient sorting method for large arrays.

Example
Example 16–25 shows Extension and Calculation Specifications coding for sorting four
arrays. Default values are used for ARRY1 in both the Extension and Calculation
Specifications. Because the Sequence field of the Extension Specifications is blank,
ARRY1 is sorted in ascending order; because the Half Adjust field of the Calculation
Specifications is blank, a heap sort is used.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...
00100E*
00200E ARRY1 5 100 7 2
00300E ARRY2 20 10
00400E ARRY3 50 12 0A
00500E ARRY4 2 12 6 D
00600C*

Example 16–25. SORTA Operation (cont.)

16–80 8600 0544–103


Operation Codes

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...
00700C* Sort ARRY1 in ascending order, using heap sort.00800C*
00900C SORTAARRY1
01000C*
01100C* Sort ARRY2 in ascending order, using bubble sort.
71200C*
01300C SORTAARRY2 B
01400C*
01500C* Sort ARRY3 in ascending order, using quick sort.
01600C*
01700C SORTAARRY3 Q
01800C*
01900C* Sort ARRY4 in descending order, using heap sort.
02000C*
02100C SORTAARRY4 H

Example 16–25. SORTA Operation

TIME (Provide Current Time)


This operation provides the current time. The current date is provided as an option. The
operation code TIME is entered in the Operation field (columns 28–32). The Result Field
(columns 43–48) names a 6-digit or 12-digit numeric field, which can be defined
elsewhere in the program or in columns 49 through 52 of the Calculation Specifications.
The Result Field cannot be a whole array. The Factor 1 (columns 18–27), Factor 2
(columns 33–42), Half Adjust (column 53), and Resulting Indicators (columns 54–59)
fields must be blank.

After this operation is performed, a 6-digit Result Field contains the system time in the
format HHMMSS (where HH represents hours, MM represents minutes, and SS
represents seconds). A 12-digit Result Field contains both the system time and the
system date. The format of the system date depends on the entry in the Inverted Print
field (column 21) in the Control Specification. If the Inverted Print field contains a blank,
the Result Field is provided in the format HHMMSSmmDDYY (where HH represents
hours, MM represents minutes, SS represents seconds, mm represents the month, DD
represents the day, and YY represents the year). If the Inverted Print field contains D, I,
or J, the Result Field is in the format HHMMSSDDmmYY.

ZIP (Activate WFL Statement)


This operation causes the operating system to activate a Work Flow Language (WFL)
statement that initiates another program independently. Refer to the Task Attributes
Reference Manual for WFL syntax.

The Factor 2 field (columns 33–42) must contain the information required for the WFL
statement and must be an alphanumeric field, table name, vector element, or literal. This
operation can be conditioned by the Indicators field (columns 9–17).

8600 0544–103 16–81


Operation Codes

If a resulting indicator is specified in columns 58 through 59, it is turned on if the WFL


statement is invalid. The program does not wait until the WFL statement is completed; it
waits only until syntax checking has been performed. All other fields must be blank.

Example
Example 16–26 shows ZIP operation coding.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*...
00200F*
00300FFILEIN IP 80 80 DISK
00600IFILEIN AA 01
00700I 5 10 FIELD1
00800I 22 292FIELD2
00900I 35 442FIELD3
01000C ZIP FIELD1
01100C ZIP 'START X'

Example 16–26. ZIP Operation

COMS Operations
For information about COMS operations, refer to Volume 2 of this manual.

DMSII Operations
For information about DMSII operations, refer to Volume 2 of this manual.

16–82 8600 0544–103


Section 17
Output-Format Specifications

Output-Format Specifications state the location in a file to which a record is written.


These specifications also define the time to write data, the data to write, and the location
and format of the data within the record.

The name of this specification is shortened to Output Specifications to increase


readability. The terms Output-Format Specifications and Output Specifications are
synonyms.

RPG can be used to write to line and character printers, tapes, disks, and cards. Although
any of these devices can be used to create new files or records, only disks are suitable
for changing a record in place without changing the location of the record in the file. The
Output Specifications can be used to describe only the part of a record to be changed.

For information about output to databases and to the COMS message control system
(MCS), refer to Volume 2 of this manual.

The Device field (columns 40–46) in the File Specifications names the peripheral where a
file is to be written, and the Filename field (columns 7–14) associates a unique name
with the file.

The Output Specifications are functionally divided into

• Record descriptions (columns 7–37, 71--73)


• Field descriptions (columns 23–70)
A warning is displayed if a record description has no associated field descriptions, except
when DEL is entered in the Record Addition/Deletion field (columns 16–18). Record
description information and field descriptions cannot be specified on the same line. For
example, indicators specified in the Output Indicators field (columns 23–31) condition
either record output or field output in a record.

8600 0544–103 17–1


Output-Format Specifications

Output Specifications Coding Form and Summary


Figure 17–1 shows the Output Specifications coding form.

Figure 17–1. Output Specifications Coding Form

Table 17–1 summarizes the field definitions for the Output Specifications.

Table 17–1. Field Definitions Summary (Output Specifications)

Columns Description

1–5 Identifies the program sequence numbers unless the $UNSEQ compiler
control option is TRUE.
6 Identifies the type of specification for each line of code. This field must be
coded with the letter O.
7 Contains an asterisk (*) if the line is a comment.
7–14 Contains a file name specified in the File Specifications.
14–16 Puts the output indicators in an AND or OR relationship. Acceptable entries
are AND, OR, or blank.
15 Contains the type of output record to be written. Acceptable entries are the
letters H, D, T, or E. Additional entries for the DMSII interface are described
in Volume 2 of this manual.
16–18 Determines whether a record is to be added to or deleted from an indexed
sequential file. Acceptable entries are ADD, DEL, or blank.
16 Specifies either the stacker in which the output card is to be placed, or that
the overflow routine is to be invoked. Acceptable entries are the letter F, 1,
2, or blank. Additional entries for carriage control of COMS headers are
described in Volume 2 of this manual.
17–18 Designates the spacing of forms, before or after printing, for printer output
files. Acceptable entries are 0 through 9 or blank.

17–2 8600 0544–103


Output-Format Specifications

Table 17–1. Field Definitions Summary (Output Specifications)

Columns Description

19–22 Designates the skipping of forms, before or after printing, for printer output
files. Acceptable entries are 1 through 99, A0 through A9, B0 through B2, or
blank.
23-31 Output indicators are divided as follows:
• Columns 23, 26, and 29 indicate whether the output indicators in
columns 24 through 25, 27 through 28, or 30 through 31 must be on or
off. Acceptable entries are blank or N.
• Columns 24 through 25, 27 through 28, and 30 through 31 contain a
previously defined indicator that is used to condition output.
Acceptable entries are 01 through 99, L0 through L9, LR, MR, H0
through H9, U1 through U8, OA through OG, OV, 1P, or blank.
32–37 Contains a previously defined field name, special word, output group name,
vector, or vector element.
38 Specifies one of the following:
• The editing for a numeric output field when an edit word is not being
used. Acceptable entries are 1, 2, 3, 4, the letters A, B, C, D, J, K, L, M,
X, Y, Z, or blank.
• Synchronization for a specific record. Acceptable entries are the letter
S or blank.
39 Determines whether a variable is to be filled with blanks or zeros when the
output operation is finished. Acceptable entries are the letter B or a blank.
40–43 Designates the location of a field within an output record. Acceptable
entries are 1 through n (where n = maximum record length) right-justified,
or blank.
44 Specifies that an output field is to be written in alphanumeric, packed,
binary, single-precision, or double-precision format. Acceptable entries are
the letters P, J, L, R, B, S, D, or blank.
45–70 Contains a constant or edit word used to format and punctuate the output
record. The constant or edit word is enclosed in apostrophes (') and left-
justified. Acceptable entries are any valid RPG character as described in the
character set discussion in Section 2, “RPG Language Elements.”
71–73 Specifies the send type for COMS, which is described in Volume 2 of this
manual.
75–80 Contains the program identification. Any entry is valid.

Entries in columns of undefined fields in this specification might cause a warning


message to be issued.

8600 0544–103 17–3


Output-Format Specifications

Field Definitions
The fields in the Output Specifications are defined in the following text.

Sequence Number (Columns 1–5)


The Sequence Number field contains a 5-digit sequence number (00000–99999) for an
RPG program source unless the $UNSEQ compiler control option is TRUE. Refer to
Section 21, “Control of the Compilation Process,” for information about the $UNSEQ
option.

Form Type (Column 6)


The entry in the Form Type field identifies the type of specification for each line of code.
This field must be coded with the letter O.

Comment (Column 7)
Explanatory statements can appear in the source if column 7 contains an asterisk (*). The
Comment entry enables the entire line to the right of the asterisk to appear as program
documentation on the program listing. Comments are not instructions to the RPG
program or compiler, but serve as program documentation. Any valid character can be
used in a comment line. An asterisk in column 7 overrides an entry in column 6.

Example
Example 17–1 shows comment line coding.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00105O*
00110O* This is an example of how comment lines are coded. All lines
00120O* with an asterisk in column 7 are ignored by the compiler.
00140O*

Example 17–1. Coding an Output Specifications Comment Line

17–4 8600 0544–103


Output-Format Specifications

Filename (Columns 7–14)


The entry in this field identifies the file to which the subsequent record type and field
description entries belong. The file specified must have been described previously in the
File Specifications as an output, update, combined, or input file. Refer to the Record
Addition/Deletion field (columns 16–18) description later in this section for a complete
discussion of the requirements.

Every output file described in the File Specifications should also be described in the
Output Specifications, but this description is not required. If Output Specifications are not
provided for an output file, no data records (except possibly EOJ vector output) are sent
to the file; however, the file can still be opened and closed by the PLC. If this entry is
blank on a record description line, the file name of the previously described record is
assumed. The first record type described must have an entry in the Filename field.

For update files, only the fields to be changed need to be specified in an output record.
The remainder of the update record remains unchanged.

Type (Column 15)


This field describes when the record is to be written during the PLC. The values in
parentheses refer to steps in the PLC. Refer to Section 3, “RPG Program Logic Cycle
(PLC),” for information about the PLC.

The valid entries for the Type field are as follows:

Entry Definition

H The record is written during detail output (2), which occurs between detail
calculations (16) and the setting of overflow indicators (3). An H entry has the
same meaning as a D entry and is supplied only to help the programmer
distinguish between page headings from other detail output. Page headings
usually occur once on each page of printed output; detail output occurs once
during each program cycle.
D The record is written during detail output (2), which occurs between detail
calculations (16) and the setting of overflow indicators (3). This output occurs
once for each program cycle.

T The record is written during total output (10), which occurs between total
calculations (9) and testing of the last record (LR) indicator (11). This output
occurs once during each program cycle except the first.

E The record is written during exception output, which occurs during detail (16)
or total (9) calculations as the result of an EXCPT or SEND operation.

Record types can be specified in any order. However, if all output conditioning indicators
are satisfied, the sequence of output is as follows:

1. Detail output, which occurs during each cycle (2), including first page (1P) output only
during the first cycle. (Refer to the discussion of the 1P indicator in this section.)

8600 0544–103 17–5


Output-Format Specifications

2. Exception output, which occurs during total calculation (9) if an EXCPT or SEND
operation is executed. The program writes exception output during the first cycle.
3. Total output (10), which occurs during each cycle except the first.
4. Overflow output (13), which occurs during each cycle when a page overflow
condition occurs.
5. Exception output, which occurs during detail calculations (16) if an EXCPT or SEND
operation is executed.
First page output, which occurs when the 1P indicator is on, is heading or detail output
conditioned by the 1P indicator. This type of output occurs only at the beginning of
program execution, because the 1P indicator is off permanently (3) after the first
execution of detail output.

Overflow output consists of heading, detail, or total output records conditioned by an


overflow indicator. An output line conditioned by an overflow indicator preceded by an N
(in columns 23, 26, or 29) is not considered overflow output. During compilation, the
compiler extracts the output records conditioned on overflow and locates them for
execution in the overflow output routine (13) between total output (10) and detail
calculations (16).

One of the following two methods should be used for determining the output record
sequence, for ease of writing and later program maintenance:

• The records within one file are specified, beginning with heading records and
continuing with detail records, total records, and exception records.
• All the heading records are specified, followed by detail records, total records, and all
exception records.
The two methods of determining the sequence of output specifications can be varied as
required so that the proper physical sequence of records in the files can be ensured.

Total output cannot be specified for primary or secondary update files.

AND and OR Lines (Columns 14–16)


If more than three indicators are needed to condition an output operation, an AND line
can be used. The AND line follows the line on which the file is described. The word AND
must be entered in columns 14 through 16, and the additional indicators must be entered
in their respective fields. The conditions specified for all indicators in an AND relationship
must be met before the associated output operation takes place.

OR lines (OR in columns 14 through 15) can be used to group indicators so that only one
of the conditions specified must be met for the associated output operation to take
place. The OR line follows the line on which the file is described.

Both AND and OR lines can be used together on a record description line, but not on a
field description line. A maximum of three indicators on a single line in an AND
relationship can be used to condition a field. Refer to Example 17–3 later in this section
for coding of the AND and OR lines.

17–6 8600 0544–103


Output-Format Specifications

At least one indicator must be present on an AND and OR line and on the preceding line.
Any number of AND and OR lines can be specified for a record description.

Record Addition/Deletion (Columns 16–18)


This field indicates that record addition or deletion occurs when the output record is
written to the file.

Valid entries for the Record Addition/Deletion field are as follows:

Entry Definition

ADD Add a record to a sequential, direct, indexed, or alternate index file. The file can
be opened for input, update, or output.

DEL Delete the last record read if the file is a sequential, direct, indexed, or alternate
index file.

Record Addition
A record can be added to an existing file only if all the following conditions are true:

• The file is a sequential, direct, indexed, or alternate index file opened for input,
update, or output.
• The File Addition/Unordered field (column 66) in the File Specifications contains A or
B.
• The file is a disk file.
• Columns 16 through 18 contain the entry ADD.
If the Record Addition/Deletion field is blank, the entry ADD is assumed and the compiler
displays a warning message under any of the following conditions:

• The file is an input file and the File Addition/Unordered field (column 66) of the File
Specifications contains an A, which indicates that records can be added to an
existing file.
• The file is an input file and the File Addition/Unordered field contains a B, which
indicates that records can be added or deleted.
• The file in an output file and the File Addition/Unordered field contains an A.
An ADD entry must be specified before any entries in the AND and OR field
(columns 14–16) because the ADD applies to all AND and OR lines in the group.

Refer to Section 4, “Disk Files,” for more information about adding records to a file.

8600 0544–103 17–7


Output-Format Specifications

Record Deletion
A record can be deleted from an existing file only if all the following conditions are true:

• The file is either an indexed or alternate index file or an EFS sequential or direct file.
The file must be opened for input or update.
• The File Addition/Unordered field (column 66) in the File Specifications contains D, B,
or blank.
• If the file is an EFS file, it must have been created as a delete-capable file.
• The file is a disk file.
• Columns 16 through 18 contain the entry DEL.
A DEL entry must be specified before any entries in the AND and OR field
(columns 14–16) because the DEL operation applies to all AND and OR lines in the group.

An attempt to delete a record from a BFS sequential or direct file causes the last record
read to be filled with blanks.

Refer to Section 4, “Disk Files,” for more information about deleting records from a file.

Stacker-Select/Fetch Overflow (Column 16)


This field can specify either of the following:

• The stacker into which an output or combined file card is placed after it is processed.
• The overflow routine that can be called for possible execution before the record
specified by this line is printed. This process is called fetch overflow.
The valid entries for the Stacker-Select/Fetch Overflow field are as follows:

Entry Definition

Blank This entry forces cards to go automatically to the default stacker, and printer
files do not attempt to fetch overflow.

1-2 This entry represents the stacker into which the card is to be stacked (card
files only).

F This entry causes the system to fetch overflow (printer files only).

Stacker Selection
Only output and combined card files can have stackers selected in the Output
Specifications.

When a combined file has a stacker selected and/or updated during total calculations
(step 9 or 10 of the PLC), the record being updated is the one that caused the control
break. For further discussion, refer to the discussion of the Type field (column 15) in this
section.

17–8 8600 0544–103


Output-Format Specifications

If the numeric stacker-selection entry is greater than 2, the record is selected for the
normal (default) stacker.

Record types identified by OR lines can be selected for a special stacker by an entry in
the Stacker-Select/Fetch Overflow field. However, if this field is blank, the record type
selected by the OR line goes to the default stacker; that is, the stacker-selection entry on
the previous line is not assumed. AND lines must not have a stacker-selection entry.

Overflow Fetching
Entering an F in column 16 of the record description of a printer file requests that
overflow output be checked for this file before this line is printed. (For additional
information, refer to the discussion of printing reports in this section.)

Fetched overflow can be specified for any detail, total, or exception output and must not
be conditioned by an overflow indicator; that is, the overflow routine cannot be called
during the printing of overflow.

Fetched overflow can be specified for any OR line. The entry on the previous line is not
assumed. Fetch overflow cannot be specified for AND lines.

Space (Columns 17–18)


This field specifies line spacing for printer files. The field is divided into two subfields,
Space Before (column 17) and Space After (column 18), that indicate whether line
spacing occurs before printing, after printing, or both.

Valid entries for the subfields of Space field are as follows:

Entry Definition

Blank No spacing requested.

0–9 Space the number of lines specified.

8600 0544–103 17–9


Output-Format Specifications

Skip (Columns 19–22)


This field has different uses, depending on the entry in the Line Printer Skipping field
(column 46) in the Control Specification. These uses are described in the following
paragraphs. Also, refer to the discussion of printing reports in this section for more
information about skipping.

In the following paragraphs, form length refers to the form length specified in the Line
Number, FL, Channel Number field (columns 15–19) in the Line Counter Specifications. If
no form length has been entered, the default form length is used. Overflow line refers to
the overflow line specified in the Line Number, OL, Channel Number field
(columns 29–24) in the Line Counter Specifications. If no overflow line has been entered,
the default overflow line is used. Refer to Section 11, “Line Counter Specifications,” for
more information on form length and overflow lines.

Skip to a Line Number


Skipping to a line number, as opposed to a channel number, is requested by using one of
the following entries:

• The number 2 in the Line Printer Skipping field (column 46) in the Control
Specification
• A blank in both the Line Printer Skipping field and the Source Input Dialect field
(column 51) in the Control Specification
The Skip field specifies the particular line number to which the printer is to skip. This field
is divided into two subfields: Skip Before (columns 19–20) and Skip After
(columns 21–22). These subfields indicate whether forms skipping occurs before or after
the record is printed.

Valid entries in the Skip field for skipping to a line number are as follows:

Entry Definition
Blank Do not skip.

1–99 Skip to the line number specified (1–99).

A0–A9 Skip to the line number specified (100–109).

B0–B2 Skip to the line number specified (110–112).

A Skip field entry cannot be greater than the form length.

17–10 8600 0544–103


Output-Format Specifications

If both skipping and spacing are specified on the same line, the operations are performed
in the following order:

1. Skip Before
2. Space Before
3. Skip After
4. Space After
Spacing or skipping to, or beyond, the overflow line causes the overflow indicator
associated with the file to turn on. However, spacing or skipping beyond the overflow
line to a line on the next page does not cause the overflow indicator to turn on. The
overflow area is defined as extending from the first line after the overflow line to one line
before line 1.

For OR lines, different Skip field and Space field (columns 17–18) entries can be
specified. If all such entries are blank for an OR line, spacing and skipping are performed
according to the specifications on the preceding line. If any entries are made for an OR
line, all desired spacing and skipping must be specified. Neither Space nor Skip field
entries are permitted on AND lines.

If a printer record has neither space nor skip specifications, the default value is one line
of spacing after each record printed.

Skip to a Channel Number


Skipping to a channel number is specified by using one of the following entries:

• The number 1 in the Line Printer Skipping field (column 46) in the Control
Specification
• A blank in the Line Printer Skipping field and the number 1 in the Source Input Dialect
field (column 51) in the Control Specification
The Skip field specifies the particular channel to which the printer is to skip. This form of
line printer skipping is directly related to the operation of the printer carriage control tape.
The Skip field is divided into two subfields: Skip Before (columns 19–20) and Skip After
(columns 21–22). These subfields indicate whether forms skipping occurs before or after
the record is printed.

Valid entries in the Skip field for skipping to a channel number are as follows:

Entry Definition

Blank Do not skip.

1–11 Skip to the specified channel.

8600 0544–103 17–11


Output-Format Specifications

Skipping is performed according to the format punched in the carriage control tape. Line
Counter Specifications are required to associate line numbers with the channel numbers
referenced so that the program can determine when the overflow line has been reached.
The overflow area is defined as the lines from channel 12 to one line before channel 1.

If a printer record has neither space nor skip specifications, the default value is one line
of spacing after each record printed.

Output Indicators (Columns 23–31)


This field is divided into three subfields so that up to three indicators in an AND
relationship can be specified on each line to condition an output operation.

Each subfield is divided into the following two parts:

• Not (columns 23, 26, and 29)


• Indicator (columns 24–25, 27–28, and 30--31)
The Not subfields specify that the associated indicator must be off for the operation to
occur. If this condition is desired, an N must be entered in a Not subfield; otherwise, the
Not portion must be blank.

The Indicator subfields specify the indicators to be tested.

The following entries are allowed in the indicator subfield of the Output Indicators field:

Entry Definition

Blank The operation is not conditioned by any indicator. In this case, the Not subfield
must also be blank.

01–99 The operation is conditioned by a numeric indicator used elsewhere in the


program.

L0–L9 The operation is conditioned by a control level indicator.

LR The operation is conditioned by the last record (LR) indicator.

MR The operation is conditioned by the matching record (MR) indicator.

H0–H9 The operation is conditioned by a halt indicator used elsewhere in the


program.

U1–U8 The operation is conditioned by an external indicator.

OA– The operation is conditioned by a previously defined overflow indicator.


OG,
OV

1P The operation is conditioned by the first page (1P) indicator.

Because all three indicators on one line are in an AND relationship, all indicators on one
line or group of lines must be on or off, as individually specified; otherwise, the
associated operation does not take place.

17–12 8600 0544–103


Output-Format Specifications

An indicator specified on the line describing the record type conditions the entire output
record. If an indicator and a field description are specified on the same line, the indicator
conditions that field only, are unchanged. Regardless of the field lengths,

Example
Example 17–2 shows coding for output indicators.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00300FFILEIN IP 80 80 DISK
00310FPRINT1 O 132 132 PRINTER
00320FPRINT2 O 132 132 PRINTER
00400IFILEIN AA 01
00500I 5 100FIELD1
00600I 22 292FIELD2
00700I 35 442FIELD3
00800C 01 FIELD1 ADD FIELD2 TOTAL 102
00900C 01 TOTAL COMP FIELD3 101020
01000C 01 FIELD1 COMP FIELD2 304050
01100OPRINT1 D 01
01200O FIELD1 10
01300O FIELD2 20
01400O 10 FIELD3 30
01500O 20 TOTAL 30
01600OPRINT2 D 01
01700O OR 10N50
01800O OR 3001850O OR 40
01900O 35 'UNEQUAL FIELDS'

Example 17–2. Coding Output Indicators

The types of output conditioning indicators are discussed in the following paragraphs.

8600 0544–103 17–13


Output-Format Specifications

Numeric Indicators (01–99)


The numeric indicators (01–99) can be used as follows:

• To condition output operations that are to be performed only for specific input record
types, as specified in the Record Identifying Indicators field (columns 19–20) in the
Input Specifications
• To condition output operations that are to be performed when an input field meets
certain conditions, as specified in the Field Indicators field (columns 65–70) in the
Input Specifications
• To condition output operations according to the results of calculations, as specified in
the Resulting Indicators field (columns 54–59) in the Calculation Specifications

Control Level Indicators (L0–L9)


Control level indicators can be used to condition output operations that are to be
performed only on the first record of a new control group.

Last Record (LR) Indicator


The LR indicator can be used to condition output operations that are to be performed at
EOJ.

Matching Record (MR) Indicator


The MR indicator can be used to condition output operations that are to be performed
only when matching input records are found.

Halt Indicators (H0–H9)


Halt indicators previously assigned in the Field Indicators field (columns 65–70) of the
Input Specifications or the Resulting Indicators field (columns 54–59) of the Calculation
Specifications can be used to condition output operations that are to be performed only
when an error condition occurs.

Because the program does not halt until after the record in error has been processed
through detail output, some operations might need to be prevented to avoid erroneous
output. Using halt indicators can inhibit or permit an operation, depending on the status
and specification of the indicator.

17–14 8600 0544–103


Output-Format Specifications

External Indicators (U1–U8)


If an output file is conditioned by an entry in the File Condition field (columns 71–72) in
the File Specifications, every output record described for the file should be conditioned
by the same external indicator. If the conditioning does not occur, the object program
continues to do the following:

• Build the output record.


• Perform any blank after operations specified.
• Suppress the write operation.

Overflow Indicators (OA–OG, OV)


Overflow indicators assigned in the Overflow Indicator field (columns 33–34) in the File
Specifications can be used to condition output operations that are to be performed when
the overflow area of a printer file has been reached. An overflow indicator can condition
output operations only for the file to which the indicator has been assigned.

If no overflow indicator is assigned to the file, forms advancing at end of page (EOP) is
handled automatically. Any output record specification line not conditioned by an
overflow indicator but designating a skip to the next page turns off the overflow indicator
before the skip takes place.

Overflow indicators cannot condition exception records, but can condition fields within
exception records. No more than one overflow indicator can be associated with a group
of output indicators in an AND and OR relationship. Overflow is described in detail in the
discussion of printing reports in this section.

First Page (1P) Indicator


The 1P indicator can be used to enable printing of heading information on the first page
of a printer output file. This indicator can be used with an overflow indicator in an OR
relationship to enable printing of the same heading information on all pages. Update or
combined file records cannot be conditioned by this indicator.

The 1P indicator can be used to condition heading, detail, total, or exception lines.
However, a 1P indicator turned on for a total record, an exception record, or field
descriptions prevents all output for that record or field.

8600 0544–103 17–15


Output-Format Specifications

Example
Example 17–3 shows the use of the 1P indicator.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00300FFILEIN IP 80 80 DISK
00400FPRINT1 O 132 132 PRINTER
00500FPRINT2 O 132 132 OF PRINTER
00600IFILEIN AA 01
00700I 5 100FIELD1
00800I 22 292FIELD2
00900I 35 442FIELD3
00910C 01 FIELD1 COMP 0 020303
00920C 01 FIELD2 COMP 0 040505
00930C 01 FIELD3 COMP 0 060707
01000C 01 FIELD1 ADD FIELD2 TOTAL 102
01100C 01 TOTAL COMP FIELD3 101020
01200C 01 FIELD1 COMP FIELD2 304050
01210OPRINT1 H 3 1P
01220O 35 'REPORT HEADING #1'
01300O D 01 02 04
01310O AND 06
01320O FIELD1 10
01500O FIELD2 20
01600O 10 FIELD3 40
01700O 20 TOTAL 40
01710OPRINT2 H 201 1P
01720O OR OF
01730O 35 'REPORT HEADING #2'
01800O D 01
01900O OR 10N50
02000O OR 30
02050O OR 40
02100O 35 'UNEQUAL FIELDS'

Example 17–3. Using the 1P Indicator

17–16 8600 0544–103


Output-Format Specifications

Field Name (Variable Name) (Columns 32–37)


The Field Name (Variable Name) field (columns 32–37) either assigns an identifier or
names an output group name.

This field assigns an identifier to an output data field. The identifier used must have been
defined previously in one of the following fields unless it is a special word:

• Field Name field (columns 53–58) of the Input Specifications


• Vector Name field (columns 27–32) of the Extension Specifications
• Result Field (columns 43–48) of the Calculations Specifications
A separate line is used for each field description. Fields can be listed in any order within
each record type because their locations are determined by the entry in the Field End
Position field (columns 40–43). If fields overlap, the last field specified appears intact in
the output record. The exact result depends on the degree of overlap.

A field name entry occurs on the field description line.

An output group name can be used to identify a group of records for output. The group is
used only with exception output. Exception records with an output group name are
processed when the output name is specified in the Factor 2 field of an EXCPT or SEND
operation. If the Factor 2 field contains a blank, a file name for the EXCPT operation, or a
file name for the SEND operation, then exception records with an output group name are
not processed.

An output group name entry occurs on a record description line.

Using output group names can reduce the need for conditioning indicators on exception
records. However, conditioning indicators can still be used to determine whether or not
the fields are to be written. Overflow indicators cannot be used to condition a record with
an output group name.

Refer to the discussion of the EXCPT operation in Section 16, “Operation Codes,” for an
example of output group names.

The following special words are reserved for use as variable names:

PAGE PAGEn (where n equals an integer 1 through 9)

UDATE UMONTH

UDAY UYEAR

UTIME UDAYNM

JDATE *PLACE

A discussion of *PLACE is provided later in this section. For information about the
remaining special words, refer to Section 2, “RPG Language Elements.”

8600 0544–103 17–17


Output-Format Specifications

Edit Codes (Column 38)


An entry in this field specifies either of the following:

• Editing of a numeric output field


Editing operations have been provided for which an edit word need not be specified;
these operations and their corresponding edit codes are summarized in the Edit
Codes table on the Output Specifications forms. For a description of edit codes, refer
to the discussion later in this section.
• Synchronization of specified output records
Synchronization of all output records for BFS files with sequential organization can be
designated as an attribute in the Attribute Specifications. Synchronization means that
output must be written to the physical file before the program initiating the output
can resume execution. An appropriate entry in the Edit Codes field, however,
enables the user to change the synchronization coded in the Attribute Specifications
for a specific output record.
Changes to the synchronization of a specific record can be made with the following
entries:
Entry Definition

Blank Output is performed according to the current setting of the SYNCHRONIZE


file attribute.

S The record output is synchronized. This entry overrides the SYNCHRONIZE


file attribute.

If the record identified in columns 14 through 16 of an OR line is left blank (in the
AND and OR Line field), the entry designated for synchronization of the previous line
is assumed. A record identified in an AND line must not have an entry for
synchronization.
Additional information on synchronization of output is provided in the File Attributes
Reference Manual.

17–18 8600 0544–103


Output-Format Specifications

Blank After (Column 39)


An entry in this field specifies that a variable is reinitialized after the output operation is
finished. Alphanumeric fields are initialized to blanks, and numeric fields are initialized to
zeros. Constants and the special words JDATE, UDATE, UDAY, UDAYNM, UMONTH,
UTIME, and UYEAR must not be specified with the Blank After field.

Valid entries for the Blank After field are as follows:

Entry Definition

Blank Field is not to be reinitialized.

B Field is to be reinitialized after being moved to the output buffer.

If the Zero/Blank Indicator Setting field (column 42) in the Control Specification contains
an R, or both column 42 and the Source Input Dialect field (column 51) in the Control
Specification are blank, then the Blank After field entry has no effect on zero/blank
indicators.

The zero/blank indicator is turned on when the following conditions are true:

• If the Zero/Blank Indicator Setting field contains an S or is blank and the Source Input
Dialect field contains the number 1
• If an indicator has been assigned to the field in the Input or Calculation Specifications
to test for zero or blank and the same field is used in the Output Specifications with
Blank After specified
If more than one indicator is assigned to the same field as a zero/blank indicator in
different Input or Calculation Specifications, only the first one is turned on when the field
is reinitialized. Whenvectors or vector elements are written with Blank After, zero/blank
indicators are not changed.

Field End Position (Columns 40–43)


This field locates a field in the output record by specifying the location of the rightmost
position of the field. The number of positions to the left of that location is determined by
the length of the output field. Space must also be included for edit codes or edit words
that are written. Valid values for this field are a blank or the numbers 1 through n, where
n is the maximum record length specified for the file. If the end position is blank on a
field description line, the output for the field immediately follows the previous field. If
columns 40 through 43 are blank for the first field description line, the field starts in
position 1.

8600 0544–103 17–19


Output-Format Specifications

Example
Example 17–4 shows code in which an end position is designated. The specified end
position is 30. Because the end position for the next field is blank, the first position for
that field is 31.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
02000OPRINT
03000O 30 'THIS MESSAGE APPEARS '
04000O 'ON ONE LINE.'
05000O*
06000O* The output record that appears is:
06000O* THIS MESSAGE APPEARS ON ONE LINE.

Example 17–4. Designating an End Position

For information on how the specified end position relates to the result obtained by using
various edit codes, refer to Table 17–3 later in this section.

Packed (Column 44)


This field specifies the data format of an output field. Binary fields cannot be displayed on
an ODT or printed. Packed decimal fields cannot be printed, displayed on a an ODT, or
included in an output file being translated to a character code set other than EBCDIC.

Valid entries for this field are as follows:

Entry Definition

Blank Field is to be written in alphanumeric or unpacked decimal format.

P Field is to be written in signed, packed decimal format.

J Field is to be written in unsigned, packed decimal format.

L Field is to be written in unpacked decimal format with a leading sign as a


separate plus sign (+) or minus sign (–) in the first position of the field.

R Field is to be written in unpacked decimal format with a trailing sign as a


separate plus sign (+) or a minus sign (–) in the last position of the field.

B Field is to be written in binary format. The number of bytes used depends on


the number of digits. Binary format is in two's complement representation. An
entry of from 1 to 4 digits implies 2-byte format; an entry of from 5 to 9 digits
implies 4-byte format.

S Field is to be written in single-precision numeric format. The field can have from
1 to 11 digits and occupies 6 bytes.

D Field is to be written in double-precision numeric format. The field can have up


to 23 digits and occupies 12 bytes.

17–20 8600 0544–103


Output-Format Specifications

The internal format of numeric data is not necessarily the same as the external data
format. Any necessary conversion is performed automatically. Packed data fields are
always character aligned (byte aligned). The output of a field specified with signed,
packed data format (P format) creates a field with an odd number of digits and a sign.
The output of a field specified with unsigned, packed decimal format (J format) creates a
field with an even number of digits and no sign.

This field must be blank if the following occurs:

• The Field Name field (columns 32–37) is alphanumeric.


• The Edit Codes field (column 38) is specified.
• The Constant or Edit Word field (columns 45–70) is specified.

Constant or Edit Word (Columns 45–70)


Constants and edit words are entered in this field. A description of each type of entry is
provided later in this section.

Program Identification (Column 75–80)


The Program Identification field is not used by the compiler but appears on the source
program listing so that the field can be used to document different portions of the
program.

8600 0544–103 17–21


Output-Format Specifications

Constants
A description of the use of constants, *PLACE, edit codes, and edit words follows.

Constants are literals and contain information that is not changed by any operation.
Constants appear in the output exactly as they are written in the Output Specifications,
at the position specified in the Field End Position field (columns 40–43).

The following rules must be observed when constants are used:

• The Field Name field (columns 32–37) must be blank.


• Constants must be left-justified, enclosed in apostrophes ('), and no longer than 24
characters.
• When apostrophes appear in the constant, two consecutive apostrophes must be
coded for each apostrophe required. In regard to the end position, two apostrophes
count as one.
• Numeric data can be used as a constant, but must still be enclosed in apostrophes.
This type of constant is considered an alphanumeric literal composed entirely of
numeric characters.
Example
Example 17–5 shows the coding of constants.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00300FFILEIN IP 80 80 DISK
00400FPRINT1 O 132 132 PRINTER
00600IFILEIN AA 01
00700I 5 100FIELD1
00800I 22 292FIELD2
00900I 35 442FIELD3
01000C 01 FIELD1 ADD FIELD2 TOTAL 102
01100C 01 TOTAL COMP FIELD3 101020
01200C 01 FIELD1 COMP FIELD2 304050
01300OPRINT1 H 304 1P
01400O 33 'ONE O''CLOCK REPORT'
01410O H 1 1P
01420O 10 'FIELD1'
01430O 20 'FIELD2'
01440O 30 'FIELD3'
01450O 40 'TOTAL'
01500O D 01
01600O FIELD1 10
01700O FIELD2 20
01800O 10 FIELD3 30
01900O 20 TOTAL 40

Example 17–5. Coding Output Constants

17–22 8600 0544–103


Output-Format Specifications

Special Word *PLACE


*PLACE enables the same fields to be written in more than one place in an output record
and does not require the field names and end positions to be specified more than once.
Each use of *PLACE causes all field descriptions previously specified for this record to
be moved, as a group, to the end position associated with *PLACE. Identical results can
be obtained in either of the following ways:

• By defining each field and corresponding end position every time it is to appear in the
output record
• By using the special word *PLACE
Both methods produce identical results, but using the *PLACE entry requires less
coding.

The following rules apply when *PLACE is used:

• All fields within the record type preceding the *PLACE entry are repeated according
to the *PLACE end position, not only the one preceding line.
• An end position must be given for every *PLACE entry.
• An additional *PLACE entry (on a separate line) must be used every time the fields
are to be repeated.
• Because *PLACE applies only to fields previously described in the record, *PLACE
cannot be the first field description.
• The end position specified for *PLACE should be at least twice that of the highest
end position previously specified. If enough space is not allowed for all fields to be
printed again, overlapping occurs (with the *PLACE output overlapping the previous
characters).
• The end position specified for *PLACE must not be lower than the highest previously
specified field end position.
• *PLACE moves all the fields beginning in position 1 of the record through the highest
non*PLACE end position specified in the preceding field descriptions.
• Only the Output Indicators (columns 23–31), Field Name (columns 32–37), and Field
End Position (columns 40–43) fields can have entries.

8600 0544–103 17–23


Output-Format Specifications

Example
Example 17–6 shows the use of the *PLACE special word to write the same output to
files PRINT1 and PRINT2.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00300FFILEIN IP 80 80 DISK
00400FPRINT1 O 132 132 PRINTER
00500FPRINT2 O 132 132 PRINTER
00600IFILEIN AA 01
00700I 1 50FIELD1
00800I 11 150FIELD2
00900I 21 250FIELD3
01100OPRINT1 D 01
01200O FIELD1 5
01300O FIELD2 15
01310O FIELD3 25
01320O FIELD1 35
01330O FIELD2 45
01340O FIELD3 55
01342O FIELD1 65
01344O FIELD2 75
01346O FIELD3 85
01350O*
01360O* The above output definition can be defined using the *PLACE
01370O* specification as shown below:
01380O*
01400OPRINT2 D 01
01500O FIELD1 5
01600O FIELD2 15
01700O FIELD3 25
01800O *PLACE 55
01900O *PLACE 85

Example 17–6. Using the *PLACE Special Word

17–24 8600 0544–103


Output-Format Specifications

Edit Codes
Edit codes are single-character codes used to edit numeric fields. Only numeric fields can
be edited by using edit codes. If an edit code is specified, the Constant or Edit Word field
(columns 45–70) must be blank; however, if check-protect asterisks or a floating dollar
sign is desired, an asterisk enclosed in apostrophes ('*') or a dollar sign enclosed in
apostrophes ('$'), respectively, can be entered in columns 45 through 47. Edit codes X, Y,
and Z cannot be used with a check-protect asterisk or a floating dollar sign.

When an entire array is edited using an edit code, the following points must be
considered if an end position large enough for all the output data is specified:

• Two spaces are inserted to the left of each element.


• Commas (,), decimal points (.), and minus signs (–) occupy one character each, and
the credit sign (CR) occupies two.
The rules for the use of edit codes are as follows:

• Conditioning indicators on the record description line and on the field description line
determine when the field is written.
• The variable name specified in the Field Name field (columns 32–37) must have been
previously defined as one of the following:
− An entire numeric array
− A single element of a numeric vector
− A numerically defined field
− A numerically defined special word
• An edit code entry in column 38 causes specific punctuation of the variable. (Refer to
the examples in Table 17–4 later in this section.)
• An entry of B in the Blank After field (column 39) does not affect the editing specified
on this line.
• The Field End Position field (columns 40–43) defines where the last character of the
edited output appears.
Note: A syntax error occurs if the total length in bytes of the variable plus all
inserted editing symbols is greater than the length in bytes, from the specified end
position to position 1, of the output record.

• The Packed field (column 44) must be blank.


• The Constant or Edit Word field (columns 45–70) must remain blank, except in the
following cases:
− If check-protect asterisks are desired, an asterisk enclosed in apostrophes ('*')
can be entered in columns 45 through 47.
− If a floating dollar sign is desired, a dollar sign enclosed in apostrophes ('$') is
entered in columns 45 through 47.
Note: The check-protect asterisk and the floating dollar sign cannot be used
with edit codes X, Y, or Z.

8600 0544–103 17–25


Output-Format Specifications

• Edit codes A, B, J, K, 1, and 2 provide the comma option. Commas (,) are inserted in
the edited output only if more than three significant, nonzero digits appear to the left
of the implied decimal point.
• Edit codes A, C, J, L, 1, and 3 provide the zero balance option. This option ensures
that at least one 0 (zero) is written if the value of the field is 0.
The number of zeros written is determined by the number of decimal positions
assigned to the field, as shown in the following example:

Decimal Positions Zero-Balance Output

0 0
1 .0
2 .00
9 .000000000

• Edit codes B, D, K, M, 2, and 4 suppress output of the field if the value is 0. A


floating dollar sign, if specified in columns 45 through 47, is suppressed under this
condition; however, check-protect asterisks, if specified in columns 45 through 47,
are printed.
• Reporting the sign of the data is known as status reporting. The status of a field can
be requested or ignored as follows:
− A, B, C, and D provide a credit sign (CR) for reporting a negative status.
− J, K, L, and M provide a minus sign (–) for reporting a negative status.
− 1, 2, 3, and 4 provide for no status reporting.
For more information on editing status reports, refer to the edit word discussion in
this section.
• Edit code X removes a plus sign (+) from the field without suppressing a zero value.
• Edit code Y provides date-field format editing. If the variable is shorter than 3 digits or
longer than 6 digits, the compiler displays a warning message. If the variable is
longer than 6 digits, editing begins with the leftmost digit and the program writes all
digits (except the first leading zero). The character used as the date separator is
determined by the Inverted Print field (column 21) and Date Edit field (column 24) in
the Control Specification.
• Edit code Z removes all signs and suppresses leading zeros.
• An entire array can be edited with one edit code. The following must be included
when the Field End Position field (columns 40–43) is specified:
− One space for each character of the array
− Two spaces to be inserted to the left of each element
− One space for each comma that can be inserted
− One space for each decimal that is inserted, along with either of the following
(unless edit codes 1, 2, 3, or 4 are used): one space for each possible

17–26 8600 0544–103


Output-Format Specifications

minus sign (–) for each array element, or two spaces for each possible CR for
each array element

Edit Code Descriptions


Table 17–2 describes the edit codes. Refer to Section 7, “Control Specification,” for a
discussion of the Inverted Print field and the Date Edit field.

Table 17–2. Edit Codes

Printout on Zero-Balance Inverted Print Option

Suppress Sign for D or Blank I J


Edit Decimal Leading Negative
Code Comma Point Zeros Balance

1 Yes Yes Yes No sign .00 or 0 ,00 or 0 0,00 or


0
2 Yes Yes Yes No sign Blanks Blanks Blanks
3 No Yes Yes No sign .00 or 0 ,00 or 0 0,00 or
0
4 No Yes Yes No sign Blanks Blanks Blanks
A Yes Yes Yes CR .00 or 0 ,00 or 0 0,00 or
0
B Yes Yes Yes CR Blanks Blanks Blanks
C No Yes Yes CR .00 or 0 ,00 or 0 0,00 or
0
D No Yes Yes CR Blanks Blanks Blanks
J Yes Yes Yes -- .00 or 0 ,00 or 0 0,00 or
0
K Yes Yes Yes -- Blanks Blanks Blanks
L No Yes Yes -- .00 or 0 ,00 or 0 0,00 or
0
M No Yes Yes -- Blanks Blanks Blanks
X? No No No Zone sign
Y?? No No Yes No sign
Z No No Yes No sign

Legend
? The X edit code removes a plus sign (+).
?? The Y edit code suppresses the leftmost zero only.

8600 0544–103 17–27


Output-Format Specifications

Effects of Edit Codes on Output


The following six tables show the effects of the edit codes on various input data.

Table 17–3 summarizes the results obtained when each of the edit codes is used to edit
a 2-decimal-position field whose length is 5 and whose value is –3.12. The Output
Specifications specify a Field End Position value of 12. A right brace (}) represents a
negative 0.

Table 17–3. Effects of Edit Codes on Field End Position

Edit Code Output Positions

6 7 8 9 10 11 12 13

None } 0 3 1 2
1 3 . 1 2
2 3 . 1 2
3 3 . 1 2
4 3 . 1 2
A 3 . 1 2 C R
B 3 . 1 2 C R
C 3 . 1 2 C R
D 3 . 1 2 C R
J 3 . 1 2 --
K 3 . 1 2 --
L 3 . 1 2 --
M 3 . 1 2 --
X } 0 3 1 2
Y 0 / 3 1 / 2
Z 3 1 2

17–28 8600 0544–103


Output-Format Specifications

Table 17–4 lists examples that show the effects of the Y edit code on given input strings.

Table 17–4. Effects of Y Edit Code

Input String Output String Explanation

093074 9/30/74 Code used for editing date fields.


09307 9/30/7 A 5-digit date field is written.
0930 9/30 A 4-digit date field is written.
093 9/3 A 3-digit date field is written.
09 9 Two digits or fewer are written.
0930745 9/30/745 Seven digits or more are written.

Table 17–5 lists examples that show the effects of various edit codes on a positive zero
input string.

Table 17–5. Effect of Edit Codes on Positive Zero Input String

Edit Input String Output Explanation


Code String

1 +0000000000 0 Commas and zero balance print


without a sign.
2 +0000000000 Commas print without a zero balance
or sign.
A +0000000000 0 Commas and zero-balance print. CR is
printed for negative status reporting.
B +0000000000 Commas print without a zero-balance.
CR is printed for negative status
reporting.
X +0000000000 0000000000 Plus sign (+) is removed.
Z +0000000000 Zero suppression is performed.

8600 0544–103 17–29


Output-Format Specifications

Table 17–6 lists examples that show the effects of various edit codes on a negative zero
input string.

Table 17–6. Effects of Edit Codes on Negative Zero Input String

Edit Input String Output Explanation


Code String

1 –0000000000 0 Commas and zero balance print


without a sign.
2 –0000000000 Commas print without a zero balance
or sign.
A –0000000000 0 Commas and zero-balance print. CR
is printed for negative status
reporting.
B –0000000000 Commas print without zero-balance.
CR is printed for negative status
reporting.
J –0000000000 0 Commas and zero-balance print. The
minus sign (–) is printed for negative
status reporting.
K –0000000000 Commas print without zero-balance.
The minus sign (–) is printed for
negative status reporting.
X –0000000000 0000000000 Minus sign (–) is removed.
Z –0000000000 Zero suppression is performed.

17–30 8600 0544–103


Output-Format Specifications

Table 17–7 lists examples that show the effects of the edit codes on a positive, 10-digit
field with two implied decimal places.

Table 17–7. Effects of Edit Codes on Positive Data with Two Implied
Decimal Places

Edit Input String Output Explanation


Code String

1 +0000000000 .00 Commas and zero balance print without


a sign.
1 +0000123456 1,234.56 Commas and zero balance print without
a sign.
2 +0000123456 1,234.56 Commas print without zero balance or a
sign.
3 +0000123456 1234.56 Zero balance prints without commas or
a sign.
4 +0000123456 1234.56 No commas, zero-balance, or sign are
printed.
A +0000123456 1,234.56 Commas and zero-balance print. CR is
printed for negative status reporting.
B +0000123456 1,234.56 Commas print without zero-balance. CR
is printed for status reporting.
C +0000123456 1234.56 Zero balance prints without commas.
CR is printed for negative status
reporting.
D +0000123456 1234.56 No commas or zero balance is printed.
CR is printed for negative status
reporting.
J +0000123456 1,234.56 Commas and zero balance print. The
minus sign (–) is printed for negative
status reporting.
K +0000123456 1,234.56 Commas print without zero balance.
The minus sign (–) is printed for
negative status reporting.
L +0000123456 1234.56 Zero balance prints without commas.
The minus sign (–) is printed for
negative status reporting.
M +0000123456 1234.56 No commas or zero balance is printed.
The minus sign (–) is printed for
negative status reporting.
X +0000123456 0000123456 The plus sign (+) is removed.
Z +0000123456 123456 Zero suppression is performed.

8600 0544–103 17–31


Output-Format Specifications

Table 17–8 lists examples that show the effects of the edit codes on a negative, 10-digit,
numeric field with two implied decimal places.

Table 17–8. Effects of Edit Codes on Negative Data with Two Implied
Decimal Places

Edit Input String Output Explanation


Code String

1 –0000123456 1,234.56 Prints commas and zero balance


without a sign.
2 –0000123456 1,234.56 Prints commas without a zero balance
or a sign.
3 –0000123456 1234.56 Prints zero balance without commas or
a sign.
4 –0000123456 1234.56 No commas, zero balance, or sign is
printed.
A –0000123456 1,234.56CR Prints commas and zero balance. CR is
printed for negative status reporting.
B –0000123456 1,234.56CR Prints commas without a zero balance.
CR is printed for negative status
reporting.
C –0000123456 1234.56CR Prints zero balance without commas.
CR is printed for negative status
reporting.
D –0000123456 1234.56CR No commas or zero balance is printed.
CR is printed for negative status
reporting.
J –0000123456 1,234.56-- Prints commas and zero balance. The
minus sign (–) is printed for negative
status reporting.
K –0000123456 1,234.56-- Prints commas without a zero balance.
The minus sign (–) is printed for
negative status reporting.
L –0000123456 1234.56-- Prints a zero balance without commas.
The minus sign (–) is printed for
negative status reporting.
M –0000123456 1234.56-- No commas or zero balance is printed.
The minus sign (–) is printed for
negative status reporting.
X –0000123456 }000123456 A right brace (}) indicates negative
zero.
Z –0000123456 123456 Zero suppression is performed.

17–32 8600 0544–103


Output-Format Specifications

Edit Words
Edit words are alphanumeric literals that can be used instead of an edit code when a
special edit format is desired.

Note: An asterisk enclosed in apostrophes ('*') or a dollar sign enclosed in apostrophes


('$') is entered in columns 45 through 47 of the Edit Word field if a check-protect asterisk
or floating dollar sign is desired with an edit code. (Refer to the description of edit codes
earlier in this section.)

Edit words are functionally subdivided into the following three parts:

Part Description

Body Holds the significant data contained in the variable

Status Holds the sign of the data contained in the variable

Extension Holds the constant information to be printed with the body and the
status data used to make the resulting output field more
understandable

The body is defined differently depending on whether the RPG I or RPG II dialect is used.
For more information about which dialect is in effect, refer to the Source Input Dialect
field (column 51) of the Control Specification.

The body, working from left to right, consists of the following:

Dialect Contents of Body

RPG I Everything up to and including the nth replaceable character (where n


is the length of the numeric field to be edited)

RPG II Every replaceable character in the edit word up to, and including, the
rightmost replaceable character

Examples of valid entries for replaceable characters are shown later in this section.

The body generally contains appropriately spaced decimal points (.), commas (,),and
slashes (/). Other characters can also be specified to appear with the data of the variable
named in the Field Name field (columns 32–37). All leading zeros are suppressed up to
the position following a zero-suppression character.

The body should be at least as long as the variable, plus 1 byte for each punctuation
character specified. If the number of replaceable characters in the body is less than the
length of the variable, a syntax error occurs. If the number of replaceable characters
exceeds the length of the variable, the data is placed in the edit word right-justified in
RPG II and left-justified in RPG I.

8600 0544–103 17–33


Output-Format Specifications

The preceding rule regarding the size of the body of an edit word has the following
exceptions:

• Zero suppression of the high-order position of a variable can occur when the number
of replaceable characters in the body of the edit word equals the length specified for
the variable. The zero suppression of the high-order position of a variable does not
occur if the number of replaceable characters in the body of the edit word exceeds
the length of the variable by 1 and if the leftmost position of the edit word contains a
0 (zero).
• An extra space must be allowed in the edit word for a floating dollar sign if output is
to appear correctly when the variable contains its maximum value. If an extra space
is not allowed, a warning message is displayed. If the field contains its maximum
value, the leftmost digit is not printed.
A replaceable character is a part of the edit word that does not require an extra position
in the output field. The replaceable characters are as follows:

Entry Definition

Blank No entry

0 Zero suppression from this position, to the left

* Check-protect (asterisk fill)

The status entry of an edit word is either the minus sign (–) or the credit sign (CR). If the
value of the data is positive, the sign is not written, because no sign implies a positive
sign. If either a CR or a minus sign (–) appears after the body, the status portion of an
edit word consists of everything after the body up to and including the first CR or minus
sign (–). If a CR or a minus sign does not occur after the body, the edit word has no
status portion. The entire status section is written only if the value of the numeric
variable is negative.

The extension portion of the edit word contains constant data written with the variable
data to improve readability.

The extension portion of an edit word is optional and, if present, consists of everything
that appears after the body and status sections, if present. The extension section is
always printed exactly as coded except for the ampersand (&), which is printed as a blank
in RPG II and as an ampersand (&) in RPG I. In the following example, O'CLOCK is a
constant within the body of the edit word, and MIN. (minute) is the extension:

' &O''CLOCK& &MIN.'

The following rules must be observed when edit words are used:

• The Field Name field (columns 32–37) entry must be a numeric variable.
• Edit words must be left-justified, enclosed in apostrophes, and no longer than 24
characters.
• The entire character set is valid in edit words, with the exception of replaceable
characters.

17–34 8600 0544–103


Output-Format Specifications

• The number of replaceable characters in the edit word should be greater than or
equal to the length of the field to be edited.
• The field is padded with leading zeros before editing if the number of replaceable
characters in the body exceeds the length of the field to be edited.
• The Edit Code field (column 38) and the Packed field (column 44) must be blank.
• A zero or asterisk (*) in the edit word has the following effects:
− A zero causes insignificant zeros in the variable data to be filled with blanks in the
body.
− An asterisk (*) causes insignificant zeros in the variable data to be filled with
asterisks.
This substitution of characters begins at the position of the zero-suppress character
and extends left to the end of the field.
• All zeros and asterisks except the leftmost are considered constants if more than
one zero or asterisk is used in the edit word.
• Any constant to the left of the zero-suppression character (zero or asterisk), except
for the dollar sign ($), is also suppressed.
• Only the first zero is suppressed when the first character of the edit word is zero and
the field being edited contains leading zeros equal in length to the number of
replaceable characters.
• The leading zeros are not suppressed when the first character of the edit word is
zero and the variable field contains leading zeros of a length less than the number of
replaceable characters. Refer to edit word examples 61 and 62 later in this section.
• The ampersand (&) is replaced by a blank in the body and status portions of all edit
words. In the extension portion, the ampersand is replaced by a blank in RPG II and
is printed as an ampersand in RPG I.
• A floating dollar sign ($) is specified by placing a dollar sign immediately to the left of
the zero-suppression character—either a zero or an asterisk (*). The symbol printed
depends on the entry in the Currency Symbol field (column 22) in the Control
Specification.
Fixed dollar signs ($), decimal points (.), commas (,), ampersands (&), minus signs (–), and
constant information all require extra space in the output field.

Following are 63 examples of how to use edit words. The leftmost entry is the edit word,
which is coded in columns 45 through 70 of the Output Specifications. The input string
shows the input, and the output string shows the result of the editing.

8600 0544–103 17–35


Output-Format Specifications

Example 1
*....5....*....6....*....7 Input String Output String
0000123456 0000123456

Example 1 shows that without an edit word, a positive sign is forced to alphanumeric 0
through 9. Refer to the discussion of the External Sign Handling field (Column 40) in
Section 7, “Control Specification,” for information on printing of a positive zone sign.

Example 2
*....5....*....6....*....7 Input String Output String
-0000123456 }000123456

Example 2 shows that without an edit word, the sign position is not converted to a
numeric character. A right brace (}) indicates negative zero (–0).

Example 3
*....5....*....6....*....7 Input String Output String
' ' 0000000000

Example 3 shows that a blank edit word suppresses leading zeros.

Example 4
*....5....*....6....*....7 Input String Output String
' ' +0000123456 123456

Example 4 shows that a blank edit word suppresses leading zeros.

Example 5
*....5....*....6....*....7 Input String Output String
' ' -0000123456 123456

Example 5 shows that a blank edit word suppresses leading zeros.

Example 6
*....5....*....6....*....7 Input String Output String
' , , 0. ' 0000000005 .05

Example 6 shows a standard approach to editing an amount field. The decimal appears
between the dollars and cents. The commas mark each of three positions to the left of
the decimal. The zero-suppression character (0) immediately to the left of the decimal
causes zero suppression to the left.

17–36 8600 0544–103


Output-Format Specifications

Example 7
*....5....*....6....*....7 Input String Output String
' , , 0 -' 00000000 0

Example 7 shows that zero suppression begins where the zero-suppression character is
specified and continues to the left. An extra space occurs on the right side for the minus
sign (–).

Example 8
*....5....*....6....*....7 Input String Output String
' , , . -' -00000000123 1.23-

Example 8 shows that the status portion prints when the field is negative. Because no
zero-suppression character is specified, all insignificant zeros are suppressed.

Example 9
*....5....*....6....*....7 Input String Output String
' 0' -0000123456 123456

Example 9 shows that zero suppression performs no function when it is specified in the
rightmost position. The sign is not printed, because no status is specified in the edit
word.

Example 10
*....5....*....6....*....7 Input String Output String
'0 ' +0000123456 000123456

Example 10 shows that zero suppression begins where the zero-suppression character is
specified and continues to the left.

Example 11
*....5....*....6....*....7 Input String Output String
'$ 0 &CR GROSS' 0000000000 $ 00 GROSS
'$ 0 &CR GROSS' 0000000000 $ 00 CR0GROSS
'$ 0 &CR&GROSS' 0000000000 $ 00 &GROSS
'$ 0 &CR&GROSS' 0000000000 $ 00 GROSS

The output for example 11 depends on whether RPG I or RPG II is specified. The first
and third lines show the output for RPG I. Ten characters are present from the right of
the dollar sign ($) to the left of the ampersand (&). Eight zeros are suppressed. All zero
fields are positive.

The second and fourth lines show the output for RPG II. The blank between CR and
GROSS is interpreted as the last replaceable character, so CR is considered a constant
within the body and GROSS is the extension. An ampersand (&) is needed in place of the
blank between CR and GROSS to obtain the same output as in the first example.

8600 0544–103 17–37


Output-Format Specifications

Example 12
*....5....*....6....*....7 Input String Output String
' , , , -OLD BAL' 0000000000 OLD BAL
' , , , -OLD BAL' 0000000000 BAL
' , , , -OLD&BAL' 0000000000 OLD&BAL
' , , , -OLD&BAL' 0000000000 OLD BAL

The output for example 12 depends on whether RPG I or RPG II is specified. The first
and third lines show the output for RPG I. All 10 zeros are suppressed. Only the
extension portion of the edit word is displayed.

The second and fourth lines show the output for RPG II. The blank between OLD and
BAL is interpreted as the last replaceable character. All constants to the left of the zero-
suppression character, or the first printed digit, are suppressed. BAL is the extension. An
ampersand (&) is needed in place of the blank between OLD and BAL to obtain the same
output as RPG I.

Example 13
*....5....*....6....*....7 Input String Output String
' , 0. ' 000000 .00

Example 13 shows a standard approach to editing an amount field. A decimal point


appears between the dollars and cents. The comma marks three positions to the left of
the decimal. The zero-suppression character (0) immediately to the left of the decimal
causes zero suppression to the left.

Example 14
*....5....*....6....*....7 Input String Output String
' , .0 ' 000000 0

Example 14 shows how to suppress all insignificant zeros and punctuation.

Example 15
*....5....*....6....*....7 Input String Output String
' , , 0 * ' 0000000000 0*00

Example 15 shows that the zero-suppression character is the zero. The asterisk (*) is a
constant.

Example 16
*....5....*....6....*....7 Input String Output String
'0, ,0 ' 001234 ,012,034

Example 16 shows that only the first zero of the source data is suppressed. The second
zero of the edit word is considered a constant.

17–38 8600 0544–103


Output-Format Specifications

Example 17
*....5....*....6....*....7 Input String Output String
' , , . -' -000000015 15-

Example 17 shows the suppression of all insignificant zeros and punctuation.

Example 18
*....5....*....6....*....7 Input String Output String
' , , 0. -' 000000005 0.05

Example 18 shows the suppression of all insignificant zeros and punctuation to the left of
the zero-suppression character. An extra space occurs on the right side for the minus
sign (–).

Example 19
*....5....*....6....*....7 Input String Output String
' , ,$0. -' 0000000005 $0.05

Example 19 shows zero suppression along with a floating dollar sign ($). Placing the
dollar sign next to the zero-suppression character causes the currency symbol to float to
the last position that is zero-suppressed. An extra space occurs on the right side for the
minus sign (–).

Example 20
*....5....*....6....*....7 Input String Output String
' , , $0. CR**' -0012345678 $123,456.78CR**

Example 20 shows a floating dollar sign ($) with a negative amount. The edit word needs
one more replaceable position than is in the length of the source data to ensure a
position for the currency symbol when the output field is full.

Example 21
*....5....*....6....*....7 Input String Output String
'$ , , 0. ' 0000000000 $ .00

The dollar sign ($) in example 21 is not a floating dollar sign because it does not
immediately precede the zero-suppression character. All punctuation to the left of the
zero-suppression character is suppressed.

8600 0544–103 17–39


Output-Format Specifications

Example 22
*....5....*....6....*....7 Input String Output String
'$ &- NET' +0000123456 $ 123456 NET
'$ &- NET' +0000123456 $ 12345 -6NET
'$ &-&NET' +0000123456 $ 123456 &NET
'$ &-&NET' +0000123456 $ 123456 NET

The output for example 22 depends on whether RPG I or RPG II is specified. The first
and third lines show the output for RPG I. The edit word includes zero suppression along
with a constant dollar sign ($) and an extension portion.

The second and fourth lines show the output for RPG II. The blank between the minus
sign (–) and NET is interpreted as the last replaceable character. The minus sign (–) is
assumed to be a constant within the body, and NET is the extension. An ampersand (&)
is needed in place of the blank between the minus sign (–) and NET to obtain the same
output as for RPG I.

Example 23
*....5....*....6....*....7 Input String Output String
'$ &- NET' -0000123456 $ 123456 – NET
'$ &- NET' -0000123456 $ 12345 -6NET
'$ &-&NET' -0000123456 $ 123456 -&NET
'$ &-&NET' -0000123456 $ 123456 - NET

The output for example 23 depends on whether RPG I or RPG II is specified. The first
and third lines show the output for RPG I and include zero suppression with the status
portion reporting negative.

The second and fourth lines show the output for RPG II. The blank between the minus
sign (–) and NET is interpreted as the last replaceable character. The minus sign (–) is
assumed to be a constant within the body, and NET is the extension. An ampersand (&)
is needed in place of the blank between the minus sign (–) and NET to obtain the same
output as for RPG I.

Example 24
*....5....*....6....*....7 Input String Output String
'$0 - NET' +0000123456 $000123456 NET
'$0 - NET' +0000123456 $000012345-6NET
'$0 -&NET' +0000123456 $000123456 &NET
'$0 -&NET' +0000123456 $000123456 NET

The output for example 24 depends on whether RPG I or RPG II is specified. The first
and third lines show the output for RPG I and include both zero suppression in the high-
order position and a floating dollar sign ($).

The second and fourth lines show the output for RPG II. The blank between the minus
sign (–) and NET is interpreted as the last replaceable character. The minus sign (–) is
assumed to be a constant within the body, and NET is the extension. To obtain the same

17–40 8600 0544–103


Output-Format Specifications

output as for RPG I, an ampersand (&) is needed in place of the blank between the minus
sign (–) and NET.

Example 25
*....5....*....6....*....7 Input String Output String
' $0 &CR' -0000123456 $123456 CR

Example 25 shows a floating dollar sign ($) with the status portion reporting negative.

Example 26
*....5....*....6....*....7 Input String Output String
' $0 &CR' -1234567890 $1234567890 CR

Example 26 shows a floating dollar sign ($) with the status portion reporting negative.

Example 27
*....5....*....6....*....7 Input String Output String
' , ,$0 . NET' 0000000005 0.05 NET
' , ,$0 . NET' 0000000005 0.005NET
' , ,$0 . &NET' 0000000005 0.05&NET
' , ,$0 . &NET' 0000000005 0.05 NET

The output for example 27 depends on whether RPG I or RPG II is specified. The first
and third lines show the output for RPG I and include a floating dollar sign ($) with no
status. An extra blank in the edit word after the body is used to print a space between
the body and the extension.

The second and fourth lines show the output for RPG II. The blank is interpreted as the
last replaceable character and no blank is printed. An ampersand (&) placed between the
body and the extension to obtain the same result as for RPG I.

Example 28
*....5....*....6....*....7 Input String Output String
' , , $0. ' 0000000005 $.05

Example 28 shows a floating dollar sign ($).

Example 29
*....5....*....6....*....7 Input String Output String
' , , $0. -' -1234567890 $12,345,678.90-

Example 29 shows an edit word with a number of replaceable characters that exceeds
(by 1) the length of the field being edited so that there is enough space to print all the
digits.

Example 30
*....5....*....6....*....7 Input String Output String
' , , $0. CR' -0001234567 $12,345.67CR

8600 0544–103 17–41


Output-Format Specifications

Example 30 shows an edit word with a number of replaceable characters that exceeds
(by 1) the length of the field being edited so that there is enough space to print all the
digits.

Example 31
*....5....*....6....*....7 Input String Output String
' , $0, . -SALES' 0000001234 $,012.34 SALES

Example 31 shows an edit word with a number of replaceable characters that exceeds
(by 1) the length of the field being edited so that there is enough space to print all the
digits. The placement of the zero-suppression character causes undesirable results.

Example 32
*....5....*....6....*....7 Input String Output String
' , $,0 . ' 00123456 1$,234.56

Example 32 shows a dollar sign ($) and zero-suppression character that are separated;
therefore, the dollar sign is a constant in the body, not a floating dollar sign.

Example 33
*....5....*....6....*....7 Input String Output String
' , , * . &-' 0000123456 *****1,234.56

Example 33 shows that the check-protect asterisk (*) suppresses insignificant zeros and
punctuation, filling each position with an asterisk. Two extra spaces occur on the right
side, one for the ampersand (&) and one for the minus sign (–).

Example 34
*....5....*....6....*....7 Input String Output String
'* ' -0000123456 *000123456

Example 34 shows an edit word that is the same length as the field being edited, so the
asterisk (*) occupies one of the positions.

Example 35
*....5....*....6....*....7 Input String Output String
'* ' +1234567890 1234567890

Example 35 shows that the asterisk (*) is a replaceable character; when no insignificant
characters are present, it is replaced.

Example 36
*....5....*....6....*....7 Input String Output String
' *' -0000123456 ****123456

Example 36 shows that the check-protect asterisk (*) suppresses insignificant zeros and
punctuation, filling each position with an asterisk.

17–42 8600 0544–103


Output-Format Specifications

Example 37
*....5....*....6....*....7 Input String Output String
' , *, * ' 0000001234 ******,012*34

Example 37 shows that the check-protect asterisk (*) suppresses insignificant zeros and
punctuation, filling each position with an asterisk. The second asterisk is a constant in the
body. Placing the check-protect asterisk before the comma causes undesirable results.

Example 38
*....5....*....6....*....7 Input String Output String
'& ,* 0, ' 012345 **120,345

Example 38 shows that the ampersand (&) is for spacing and is not a replaceable
character. Check-protect asterisks (*) fill all insignificant positions. The zero is a constant
in the body.

Example 39
*....5....*....6....*....7 Input String Output String
' &CR NET' +0000123456 123456 NET
' &CR NET' +0000123456 12345 CR6NET
' &CR&NET' +0000123456 123456 &NET
' &CR&NET' +0000123456 123456 NET

The output for example 39 depends on whether RPG I or RPG II is specified. The first
and third lines show the output for RPG I. The first ampersand (&) is in the status portion
of the edit word and is replaced by a blank.

The second and fourth lines show the output for RPG II. The blank between CR and NET
is interpreted as the last replaceable character. CR is assumed to be a constant within
the body, and NET is the extension. An ampersand (&) is needed in place of the blank
between CR and NET to obtain the same output as for RPG I.

Example 40
*....5....*....6....*....7 Input String Output String
' &CR NET' -0000123456 123456 CR NET
' &CR NET' -0000123456 12345 CR6NET
' &CR&NET' -0000123456 123456 CR&NET
' &CR&NET' -0000123456 123456 CR NET

The output for example 40 depends on whether RPG I or RPG II is specified. The first
and third lines show the output for RPG I. The first ampersand (&) is in the status portion
of the edit word and is replaced by a blank. The status reports negative.

The second and fourth lines show the output for RPG II. The blank between CR and NET
is interpreted as the last replaceable character. CR is assumed to be a constant within
the body, and NET is the extension. The blank between CR and NET should be replaced
by an ampersand (&) to obtain the same output as for RPG I.

8600 0544–103 17–43


Output-Format Specifications

Example 41
*....5....*....6....*....7 Input String Output String
' &- NET' -0000123456 123456 – NET
' &- NET' -0000123456 12345 -6NET
' &-&NET' -0000123456 123456 -&NET
' &-&NET' -0000123456 123456 - NET

The output for example 41 depends on whether RPG I or RPG II is specified. The first
and third lines show the output for RPG I, which is the same as example 40, except that
a minus sign (–) is used for the status instead of CR.

The second and fourth lines show the output for RPG II. The blank between the minus
sign (–) and NET is interpreted as the last replaceable character. The minus sign (–) is
assumed to be a constant within the body, and NET is the extension. An ampersand (&)
is needed in place of the blank between the minus sign (–) and NET to obtain the same
result as for RPG I.

Example 42
*....5....*....6....*....7 Input String Output String
' &NET&CR' 0000123456 123456

Example 42 shows NET as part of the status, not the extension. NET is not displayed,
because the status is positive. If the order of CR and NET is reversed, then NET would
be printed regardless of the status. Extra spaces occur on the right side for &NET&CR.

Example 43
*....5....*....6....*....7 Input String Output String
' &NET CR' -0000123456 123456 NET CR
' &NET CR' -0000123456 12345 NET6CR
' &NET&CR' -0000123456 123456 NET CR

The output for example 43 depends on whether RPG I or RPG II is specified. The first line
shows the output for RPG I. NET is part of the status, not the extension. NET is
displayed because the extension reports negative. The second example shows the
output for RPG II. The blank between NET and CR is interpreted as the last replaceable
character. The blank between NET and CR should be replaced by an ampersand (&) to
obtain the same output as for RPG I. Because the ampersand (&) is placed in the status,
the last example results in identical output for RPG I and RPG II.

Example 44
*....5....*....6....*....7 Input String Output String
'$& , , . CR' -1234567890 $ 12,345,678.90CR

Example 44 shows a constant dollar sign ($). The ampersand (&) is used for spacing. The
status reports negative.

17–44 8600 0544–103


Output-Format Specifications

Example 45
*....5....*....6....*....7 Input String Output String
' , , *. *CR**' +0000123456 *****1,234.56 **

Example 45 shows that the first asterisk (*) indicates check-protect. The second asterisk
is part of the status. The third and fourth asterisks are the extension.

Example 46
*....5....*....6....*....7 Input String Output String
' , , *. *CR**' -0000123456 *****1,234.56*CR**

Example 46 is the same as example 45, but with the status reporting negative.

Example 47
....5....*....6....*....7 Input String Output String
'$& , , 0. &- GROSS' -1234567890 $ 12,345,678.90 – GROSS
'$& , , 0. &- GROSS' -1234567890 $ 1,234,567.89 -0GROSS
'$& , , 0. &-&GROSS' -1234567890 $ 12,345,678.90 -&GROSS
'$& , , 0. &-&GROSS' -1234567890 $ 12,345,678.90 - GROSS

The output for example 47 depends on whether RPG I or RPG II is specified. The first
and third lines show the output for RPG I and include a constant dollar sign ($). Leading
zeros are suppressed. The ampersands (&) are used for spacing. The status reports
negative. The extension is GROSS.

The second and fourth lines show the output for RPG II. The blank between the minus
sign (–) and GROSS is interpreted as the last replaceable character. The blank between
the minus sign (–) and GROSS should be replaced by an ampersand (&) to obtain the
same result as for RPG I.

Example 48
*....5....*....6....*....7 Input String Output String
'$& , , 0 . &-NET PAY' -1234567890 $ 12,345,678.90 -NET PAY
'$& , , 0 . &-NET PAY' -1234567890 $ 1,234,567.89 -NET0PAY
'$& , , 0 . &-NET&PAY' -1234567890 $ 12,345,678.90 -NET&PAY
'$& , , 0 . &-NET&PAY' -1234567890 $ 12,345,678.90 -NET PAY

The output for example 48 depends on whether RPG I or RPG II is specified. The first
and third lines show the output for RPG I, which is the same as that in example 47
except that the extension contains NET PAY instead of GROSS.

The second and fourth lines show the output for RPG II. The blank between NET and
PAY is interpreted as the last replaceable character. The –NET is assumed to be a
constant within the body, and PAY is the extension. An ampersand (&) is needed
between NET and PAY to obtain the same result as for RPG I.

8600 0544–103 17–45


Output-Format Specifications

Example 49
*....5....*....6....*....7 Input String Output String
'$& , , *. CR' -0000123456 $ *****1,234.56CR

Example 49 shows a constant dollar sign ($). Check-protect asterisks (*) are substituted
for insignificant zeros and punctuation.

Example 50
*....5....*....6....*....7 Input String Output String
' 0 LBS.& OZ.TARE&-' +000002 0LBS. 02

Example 50 shows that the first three zeros of source data are suppressed. The fourth
zero and the constant LBS are displayed. The ampersand (&) is used for spacing, and 02
is inserted. OZ.TARE&-- is the status. Because the value is positive, the status is not
printed. Extra spaces occur on the right side for OZ.TARE& and the minus sign (–). For
more meaningful output, refer to example 51.

Example 51
*....5....*....6....*....7 Input String Output String
' 0 &LBS.& - OZ. TARE' +000002 0 LBS. 02 OZ. TARE
' 0 &LBS.& - OZ. TARE' +000002 0 LBS. 00-0OZ.2TARE
' 0 &LBS.& -&OZ.&TARE' +000002 0 LBS. 02 &OZ.&TARE
' 0 &LBS.& -&OZ.&TARE' +000002 0 LBS. 02 OZ. TARE

The output for example 51 depends on whether RPG I or RPG II is specified. The first
and third lines show the output for RPG I. The intended extension portion of the previous
example is located after the status portion.

The second and fourth lines show the output for RPG II. The blanks between the minus
sign (–) and OZ and between OZ and TARE, are considered replaceable characters. An
ampersand (&) should replace the blanks in the two previously mentioned places to
obtain the same result as for RPG I.

Example 52
*....5....*....6....*....7 Input String Output String
' 0LBS. OZ.TARE&-' -000002 LBS.02OZ.TARE -

Example 52 shows that the first three zeros of the source data are suppressed. The
fourth zero and the constant LBS are displayed, and 02 is inserted. The status reports
negative. Refer to example 51 for more readable output.

17–46 8600 0544–103


Output-Format Specifications

Example 53
*....5....*....6....*....7 Input String Output String
' & & LATER' 031274 3 12 74 LATER
' & & LATER' 031274 31 274LATER
' & & &LATER' 031274 3 12 74&LATER
' & & &LATER' 031274 3 12 74 LATER

The output for example 53 depends on whether RPG I or RPG II is specified. The first
and third lines show the output for RPG I. Leading zeros are automatically suppressed.
Ampersands (&) are used for spacing. No status portion is present.

The second and fourth lines show the output for RPG II. The value is moved into the last
blank position. An ampersand is needed before LATER to obtain the same results as for
RPG I.

Example 54
*....5....*....6....*....7 Input String Output String
' PROFIT' 0000123456 123456 PROFIT
' PROFIT' 0000123456 123456PROFIT
' &&PROFIT' 0000123456 123456&&PROFIT
' &&PROFIT' 0000123456 123456 PROFIT

The output for example 54 depends on whether RPG I or RPG II is specified. The first
and third lines show the output for RPG I. Automatic zero suppression is performed. No
status is present, but there is an extension.

The second and fourth lines show the output for RPG II. The last two blanks are part of
the body, not the extension. The last two blanks should be replaced by ampersands (&)
to obtain the same results as for RPG I.

Example 55
*....5....*....6....*....7 Input String Output String
' , , . &CR NET' -0000123456 1,234.56 CR NET
' , , . &CR NET' -0000123456 123.45 CR6NET
' , , . &CR&NET' -0000123456 1,234.56 CR&NET
' , , . &CR&NET' -0000123456 1,234.56 CR NET

The output for example 55 depends on whether RPG I or RPG II is specified. The first
and third lines show the output for RPG I. Automatic zero suppression is performed. The
status reports negative, and an extension is present.

The second and fourth lines show the output for RPG II. The blank between CR and NET
is interpreted as the last replaceable character. The CR is assumed to be a constant
within the body, and NET is the extension. The blank between CR and NET should be
replaced by an ampersand (&) to obtain the same result as for RPG I.

8600 0544–103 17–47


Output-Format Specifications

Example 56
*....5....*....6....*....7 Input String Output String
' , , DOLLARS CENTS' 0000123456 1,234DOLLARS56CENTS

Automatic zero suppression is performed in example 56. Significant punctuation and


constants are printed.

Example 57
*....5....*....6....*....7 Input String Output String
' , DOLLARS CENTS' 000000 CENTS

Example 57 shows that automatic zero suppression also suppresses insignificant


constants in the body of the edit word. CENTS is the extension.

Example 58
*....5....*....6....*....7 Input String Output String
' , 0 DOLLARS CENTS&CR' 000000 0DOLLARS00

In example 58, the first three zeros of the source data are suppressed. CENTS&CR is the
status and is not printed, because the status reports positive. Extra spaces occur on the
right side for CENTS&CR.

Example 59
*....5....*....6....*....7 Input String Output String
' - - LATER' 093074 9-30-74 LATER
' - - LATER' 093074 93-074LATER
' - - &LATER' 093074 9-30-74&LATER
' - - &LATER' 093074 9-30-74 LATER

The output for example 59 depends on whether RPG I or RPG II is specified. The first
and third lines show the output for RPG I. Automatic zero suppression is performed.

The second and fourth lines show the output for RPG II. The rightmost blank is
interpreted as the last replaceable character. The last blank should be replaced by an
ampersand (&) to obtain the same result as for RPG I.

Example 60
*....5....*....6....*....7 Input String Output String
'0 - - ' 063369690 63-36-9690

Example 60 shows one method of editing a social security number. If the high-order zero
is not to be suppressed, refer to example 61.

17–48 8600 0544–103


Output-Format Specifications

Example 61
*....5....*....6....*....7 Input String Output String
'0 - - ' 063369690 633-69-690
'0 - - ' 063369690 063-36-9690

The output for example 61 depends on whether RPG I or RPG II is specified. The first line
shows the output for RPG I. Suppression of the high-order zero cannot be avoided.
Because RPG I considers the body to be the first n replaceable characters (where n
equals the length of the field being edited), the field is not filled on the left with an extra
zero.

The second line shows the output for RPG II. Suppression of the high-order zero can be
avoided by specifying an edit word with one extra position to the left of the body and by
placing the zero-suppression character in this position.

Example 62
*....5....*....6....*....7 Input String Output String
'0 HRS. MINS. 0''CLOCK' 0042 0HRS.42MINS. O'CLOCK
'0 HRS. MINS. 0''CLOCK' 0042 0HRS.04MINS.2O'CLOCK
'0 HRS. MINS.&0''CLOCK' 0042 0HRS.42MINS.&O'CLOCK
'0 HRS. MINS.&0''CLOCK' 0042 0HRS.42MINS. O'CLOCK

The output for example 62 depends on whether RPG I or RPG II is specified. The first
and third lines show the output for RPG I. Only the high-order position is zero-
suppressed. Because the apostrophe (') is used to delimit edit words and constants, it
must be specified twice for each time it appears in the output. Insertion of additional
ampersands (&) in the body of the edit word makes the output more readable.

The second and fourth lines show the output for RPG II. The blank between the period
and the O is interpreted as the last replaceable character. The blank should be replaced
by an ampersand to obtain the same result as for RPG I.

Example 63
*....5....*....6....*....7 Input String Output String
' / / ' 093074 9/30/74

Example 63 shows a method of editing a 6-digit date field. This method is comparable to
using the Y edit code on the same field.

8600 0544–103 17–49


Output-Format Specifications

Comparison of Edit Words and Edit Codes


Edit codes and edit words can be used to format output similarly, as shown in the
following example.

Example
Example 17–7 shows edit words and edit codes that produce the same formatted
output.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00300FFILEIN IP 80 80 DISK
00400FPRINT1 O 132 132 PRINTER
00500FPRINT2 O 132 132 PRINTER
00600IFILEIN AA 01
00700I 5 132AMT1
00800I 15 222AMT2
00900I 31 360DATE
00950I 40 470AMT3
01300OPRINT1 D 01
01400O AMT1 15 ' , , 0. -'
01500O AMT2 30 ' , . CR'
01600O DATE 40 ' / / '
01700O AMT3 50 ' '
01800O*
01900O* The following detail output record produces the same results
01910O* as the detail output record above.
01920O*
01930OPRINT2 D 01
01940O AMT1 J 15
01950O AMT2 B 30
01960O DATE Y 40
01970O AMT3 Z 50

Example 17–7. Comparing Edit Words and Edit Codes

17–50 8600 0544–103


Output-Format Specifications

Printing Reports
An important objective of most RPG programs is generating a printed report. Producing
readable report with minimum programming is the purpose of special features and
functions that have been incorporated into the language.

One special feature includes line printer skipping. Different methods are used by RPG I
and RPG II. The distinction between RPG I and RPG II is made in either the Line Printer
Skipping field (column 46) in the Control Specification or the Source Input Dialect field
(column 51) in the Control Specification. The skip to channel option is compatible with
RPG I, and the skip to line number option is compatible with RPG II.

Forms Specifications
Both the skip to channel and the skip to line number options can use Line Counter
Specifications, carriage control tapes, or both to control the paper movement on the
printer. No check is made to ensure that the carriage control tape agrees with the
channel-line equations; this check is the user's responsibility. However, the usages and
specifications for the two options differ in several respects, as described in the following
paragraphs.

Skip to Channel Option


When the skip to channel option is used, Line Counter Specifications are required and
must contain at least channel-line equations for channel 1 and channel 12. In addition, if
the default value for the form length is unsatisfactory, the form length and overflow line
should be given. If the line numbers associated with channel 12 and the overflow line are
not the same, the compiler displays an error message. If no overflow line is specified,
then the line number associated with channel 12 is considered the overflow line.

The default value for the form length is 66 lines, and the default value for the overflow
line is line 60. When these default values are acceptable, as many as 12 channel-line
equations can be specified in the Line Counter Specifications. If the default values are
not desired, the form length and overflow line must be entered in the first two sections
of the Line Counter Specifications, and only 10 channel-line equations can be specified.

In either case, every number specified in the Skip field (columns 19–22) in the Output
Specifications is assumed to be a channel number and must be equated to a line number
in the Line Counter Specifications. A syntax error is displayed if a skip to channel is
specified for a channel that does not have an associated line number.

Skip to Line Number Option


Line Counter Specifications are optional when the skip to line number option is used. The
default value for the form length is 66 lines, and for the overflow line it is line 60. When
these default values are acceptable, as many as 12 line-channel equations can be
specified on the Line Counter Specifications entry. If the default values are not desired,
then both the form length and the overflow line must be entered in the first two sections
of the Line Counter Specifications, and only 10 line-channel equations can be specified.

8600 0544–103 17–51


Output-Format Specifications

Entries in the Skip field (columns 19–22) in the Output Specifications are line numbers.

If a channel-line equation is specified for a line number used in the Skip field, a skip to
channel operation, rather than a skip to line number operation, is performed.

Page Formatting
The definition of a page depends on the type of line printer skipping being performed.

A page is defined in one of the following two ways:

• For the skip to channel option, a page is the potential number of lines of print,
starting at channel 1 of the carriage control tape and continuing through the line
before channel 12 of the carriage control tape.
• For the skip to line number option, a page is the potential number of print lines
between line 1 and the overflow line, inclusive.

End of Page (EOP)


The physical end of a page is reached when the paper becomes positioned in the
overflow area.

The overflow area is defined in one of the following two ways:

• For the skip to channel option, the overflow area extends from channel 12 to one line
before channel 1.
• For the skip to line number option, the overflow area extends from the first line after
the overflow line to one line before line 1.
When EOP is reached during a printer operation, one of the following actions occurs:

• Automatic skipping occurs when no overflow indicator is assigned to the file in the
Overflow Indicator field (columns 33–34) in the File Specifications. Because no
overflow indicator is defined for the file, one cannot be used to condition output.
Automatic skipping moves the paper from the overflow area to the top of the next
page before resuming print operations.
The paper is moved in one of the following two ways:
− The skip to channel option moves the paper from the overflow area to channel 1.
− The skip to line number option moves the paper from the overflow area to line 6.
• Continuous printing occurs when an overflow indicator is assigned to the file (in the
Overflow Indicator field) but is not used to condition printer-file record output. The
overflow indicator is defined and can be used in the Calculation Specifications. If
used in the Output Specifications, the overflow indicator is used only to condition
field descriptions of printer files.

17–52 8600 0544–103


Output-Format Specifications

• Overflow operations occur when an overflow indicator is assigned to the file (in the
Overflow Indicator field) and that indicator is used to condition printer-file record
output. Using the overflow indicator to condition printer-file record output defines the
lines of print that are to be written during overflow output. Skipping based on
overflow must be requested because this skipping is not done automatically.
When overflow operations are specified, normal overflow output can be printed when
the overflow output routine in the RPG cycle is reached. If fetched overflow is specified
(F in the Fetch Overflow field, column 16 in the Output Specifications), overflow output
can be printed immediately before the record described on the line containing the F in
column 16. This output is called fetched overflow output.

Overflow Indicators
One overflow indicator and one PAGE field are allowed for each printer file. These
indicators, OA–OG and OV, are the only method of determining the status of printer files.

Overflow indicators can be used only with printer files and are not assigned by default.
The assignment of overflow indicators determines the type of paper motion and overflow
handling that occurs according to the discussion of EOP in this section.

Overflow indicators work differently for the skip to channel option and the skip to line
number option, as described next.

Skip to Channel Option


An overflow indicator turns on in the following situations:

• When a line is actually printed in the overflow area.


• When the overflow area is used in the Resulting Indicators field (columns 54–59) in
the Calculation Specifications and is turned on by a calculation operation.
An overflow indicator turns off in the following situations:

• When the overflow indicator is used in the Resulting Indicators field in the Calculation
Specifications, and the operation turns it off.
• When the conditions of the overflow turn-off routine are satisfied. Refer to
Example 17–7 earlier in this section.

8600 0544–103 17–53


Output-Format Specifications

Skip to Line Number Option


An overflow indicator turns on in the following situations:

• When the destination specified in the Skip field (columns 19–22) in the Output
Specifications is in the overflow area.
• When the destination specified in the Space field (columns 16–18) in the Output
Specifications is in the overflow area.
• When a line is printed in the overflow area.
• When the overflow indicator is used in the Resulting Indicators field (columns 54–59)
in the Calculation Specifications and is turned on by a calculation operation.
An overflow indicator turns off in the following situations:

• When the destination specified in the Skip field in the Output Specifications is a new
page, and the record is not conditioned by the overflow indicator.
• When the overflow indicator is used in the Resulting Indicators field in the Calculation
Specifications, and the operation turns it off.
• When the conditions of the overflow turn-off routine are satisfied. Refer to
Example 17–7 earlier in this section.
The overflow indicator is not turned off if a new page is reached by spacing. Refer to
Table 17–9 and Figure 16–2 for more information on overflow operations.

Table 17–9 summarizes the effect of printer operations on overflow indicators.

Table 17–9. Printer Operations: Effects on Overflow Indicators

Printer Skip to Channel Skip to Line Number Option


Operation Option

OVERFLOW
AREA:
Skip No effect Turns on
Space No effect Turns on
Print Turns on Turns on
NEW PAGE:
Skip No effect Turns off on a line not
conditioned by an overflow
indicator
Space No effect No effect
Print No effect No effect

17–54 8600 0544–103


Output-Format Specifications

Overflow
Overflow handling is performed only once for any single physical overflow, whether
fetched or performed during the normal part of the PLC when overflow processing is
performed.

The RPG program distinguishes between overflow indicators that are turned on during
detail operations and those that are turned on during total operations. If turned on during
detail operations, overflow indicators are not turned off for one full cycle. If an overflow
indicator has been turned on during detail calculations and overflow is fetched, overflow
is still performed only once.

If the program overflow specifications leave the printer in the overflow area, the cycle
does not perform the overflow processing again. To perform overflow processing again,
the program must cause another physical overflow.

Overflow indicators can be controlled by the Calculation Specifications when used as


entries in the Resulting Indicators field (columns 54–59). When an overflow indicator is
on in the Calculation Specifications, the effect is the same as if a physical overflow
condition had occurred; in addition, the cycle keeps track of whether the indicator has
been turned on during detail or total calculations. When an overflow indicator is turned
off in the Calculation Specifications, the effect is the same as when overflow processing
has just been performed.

A composite flowchart of printer overflow operations is shown in Figures 17-2 through


17-5.

8600 0544–103 17–55


Output-Format Specifications

Figure 17–2. Printer Overflow and Fetch Routines

17–56 8600 0544–103


Output-Format Specifications

Figure 17–3. Printer Skip Routine

8600 0544–103 17–57


Output-Format Specifications

Figure 17–4. Printer Space and Start Routines

17–58 8600 0544–103


Output-Format Specifications

Figure 17–5. Printer Start Routines

8600 0544–103 17–59


Output-Format Specifications

The following is the sequence of printed output operations when all conditioning
indicators are satisfied:

1. The fetch overflow routine is specified for a record if the Fetch Overflow field
(column 16) contains an F. This routine can invoke the overflow routine, which in turn
can invoke the procedures listed in the following steps 2 through 7. These
procedures can be invoked as many times as required to produce all the overflow
output.
2. The skip routine is called if the Skip Before field (columns 19–20) is specified.
3. The space routine is called if the Space Before field (column 17) is designated.
4. The print routine is called.
5. The skip routine is called if the Skip After field (columns 21–22) is specified.
6. The space routine is called if the Space After field (column 18) is designated.
7. The overflow turn-off routine is called after all detail output is complete.
8. If the last record (LR) indicator is off, either of the following is called after all total
output is complete:
• The overflow routine
• The automatic skipping routine, if automatic skipping is also specified
Examples
The programs shown in Examples 17–8 and 17–9 provide two examples of overflow
coding.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00300FFILEIN IP 80 80 DISK
00400FFILEOUT O 132 132 OF PRINTER
00600IFILEIN AA 01
00700I 5 132FIELD1
00800I 15 222FIELD2
01000C FIELD1 ADD FIELD2 TOTAL 102
01005O*
01010O* Skip to line number 1 before first page output.
01020O*
01100OFILEOUT H 301 1P
01102O*
01105O* Skip to line number 2 before overflow.
01106O*
01110O OR 02 OF
01200O 45 'HEADING'
01205O*
01210O* Skip to line number 4 before and to line number 1 after
01220O* total output conditioned on the last record (LR) indicator.
01230O*

Example 17–8. Using the Skip to Line Number Option for Overflow (cont.)

17–60 8600 0544–103


Output-Format Specifications

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
01300O T 0401 LR
01305O*
01310O* Skip to line number 2 before and to line number 1 after
01320O* total output conditioned on overflow.
01330O*
01400O OR 0201 OF
01500O 45 'TOTAL'
01600O TOTAL 1 62

Example 17–8. Using the Skip to Line Number Option for Overflow

8600 0544–103 17–61


Output-Format Specifications

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00200H 1
00300FFILEIN IP 80 80 DISK
00400FFILEOUT O 132 132 OF PRINTER
00410L*
00412L* Define the line numbers associated with each channel number.
00414L*
00450LFILEOUT 1001 4510 1302 5011 5512
00500IFILEIN AA 01
00600I 5 132FIELD1
00700I 15 222FIELD2
00800C FIELD1 ADD FIELD2 TOTAL 102
00810O*
00820O* Skip to channel 1 before first page output.
00830O*
00900OFILEOUT H 01 1P
00910O*
00920O* Skip to channel 2 before overflow.
00930O*
01000O OR 02 OF
01100O 45 'HEADING'
01110O*
01120O* Skip to channel 11 before and to channel 1 after total
01130O* output conditioned on the LR indicator.
01140O*
01200O T 1101 LR
01210O*
01220O* Skip to channel 10 before and to channel 1 after total
01230O* output conditioned on overflow.
01240O*
01300O OR 1001 OF
01400O 45 'TOTAL'
01500O TOTAL 1 62

Example 17–9. Using the Skip to Channel Option for Overflow

Normal Overflow Output


The compiler performs normal overflow output when the following conditions are true:

• The overflow area is reached.


• The overflow indicator turns on.
• Normal overflow output is specified.
Columns 1 through 4 in Figure 17–6 illustrate four sequences of events that occur during
normal overflow output, depending where the overflow indicator turns on.

17–62 8600 0544–103


Output-Format Specifications

Figure 17–6. Printer Overflow Operations for Normal and Fetched Output

8600 0544–103 17–63


Output-Format Specifications

If the overflow area is reached during detail calculation exception output (refer to column
1 in the preceding figure), the following actions occur:

1. Remaining detail calculations are completed.


2. Detail and heading output not conditioned by the overflow indicator is performed.
3. The next record is read.
4. Total calculations are performed if a control break occurred in step 3.
5. Total output not conditioned by the overflow indicator is performed.
6. Total output conditioned by the overflow indicator is performed.
7. Heading and detail output conditioned by the overflow indicator is performed.
8. Detail calculations are performed.
9. Heading and detail output not conditioned by the overflow indicator is performed.
10. The overflow indicator is turned off.
When the overflow area is reached during detail output (refer to column 2 in Figure 17–
6), steps 2 through 10 are performed.

When the overflow area is reached during total calculation exception output (see column
3 in Figure 17–6), steps 4 through 10 are performed.

When the overflow area is reached during total output (see column 4 in Figure 17–6),
steps 5 through 10 are performed.

Fetched Overflow Output


If the overflow area is reached and fetched overflow has been specified, the compiler
performs the following sequence of operations before the record that specified the fetch
is printed (see column 5 in Figure 17–6):

1. Total output conditioned by the overflow indicator is performed.


2. Heading and detail output conditioned by the overflow indicator is performed.
3. The record that caused the overflow routine to be fetched is printed.
If the overflow area is reached during detail calculation exception output, the following
additional sequence of operations is performed:

1. Any remaining detail calculation exception output is performed.


2. The remaining detail calculations are finished.
3. Detail output that is not conditioned by the overflow indicator is performed.
4. The next record is read.
5. Total calculations are performed if a control break occurred in step 4.
6. Total output that is not conditioned by the overflow indicator is performed.

17–64 8600 0544–103


Output-Format Specifications

7. Overflow output is not performed. For exceptions, refer to the following discussion
of multiple output lines.
8. Detail calculations are performed.
9. Detail output is performed.
10. The overflow indicator is turned off.
If the overflow area is reached during detail output (see column 6 in Figure 17–6)
additional steps 3 through 10 are performed.

If the overflow area is reached during total calculation exception output (see column 7 in
Figure 17–6), additional steps 5 through 10 are performed.

If the overflow area is reached during total output (see column 8 in Figure 17–6),
additional steps 6 through 10 are performed.

Multiple Output Lines


When multiple output lines have been specified for a printer file, printing can be
continued either before or after overflow output, and the overflow area can be the final
destination again. In this case, all overflow can be printed again.

8600 0544–103 17–65


Output-Format Specifications

17–66 8600 0544–103


Section 18
Alternate Collating Sequence
Specifications

The system represents characters by hexadecimal (hex) values. The sequence of values
representing characters is called the normal collating sequence. Alternate Collating
Sequence Specifications explicitly modify the values of those characters and thus their
position in the collating sequence.

Table B–2 in Appendix B, “Reference Tables,” shows the EBCDIC values that can be
used for the normal collating sequence for RPG. The EBCDIC values are also used for the
translation table for RPG. Because the EBCDIC character set begins with 00 (hex) and
the hex value of any character is greater than 0 (zero), the position of a character in the
collating sequence is the decimal value of that character plus 1. For example, the
EBCDIC value of an A is 194, which has a decimal value of 193, or C1 (hex).

Note: In some cases, there are differences between the collating sequence for MCP
based systems and that of other systems. Data transferred from another system use the
hexadecimal value of the EBCDIC representation of the other system. As an example,
the differences between the MCP based systems and the IBM System/36 EBCDIC
tables are noted in Table B–2 later in this manual.

Either of the following methods can be used to specify a user-defined collating


sequence:

• Alternate Collating Sequence Specifications


• ** Specifications
Each method has advantages. However, it is easier to change a range of numbers with
the Alternate Collating Sequence Specifications. It is easier to exchange characters with
the ** Specifications.

For either method, the alternate collating sequence records must follow any Output
Specifications and precede any compile-time vector records. File translation records can
immediately precede or follow alternate collating sequence records.

File translation is another way to change the EBCDIC values. For more information, refer
to Section 19, “File Translation Specifications.”

8600 0544–103 18–1


Alternate Collating Sequence Specifications

Alternate Collating Sequence Specifications Coding


Form and Summary
The Alternate Collating Sequence Specifications use the values listed in Table B-2 in
Appendix B, “Reference Tables,” to create the alternate collating sequence.

Following are the rules for coding changes:

• The Collating Sequence field (column 26) in the Control Specification must contain an
S.
• Multiple sequence specifications can be entered if required. If multiple sequence
specifications are used, they must be grouped together. Only one collating sequence
can be specified for a program.
The following features are affected by an alternate collating sequence:

• Indexed file processing


• Match field comparisons
• Sequence checking of preexecution-time vectors
• ANDxx, CASxx, COMP, DOUxx, DOWxx, IFxx, LOKUP, and ORxx operations in the
Calculation Specifications
Figure 18–1 shows the Alternate Collating Sequence Specifications coding form.

Figure 18–1. Alternate Collating Sequence Specifications Coding Form

18–2 8600 0544–103


Alternate Collating Sequence Specifications

Table 18–1 summarizes the field definitions for the Alternate Collating Sequence
Specifications form.

Table 18–1. Field Definitions Summary (Alternate Collating Sequence


Specifications)

Columns Description

1–5 Identifies the program sequence numbers unless the $UNSEQ compiler
control option is TRUE.
6 Identifies the type of specification for each line of code. This field must be
coded with the letter S.
7 Contains an asterisk (*) if the line is a comment.
7–74 Designates the relative positions that the EBCDIC characters occupy in the
modified collating sequence.
75–80 Contains the program identification. Any entry is valid.

An entry in a column that is not part of any of the defined fields in a specification might
cause a warning message to be displayed.

Field Definitions
Field definitions for the Alternate Collating Sequence Specifications are discussed in the
following paragraphs.

Sequence Number (Columns 1–5)


The Sequence Number field contains a 5-digit sequence number (00000–99999) for an
RPG program source unless the $UNSEQ compiler control option is TRUE. Refer to
Section 21, “Control of the Compilation Process” for information about the $UNSEQ
option.

Form Type (Column 6)


The entry in the Form Type field identifies the type of specification. This field must
contain an S.

Comment (Column 7)
Explanatory statements can appear in the source if column 7 contains an asterisk (*). The
Comment entry enables the entire line to the right of the asterisk to appear as program
documentation on the program listing. Comments are not instructions to the RPG
program or compiler, but serve as program documentation. Any valid character can be
used in a comment line. An asterisk in column 7 overrides an entry in column 6.

8600 0544–103 18–3


Alternate Collating Sequence Specifications

Sequence Specifications (Columns 7–74)


Following are the rules for using the Sequence Specifications field:

• The characters specified in this field must be in the relative positions that they are to
occupy in the modified collating sequence, beginning with position 1 of that collating
sequence.
• Literals must be used to specify the characters. These literals can be numeric,
alphanumeric, or hexadecimal. The rules for the formation of literals are described in
Section 2, “RPG Language Elements.”
• Character values not specified by a literal have values greater than those specified in
the modified collating sequence. The relative order of these unspecified characters is
unchanged from the normal collating sequence.
• If a numeric literal is used, it specifies the position of a character in the normal
collating sequence. This literal must be an unsigned integer in the range 1 through
256 (the maximum number of characters in the EBCDIC character set).
• If an alphanumeric literal is used, it specifies the collating sequence position of that
character. If the value of the alphanumeric literal contains multiple characters, each
character in the literal, starting with the leftmost character, is assigned a successive
ascending position in the modified collating sequence.
• If a hexadecimal literal is used, it specifies the character with that value.
• A range of characters can be specified by placing a dash (–) between the beginning
and ending literals of the range. If a range is specified, the contiguous characters in
the character set are assigned successive ascending positions in the modified
collating sequence, beginning with the character specified by the leftmost literal and
ending with the character specified as the rightmost literal. This range can be in
either ascending or descending order. If the literal is alphanumeric, the beginning and
ending literals of the range must each contain one character.
• Two or more characters in the normal collating sequence can be assigned the same
position in the modified collating sequence by specifying the literals for each of the
characters with an ampersand (&) between them.
• No character can be assigned more than one position in the collating sequence.

Program Identification (Columns 75–80)


The Program Identification field entry is not used by the compiler but appears on the
source program listing so that the field can be used to document different portions of the
program.

18–4 8600 0544–103


Alternate Collating Sequence Specifications

Examples of Coding Alternate Collating Sequence


Specifications
The following examples assume that each Alternate Collating Sequence Specification is
the only one included in the RPG program. The characters enclosed in apostrophes are
alphanumeric literals.

Example 1
In this example, characters G and F, which have values of 200 and 199, are modified to
be the first and second characters of the collating sequence.

01000S 200 199

The modified collating sequence is as follows:

Position 1 2 ... 198 199 200 201 ...

Character G F ... D E H I ...

Hex Value C7 C6 ... C4 C5 C8 C9 ...

Example 2
The following example shows three methods for specifying the same alternate collating
sequence. The first 14 characters in the collating sequence are unchanged; however, 'H'
has a value of 15 and 'G' has a value of 16. The remaining characters then follow 'G' in
the new collating sequence.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00500S* First method
00600S*
00700S @00@ - @0D@ 'H' 'G'
00800S*
00900S* Second method
01000S*
01100S @00@ - @0D@ 'HG'
01200S*
01300S* Third method
01400S
01500S@00@ - @0D@ @C8C7@

8600 0544–103 18–5


Alternate Collating Sequence Specifications

The modified collating sequence is as follows:

Position 1 ... 14 1 16 17 18 ...


5

Character NUL ... CR H G S0 S1 ...

Hex Value 00 ... 0D C C7 0E 0F ...


8

Example 3
In the following example, the characters in positions 241 through 250 of the normal
collating sequence (that is, '0' through '9') occupy positions 1 through 10 in the modified
collating sequence.

01000S 241-250

Example 4
In the following example, characters '9' through '0', in descending order, appear in
positions 1 through 10 in the modified collating sequence.

01000S '9' - '0'

Example 5
In the following example, the characters 'A', 'B', and 'C' occupy positions 1, 2, and 3 of
the modified collating sequence.

01000S 'A' 'B' 'C'

Example 6
In the following example, the characters in positions 12, 13, 14, and 15 of the normal
collating sequence occupy position 1 of the modified collating sequence.

01000S 12 & 13 & 14 & 15

Example 7
In the following example, the characters 'A' and 'B' occupy position 1 of the modified
collating sequence. The character 'C', in position 196 of the normal collating sequence,
occupies position 2 of the modified collating sequence. The character 'D' (C4 hex)
occupies position 3 of the modified collating sequence.

01000S 'A' & 'B' 196 @C4@

18–6 8600 0544–103


Alternate Collating Sequence Specifications

Example 8
Example 18–1 shows a program sample that changes the collating sequence by using
the Control Specification and the Alternate Sequence Collating Specifications. The
relative order of characters in the collating sequence is important rather than the position.
The values for '0' through '9' are equal to each other, but are less than any characters.
The new sequence makes 'b' greater than A, H less than 'i', and '9' equal to '4'.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00200H S
00400FDUMMY IP F 80 80 DISK
00600FOUTPUT O 80 80 DISK
00700IDUMMY NS 01
00800I*
00900C 'bbb' COMP 'AAA' 1012
00920C EXCPT
00930C 'CHS' COMP 'CiS' 1012
00940C EXCPT
00960C '131' COMP '486' 101214
00970C EXCPT
01600OOUTPUT E
01700O 10 40 'F1 > F2'
01800O 12 40 'F1 < F2'
01889O 14 40 'F1 = F2'
01900S* The next line makes all numbers occupy position 1
01950S '0' & @F1@ & 243 & '3' & '4' & @F5@ & '6' & '7' & '8' & '9'
02000S 'a''A''b''B''c''C''d''D''e''E''f''F''g''G''h''H''i''I'
02100S 'j''J''k''K''l''L''m''M''n''N''o''O''p''P''q''Q''r''R'
02200S 's''S''t''T''u''U''v''V''w''W''x''X''y''Y''z''Z'

Example 18–1. Changing the Collating Sequence Using the Alternate Collating
Sequence Specifications

8600 0544–103 18–7


Alternate Collating Sequence Specifications

** Specifications
Following are rules for changing the collating sequence by using the ** Specifications:

• Using the ** Specifications requires using the $UNSEQ compiler control option.
When $UNSEQ is TRUE, an RPG source record is not required to have a sequence
number in columns 1 through 5. The $UNSEQ compiler control option is described
further in Section 21, “Control of the Compilation Process.”
• The Collating Sequence field (column 26) in the Control Specification must contain an
S.
• The first data record must contain two asterisks (**) followed by a blank character in
columns 1 through 3.
• The second and any additional data records must be coded as follows:
Columns Description

1–6 Must contain ALTSEQ.

7–8 Must be blank.

9–10 Must contain the hexadecimal value of the character whose normal
collating sequence is being changed.

11–12 Must contain the hexadecimal value of the character that replaces the
character in the normal collating sequence.

13–16, Can be used in the same way as columns 9 through 12 are used to fill up
17–20, the entire record with changes to the collating sequence. Blanks are not
21–24,..., allowed between the 4-position entries because the first blank ends the
93--96 record.

• More than one record can be used if the collating sequence of many characters
needs to be changed.
• A record with double asterisks (**) and then a blank character in columns 1 through 3
must follow the last record that specifies an alternate collating sequence.
• If a character is inserted between two consecutive characters, the collating
sequence must be changed for every character affected. For example, if you insert
an A between the lowercase letters a and b, then the collating sequence from b
through i must be changed.

18–8 8600 0544–103


Alternate Collating Sequence Specifications

Example
Example 18–2 shows a program sample that changes the collating sequence of the
lowercase letters a through m to take the positions of A through M; that is, lowercase a
takes the position of A, b takes the position of B, and so on.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00050H* The Control Specification must contain an S in column 26.
00060H*
00100H S
00150F*
00200F* File, Input, Calculation, and Output Specifications
**
ALTSEQ 81C182C283C384C485C586C687C788C889C991D192D2N3D394D4
**

Example 18–2. Changing the Collating Sequence Using the ** Specifications

8600 0544–103 18–9


Alternate Collating Sequence Specifications

18–10 8600 0544–103


Section 19
File Translation Specifications

File translation is used to alter the hexadecimal value of one or more characters of the
file. File translating often is used for file security. I/O data can be translated to protect
classified information.

Characters for an input file are translated when the file is read. Characters for an output
file are translated before the file is written. Characters for an update or combined file are
translated when the file is read and when it is written.

Table B–2 in Appendix B, “Reference Tables,” shows the EBCDIC values that can be
used for the system-defined translation table for RPG. The EBCDIC values are also used
for the normal collating sequence for RPG. Because the EBCDIC character set begins
with 00 (hex) and the value of a character must be an integer greater than 0, the value of
a character is the decimal value of that character plus 1. For example, the EBCDIC value
of an A is 194, which has a decimal value of 193, or C1 (hex).

Note: In some cases, there are differences between the MCP based systems
translation table and that of other systems. Data transferred from another system use
the hexadecimal value of the EBCDIC representation of the other system. As an
example, the differences between the MCP based systems and the IBM System/36
EBCDIC tables are noted in Table B–2.

Either of the following methods can be used to specify a user-defined file translation. A
translation table is used to change the collating sequence of a file.

• File Translation Specifications


• ** Specifications
Each method has advantages. It is easier to translate a range of numbers with the File
Translation Specifications. It is easier to exchange characters with the ** Specifications.

Refer to Section 18, “Alternate Collating Sequence Specifications,” for more information
about changing the EBCDIC values.

8600 0544–103 19–1


File Translation Specifications

File Translation Specifications Coding Form and


Summary
The file to be translated must have one of the following to use the File Translation
Specifications:

• The File Translation field (column 67) in the File Specifications for this file must
contain an S.
• The File Translation field (column 43) in the Control Specification must contain an F.
Figure 19–1 shows the File Translation Specifications form.

Figure 19–1. File Translation Specifications Coding Form

Table 19–1 summarizes the field definitions for the File Translation Specifications coding
form.

Table 19–1. Field Definitions Summary (File Translation


Specifications)

Columns Description

1–5 Identifies the program sequence numbers unless


6 Identifies the type of specification for each line of code. This field must be
coded with the letter X.
7 Contains an asterisk (*) if the line is a comment.
7–14 Names the file being translated.
15–74 Designates the relative positions that the EBCDIC characters occupy in
the translation table.
75–80 Contains the program identification. Any entry is valid.

An entry in a column that is not part of any of the defined fields in a specification might
cause warnings to be displayed.

19–2 8600 0544–103


File Translation Specifications

Field Definitions
Field definitions for the File Translation Specifications are discussed in the following
paragraphs.

Sequence Number (Columns 1–5)


The Sequence Number field contains a 5-digit sequence number (00000–99999) for an
RPG program source unless the $UNSEQ compiler control option is TRUE. Refer to
Section 21, “Control of the Compilation Process,” for information about the $UNSEQ
option.

Form Type (Column 6)


The entry in the Form Type field identifies the type of specification. This field must
contain an X.

Comment (Column 7)
Explanatory statements can appear in the source if column 7 contains an asterisk (*). The
Comment entry enables the entire line to the right of the asterisk to appear as program
documentation on the program listing. Comments are not instructions to the RPG
program or compiler, but serve as program documentation. Any valid character can be
used in a comment line. An asterisk in column 7 overrides an entry in column 6.

Filename (Columns 7–14)


This field identifies the file for which this translation table is to be used. If the Filename
field is blank, the file name defaults to the file name on the previous File Translation
Specifications. The first File Translation Specifications must specify a file name. File
Translation Specifications that apply to the same file must be grouped together.

Translation Table (Columns 15–74)


This field specifies the position that the translated characters are to occupy, beginning
with position 1.

The compiler displays a warning message if the complete table is not specified. All
unspecified characters are allocated to unused positions that are greater than the
specified positions in the table. The unspecified characters remain in the same relative
order as in the EBCDIC character sequence.

The characters are specified in the form of RPG literals. These literals can be numeric,
alphanumeric, or hexadecimal.

Numeric literals specify the ordinal position of a character in the EBCDIC character set.
This literal must be an unsigned integer in the range 1 through 256 (the maximum
number of characters in the EBCDIC character set).

8600 0544–103 19–3


File Translation Specifications

If an alphanumeric literal or a hexadecimal literal is used, it specifies the actual character


in the EBCDIC character set. If the value of the alphanumeric literal contains multiple
characters, each character in the literal is assigned a successive ascending position in the
translation table, starting with the leftmost character.

A range of characters can be specified by placing a hyphen (–) between the beginning
and ending literals of the range. This range of contiguous characters in the EBCDIC
character set can be in either ascending or descending order. Specifying a range of
characters causes each character within that range of the EBCDIC character set to be
assigned a successive ascending position in the nonnative character set. If alphanumeric
literals are used, the beginning and ending literals of the range must each contain one
character.

Mapping two or more nonnative characters to one native character is allowed only for
input files. This mapping can occur if a particular native character appears two or more
times in the File Translation Specifications for an input file.

Mapping of one nonnative character to more than one native character is allowed only for
output files. Two or more characters in the EBCDIC character set can be assigned to the
same character in the nonnative character set by specifying the literals for each of the
characters with an ampersand (&) between them. No character can be specified more
than once.

For an update or combined file, the specified mapping must be a one-to-one mapping so
that the characters in the two code sets are uniquely paired.

The character representation is assumed to be an 8-bit byte.

Program Identification (Columns 75–80)


The Program Identification field entry is not used by the compiler but appears on the
source program listing so that the field can be used to document different portions of the
program.

19–4 8600 0544–103


File Translation Specifications

Examples of Coding File Translation Specifications


The following examples assume that each File Translation Specifications is the only one
in the RPG program. The characters enclosed in apostrophes are alphanumeric literals.

Example 1
In the following example, the characters occupying positions 1 and 2 in the nonnative
character set from file FILE1 are reversed; that is, the characters are mapped onto
positions 2 and 1 in the native character set.

00100XFILE1 2 1

Example 2
In the following example, characters '9' through '0' in the native character set from FILE1
are associated with positions 1 through 10 in the nonnative character set.

00100XFILE1 '9'-'0'

Example 3
In the following example, characters in positions 1 through 3 of the nonnative character
set from FILEIN are mapped onto character 'A' in the native character set. Many-to-one
mappings, such as this one, are allowed only for input files.

00100XFILEIN 'A' 'A' 'A'

Example 4
In the following example, characters 'A', 'B', and 'C' in the native character set for
FILEOUT are mapped onto the character associated with position 1 in the nonnative
character set. One-to-many mappings, such as this one, are allowed for output files only.

00100XFILEOUT 'A' & 'B' & 'C'

8600 0544–103 19–5


File Translation Specifications

** Specifications
Following are the rules for using the ** Specifications for file translation:

• Using the ** Specifications requires using the $UNSEQ compiler control option.
When $UNSEQ is TRUE, an RPG source record is not required to have a sequence
number in columns 1 through 5. The $UNSEQ compiler control option is described
further in Section 21, “Control of the Compilation Process.”
• The file to be translated must have one of the following:
− The File Translation field (column 67) in the File Specifications for this file must
contain an S.
− The File Translation field (column 43) in the Control Specification must contain an
F.
• The first data record must contain two asterisks (**) followed by a blank character in
columns 1 through 3. The remaining columns can be used for comments. The two
asterisks are used in place of a specific coding form.
• The second and subsequent data records must contain the following:
Columns Description

1–8 To translate all files, columns 1 through 6 must contain *FILES and
columns 7 and 8 must be blank. The compiler translates all input,
output, update, and combined files.

To translate a specific file, columns 1 through 8 must contain the name


of the specific file to be translated.

9–10 Must contain the hexadecimal value of the EBCDIC character that is to
be replaced.

11–12 Must contain the hexadecimal value of the EBCDIC character that is
replacing the original character.

13–16, Can be used in the same way as columns 9 through 12 are used to fill
17–20, ..., the entire record with translation entries. The first blank ends the record.
93--96 If needed, more than one record can be used.

19–6 8600 0544–103


File Translation Specifications

Example
In Example 19–1, the name RON is replaced by a code name JIM.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00050H* The Control Specification must contain an F in column 43.
00060H*
00100H F
00100F*
00200F* File, Input, and Calculation Specifications
00500O* Output Specifications
00600O* D9=R, D1=J, D6=O, C9=I, D5=N, D4=M
**
*FILES D9D1D6C9D5D4

Example 19–1. Translating a File Using the ** Specifications

8600 0544–103 19–7


File Translation Specifications

19–8 8600 0544–103


Section 20
Vector Data Specifications

A compile-time vector is loaded with data at compilation time. The data to be loaded are
read into the program memory, which is reserved by the entries in the Extension
Specifications.

Compile-time vector data are placed at the end of the source program after any Alternate
Collating Sequence or File Translation Specifications.

A loaded compile-time vector becomes a permanent part of the program so that a vector
file is not needed when the program is executed. Only vectors that do not change often
should be compiled into the program. Refer to the description of source-file maintenance
in Section 21, “Control of the Compilation Process,” for more information.

More than one compile-time vector (or pair of alternating compile-time vectors) can be
loaded.

The maximum length of an alphanumeric compile-time vector is equal to the length of


the specification used for input. The maximum length is 96 characters.

The following entries are required in the Extension Specifications when a compile-time
vector is used:

• The Entries Per Record field (columns 33–35) must identify the maximum number of
entries that are contained in the vector.
• The From Filename field (columns 11–18) must be blank.
• The Packed field (column 43) must not contain P, J, or B because a compile-time
vector cannot be in packed or binary format.
The following list describes the vector data specification record:

• The vector data specification record can be either a Vector Data Specifications form
or an ** Specifications. The two types of vector data specification records are
described further on the following pages.
• Each set of compile-time vector data must appear in the order in which the
associated vector was specified. The data start on a new record and must be
preceded by a vector data specification record.
• The vector data are separated from the source code by a Vector Data Specifications
record. All records up to (but not including) the next Vector Data Specifications record
or EOF are loaded into the first compile-time vector (or pair of alternating compile-
time vectors) specified in the Extension Specifications.

8600 0544–103 20–1


Vector Data Specifications

If more records occur than are needed to load the vector, the excess records are ignored.
If fewer records occur than are needed to load the vector (that is, a short vector), any
remaining vector elements are initialized as follows:

Vector Element Results of Initialization

Unordered alphanumeric Blanks

Unordered numeric Zeros

Ascending alphanumeric FF (hex)

Ascending numeric 9s (and + in the sign position)

Descending alphanumeric 00 (hex)

Descending numeric 9s (and – in the sign position)

If any set of data contains either more records or fewer records than the number
specified to fill the vector, a warning message is displayed.

20–2 8600 0544–103


Vector Data Specifications

Vector Data Specifications Coding Form and


Summary

The coding form for Vector Data Specifications is shown in Figure 20–1.

Figure 20–1. Vector Data Specifications Coding Form

Table 20–1 summarizes the field definitions for the Vector Data Specifications form.

Table 20–1. Field Definitions Summary (Vector Data Specifications)

Columns Description

1–5 Identifies the program sequence numbers unless the $UNSEQ compiler
control option is TRUE.
6 Identifies the type of specification for each line of code. This field must be
coded with the letter V.
7 Contains an asterisk (*) if the line is a comment.
7–12 Contains the word VECTOR.
14–16 Controls the starting column position of the vector data. Acceptable
entries are blank or SEQ.
75–80 Contains the program identification. Any entry is valid.

An entry in a column that is not part of any of the defined fields in a specification might
cause a warning message to be displayed.

Field Definitions
Following are the field definitions for the Vector Data Specifications form.

Sequence Number (Columns 1–5)


The Sequence Number field contains a 5-digit sequence number (00000–99999) for an
RPG program source unless the $UNSEQ compiler control option is TRUE. Refer to
Section 21, “Control of the Compilation Process,” for information about the $UNSEQ
option.

8600 0544–103 20–3


Vector Data Specifications

Form Type (Column 6)


The entry in the Form Type field identifies the type of specification. This field must
contain a V.

Comment (Column 7)
Explanatory statements can appear in the source if column 7 contains an asterisk (*). The
Comment entry enables the entire line to the right of the asterisk to appear as program
documentation on the program listing. Comments are not instructions to the RPG
program or compiler, but serve as program documentation. Any valid character can be
used in a comment line. An asterisk in column 7 overrides an entry in column 6.

Vector Specifications (Columns 7–12)


This field must contain the word VECTOR.

No comments can appear after the first VVECTOR record. An asterisk (*) in column 7 is
considered part of a vector data record.

SEQ (Columns 14–16)


This field controls the starting column position of the vector data.

Valid entries for the SEQ field are as follows:

Entry Description

Blank The vector data are encoded starting at the first position in each record. Only
the VVECTOR records have sequence numbers in columns 1 through 5.

SEQ The vector data are encoded in columns 6 through 80. The Sequence
Number field and the mark field are treated the same as other records of the
source program are treated.

Columns 13, 17–74


These columns must be blank.

Program Identification (Columns 75–80)


The Program Identification field entry is not used by the compiler but appears on the
source program listing so that the field can be used to document different portions of the
program.

20–4 8600 0544–103


Vector Data Specifications

Examples of Coding Vector Data Specifications


The following are examples of loading compile-time vectors.

Example 1
Example 20–1 shows the loading of three compile-time vectors.

The two lines following 11000 are used to load ARRAY1. The line following line 11500 is
used to load ARRAY2. The five lines following line 12000 load TABLE1 and TABLE2 in
alternating format. The first five characters on each line are placed in TABLE1, and the
remaining seven numbers on each line are loaded into TABLE2. Refer to Section 10,
“Extension Specifications,” for information about vectors in alternating format.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
02000FFILEIN IP 80 80 DISK
03000FFILEOUT O 132 132 PRINTER
04000E FILEOUT ARRAY1 2 3 4 A
05000E ARRAY2 3 3 3 1
06000E TABLE1 1 5 5 ATABLE2 7 2A
07000IFILEIN AA 01
08000I 5 80FILLER
09000OFILEOUT D 01
10000O FILLER 8
11000VVECTOR
AAAABBBB
CCCC
11500VVECTOR
111222333
12000VVECTOR
AAAAA1111111
BBBBB2222222
CCCCC3333333
DDDDD4444444
EEEEE5555555

Example 20–1. Loading Three Compile-Time Vectors Without Using the SEQ Field

8600 0544–103 20–5


Vector Data Specifications

Example 2
Example 20–2 shows the loading of a compile-time record when SEQ is entered on a
VVECTOR specification.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
04100E MSG 1 2 60
04200E*
04200E* Vector MSG has two 60-character alphanumeric
04400E* elements with one element per record of the source file.
05000E* :
06000E* :
....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
98000VVECTOR SEQ
98100THIS LINE IS THE VALUE OF THE FIRST ELEMENT OF 'MSGS'
98200THIS LINE IS THE VALUE OF THE SECOND ELEMENT OF 'MSGS'

Example 20–2. Loading a Compile-Time Vector Using the SEQ Field

20–6 8600 0544–103


Vector Data Specifications

** Specifications
A record with ** followed by a blank character in columns 1 through 3 must precede the
data for each compile-time vector.

Example
Example 20–3 is the same as Example 20--1 except that ** Specifications are used
instead of Vector Data Specifications.

.....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
02000FFILEIN IP 80 80 DISK
03000FFILEOUT O 132 132 PRINTER
04000E FILEOUT ARRAY1 2 3 4 A
05000E ARRAY2 3 3 3 1
06000E TABLE1 1 5 5 ATABLE2 7 2A
07000IFILEIN AA 01
08000I 5 80FILLER
09000OFILEOUT D 01
10000O FILLER 8
**
AAAABBBB
CCCC
**
111222333
**
AAAAA1111111
BBBBB2222222
CCCCC3333333
DDDDD4444444
EEEEE5555555

Example 20–3. Loading Three Compile-Time Vectors Using ** Specifications

8600 0544–103 20–7


Vector Data Specifications

20–8 8600 0544–103


Section 21
Control of the Compilation Process

This section describes the files the compiler uses during compilation, the compilation
process, the methods used to control the compilation, and the report the compiler
provides to estimate the memory it will use.

The compilation is controlled by compiler control records (CCRs) or compiler directives.


CCRs contain compiler control options that control the compilation. A description of each
compiler control option and compiler directive is provided. Compiler directives can be
designated in any specification except for the Vector Data Specifications.

Compiler Files
The compiler files are the files the compiler uses and creates during the compilation.

The files the compiler uses for input are described in the following list:

• The CARD file is the first file the compiler reads. The function of the CARD file
depends on the setting of the MERGE compiler control option, which if used must
appear in the CARD file.
− If the MERGE option is FALSE, the compiler uses the CARD file as the symbol
file (that is, the primary input file that contains the source language input of the
program to be compiled.)
− If the MERGE option is TRUE, the compiler uses the SOURCE file as the symbol
file and the CARD file as the file that updates the SOURCE file with patches.
• The SOURCE file is the file from which the compiler reads previously stored source
records. The compiler is directed to this file when the MERGE option is TRUE.
Patches to this file appear in the CARD file.
The DEPENDENTSPECS file attribute is set to TRUE for all compiler input files. To set file
attributes that are different from the permanent file (for example, the file attribute
BLOCKSIZE), you must set DEPENDENTSPECS to FALSE.

The files the compiler uses for output are described in the following list:

• The NEWSOURCE file is the output symbol file that is created when the NEW option
is TRUE. A NEWSOURCE file can be used as a symbol file for a subsequent
compilation.
− If the MERGE option is FALSE, this symbol file is a copy of the CARD file.

8600 0544–103 21–1


Control of the Compilation Process

− If the MERGE option is TRUE, a symbol file is created that merges the CARD file
and SOURCE file.
• The LINE file is the file the compiler generates as its output listing.
• The CODE file contains the compiled object code.
• The ERRORS file contains any source records that have syntax errors and the error
messages for those source records. If no syntax errors occur during the compilation,
no ERRORS file is produced.
− If the compiler is started with WFL and compiler file equation is not applied to
the ERRORS file, errors are written to the LINE file and no ERRORS file is
created.
− If the compiler is started with CANDE, the ERRORS file is written to the remote
station that started the compiler.
• The ERRORSOURCE file contains both the source program and the error messages
intermixed.
Table 21–1 shows the default device and the purpose of each compiler file.

Table 21–1. Purposes and Default Devices for Compiler


Files

Internal and Default Device Purpose


Default Title

CARD READER Primary input


SOURCE DISK Secondary input
NEWSOURCE DISK Symbolic output
LINE PRINTER Output listing
CODE DISK Object code output
ERRORS PRINTER Error output
ERRORSOURCE DISK Symbolic output with
error

21–2 8600 0544–103


Control of the Compilation Process

Compilation of the Program


Programs can be compiled through CANDE or WFL. The user can choose the method
that is the most familiar or most convenient. It is important to note that the default value
of a compiler control option for a given program can be different for each method of
compilation.

Table 21–2 shows the different default values for compiler control options when a
program is compiled through CANDE or WFL. If an option is not listed, its default value is
the same for both compilation methods and is described in the discussion of the
particular option.

Table 21–2. Default Values of


Compiler Control Options

Option CANDE WFL

ERRORLIMIT 5 150
LINEINFO TRUE FALSE
LIST FALSE TRUE

Using CANDE
RPG programs can be created with the MAKE command in CANDE. Enter a command in
the following form to create and edit an RPG source program. In this example, MYFILE is
the source program, U is the UTILITY command, and EDITOR is the utility used to edit
the program.

MAKE <MYFILE> RPG;U <EDITOR>

A file can be compiled by using the COMPILE command. If a source file is created as an
RPG file as shown in the preceding example, then it can be compiled by entering the
following CANDE command:

COMPILE

Refer to the CANDE Operations Reference Manual for information about the COMPILE,
MAKE, and UTILITY commands.

8600 0544–103 21–3


Control of the Compilation Process

Using WFL
WFL can be used to compile a program. WFL is invoked by using the WFL START
command in CANDE.

Example 1
Example 21–1 shows a WFL job that compiles a source program without editing.

BEGIN JOB COMPILE;


COMPILE OBJECT/RPGTEST WITH RPG LIBRARY;
RPG DATA CARD
<source program>
?
END JOB.

Example 21–1. Compiling a Source Program without Editing

Example 2
An existing RPG source file can be edited by using a file called a patch file. The patch file
contains replacement and insertion records and appropriate compiler control options.

Insertion and replacement records from the patch file are merged into the source file by
comparing the sequence entries in columns 1 through 5.

All merging is based on the EBCDIC collating sequence, which determines the results
when blank or nonnumeric sequence entries occur.

Example 21–2 shows a WFL job used to compile a source program that merges a patch
file with an existing source program.

BEGIN JOB COMPILE;


COMPILE OBJECT/RPGTEST WITH RPG LIBRARY;
RPG FILE SOURCE (TITLE = RPGTEST);
RPG DATA CARD
00001$ SET MERGE
<patch file records>
?
END JOB.

Example 21–2. Compiling a Source Program That Merges a Patch File

21–4 8600 0544–103


Control of the Compilation Process

Example 3
Example 21–3 shows a WFL job used to compile a source program that merges a patch
file with an existing source program and creates a new merged file.

BEGIN JOB COMPILE;


COMPILE OBJECT/RPGTEST WITH RPG LIBRARY;
RPG FILE SOURCE (TITLE = RPGTEST);
RPG FILE NEWSOURCE (TITLE = NEWRPGTEST);
RPG DATA CARD
00001$ SET MERGE NEW
<patch file records>
?
END JOB.

Example 21–3. Compiling a Source Program That Creates a New Merged File

When a separate initiating file is used, the name and device type of the patch file must
be identified in one of the following ways:

• A file equation
• A fixed default
• Extra parameters to be included in the initiating file
Refer to the WFL Reference Manual for more information about using WFL to compile
programs.

Example 4
The TASKSTRING task attribute can be used to pass compiler control options to the RPG
compiler from a WFL job. Example 21–4 shows a WFL job using the TASKSTRING
attribute that can be used to reset the LIST compiler control option.

BEGIN JOB COMPILE;


COMPILE OBJECT/PROG WITH RPG LIBRARY;
COMPILER TASKSTRING = "$RESET LIST";
RPG FILE CARD (TITLE=PROG ON DISK);
END JOB.

Example 21–4. WFL Job with TASKSTRING Attribute

Refer to the Task Attributes Reference Manual for information about using the
TASKSTRING task attribute.

8600 0544–103 21–5


Control of the Compilation Process

Compiler Control Records (CCRs)


A CCR is a mechanism by which the programmer assigns options provided by the
compiler. These options fall into one of six categories that control the following:

• Source language input


• Source language output
• Optional compilation mechanisms
• Printed output
• Compiler diagnostic messages
• Compiler debugging
A CCR contains compiler control options and their associated parameters. If no compiler
control option appears on a CCR, the CCR is considered null.

A CCR contains a dollar sign ($) in column 6 of the input record. Records with a dollar
sign only in column 6 are temporary CCRs. They affect only the current compilation, they
are not saved in the NEWSOURCE file, if any, and (unless the $LISTDOLLAR option is
TRUE), they are not printed in the program listing.

Records containing a dollar sign in both columns 6 and 7 are permanent CCRs. They
remain permanently associated with the language portion of the input and output files.

CCRs can appear anywhere in the source input specifications. CCRs are in free format
from column 6 through 74, so they have no standard specification form.

21–6 8600 0544–103


Control of the Compilation Process

Types of Compiler Control Options


The types of compiler control options are described in the following list:

• A Boolean option can be set or reset by using the SET and RESET keywords. If the
option is SET, it is assigned a value of TRUE. If the option is RESET, it is assigned a
value of FALSE.
When an option is SET, the compiler applies an associated function to all subsequent
processing until the option is RESET. Boolean options can also have associated
parameters that are related to the function the Boolean option affects.
Depending on the syntax used, the status of Boolean options is determined in one of
the following three ways:
− If a Boolean option appears on a CCR without the SET or RESET keyword, then it
is implicitly assigned the value TRUE.
− If a Boolean option appears on a CCR with the SET or RESET keyword, then the
specified Boolean option is explicitly assigned the value TRUE or FALSE,
respectively.
− If the CLEAR option appears on a CCR, then all Boolean options are assigned
the value FALSE, except for the MERGE option and the NEW option.
• An immediate option causes the compiler to perform a function that is independent
of subsequent processing. Immediate options can also have associated parameters.
• The special option INCLUDE inserts source program text into the program being
compiled.
• A value option causes the compiler to store a value associated with a given function.
Example
Example 21–5 shows how CCRs are entered on a coding form. Note that Boolean
options use SET and RESET. Value, immediate, and include options do not. Also, note
that more than one option can appear on a CCR. The options specified cause the title,
NOVEMBER REPORT, to be printed at the top of each page, the compiler listing to be
double-spaced, and a page to be ejected before source listing is printed.

....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*.
00100$$TITLE "NOVEMBER REPORT"
00200$$SET DOUBLE LIST
00300$$PAGE
00350H*
00400H* BEGINNING OF SPECIFICATIONS

Example 21–5. Coding Compiler Control Records (CCRs)

8600 0544–103 21–7


Control of the Compilation Process

CCR Syntax
CCRs are interpreted from left to right, beginning at the first text position following the
dollar sign ($) and continuing until the last text position.

Individual compiler control options are defined further in this section.

<compiler control record>


ÚêÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
ÄÄÂÄ $ ÄÄÂÄÁÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÁÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄ%
ÀÄ $$ ÄÙ ÃÄ<Boolean option>ÄÄÄ´ ÀÄ<include option>ÄÙ
ÃÄ<immediate option>Ä´
ÃÄ<value option>ÄÄÄÄÄ´
ÃÄ SET ÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
ÃÄ RESET ÄÄÄÄÄÄÄÄÄÄÄÄ´
ÀÄ POP ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ

<Boolean option>
ÄÄÂÄ<accessopen option>ÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
ÃÄ<code option>ÄÄÄÄÄÄÄÄÄÄÄÄ´
ÃÄ<delete option>ÄÄÄÄÄÄÄÄÄÄ´
ÃÄ<DMSname option>ÄÄÄÄÄÄÄÄÄ´
ÃÄ<dollarisdata option>ÄÄÄÄ´
ÃÄ<double option>ÄÄÄÄÄÄÄÄÄÄ´
ÃÄ<eofclose option>ÄÄÄÄÄÄÄÄ´
ÃÄ<fzone option>ÄÄÄÄÄÄÄÄÄÄÄ´
ÃÄ<KEYEDIOIIOUTPUT option>Ä´
ÃÄ<lineinfo option>ÄÄÄÄÄÄÄÄ´
ÃÄ<list option>ÄÄÄÄÄÄÄÄÄÄÄÄ´
ÃÄ<listdeleted option>ÄÄÄÄÄ´
ÃÄ<listdollar option>ÄÄÄÄÄÄ´
ÃÄ<listincl option>ÄÄÄÄÄÄÄÄ´
ÃÄ<listomitted option>ÄÄÄÄÄ´
ÃÄ<listp option>ÄÄÄÄÄÄÄÄÄÄÄ´
ÃÄ<map option>ÄÄÄÄÄÄÄÄÄÄÄÄÄ´
ÃÄ<merge option>ÄÄÄÄÄÄÄÄÄÄÄ´
ÃÄ<new option>ÄÄÄÄÄÄÄÄÄÄÄÄÄ´
ÃÄ<omit option>ÄÄÄÄÄÄÄÄÄÄÄÄ´
ÃÄ<rsign option>ÄÄÄÄÄÄÄÄÄÄÄ´
ÃÄ<seq option>ÄÄÄÄÄÄÄÄÄÄÄÄÄ´
ÃÄ<statistics option>ÄÄÄÄÄÄ´
ÃÄ<summary option>ÄÄÄÄÄÄÄÄÄ´
ÃÄ<unseq option>ÄÄÄÄÄÄÄÄÄÄÄ´
ÃÄ<userdebug option>ÄÄÄÄÄÄÄ´
ÃÄ<warnfatal option>ÄÄÄÄÄÄÄ´
ÃÄ<warnsupr option>ÄÄÄÄÄÄÄÄ´
ÃÄ<xref option>ÄÄÄÄÄÄÄÄÄÄÄÄ´
ÀÄ<xreffiles option>ÄÄÄÄÄÄÄÙ

21–8 8600 0544–103


Control of the Compilation Process

<immediate option>
ÄÄÂÄ<clear option>ÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
ÀÄ<page option>ÄÄÙ

<value option>
ÄÄÂÄ<errorlimit option>ÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
ÃÄ<errorsource option>ÄÄÄÄÄÄÄÄ´
ÃÄ<pagesize option>ÄÄÄÄÄÄÄÄÄÄÄ´
ÃÄ<sequence base option>ÄÄÄÄÄÄ´
ÃÄ<sequence increment option>Ä´
ÃÄ<target option>ÄÄÄÄÄÄÄÄÄÄÄÄÄ´
ÀÄ<title option>ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ

Explanation

$ or $$ (One or Two Dollar Signs)

The first dollar sign ($) is required in column 6. If used, the second dollar sign ($) must
appear in column 7. The second dollar sign makes the option a permanent CCR.

<Boolean option>

These options have a value of TRUE or FALSE. If the option is not assigned, the default
value is used. If the option is present, the assigned value is used.

<immediate option>

These options cause the compiler to apply a function that is independent of subsequent
processing.

<value option>

These options cause the compiler to store a value associated with a given function.

SET

The SET keyword assigns a value of TRUE to a given Boolean option.

RESET

The RESET keyword assigns a value of FALSE to a given Boolean option.

POP

The POP keyword discards the current value of the Boolean option and restores the
setting to its previous value.

8600 0544–103 21–9


Control of the Compilation Process

Compiler Control Options


The options that appear on CCRs are defined in the following paragraphs. Values that
must be quoted, such as file names, can be enclosed in either quotation marks (“”) or
apostrophes ('). The same symbol (a quotation mark or an apostrophe) must be used at
both the beginning and the end of the value; the symbols cannot be mixed.

ACCESSOPEN (Boolean)
ÄÄ ACCESSOPEN ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´

The ACCESSOPEN option causes files to open at the time of first access, rather than at
beginning of job (BOJ) (as specified in the PLC). Program processing occurs as if an S
had been placed in the Time of File Open field (column 52) of the Control Specification.

The ACCESSOPEN option overrides the Time of File Open field entry in the Control
Specification unless that entry is an N. If the Time of File Open field contains an N, the
ACCESSOPEN option is ignored and processing continues as if the Time of File Open
field contained a blank.

The default value for the ACCESSOPEN option is FALSE.

CLEAR (Immediate)
ÄÄ CLEAR ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´

The CLEAR option assigns the value FALSE to all Boolean options except the MERGE
option and, conditionally, the NEW option.

If a source-language record has been written to the new symbolic file (NEWSOURCE)
because the NEW option is TRUE, then the NEW option is not assigned the value FALSE.

CODE (Boolean)
ÄÄ CODE ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´

The CODE option produces a listing of the object code. The default value is FALSE.

DELETE (Boolean)
ÄÄ DELETE ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´

The DELETE option discards source language records from the secondary input file
(SOURCE) until the option is assigned a value of FALSE.

This option can appear only on a CCR in the primary source-language input file (CARD).

This option is ignored if the MERGE option is FALSE. The DELETE option does not alter
the normal merging process. Instead, it causes the compiler to discard all source
language records selected from the secondary input file, including CCRs.

21–10 8600 0544–103


Control of the Compilation Process

The source-language records that are discarded when this option is TRUE are not carried
forward to the output symbolic file (NEWSOURCE) if the NEW option is TRUE. In
addition, these records are not listed unless the LISTDELETED option is TRUE.

The default value for the DELETE option is FALSE.

DMSNAME (Boolean)
ÄÄ DMSNAME ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´

The DMSNAME option produces a listing of the data set structures for the database
declared in the Database Specification. Only those structures that are defined in the
program are listed. The LIST option must also have a value of TRUE.

The Database Specification is discussed in Volume 2 of this manual.

The default value of the DMSNAME option is FALSE.

DOLLARISDATA (Boolean)
ÄÄ DOLLARISDATA ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´

The DOLLARISDATA option causes dollar signs ($) that appear in column 6 after a vector
data specification to be treated as vector data rather than as a compiler control option.
The default value for the DOLLARISDATA option is FALSE.

DOUBLE (Boolean)
ÄÄ DOUBLE ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´

The DOUBLE option double-spaces all printed compiler output. If no listing is produced,
then this option has no effect.

The default value is FALSE.

EOFCLOSE (Boolean)
ÄÄ EOFCLOSE ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´

The EOFCLOSE option causes serial input files to close at end of file (EOF), rather than at
end of job (EOJ) (as specified in the PLC). Program processing occurs as if an S had been
placed in the Time of File Close field (column 53) of the Control Specification.

The EOFCLOSE option overrides the Time of File Close field entry in the Control
Specification unless that entry is an N. If the Time of File Close field contains an N, the
EOFCLOSE option is ignored and processing continues as if the Time of File Close field
contained a blank.

The default value for the EOFCLOSE option is FALSE.

8600 0544–103 21–11


Control of the Compilation Process

ERRORLIMIT (Value)
ÄÄ ERRORLIMIT ÄÂÄÄÄÄÄÂÄ <integer> ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
ÀÄ = ÄÙ

The ERRORLIMIT option specifies the maximum number of errors that the compiler can
produce before the compilation ends.

The compiler keeps a count of the syntax errors produced; warnings are counted only
when the WARNFATAL option is TRUE. When this count exceeds the specified or
default error limit, the compilation ends.

If the error limit is exceeded, the compiler produces a listing of the errors up to the
maximum and informs the user that the compilation ended for this reason.

If the error limit is exceeded and the NEW option is TRUE, the new file being created is
purged when the compilation ends, if possible. Refer to the NEW option in this section.

The integer can be any unsigned integer.

The default value is 5 if the compilation is started through CANDE and 150 if the program
is started through WFL.

ERRORSOURCE (Value)
ÄÄ ERRORSOURCE ÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
ÃÄÄÄÄÄÂÄ <file name> ÄÙ
ÀÄ = ÄÙ

The ERRORSOURCE option causes syntax error information to be written to the


ERRORSOURCE file.

The ERRORSOURCE file contains both the program source and error messages,
intermixed. If a file name is specified, it must be quoted. The default name of the error
source file is ERRORSOURCE. If the LIST option is TRUE, errors are written to both the
error source file and the output listing file (LINE).

Error messages in the error source file have a question mark (?) in column 2 of the
record.

When the ERRORSOURCE option is assigned the value TRUE and an INCLUDE option is
encountered, the INCLUDE option is placed in the ERRORSOURCE file. Included records
are placed in the ERRORSOURCE file only if an error occurs in the INCLUDE file. Then
the record in the ERROR file is written to the ERRORSOURCE file with a question mark
(?) in column 2.

When the ERRORSOURCE option is TRUE and an OMIT option is encountered, omitted
lines are moved into the error source file, but are not compiled for syntax.

The ERRORSOURCE option cannot be specified with the MERGE option or the SEQ
option. The ERRORSOURCE option cannot be changed during compilation. Once

21–12 8600 0544–103


Control of the Compilation Process

assigned, it stays in effect for the remainder of the compilation. The ERRORSOURCE
option can occur only in the CARD file.

When an ERRORSOURCE file is compiled, the UNSEQ option must be TRUE. The
compiler discards records with a question mark (?) in column 2.If an error occurs on a
VVECTOR line, when the ERRORSOURCE file is compiled, then the error line is
considered to be part of the vector, so it should be deleted from the file before
compilation.

FZONE (Boolean)
ÄÄ FZONE ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´

The FZONE option indicates that external numeric data and numeric values in data
structures use an F positive zone sign.

This option applies to both right and left signed data in display format (blank in the
PACKED field) of Input or Output Specifications. If this option is FALSE, a positive zone
sign is represented with a C for external numeric data and numeric values in data
structures.

The default value for the FZONE option is FALSE.

INCLUDE (Special)
ÄÄ INCLUDE ÄÂÄ<file title>ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄë
ÀÄ<internal file name>ÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
ÀÄ = ÄÄ<file title>ÄÙ
ëÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ%
ÀÄ<sequence number>ÄÙ ÃÄ TO ÄÂÄ<sequence number>ÄÙ
ÀÄ - ÄÄÙ

<internal file name>


ÄÄ<identifier>ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´

<sequence number>
ÚêÄÄÄÄÄÄÄÄÄÄÄÄ¿
ÄÄÁÄ/5\Ä<digit>ÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´

The INCLUDE option suspends the merging process and accepts input from the file
specified by the parameters.

If a starting sequence number is specified, inclusion of source records begins with the
first record in the included file that has a sequence number greater than or equal to the
specified sequence number. If a starting sequence number is not specified, inclusion of
the source records begins with the first record.

If an ending sequence number is specified, inclusion of the source records ends when a
record in the included file has a sequence number greater than the specified ending

8600 0544–103 21–13


Control of the Compilation Process

sequence number. If an ending sequence number is not specified, the inclusion of


source records ends after the last record in the file.

When the UNSEQ option is TRUE, the starting sequence number and/or the ending
sequence number cannot be specified in an INCLUDE option.

A file that is included can contain CCRs with INCLUDE options. This option can be nested
up to five levels.

The source-language records included when the INCLUDE option is used are listed only if
the LISTINCL option is TRUE.

The INCLUDE option can be preceded by other options, but no other options can follow it
on a line.

If the NEW option has the value TRUE, the source-language records included when the
INCLUDE option is used are not carried forward to the output symbolic file
(NEWSOURCE).

The source records from an included file are independent of the merging process.

The <file title> variable is a quoted string containing a usercode, file name, and family
statement.

KEYEDIOIIOUTPUT (Boolean)
ÄÄ KEYEDIOIIOUTPUT ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´

The KEYEDIOIIOUTPUT option invokes special file handling for a program that is creating
or using EFS disk files.

Following are two instances when using the KEYEDIOIIOUTPUT option is important:

• When a disk file is created by an RPG program with the KEYEDIOIIOUTPUT option
assigned the value TRUE, the disk file is created as an EFS file.
• When records are added to a disk file by an RPG program, continuation records can
be used only when the KEYEDIOIIOUTPUT option is TRUE.
The default value for the KEYEDIOIIOUTPUT option is FALSE.

LINEINFO (Boolean)
ÄÄ LINEINFO ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´

The LINEINFO option stores sufficient information with the object program so that the
source-language sequence number associated with a given program address can be
determined. Consequently, if a program ends abnormally, the source-language sequence
number of the ending point can be provided or easily determined.

The default value of this option is FALSE when the program is compiled through WFL
and is TRUE when compiled through CANDE.

21–14 8600 0544–103


Control of the Compilation Process

LIST (Boolean)
ÄÄ LIST ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´

The LIST option produces a listing of the following:

• The source input accepted for compilation


• Any associated compiler diagnostic messages
• A summary of appropriate information about the compilation
The default value is FALSE when the program compiled through CANDE and TRUE when
compiled through WFL.

LISTDELETED (Boolean)
ÄÄ LISTDELETED ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´

The LISTDELETED option produces a listing of any source-language input that is deleted
when the DELETE option is TRUE. The deleted source language input that is read is
identified on the listing with a D.

The default value is FALSE.

LISTDOLLAR (Boolean)
ÄÄ LISTDOLLAR ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´

The LISTDOLLAR option produces a listing of temporary CCRs encountered during the
compilation.

The default value is FALSE.

LISTINCL (Boolean)
ÄÄ LISTINCL ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´

The LISTINCL option causes the records included when the INCLUDE option is used to
be included in the printout when the LIST option is TRUE. The LISTINCL option has no
effect when the LIST option is FALSE.

The default value is FALSE.

LISTOMITTED (Boolean)
ÄÄ LISTOMITTED ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´

The LISTOMITTED option produces a listing of any source-language input that is omitted
when the OMIT option is TRUE. The LISTOMITTED option has no effect when the LIST
option is FALSE.

8600 0544–103 21–15


Control of the Compilation Process

The default value is FALSE.

LISTP (Boolean)
ÄÄ LISTP ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´

The LISTP option produces a listing of the source-language records that appear in the
primary input file (CARD). Source-language records from the secondary input file
(SOURCE) are not listed. If the LIST option is TRUE, then the LISTP option has no effect.

The default value for the LISTP option is FALSE.

MAP (Boolean)
ÄÄ MAP ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´

The MAP option includes in the output listing information about the allocation of variables
in the object code.

The default value for the MAP option is FALSE.

MERGE (Boolean)
ÄÄ MERGE ÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
ÃÄ<file title>ÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
³ ÃÄÄÄÄÄÂÄ<device>ÄÄÄÄÄÄÄÄÄÄÄÄ´
³ ÀÄ , ÄÙ ³
ÀÄ ( ÄÄ<file title>ÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄ ) ÄÙ
ÃÄÄÄÄÄÂÄ<device>ÄÙ
ÀÄ , ÄÙ

<device>
ÄÄÂÄ DISK ÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
ÃÄ TAPE Ä´
ÃÄ PACK Ä´
ÀÄ CARD ÄÙ

The MERGE option merges primary source-language records (CARD) with secondary
source-language input records (SOURCE) specified by the MERGE option parameters.

Once assigned the value TRUE, this option remains TRUE throughout the compilation
and cannot be changed. An attempt to change the value of this option during a
compilation causes an error to occur. If no MERGE option parameters appear, the
SOURCE file is used.

The <file title> is a quoted string specifying the name of the file containing secondary
source-language records. If the file title is not specified, then the SOURCE file is used
unless a file equation overrides it.

The <device> is the device on which the file to be merged resides. If the device is not
specified, DISK is used unless a file equation overrides it.

21–16 8600 0544–103


Control of the Compilation Process

The default value for the MERGE option is FALSE.

NEW (Boolean)
ÄÄ NEW ÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
ÃÄ<file title>ÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
³ ÃÄÄÄÄÄÂÄ<device>ÄÄÄÄÄÄÄÄÄÄÄÄ´
³ ÀÄ , ÄÙ ³
ÀÄ ( ÄÄ<file title>ÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄ ) ÄÙ
ÃÄÄÄÄÄÂÄ<device>ÄÙ
ÀÄ , ÄÙ

<device>
ÄÄÂÄ DISK ÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
ÃÄ TAPE Ä´
ÃÄ PACK Ä´
ÀÄ CARD ÄÙ

The NEW option begins writing all input source-language records accepted for
compilation to a new symbolic file (NEWSOURCE). These records include input records
omitted by the OMIT option and permanent CCRs, but exclude records discarded by the
DELETE option.

The NEW option remains TRUE throughout the compilation and cannot be changed. Any
attempt to change this value during compilation causes an error to occur.

The <file title> variable is a quoted string specifying the name of the symbolic file to
which accepted records are written. If the file title is not specified, then the
NEWSOURCE file is used unless a file equation overrides it.

The <device> variable is the device on which the new symbolic file is to reside. If the
device is not specified, DISK is used unless a file equation overrides it.

The default value is FALSE.

8600 0544–103 21–17


Control of the Compilation Process

OMIT (Boolean)
ÄÄ OMIT ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´

The OMIT option causes all source-language records to be ignored, but not discarded,
during compilation. This option can appear on a CCR in either the primary (CARD) or the
secondary (SOURCE) source-language input.

The source-language records omitted when this option is TRUE are carried forward to the
output symbolic file (NEWSOURCE) if the NEW option is also TRUE.

The source-language records omitted when this option is TRUE are not listed unless the
LISTOMITTED option is also TRUE.

Any CCRs encountered in the source-language input while this option is TRUE are
processed in the normal fashion.

The default value is FALSE.

PAGE (Immediate)
ÄÄ PAGE ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´

The PAGE option causes the compiler to skip to the top of the next page on the output
listing.

If the LIST option is FALSE, the PAGE option is ignored.

If the OMIT option is TRUE and the LISTOMITTED option is FALSE, then the PAGE
option is ignored.

PAGESIZE (Value)
ÄÄ PAGESIZE ÄÂÄÄÄÄÄÂÄ<integer>ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
ÀÄ = ÄÙ

The PAGESIZE option indicates the maximum number of lines that can appear on a page
of the output listing.

The specified page size includes the number of lines necessary for a page heading, if
any. The compiler ensures that the specified integer is large enough so that both page
headings and at least one line of text can be printed on a page.

If the compiler is unable to create an output listing with a page heading, then this option
has no effect.

The <integer> variable is any unsigned integer.

The default value is 58.

21–18 8600 0544–103


Control of the Compilation Process

RSIGN (Boolean)
ÄÄ RSIGN ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´

The RSIGN option causes the compiler to assume that all signs are in the low-order
(rightmost) position of numeric fields. This assumption applies only to the location of the
sign in external numeric data items and numeric fields of data structures. It does not
affect the internal storage of data. If the RSIGN option is assigned a FALSE value, all
signs are assumed to be in the high-order (leftmost) position of the field.

This option can be assigned a value of TRUE or FALSE at different points in the RPG
source program so that different fields are allowed to have different sign positions. If the
RSIGN option appears before the Control Specification, it is overridden by a valid
nonblank entry in the Sign Position field (column 17) in the Control Specification or by any
following RSIGN option. If the RSIGN option appears after the Control Specification, it
overrides any previous assignment of the sign position either by default, by another
RSIGN option, or by a valid nonblank entry in the Sign Position field.

This option remains TRUE and applies to all following source specifications until it is
assigned the value FALSE. Similarly, this option remains FALSE and relates to all
following source specifications until it is assigned the value TRUE.

The RSIGN option default value is FALSE.

SEQ (Boolean)
ÄÄ SEQ ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´

The SEQ option assigns new sequence numbers to the source-language records
accepted for compilation.

This option assigns new sequence numbers to the NEWSOURCE file. The sequence
numbers are based on the values of the SEQUENCE BASE option and the SEQUENCE
INCREMENT option.

This option affects only input source-language records encountered by the compiler,
following the merging process. These records include those that are omitted when the
OMIT option has the value TRUE.

Sequencing occurs before the production of a new symbolic and, if the symbolic is listed,
before the source-language records are listed. If the resulting base exceeds the
sequence maximum value (99999) when the compiler increments the SEQUENCE BASE
option by the SEQUENCE INCREMENT option, then the SEQ option is assigned the value
FALSE and a sequencing error occurs.

The default value is FALSE.

8600 0544–103 21–19


Control of the Compilation Process

SEQUENCE BASE (Value)


ÚêÄÄÄÄÄÄÄÄÄÄÄÄ¿
ÄÄÁÄ/5\Ä<digit>ÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´

The SEQUENCE BASE option contains the sequence number that is to be assigned to
the next source-language record when the SEQ option is TRUE. After each record is
sequenced, the value of the SEQUENCE BASE option is increased by the value of the
SEQUENCE INCREMENT option.

The default value is 100.

SEQUENCE INCREMENT (Value)


ÚêÄÄÄÄÄÄÄÄÄÄÄÄ¿
ÄÄ + ÄÁÄ/5\Ä<digit>ÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´

The value of the SEQUENCE INCREMENT option increases the value of the SEQUENCE
BASE option when records are being sequenced, because the SEQ option has the value
TRUE.

The default value is 100.

STATISTICS (Boolean)
ÄÄ STATISTICS ÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
ÀÄ ( ÄÂÄ CPU ÄÄÄÄÄÂÄ ) ÄÙ
ÃÄ IO ÄÄÄÄÄÄ´
ÀÄ ELAPSED ÄÙ

The STATISTICS option generates code to gather and report statistics about the
execution of an RPG program.

If the STATISTICS option is TRUE when an RPG program is compiled, the statistics
report is printed automatically every time the program is run.

Note: Collecting statistics requires a substantial amount of processor time. Programs


should therefore not be run with the STATISTICS option compiled into their code files,
except when the diagnostic information that is produced is needed.

The following information is reported for each line of the program compiled while the
STATISTICS option is TRUE:

• The sequence number of the specification


• The type of the specification
• The number of times the specification was executed
• The average time spent executing the specification
• The total time spent executing the specification

21–20 8600 0544–103


Control of the Compilation Process

If the STATISTICS option has the value TRUE, then by default the elapsed time is
collected and reported. However, whether elapsed time, Central Processor Unit (CPU)
time, or I/O time should be collected can be specified explicitly the first time the
STATISTICS option is assigned a value.

The STATISTICS option can have the value TRUE around groups of specifications.
However, the statistics gathered for the first and last specifications of such a group are
not reliable. All logically related lines of an operation (for example, all the lines specifying
output fields of an output record) should be included in a group for which statistics are
collected.

The default value is FALSE.

SUMMARY (Boolean)
ÄÄ SUMMARY ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´

The SUMMARY option produces a summary of information about the compilation on the
output listing.

Since the summary produced when this option is TRUE is the same as that produced
when the LIST option is TRUE, the SUMMARY option takes effect only if the LIST option
has the value FALSE.

The default value is FALSE.

TARGET (Value)
ÄÄ TARGET ÄÄ = ÄÄ<primary identifier>ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄë
ÚêÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ , ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
ëÄÁÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
ÀÄ ( ÄÄ<secondary identifier>ÄÄ ) ÄÙ

<primary identifier>
ÄÄ<target identifier>ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´

<secondary identifier>
ÄÄ<target identifier>ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´

This option designates a specific computer system or group of systems as the target for
which the generated object code is to be optimized. This option can be used to specify
all machines on which the code file needs to run.

The default TARGET option is installation defined. For information about how an
installation defines the default target, refer to the COMPILERTARGET command
discussion in the System Commands Operations Reference Manual.

TARGET must appear in the source program before the first record that is not a compiler
control record.

8600 0544–103 21–21


Control of the Compilation Process

Specification of a secondary target is optional. If specified, a secondary target must be


enclosed in parentheses. If more than one secondary target is specified, then the
additional targets must be separated from each other by a comma and the entire list
must be enclosed in parentheses.

If a secondary target is specified, the compiler does not generate any operators that are
valid for the system or systems identified by the primary target but invalid for the system
or systems identified by the secondary target.

Examples
TARGET=THIS

The compiler optimizes the object code file for the system on which it is compiled.

TARGET=THIS (ALL)

The compiler optimizes the object code file for the system on which it is compiled, but it
does not generate any operators that are invalid for other machines.

TITLE (Value)
ÄÄ TITLE ÄÂÄÄÄÄÄÂÄÂÄ ' ÄÂÄÂÄ<alphanumeric literal>ÄÂÄÂÄ ' ÄÂÄÄÄÄÄÄÄÄÄÄÄ´
ÀÄ = ÄÙ ÀÄ " ÄÙ ÀÄ<alphanumeric literal>ÄÙ ÀÄ " ÄÙ

The TITLE option stores a user-specified title to be used on all subsequent pages of the
output listing. If the compiler is unable to create an output listing with page headings, this
option has no effect.

Use of the TITLE option after the first title causes the new <alphanumeric literal>
variable to be stored and the previous title to be lost.

The alphanumeric literal is an alphanumeric string specifying the title to be used. This
literal must contain at least one character.

21–22 8600 0544–103


Control of the Compilation Process

TITLESPERFILE (Value)
ÄÄ PAGESIZE ÄÂÄÄÄÄÄÂÄ<integer>ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
ÀÄ = ÄÙ

The TITLESPERFILE option indicates the maximum number of physical file titles that can
be associated to a single logical file when that logical file has the pseudo-file attribute
TITLESPERFILE = TRUE.

The TITLESPERFILE option can be used only in COMS programs. The option is applied
with the same value to all TITLESPERFILE files in the program.

The associated integer value can be any unsigned integer in the range 1 through 999.
However, a value of 1 has no effect.

The setting of the TITLESPERFILE option cannot be changed after the first source
record. The option must be set before the first control record of the source program that
is not a compiler control record. If the option is set more than once, a warning is issued
and the first option setting is applied to the program; subsequent settings are ignored.

UNSEQ (Boolean)
ÄÄ UNSEQ ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´

The UNSEQ option causes the compiler to ignore the values in the Sequence Number
field (columns 1–5) of all records. This option and the MERGE option cannot both be
assigned the value TRUE.

The UNSEQ option is not allowed in an included file when the starting sequence number,
the ending sequence number, or both of the sequence numbers of the INCLUDE option
are designated.

The default value for the UNSEQ option is FALSE.

USERDEBUG (Boolean)
ÄÄ USERDEBUG ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´

The USERDEBUG option overrides the setting of the Debug field (column 15) of the
Control Specification. The USERDEBUG option has three values: TRUE, FALSE, and
unspecified. When the value assigned is TRUE or FALSE, this option overrides the
setting of the Debug field of the Control Specifications. If the USERDEBUG option is
unspecified, the value of the Debug field of the Control Specification is used to specify
user debugging.

If the USERDEBUG option is specified, it must be specified before the first line of the
RPG program. This option cannot be altered during program compilation.

The default value for the USERDEBUG option is unspecified.

8600 0544–103 21–23


Control of the Compilation Process

Note: This option has no effect on the linkage to the COMS library (which is also
specified in the Debug field of the Calculation Specifications).

WARNFATAL (Boolean)
ÄÄ WARNFATAL ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´

The WARNFATAL option counts warning messages as syntax errors. The default value is
FALSE.

WARNSUPR (Boolean)
ÄÄ WARNSUPR ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´

The WARNSUPR option suppresses the printing of warning messages. The default value
is FALSE.

XREF (Boolean)
ÄÄ XREF ÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
ÀÄ <line width> ÄÙ

The XREF option produces a cross-reference listing of the source program. If any syntax
errors occur during compilation, no cross-reference listing is created.

The <line width> can be any integer greater than or equal to 72 but less than or equal to
132. If not specified, the default value is 132.

If the LINE file has the USERBACKUPNAME option set and the compiler is calling the
XREFANALYZER utility to generate a cross-reference listing, the FILENAME of the LINE
file used by XREFANALYZER is the FILENAME of the LINE file with the node XREFLIST
appended.

The default value for the XREF option is FALSE.

XREFFILES (Boolean)
ÄÄ XREFFILES ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´

The XREFFILES option causes cross-reference files to be created for use by


SYSTEM/INTERACTIVEXREF and SYSTEM/EDITOR. The names of the files are shown as
follows. The variable <code file name> is the name of the code file the compiler is
generating.

XREFFILES/<code file name>/DECS


XREFFILES/<code file name>/REFS

If any syntax errors occur during compilation, no cross-reference files are created.

The default value is FALSE.

21–24 8600 0544–103


Control of the Compilation Process

For further information about SYSTEM/INTERACTIVEXREF, refer to the


INTERACTIVEXREF discussion in the System Software Utilities Manual and in the Editor
Operations Guide.

Use of Compiler Directives to Format the Compiler


Listing
Directions can be given to the compiler to improve the readability of the printer listing.
Compiler directives can be used to specify the headings and the paging of the compiler
listing.

Following are the rules for using a compiler directive:

• Compiler directives are used with the LIST option in the source program.
The LIST option can be specified by using the LIST compiler control option.
• All compiler directives begin with a slash (/) in column 7.
• A compiler directive can appear on any specification except the Vector Data
Specifications.
• The compiler directive itself does not appear on the printer output. It controls how
the output appears.
The three compiler directives and their uses are described in the following paragraphs:

/EJECT
A /EJECT entry causes the specifications following this compiler directive to begin on a
new page of the compiler listing. The PAGE compiler control option can also be used to
perform this function.

/SPACE n
A /SPACE n entry causes spaces to occur in the compiler listing. The number for n can
be 1, 2, or 3. A blank is required between /SPACE and the number. The value entered for
n is the number of lines to be spaced before the next line is printed. If a number for n is
not entered, 1 is assumed. If n is greater than the number of lines remaining on the
current page, the next line is printed on a new page.

If double-spacing is desired for the entire compiler listing, use the DOUBLE compiler
control option.

/TITLE
A /TITLE entry causes heading information to be printed on the compiler listing. The
heading information is specified in columns 14 through 74 of the same specification. The
heading appears at the top of each page in the compiler listing.

A program can contain more than one /TITLE entry. Each /TITLE entry provides heading
information for the compiler listing until the next /TITLE entry is specified.

8600 0544–103 21–25


Control of the Compilation Process

A /TITLE entry must be the first record in the program for the title to begin on the first
page of the compiler listing.

The compiler prints its own heading in addition to the heading specified by the /TITLE
entry.

A /TITLE entry causes a page to be ejected before the title is printed.

The TITLE compiler control option can perform the same functions as the /TITLE entry.

Compiler Memory Estimate


The RPG compiler prints a report that is included when the SUMMARY or LIST compiler
control option is TRUE. This report lists the memory that an RPG program is expected to
use.

Following is a description of the information in the report:

Memory Description

Nonoverlayable data The memory that must always be resident for a program to run,
space including 2400 bytes of working space to run the RPG support
library.

File buffer space The sum of the sizes of the buffers for all files. If all files are
open, this sum is the file buffer space that the program will use.
The file buffers for indexed files are controlled by the KEYEDIOII
library; therefore, this estimate is not valid for indexed files.

Minimum code space The size of the largest code segment in the program.

Program-dependent The sum of the nonoverlayable data space, the file buffer space,
required memory and the minimum code space.

Overlayable data The remainder of the data in the program.


space

Estimated memory The sum of the program-dependent required memory plus the
required to run overlayable data space. There is no attempt to estimate the
operating system overhead.

Although the RPG program can execute in the estimated


memory required to run, normally the program uses more
memory if it is available. Using more memory enables better
performance by avoiding overhead caused by overlaying data
and code segments.

21–26 8600 0544–103


Appendix A
System Messages

An error is defined as one of the following:

• An invalid entry in a field


• Two or more field entries in an invalid combination
Run-time error messages are displayed on the ODT and the terminal from which the
program was executed.

Unless otherwise specified, the operator can respond with any of the following when an
error message appears:

• ?<mix no>AX GO
• ?<mix no>AX STOP
• ?<mix no>AX DUMP
GO enables the program to continue. STOP causes the program to end in an orderly
manner by turning on the LR indicator and performing normal EOJ routines. DUMP
causes the program to write a dump. After the dump is done, a message is displayed.
The operator can respond to this message with either GO or STOP.

A program can be either continued or ended automatically, depending on the entry that
appears in the Run-Time Error field (column 49) in the Control Specification. When an
error occurs and the Run-Time Error field is blank, the operator must enter a valid
response for the error after the message is displayed.

Some run-time errors cause records, keys, and other data to be displayed. A maximum of
180 characters can be displayed; the first null, 00 (hex), stops the display of data.

System messages, with their causes and responses, are described in the following
paragraphs.

8600 0544–103 A–1


System Messages

ADD TO NON-DELETED RECORD <file identifier>

• This error occurs during exception output, detail output, or total output when the
user attempts to add a record randomly (using the RECNO field) to a record position
in an EFS file that does not contain a deleted record.
For example, this error occurs when

− An EFS file is not created with the DELETE-CAPABLE attribute set to TRUE.
− The record position of a record added between records of an EFS sequential file
contains a nondeleted record.
− The record position of a record added between records of an EFS direct file does
not contain a deleted record.
• The operator can enter one of the following responses:
Entry Definition

GO The program continues, and the record is not added to the file.

STOP The program ends in an orderly manner.

DUMP The program writes a dump. After the dump is done, a message is
displayed. The operator can respond to the message with either GO or
STOP.

AGAIN?

• This error message occurs when forms positioning is requested. The program
pauses to enable the operator to reposition the form.
• The operator can enter one of the following responses:
Entry Definition

NO The program continues and does not perform heading/detail output


lines conditioned by the first page (1P) indicator again.

YES The program performs heading/detail output lines conditioned by the


first page (1P) indicator again.

DUMP The program writes a dump. After the dump is done, a message is
displayed. The operator can respond to the message with either NO
or YES.

For information on forms positioning, see the discussion of the Forms Position field
(column 41) in Section 7, “Control Specification.”

A–2 8600 0544–103


System Messages

ATTEMPT TO MODIFY A PRIMARY KEY WITH A REWRITE


<current key value>: <update key value>

• This error occurs when an attempt is made to modify the contents of the primary key
field of an indexed file that is being accessed sequentially by key or randomly by a
record-address file.
• The operator can enter one of the following responses:
Entry Definition

GO The program continues, and the record is not changed.

STOP The program ends in an orderly manner.

DUMP The program writes a dump. After the dump is done, a message is
displayed. The operator can respond to the message with either GO
or STOP.

BAD COMS DESIGNATOR NAME: <identifier>

• This error results from an attempt to initialize a COMS designator to a name that is
not recognized by COMS.
• The operator can enter one of the following responses:
Entry Definition

GO Even though this designator is not initialized, the program continues.

STOP The program ends in an orderly manner.

DUMP The program writes a dump. After the dump is done, a message is
displayed. The operator can respond to the message with either GO
or STOP.

8600 0544–103 A–3


System Messages

BEYOND EXTEND AREA <file identifier>

• This error results from an attempt to


− Read a record, with a CHAIN operation, that is beyond the EXTEND area of an
EFS direct file.
− Write a record, with a relative record number, that is beyond the EXTEND area of
an EFS direct file. The relative record number is stored in the RECNO field.
• The operator can enter one of the following responses:
Entry Definition

GO The program continues. No record is read if the error occurs on a


CHAIN operation. No record is written if the error happens during
output.

STOP The program ends in an orderly manner.

DUMP The program writes a dump. After the dump is done, a message is
displayed. The operator can respond to the message with either GO
or STOP.

DATACOM READ ERROR <further error information>

• This data communication error results when a data communications file for which no
error indicator is specified is read.
• The operator can enter one of the following responses:
Entry Definition

GO The program continues, and the operation that caused the error is
ignored.

STOP The program ends in an orderly manner.

DUMP The program writes a dump. After the dump is done, a message is
displayed. The operator can respond to the message with either GO
or STOP.

A–4 8600 0544–103


System Messages

DATACOM WRITE ERROR <further error information>

• This data communication error results when a data communications file for which no
error indicator is specified is written to.
• The operator can enter one of the following responses:
Entry Definition

GO The program continues, and the operation that caused the error is
ignored.

STOP The program ends in an orderly manner.

DUMP The program writes a dump. After the dump is done, a message is
displayed. The operator can respond to the message with either GO or
STOP.

DEADLOCK ERROR

• This error is caused by a DMSII DEADLOCK exception. The DEAD LOCK ERROR
occurs in the following conditions:
− A deadlock occurs during an attempt to lock a record or a wait on begin
transaction. The system will have automatically freed all records for the program.
− A time-out occurs during an attempt to lock a record or a wait on begin
transaction.
− A CREATE/STORE statement is attempted on a locked structure.
− The LOCKLIMIT is exceeded. Too many records in this structure are currently
loaded.
• The operator can enter one of the following responses:
Entry Definition

RETRY The same operation is attempted again.

STOP The program ends in an orderly manner.

DUMP The program writes a dump. After the dump is done, a message is
displayed. The operator can respond to the message with either
RETRY or STOP.

For more information on a DEADLOCK exception, refer to the discussion of


exception categories in the DMSII Application Program Interfaces Programming
Guide.

8600 0544–103 A–5


System Messages

DELETE BEFORE INPUT <file identifier>

• This error occurs when a program attempts to delete a record in an EFS file that was
not the last record read. This error typically results when a program performs a READ
or a CHAIN operation that fails, but the program tries to delete the record on the
subsequent update anyway.
• The operator can enter one of the following responses:
Entry Definition

GO The program continues, and no record is deleted from the file.

STOP The program ends in an orderly manner.

DUMP The program writes a dump. After the dump is done, a message is
displayed. The operator can respond to the message with either GO or
STOP.

DELETE ERROR <further error information>

• This error results from an attempt to delete a record in one of the following cases:
− No current record is defined.
− The key value specified for the deletion does not exist in the file.
− No record was selected during this program logic cycle.
• The operator can enter one of the following responses:
Entry Definition

GO The program continues, and the current record pointer and record
work area remain unchanged.

STOP The program ends in an orderly manner.

DUMP The program writes a dump. After the dump is done, a message is
displayed. The operator can respond to the message with either GO
or STOP.

A–6 8600 0544–103


System Messages

DELETE INVALID <file identifier>

• This error occurs when an EFS file is not delete-capable, but an attempt is made to
delete a record.
• The operator can enter one of the following responses:
Entry Definition

GO The program continues, and the record is not deleted from the file.

STOP The program ends in an orderly manner.

DUMP The program writes a dump. After the dump is done, a message is
displayed. The operator can respond to the message with either GO
or STOP.

DUPLICATE KEY

• This error occurs when an attempt is made to write a record to an indexed file in
which a record with the current key already exists.
• The operator can enter one of the following responses:
Entry Definition

GO The program continues. The new record is not written to the file, thus
maintaining the integrity of the file.

STOP The program ends in an orderly manner.

DUMP The program writes a dump. After the dump is done, a message is
displayed. The operator can respond to the message with either GO
or STOP.

8600 0544–103 A–7


System Messages

HALT INDICATORS ON: <Hn>

• The HALT message is displayed at the end of a program cycle if one or more halt
indicators (H0–H9) are turned on.
An Hn is displayed for each indicator that is on. Each n represents a halt indicator,
where n is a digit from 0 through 9.

• The operator can enter one of the following responses:


Entry Definition

GO All halt indicators are turned off, and the program continues.

STOP The LR indicator is turned on, and all final total calculations and output
are performed.

DUMP The program writes a dump. After the dump is done, a message is
displayed. The operator can respond to the message with either GO
or STOP.

The program can be either continued or ended automatically, depending on the entry
in the Halt Indicator field (column 50) in the Control Specification. Refer to Section 7,
“Control Specification,” for additional information.

INPUT RECORD SEQUENCE ERROR <file identifier>: <record contents>

• This error occurs when an input record from the specified file is out of sequence
according to the entries in columns 15 through 18 in the Input Specifications.
• The operator can enter one of the following responses:
Entry Definition

GO The program continues by ignoring the record that was out of


sequence and reading the next record from the same file.

STOP The program ends in an orderly manner.

DUMP The program writes a dump. After the dump is done, a message is
displayed. The operator can respond to the message with either GO
or STOP.

A–8 8600 0544–103


System Messages

INTEGRITY ERROR

• This error is caused by a DMSII INTEGRITYERROR exception. The INTEGRITY


ERROR occurs in the following situations:
− Key and data do not match.
− An attempt is made to store a record when an automatic set or subset entry is
missing.
− An attempt is made to delete a record when an automatic set or subset is
missing.
− An automatic set or subset points to a deleted record.
− An attempt is made to allocate more than 1000 rows in an index set.
• The operator can enter one of the following responses:
Entry Definition

STOP The program ends in an orderly manner.

DUMP The program writes a dump. After the dump is done, a message is
displayed. The operator must respond to the message with STOP.

For more information on the INTEGRITYERROR exception, refer to the discussion of


exception categories in the DMSII Application Programming Guide.

KEY NOT FOUND <file identifier>: <key value>

• This error occurs in the following situations:


− A record-not-found indicator (high indicator) is not specified for the CHAIN
operation, and a record for the specified key is not in the file.
− A randomly processed update chained indexed file is updated, and no record in
the file has a key field value that equals the key field value in the output record.
− An addrout file that contains a relative record number for a record that does not
exist is used in record-address processing.
• The operator can enter one of the following responses:
Entry Definition

STOP The program ends in an orderly manner.

DUMP The program writes a dump. After the dump is done, a message is
displayed. The operator must respond to the message with STOP.

KEY OUT OF SEQUENCE <file identifier>: <key value>

• This error occurs during an ordered load of an indexed file when an out-of-sequence
record is placed in the file. A record is out of sequence when the key is less than the
key of the last record.

8600 0544–103 A–9


System Messages

• The operator can enter one of the following responses:


Entry Definition

GO The program continues, and the out-of-sequence record is not added


to the file.

STOP The program ends in an orderly manner.

DUMP The program writes a dump. After the dump is done, a message is
displayed. The operator can respond to the message with either GO
or STOP.

MATCH FIELD SEQUENCE ERROR <file identifier>: <match field values>

• This error occurs when an input record from the file specified with match field values
is out of sequence. In any one file, all records with match field values must appear in
the correct match field sequence (either ascending or descending). The sequence
checking enables consecutive records to have equal match field values.
• The operator can enter one of the following responses:
Entry Definition

GO The program continues by ignoring the out-of-sequence record and


reading the next record from the same file.

STOP The program ends in an orderly manner.

DUMP The program writes a dump. After the dump is done, a message is
displayed. The operator can respond to the message with either GO or
STOP.

A–10 8600 0544–103


System Messages

NO MATCHING CASE LABEL FOR SELECTION VARIABLE <field name>

• This error occurs when the value of the selection variable in a CASE operation does
not match any of the case labels, and *ELSE has not been specified.
• The operator can enter one of the following responses:
Entry Definition

GO The program continues. No part of this CASE operation is executed.

STOP The program ends in an orderly manner.

DUMP The program writes a dump. After the dump is done, a message is
displayed. The operator can respond to the message with either GO
or STOP.

OPEN/CLOSE ERROR OF FILE <file name>

• This error results if a system error is received when a file is being opened or closed.
• The operator can enter one of the following responses:
Entry Definition

STOP The program ends in an orderly manner.

DUMP The program writes a dump. After the dump is done, a message is
displayed. The operator must respond to the message with STOP.

READ AT END OF FILE <file identifier>

• This error occurs during a READ operation when the file specified reaches end of file
(EOF) and no indicator is specified in the Resulting Indicators field (columns 58–59) in
the Calculation Specifications.
• The operator can enter one of the following responses:
Entry Definition

GO The program continues.

STOP The program ends in an orderly manner.

DUMP The program writes a dump. After the dump is done, a message is
displayed. The operator can respond to the message with either GO
or STOP.

RECORD IDENTIFICATION ERROR <file identifier>: <record contents>

• This error occurs when an input record from the file specified cannot be identified;
that is, none of the codes specified in the Record Identification Codes field

8600 0544–103 A–11


System Messages

(columns 21–41) in the Input Specifications for the file can be found in the input
record.
• The operator can enter one of the following responses:
Entry Definition

GO The program continues by ignoring the record and reading the next
record from the same file. In the case of a chained file, the next
record is the one that originally caused the RECORD IDENTIFICATION
ERROR, as the key is not changed.

STOP The program ends in an orderly manner.

DUMP The program writes a dump. After the dump is done, a message is
displayed. The operator can respond to the message with either GO
or STOP.

RECORD KEY MISMATCH <file identifier>: <search key>: <record key>

• When an indexed file is read using the CHAIN operation, this error occurs if the key
field of the record returned for processing (record key) does not equal the key
requested (search key).
• The operator can enter one of the following responses:
Entry Definition

STOP The program ends in an orderly manner.

DUMP The program writes a dump. After the dump is done, a message is
displayed. The operator must respond to the message with STOP.

A–12 8600 0544–103


System Messages

SECURITY ERROR

• This error is caused by a DMSII SECURITYERROR exception. A SECURITY ERROR


occurs when a program violates DMSII security. The user was not permitted to use a
function if a security error occurs.
• The operator can enter one of the following responses:
Entry Definition

STOP The program ends in an orderly manner.

DUMP The program writes a dump. After the dump is done, a message is
displayed. The operator must respond to the message with STOP.

For information on a SECURITYERROR exception, refer to the discussion of


exception categories in the DMSII Application Programming Guide.

SQRT OPERATION ERROR

• This error occurs if the Factor 2 operand for the SQRT operation is negative.
• The operator can enter one of the following responses:
Entry Definition

GO The program continues, and the Result Field (columns 43–48) in the
Calculations Specifications is set to zero (0).

STOP The program ends in an orderly manner.

DUMP The program writes a dump. After the dump is done, a message is
displayed. The operator can respond to the message with either GO
or STOP.

SUBSCRIPT ERROR <line number>

• This error occurs when a program refers to a vector element with an invalid
subscript. An invalid subscript is either a value less than or equal to zero (0) or greater
than the number of elements in the vector. The number of the source line causing
the error is given to identify the location of the invalid subscript.
• The operator can enter one of the following responses:
Entry Definition

STOP The program ends in an orderly manner.

DUMP The program writes a dump. After the dump is done, a message is
displayed. The operator must respond to the message with STOP.

8600 0544–103 A–13


System Messages

UPDATE UNLOCKED RECORD <file identifier>

• This error occurs when a program tries to update an unlocked record in a file. Record-
level locking is activated by default for all EFS disk files when they are created.
Record-level locking is allowed for BFS indexed files.
Locking occurs implicitly when a record is read. If a program tries to update a record
that has not been read, then an error occurs. Allowing the update would compromise
the integrity of that record for other users of the file.

• The operator can enter one of the following responses:


Entry Definition

GO The program continues. No record is updated.

STOP The program ends in an orderly manner.

DUMP The program writes a dump. After the dump is done, a message is
displayed. The operator can respond to the message with either GO or
STOP.

VECTOR LOAD ERROR <vector file identifier>

• This error occurs when a preexecution-time vector is loaded if the number of data
records in the specified vector file is not equal to the expected number of records.
• The operator can enter one of the following responses:
Entry Definition

GO If the vector file contains more records than the expected number, the
remainder of the file is ignored. Otherwise, all unfilled vector elements
of the vector currently being loaded are left as initialized. The program
continues with the selection of the next vector file for loading.

STOP The program ends in an orderly manner.

DUMP The program writes a dump. After the dump is done, a message is
displayed. The operator can respond to the message with either GO or
STOP.

A–14 8600 0544–103


System Messages

VECTOR SEQUENCE ERROR <vector identifier>: <record contents>

• This error occurs when a preexecution time vector is loaded and the vector element
is out of sequence (either ascending or descending) with the previous element
loaded as specified by the entry in the Sequence field (column 45) in the Extension
Specifications.
• The operator can enter one of the following responses:
Entry Definition

STOP The program ends in an orderly manner.

DUMP The program writes a dump. After the dump is done, a message is
displayed. The operator must respond to the message with STOP.

VERSION ERROR

• This error is caused by a DMSII VERSIONERROR exception. A VERSION ERROR


happens when the link was unknown or deleted.
• The operator can enter one of the following responses:
Entry Definition

STOP The program ends in an orderly manner.

DUMP The program writes a dump. After the dump is done, a message is
displayed. The operator must respond to the message with STOP.

For more information on the VERSIONERROR exception, refer to the discussion of


exception categories in the DMSII Application Programming Guide.

8600 0544–103 A–15


System Messages

A–16 8600 0544–103


Appendix B
Reference Tables

This appendix contains the following reference tables for EBCDIC, ASCII, and
hexadecimal (hex) character types:

• Character representation
• Bit fields
• Character values and graphics
Regarding the signs of numeric fields, the following is true:

• 8-bit characters
The sign is in the zone bits (bits 4 through 7) of the field. A bit configuration of 1101,
D (hex), indicates a negative number. Any other bit configuration indicates a positive
number.
• 4-bit digits
The sign is carried as a separate digit, the location of which depends on the sign
position of the field. A bit configuration of 1101, D (hex), indicates a negative number.
Any other bit configuration indicates a positive number.
Table B-1 shows that characters are represented for storage as values assigned to fields
of 4 or 8 bits. The Character Type column lists the valid character types. The Field Size
and Bits Used columns show the field size in bits and the maximum number of bits,
respectively, used for each type of character. The Valid Data Types column shows the
character-oriented constructs that are used to manipulate each character type.

Table B–1. Character Representation

Character Type Field Bits Valid Data Types


Size Used

EBCDIC 8 8 Alphanumeric array, field, or literal


ASCII 8 7
Hexadecimal (Hex) 4 4 Alphanumeric array, field, or literal

Figures B–1, B–2, and B–3 show how the various character types are formatted in a word
of storage. Comparing Figures B–1 and B–2 shows that ASCII characters are stored in 8-
bit fields like EBCDIC characters. The zeros shown for ASCII bits 7, 15, 23, 31, 39, and 47
indicate that these bits must be 0 when ASCII characters are stored.

8600 0544–103 B–1


Reference Tables

Figure B–1. 8-Bit Fields (EBCDIC Code)

Figure B–2. 8-Bit Fields (ASCII Code)

Figure B–3. 4-Bit Fields (Hexadecimal Code)

B–2 8600 0544–103


Reference Tables

Table B–2 lists the 256 EBCDIC values represented in binary, octal, decimal, and
hexadecimal terms. The table also shows the corresponding ASCII and EBCDIC graphics
as they appear when printed with an EBCDIC96 print train. In the EBCDIC column, the
corresponding word appears for any nonprintable EBCDIC value.

The collating sequence can be different on different systems. As an example, the table
compares the order of characters in the IBM System/36 system collating sequence to
that of the MCP based systems by enclosing the System/36 characters in parentheses to
the right of MCP based characters when there are differences.

Table B–2. Character Values and Graphics

Binary Octal Decimal Hex ASCII EBCDIC

00000000 000 0 00 NUL


00000001 001 1 01 SOH
00000010 002 2 02 STX
00000011 003 3 03 ETX
00000100 004 4 04
00000101 005 5 05 HT
00000110 006 6 06
00000111 007 7 07 DEL
00001000 010 8 08
00001001 011 9 09
00001010 012 10 0A
00001011 013 11 0B VT
00001100 014 12 0C FF
00001101 015 13 0D CR
00001110 016 14 0E SO
00001111 017 15 0F SI
00010000 020 16 10 DLE
00010001 021 17 11 DC1
00010010 022 18 12 DC2
00010010 022 19 12 DC3
00010100 024 20 14
00010101 025 21 15 NL
00010110 026 22 16 BS
00010111 027 23 17

8600 0544–103 B–3


Reference Tables

Table B–2. Character Values and Graphics

Binary Octal Decimal Hex ASCII EBCDIC

00011000 030 24 18 CAN


00011001 031 25 19 EM
00011010 032 26 1A
00011011 033 27 1B
00011100 034 28 1C FS
00011101 035 29 1D GS
00011110 036 30 1E RS
00011111 037 31 1F US
00100000 040 32 20
00100001 041 33 21 !
00100010 042 34 22 "
00100011 043 35 23 #
00100100 044 36 24 $
00100101 045 37 25 % LF
00100110 046 38 26 & ETB
00100111 047 39 27 ' ESC
00101000 050 40 28 (
00101001 051 41 29 )
00101010 052 42 2A *
00101011 053 43 2B +
00101100 054 44 2C ,
00101101 055 45 2D -- ENQ
00101110 056 46 2E . ACK
00101111 057 47 2F / BEL
00110000 060 48 30 0
00110001 061 49 31 1
00110010 062 50 32 2 SYN
00110011 063 51 33 3
00110100 064 52 34 4
00110101 065 53 35 5
00110110 066 54 36 6

B–4 8600 0544–103


Reference Tables

Table B–2. Character Values and Graphics

Binary Octal Decimal Hex ASCII EBCDIC

00110111 067 55 37 7 EOT


00111000 070 56 38 8
00111001 071 57 39 9
00111010 072 58 3A :
00111011 073 59 3B ;
00111100 074 60 3C < DC4
00111101 075 61 3D = NAK
00111110 076 62 3E >
00111111 077 63 3F ? SUB
01000000 100 64 40 @ SP or blank
01000001 101 65 41 A
01000010 102 66 42 B
01000011 103 67 43 C
01000100 104 68 44 D
01000101 105 69 45 E
01000110 106 70 46 F
01000111 107 71 47 G
01001000 110 72 48 H
01001001 111 73 49 I
01001010 112 74 4A J [ (or ›)
01001011 113 75 4B K .
01001100 114 76 4C L <
01001101 115 77 4D M (
01001110 116 78 4E N +
01001111 117 79 4F O ! (|)
01010000 120 80 50 P &
01010001 121 81 51 Q
01010010 122 82 52 R
01010011 123 83 53 S
01010100 124 84 54 T
01010101 125 85 55 U

8600 0544–103 B–5


Reference Tables

Table B–2. Character Values and Graphics

Binary Octal Decimal Hex ASCII EBCDIC

01010110 126 86 56 V
01010111 127 87 57 W
01011000 130 88 58 X
01011001 131 89 59 Y
01011010 132 90 5A Z ] (!)
01011011 133 91 5B [ $
01011100 134 92 5C \ *
01011101 135 93 5D ] )
01011110 136 94 5E ^ ;
01011111 137 95 5F _ ^ (or ª)
01100000 140 96 60 ` --
01100001 141 97 61 a /
01100010 142 98 62 b
01100011 143 99 63 c
01100100 144 100 64 d
01100101 145 101 65 e
01100110 146 102 66 f
01100111 147 103 67 g
01101000 150 104 68 h
01101001 151 105 69 i
01101010 152 106 6A j |
(or broken
bar)
01101011 153 107 6B k ,
01101100 154 108 6C l %
01101101 155 109 6D m _
01101110 156 110 6E n >
01101111 157 111 6F o ?
01110000 160 112 70 p
01110001 161 113 71 q
01110010 162 114 72 r
01110011 163 115 73 s

B–6 8600 0544–103


Reference Tables

Table B–2. Character Values and Graphics

Binary Octal Decimal Hex ASCII EBCDIC

01110100 164 116 74 t


01110101 165 117 75 u
01110110 166 118 76 v
01110111 167 119 77 w
01111000 170 120 78 x
01111001 171 121 79 y `
01111010 172 122 7A z :
01111011 173 123 7B { #
01111100 174 124 7C | @
01111101 175 125 7D } '
01111110 176 126 7E ~ =
01111111 177 127 7F "
10000000 200 128 80
10000001 201 129 81 a
10000010 202 130 82 b
10000011 203 131 83 c
10000100 204 132 84 d
10000101 205 133 85 e
10000110 206 134 86 f
10000111 207 135 87 g
10001000 210 136 88 h
10001001 211 137 89 i
10001010 212 138 8A
10001011 213 139 8B
10001100 214 140 8C
10001101 215 141 8D
10001110 216 142 8E
10001111 217 143 8F
10010000 220 144 90
10010001 221 145 91 j
10010010 222 146 92 k

8600 0544–103 B–7


Reference Tables

Table B–2. Character Values and Graphics

Binary Octal Decimal Hex ASCII EBCDIC

10010011 223 147 93 l


10010100 224 148 94 m
10010101 225 149 95 n
10010110 226 150 96 o
10010111 227 151 97 p
10011000 230 152 98 q
10011001 231 153 99 r
10011010 232 154 9A
10011011 233 155 9B
10011100 234 156 9C
10011101 235 157 9D
10011110 236 158 9E
10011111 237 159 9F
10100000 240 160 A0
10100001 241 161 A1 ~
10100010 242 162 A2 s
10100011 243 163 A3 t
10100100 244 164 A4 u
10100101 245 165 A5 v
10100110 246 166 A6 w
10100111 247 167 A7 x
10101000 250 168 A8 y
10101001 251 169 A9 z
10101010 252 170 AA
10101011 253 171 AB
10101100 254 172 AC
10101101 255 173 AD
10101110 256 174 AE
10101111 257 175 AF
10110000 260 176 B0
10110001 261 177 B1

B–8 8600 0544–103


Reference Tables

Table B–2. Character Values and Graphics

Binary Octal Decimal Hex ASCII EBCDIC

10110010 262 178 B2


10110011 263 179 B3
10110100 264 180 B4
10110101 265 181 B5
10110110 266 182 B6
10110111 267 183 B7
10111000 270 184 B8
10111001 271 185 B9
10111010 272 186 BA
10111011 273 187 BB
10111100 274 188 BC
10111101 275 189 BD
10111110 276 190 BE
10111111 277 191 BF
11000000 300 192 C0 {
11000001 301 193 C1 A
11000010 302 194 C2 B
11000011 303 195 C3 C
11000100 304 196 C4 D
11000101 305 197 C5 E
11000110 306 198 C6 F
11000111 307 199 C7 G
11001000 310 200 C8 H
11001001 311 201 C9 I
11001010 312 202 CA
11001011 313 203 CB
11001100 314 204 CC
11001101 315 205 CD
11001110 316 206 CE
11001111 317 207 CF
11010000 320 208 D0 }

8600 0544–103 B–9


Reference Tables

Table B–2. Character Values and Graphics

Binary Octal Decimal Hex ASCII EBCDIC

11010001 321 209 D1 J


11010010 322 210 D2 K
11010011 323 211 D3 L
11010100 324 212 D4 M
11010101 325 213 D5 N
11010110 326 214 D6 O
11010111 327 215 D7 P
11011000 330 216 D8 Q
11011001 331 217 D9 R
11011010 332 218 DA
11011011 333 219 DB
11011100 334 220 DC
11011101 335 221 DD
11011110 336 222 DE
11011111 337 223 DF
11100000 340 224 E0 \
11100001 341 225 E1
11100010 342 226 E2 S
11100011 343 227 E3 T
11100100 344 228 E4 U
11100101 345 229 E5 V
11100110 346 230 E6 W
11100111 347 231 E7 X
11101000 350 232 E8 Y
11101001 351 233 E9 Z
11101010 352 234 EA
11101011 353 235 EB
11101100 354 236 EC
11101101 355 237 ED
11101110 356 238 EE
11101111 357 239 EF

B–10 8600 0544–103


Reference Tables

Table B–2. Character Values and Graphics

Binary Octal Decimal Hex ASCII EBCDIC

11110000 360 240 F0 0


11110001 361 241 F1 1
11110010 362 242 F2 2
11110011 363 243 F3 3
11110100 364 244 F4 4
11110101 365 245 F5 5
11110110 366 246 F6 6
11110111 367 247 F7 7
11111000 370 248 F8 8
11111001 371 249 F9 9
11111010 372 250 FA
11111011 373 251 FB
11111100 374 252 FC
11111101 375 253 FD
11111110 376 254 FE
11111111 377 255 FF

8600 0544–103 B–11


Reference Tables

B–12 8600 0544–103


Index

field definitions, 18-3


Comment (column 7), 18-3
A Form Type (column 6), 18-3
Program Identification
abnormal end, 8-30 (columns 75-80), 18-4
ACCESSOPEN compiler control option, 21-10 Sequence Number (columns 1-5), 18-3
Actual Name field in Library Subroutine Sequence Specifications
Specifications, 13-6 (columns 7-74), 18-4
ADD operation, 16-6 Alternate Collating Sequence Specifications
ADD TO NON-DELETED RECORD error coding, 18-5
message, A-2 alternate index file
adding records to a file, 4-43 description of, 4-3
BFS File Specifications for, 4-41
direct, 4-43 organization of, 4-3
indexed, 4-48 processing using Addrout file, 4-41
sequential, 4-43 random processing of, 4-34
EFS reading sequentially by key, 4-25
direct, 4-47 using to process an indexed file, 4-26
indexed, 4-48 with noncontiguous fields
sequential, 4-44 coding of, 4-27
sequential between records, 4-45 reading randomly by key, 4-37
using Output Specifications, 17-7 sequentially within limits, 4-32
Addrout file, 4-39 Alternate index file
coding requirements, 4-41 processing of, 4-28
for random file processing, 4-39 alternate keys, See Alternate index file
length of when producing by SORT alternating vector format, 10-17
program, 8-17 in Entries per Record field, 10-6
AGAIN? error message, A-2 in Entries per Vector field, 10-7
aliases for indicators, 2-13 in Extension Specifications example, 10-5
ALLOCATION file attribute, 4-4 loading vectors in Extension
in EFS direct files, 4-9 Specifications, 10-13
alphanumeric Alternating Vector Format field
aliases for indicators, 2-13 in Extension Specifications, 10-10
fields of comparison operations, 16-12 AND and OR lines, 14-14
format, 14-17 control level indicators for, 15-7
literal, 2-8 AND and OR Lines field
alternate collating sequence in Input Specifications, 14-6
using ** Specifications, 18-8 in Output Specifications, 17-6
using the coding form method, 18-2 synchronization of record in, 17-18
Alternate Collating Sequence ANDxx operation, 16-32
Specifications, 18-1 applications, 1-1
description of, 1-4

8600 0544–103 Index–1


Index

arithmetic operations, 16-4 attributes


ADD, 16-6 modification of, 9-8
compile-time warning methods with, 16-5 of data communications files
DIV, 16-7 LASTSUBFILE, 12-6
MULT, 16-8 of disk files
MVR, 16-8 ALLOCATION, 4-4
resulting indicators, meaning of, 16-4 DELETE-CAPABLE, 4-3, 4-4
SQRT, 16-9 EXTEND, 4-5
SUB, 16-10 RECORDLEVELLOCK, 4-3, 4-6
XFOOT, 16-10 of files
Z-ADD, 16-11 DESTINATION, 9-9
arithmetic operatiOns KIND, 9-1
Z-SUB, 16-11 RESIDENT, 9-7
arrays, See vectors of libraries, 13-1, See Library Specifications
ASCII FUNCTIONNAME, 13-4
character values of, table, B-3 LIBACCESS, 13-3
in File Translation field of Control LIBPARAMETER, 13-4
Specification, 8-26 TITLE, 13-4
ATTEMPT TO MODIFY A PRIMARY KEY of tasks
WITH A REWRITE error TASKSTRING, 14-46, 21-5
message, A-3 OPTIONS, 16-76
Attribute Designation field in Attribute task
Specifications, 9-4 SW1 through SW8, 8-31
attribute identifier, 9-5 automatic skipping, 17-52
Attribute Specifications, 9-1
alphanumeric identifier in, 9-4
attributes, assigning initial values, 9-4 B
Boolean identifier in, 9-4
coding field definitions in, 9-7 BAD COMS DESIGNATOR NAME error
coding of, 9-1 message, A-3
description of, 1-4 basic file system (BFS) files, 4-1
effects on Calculation Specifications adding records to
fields, 9-8 direct, 4-43
examples of, 9-5 indexed, 4-48
field definitions, 9-3 sequential, 4-43
Attribute Designation comparison to EFS, 4-1
(columns 9-65), 9-4 creating, direct, 4-15
Comment (column 7), 9-3 creating, indexed, 4-19
Field Length (columns 72-74), 9-6 creating, sequential, 4-12
Form Type (column 6), 9-3 deleting from, direct, 4-51
Program Identification deleting from, indexed, 4-53
(columns 75-80), 9-6 deleting from, sequential, 4-51
Sequence Number (columns 1-5), 9-3 describing multiple keys for, 8-10
Specifications Continuation BEGSR operation, 16-54
(columns 7-8), 9-4 BEYOND EXTEND AREA error message, A-4
Variable Name (columns 66-71), 9-5 BFS files, See basic file system (BFS) files
for libraries, 13-4 binary character values, table of, B-3
identifier, type of, 9-4 binary field operations, 16-26
kinds of, 9-1 BITOF, 16-27
mnemonic identifier in, 9-4 BITON, 16-27
modifying attributes, 9-8 example of, 16-26
numeric identifier in, 9-4 TESTB, 16-27
order required by compiler, 9-1

Index–2 8600 0544–103


Index

binary format, 14-19 description of, 1-4


BITOF operation, 16-27 detail calculations in, 15-1
BITON operation, 16-27 DIV operation in, 16-7
BLANK figurative constant, 2-6 DO operation in, 16-42
BLANKS figurative constant, 2-6 DOUxx operation in, 16-44
Block Length field DOWxx operation in, 16-45
default values for, 8-15 DSPLY operation in, 16-64
in File Specifications, 8-14 DUMP operation in, 16-74
minimum and maximum values for, 8-14 EEXSR operation in, 16-54
resulting values for, table, 8-15 ELSE operation in, 16-47
Block Length field ENDSR operation in, 16-54
in Telecommunications File EXCPT operation in, 16-65
Specifications, 12-10 EXSR operation in, 16-54
Boolean compiler control options, 21-7 field definitions, 15-2
Boolean operators in structured programming Comment (column 7), 15-4
operations, 16-31 Comments (columns 60-74), 15-16
bubble sort, recommended entry in Half Control Level (columns 7-8), 15-5
Adjust field, 16-80 Decimal Positions (column 52), 15-13
buffer allocation, 8-19 Factor 1 (columns 18-27), 15-11
business conventions Factor 2 (columns 33-42), 15-12
for internationalization, 5-10 Field Length (columns 49-51), 15-13
BYFUNCTION in Library Attribute Form Type (column 6), 15-4
Specifications, 13-4 Half Adjust (column 53), 15-14
BYTITLE in Library Attribute Indicators (columns 9-17), 15-8
Specifications, 13-4 Operation (columns 28-32), 15-11
Program Identification
(columns 75-80), 15-16
C Result Field (columns 43-48), 15-12
Resulting Indicators
C (Character) portion of C/Z/D field in Input (columns 54-59), 15-14
Specifications, 14-16 Sequence Number (columns 1-5), 15-4
Calculation Specifications, 15-1 FORCE operation in, 16-67
ADD operation in, 16-6 GOTO operation in, 16-29
AND and OR lines in, 15-7 I/O operations in, 16-58
ANDxx operations in, 16-32 IFxx operation in, 16-46
arithmetic operations in, 16-4 in program, sequence of, 15-1
BEGSR operation in, 16-54 indicators
binary field operations in, 16-26 (01-99), 15-9
BITOF operation in, 16-27 control level, 15-6
BITON operation in, 16-27 external, 15-10
CASE operation in, 16-38 halt, 15-10
CASxx and CAS operations in, 16-36 last record (LR), 15-6, 15-9
CHAIN operation in, 16-58 matching record, 15-10
CLOSE operation in, 16-61 overflow, 15-10
coding form for, 15-2 library operations in, 16-54
COMP operation in, 16-12 LOKUP operation in, 16-76
compare operations in, 16-12 LR indicator in, 15-9
Control Level field in, 15-7 MHHZO operation in, 16-24
control level indicators L0-L9 in, 15-9 MHLZO operation in, 16-24
DEBUG operation in, 16-71 MLHZO operation in, 16-24
DEFN operation in, 16-72 MLLZO operation in, 16-25
DELET operation in, 16-63 MOVE operation in, 16-15
move zone operations in, 16-24

8600 0544–103 Index–3


Index

MOVEA operation in, 16-18 ccsversion


MOVEL operation in, 16-22 definition of, 5-4
MULT operation in, 16-8 selecting, 5-4
MVR operation in, 16-8 CCSVSNLIST CENTRALSUPPORT library
operation codes, See operation codes procedure, 5-37
indicator operations, 16-28 CCSVSNNAME CENTRALSUPPORT library
list of, 16-1 procedure, 5-39
ORxx operations in, 16-48 example of, 5-40
PARAM operation in, 16-55 CCSVSNNUM CENTRALSUPPORT library
program branching operations in, 16-29 procedure, 5-41
READ operation in, 16-67 example of, 5-42
READE operation in, 16-68 CENTRALSUPPORT library procedures
READP operation in, 16-69 CCSTRANTXT, 5-34
RECV operation in, 16-69 CCSVSNLIST, 5-37
SEND operation in, 16-69 CCSVSNNAME, 5-39
SETOF operation in, 16-28 CCSVSNNUM, 5-41
SETON operation in, 16-28 CENTSTATUS, 5-43
SETTL operation in, 16-70 CNVCURNCY, 5-46
SORTA operation in, 16-80 CNVDATE, 5-48
SQRT operation in, 16-9 CNVDATTIM, 5-51
SR entry in, 15-5 CNVDSPYMDL, 5-54
SUB operation in, 16-10 CNVFORMSIZ, 5-56
subroutine entry in, 15-6 CNVLIST, 5-58
subroutine operations in, 16-52 CNVNAME, 5-61
TAG operation in, 16-29 CNVSYMBOLS, 5-62
TESTB operation in, 16-27 CNVTIME, 5-67
TESTN operation in, 16-13 CNVTPLT, 5-70
TESTZ operation in, 16-14 CSMSG, 5-72
TIME operation in, 16-81 functions of (table), 5-14, 5-16
total calculations in, 15-1 library calls, 5-19
XFOOT operation in, 16-10 MCPLANGS, 5-76
Z-ADD operation in, 16-11 TPLTDATE, 5-78
ZIP operation in, 16-81 TPLTDATTIM, 5-80
Calculation SpecifiCations TPLTTIME, 5-82
Z-SUB operation in, 16-11 VSNCOMPTXT, 5-85
CANDE, See Command and Edit (CANDE) VSNESCAPE, 5-89
CARD file, See file, compiler VSNGETORD1, 5-92
card file closing, 8-28 VSNINSPTXT, 5-95
CAS operation, See CASxx and CAS VSNTRANTXT, 5-98
operations CENTRALSUPPORT Library Specifications file
CASE operation, 16-38 example of, 5-22
examples of, 16-39 CENTSTATUS CENTRALSUPPORT library
field definitions for, 16-39 procedure, 5-43
labels for, 16-39 example of, 5-43
CASxx and CAS operations, 16-36 CHAIN operation, 16-58
examples of, 16-37 field entries in, 16-58
field definitions for, 16-36 for sign conversion, indexed files, 16-60
resulting indicators for, 16-36 unexpected found condition in, 16-58
specifying collating sequence for, 7-7 used with index name in Result Field, 8-22
CCR, See compiler control record (CCR) with example of sequential files, 16-61
CCS, See coded character set with indexed files, 16-58
CCSTRANTXT CENTRALSUPPORT library chained files, See file, chained
procedure, 5-34 chained indexed files coding example, 16-60

Index–4 8600 0544–103


Index

channel line equation, 11-4 for internationalization, 5-7


Channel Number field, 11-4 Collating Sequence field in the Control
in Line Counter Specifications, 11-5, 11-6 Specification, 7-7
rules for specifying, 11-6 combined file, 8-6
Character field in Input Specifications, 14-16 comma option, 17-26
character set, 2-1, 5-1, 5-4 Command and Edit (CANDE)
designating, 5-5 using to compile, 21-3
in alphanumeric literals, 2-1 Comment field
in edit words, 2-1, 2-3 in Alternating Collating Sequence
in forming names, 2-2 Specifications, 18-3
in identifiers, 2-2 in Attribute Specifications, 9-3
representation of, B-1 in Calculation Specifications, 15-4
check-protect asterisk, 17-25 in Control Specification, 7-3
CLEAR compiler control option, 21-10 in Extension Specifications, 10-3
CLOSE operation, 16-61 in File Specifications, 8-4
example of, 16-62 in File Translation Specifications, 19-3
option values for, 16-61 in Input Specifications, 14-4
when no CLOSE option is specified, 16-62 in Line Counter Specifications, 11-3
CNVCURNCY CENTRALSUPPORT library in Output Specifications, 17-4
procedure, 5-46 in Telecommunications
example of, 5-46 Specifications, 12-4
CNVDATE CENTRALSUPPORT library in Vector Data Specifications, 20-4
procedure, 5-48 comment line coding
CNVDATTIM CENTRALSUPPORT library example of, 10-3, 11-3
procedure, 5-51 Comments field in Extension
example of, 5-51 Specifications, 10-10
CNVDSPYMDL CENTRALSUPPORT library COMP operation, 16-12
procedure, 5-54 specifying collating sequence for, 7-7
example of, 5-54 comparing text
CNVFORMSIZ CENTRALSUPPORT library for internationalization, 5-7
procedure, 5-56 comparison operations, 16-12
example of, 5-56 COMP, 16-12
CNVLIST CENTRALSUPPORT library comparing
procedure, 5-58 alphanumeric fields in, 16-12
example of, 5-58 numeric fields, 16-12
CNVNAME CENTRALSUPPORT library TESTN, 16-13
procedure, 5-61 TESTZ, 16-14
example of, 5-61 compiled program, formatting printer
CNVSYMBOLS CENTRALSUPPORT library listing, 21-25
procedure, 5-62 compiler control options
example of, 5-62 ACCESSOPEN, 21-10
CNVTIME CENTRALSUPPORT library CLEAR, 21-10
procedure, 5-67 CODE, 21-10
CNVTPLT CENTRALSUPPORT library DELETE, 21-10
procedure, 5-70 DMSNAME, 21-11
example of, 5-70 DOLLARISDATA, 21-11
CODE compiler control option, 21-10 DOUBLE, 21-11
CODE file, See file, compiler EOFCLOSE, 21-11
coded character set, 5-4 ERRORLIMIT, 21-12
selecting, 5-4 ERRORSOURCE, 21-12
collating sequence FZONE, 21-13
accessing default, 5-8 INCLUDE, 21-13
defining a specific, 5-8 KEYEDIOIIOUTPUT, 21-14

8600 0544–103 Index–5


Index

LINEINFO, 21-14 ANDxx operation in, 16-48


LIST, 21-15 DOUxx operation in, 16-43
LISTDELETED, 21-15 DOWxx operation in, 16-45
LISTDOLLAR, 21-15 IFxx operation in, 16-46
LISTINCL, 21-15 IFxx/ELSE operation in, 16-47
LISTOMITTED, 21-15 COMS operations, 16-82
LISTP, 21-16 COMS-time
MAP, 21-16 fields, 13-8
MERGE, 21-16 result types, 13-6
NEW, 21-17 type vectors, 10-11
OMIT, 21-18 consecutive file processing, 4-22
PAGE, 21-18 of direct files, 4-22
PAGESIZE, 21-18 of indexed files, 4-22
RSIGN, 21-19 of sequential files, 4-22
SEQ, 21-19 constants, rules when forming, 17-22
SEQUENCE BASE, 21-20 continuation line
SEQUENCE INCREMENT, 21-20 example of, 4-46
STATISTICS, 21-20 Continuation Line field in File
SUMMARY, 21-21 Specifications, 8-22
TARGET, 21-21 Continuation Options field
TITLE, 21-22 in File Specifications, 8-24
TITLESPERFILE, 21-23 continuous printing, 17-52
types of, 21-7 control break
UNSEQ, 21-23 field in Input Specifications, 14-25
USERDEBUG, 21-23 in program logic cycle (PLC), 3-5
WARNFATAL, 21-24 Control field
WARNSUPR, 21-24 in Input Specifications, 14-25
XREF, 21-24 in program logic cycle (PLC), 3-5
XREFFILES, 21-24 Control group field in Input
compiler control record (CCR), 21-6 Specifications, 14-25
compiler control options, See compiler Control Level field
control options in Calculation Specifications
default values, 21-7 (columns 7-8), 15-5
example of use, 21-7 in Input Specifications, 14-25
files, compiler, 21-1 control level indicators (L0-L9), 15-5, 17-14
options of, 21-7 in Calculation Specifications, 15-6
syntax, 21-8 in Output Specifications, 17-14
<Boolean option>, 21-9 rules for assigning, 14-26
explanation, 21-9 use, conditions for, 15-9
<immediate option>, 21-9 with AND and OR lines, 15-7
<value option>, 21-9 control level indicators (L1-L9)
types of, 21-6 assigning to more than one field, 14-27
compiler directives, 21-25 use, for field record relations, 14-36
/EJECT, 21-25 with record type change, 14-9
/SPACE, 21-25 Control Specification, 7-1
/TITLE, 21-25 coding form for, 7-1
compiler files, See file, compiler description, 1-4
compiler memory estimate, 21-26 field definitions, 7-3
compiling Collating Sequence (column 26), 7-7
using CANDE, 21-3 Comment (column 7), 7-3
using WFL, 21-4 Currency Symbol (column 22), 7-6
compound conditional expression Date Edit (column 24), 7-7
AND operation in, 16-32 Date Format (column 23), 7-6

Index–6 8600 0544–103


Index

Debug (column 15), 7-4 D


External Sign Handling (column 40), 7-8
File Translation (column 43), 7-10
D (digit) portion of C/Z/D field in Input
Form Type (column 6), 7-3
Specifications, 14-16
Forms Position (column 41), 7-9
data class, definition of, 5-6
Halt Indicator (column 50), 7-11
data communications files, 12-1
Indicator Setting (column 42), 7-9
end of job (EOJ), 12-10
Inverted Print (column 21), 7-5
File Specifications for, 12-9
Line Printer Skipping (column 46), 7-10
data communications protocols,
Object Output (column 10), 7-4
international, 5-1
Program Identification
data extraction in program logic cycle
(columns 75-80), 7-13
(PLC), 3-7
Run-Time Error (column 49), 7-11
data format, 17-21
Sequence Number (columns 1-5), 7-3
data structure name, 2-4
Sign Handling (column 40), 7-8
data structures, 14-40
Sign Position (column 17), 7-5
coding, 14-43
Source Input Dialect (column 51), 7-12
for a local data area, 14-46
Time of File Close (column 53), 7-13
name descriptions, 14-41
Time of File Open (column 52), 7-13
subfield descriptions, 14-42
Zero/Blank Indicator Setting
Database Specification, 21-11
(column 42), 7-9
description, 1-4
use of, 7-1
DATACOM device type, 12-12
CONVENTION task attribute, 5-3
DATACOM READ ERROR message, A-4
conventions
DATACOM WRITE ERROR message, A-5
for localization, establishing, 5-3
date
CR credit symbol
system provided
for reporting negative status
CURRENT_DATE procedure, 13-20
using edit codes, 17-26
Date Edit field in Control Specification, 7-7
using edit words, 17-34
Date Format field in Control Specification, 7-6
creating a disk file, 1-2, 4-11
date formats
BFS
for internationalization, 5-11
direct, 4-15
DEAD LOCK ERROR message, A-5
indexed, 4-19
Debug field in Control Specification, 7-4
sequential, 4-12
DEBUG operation, 16-71
EFS
example of, 16-72
direct, 4-16
debugging, 7-4
indexed, 4-20
USERDEBUG compiler control
sequential, 4-13
option, 21-23
creating multilingual messages, guidelines
decimal character values, table of, B-1
for, 5-10
Decimal Positions field
crunch files, 8-29
in Calculation Specifications, 15-13
CRUNCH option, 16-61, 16-62
in Extension Specifications, 10-9
CSMSG CENTRALSUPPORT library
in Input Specifications, 14-23
procedure, 5-72
default settings for internationalization, 5-2
cultural conventions
DEFN operation, 16-72
for internationalization, 5-10
*LIKE field in, 16-73
currency displays
example of, 16-73
for internationalization, 5-12
field definitions for, 16-73
Currency Symbol field in Control
DEL
Specification, 7-6
using to delete records
cycle initialization in program logic cycle
from indexed files, 4-53
(PLC), 3-3

8600 0544–103 Index–7


Index

from sequential or direct files BFS


(BFS), 4-51 adding records to, 4-43
from sequential or direct files creating, 4-15
(EFS), 4-52 deleting records from, 4-51
DELET operation, 16-63 writing, 4-9
programmed control of I/O, 16-63 consecutive processing of, 4-22
used to delete records from indexed creating
files, 4-53 BFS, 4-15
used with index name in Result Field, 8-22 EFS, 4-16
DELETE BEFORE INPUT error message, A-6 creating delete-capable EFS, 4-16
DELETE compiler control option, 21-10 creating nondelete-capable EFS, 4-18
DELETE ERROR message, A-6 deleting records from
DELETE INVALID error message, A-7 BFS, 4-51
DELETE-CAPABLE file attribute, 4-4 EFS, 4-52
in disk files, 4-3 EFS
in EFS direct files, 4-9 adding records to, 4-47
Delete-Capable File field in File creating, 4-16
Specifications, 8-27 creating nondelete-capable, 4-18
delete-capable file, creating EFS direct, 4-16 deleting records from, 4-52
deleting records from a file writing, 4-9
BFS organization of, 4-8
direct, 4-51 random processing of, 4-34
indexed, 4-53 using relative record numbers, 4-34
sequential, 4-51 with an addrout file, 4-39
EFS writing
direct, 4-52 BFS, 4-9
sequential, 4-52 EFS, 4-9
demand file, 8-8 disk files
DEPENDENTSPECS file attribute, and adding records to, 4-43
compiler input files, 21-1 alternate index files in, 4-3
designator attributes of, 4-2
field type passed, 13-8 closing, options for, 8-29
result type, 13-6 creating, 4-11
type vectors, 10-11 deleting records from, 4-51
detail calculations, 15-1 in EFS files, 4-4
in program logic cycle (PLC), 3-7 organization of, 4-6
detail output in program logic cycle (PLC), 3-3, processing of, 4-11, 4-22
17-5 RECNO option in continuation lines, 8-24
Device RECORDLEVELLOCK file attribute, 4-6
DATACOM type, 12-12 systems in
REMOTE type, 12-12 BFS, 4-1
Device field EFS, 4-1
in File Specifications, 8-21 types of, 4-6
in Telecommunications File disk files, freeing locked records in, 4-54
Specifications, 12-12 display file, 8-6
dialect DIV operation, 16-6, 16-7
specifying RPGI or RPG II, 7-12 division, See DIV operation
direct files, 4-8 DMSII operations, 16-82
adding records to DMSNAME compiler control option, 21-11
BFS at end, 4-43 DO operation, 16-41, 16-42
EFS between records, 4-47 example of, 16-42
alternate index file for, 4-3 field definitions for, 16-42
attributes of, 4-2 dollar card, 21-9

Index–8 8600 0544–103


Index

DOLLARISDATA compiler control for numeric output, 17-18


option, 21-11 for synchronization of output
DOUBLE compiler control option, 21-11 records, 17-18
double-precision word format, 14-20 edit words, 17-33
DOUxx operation, 16-41, 16-44 body of, 17-33
example of, 16-44 examples of use, 17-35
field definitions for, 16-44 extension of, 17-34
specifying collating sequence for, 7-7 replaceable character in, 17-34
DOWxx operation, 16-41, 16-45 rules for using, 17-34
example of, 16-45 status in, 17-34
field definitions for, 16-45 zero-suppression character, 17-35
specifying collating sequence for, 7-7 EEXSR operation, 16-54
DSED option, use in symbolic dump, 16-76 example of, 16-57
DSPLY operation, 16-64 efficiency of program, use of I/O buffers, 8-19
example of, 16-65 EFS files, See extended file system (EFS)
DUMP operation, 16-74 files
after HALT, 16-75 ELSE operation, 16-47
field definitions for, 16-75 encrypting data, 19-1
DUPLICATE KEY error message, A-7 end of file (EOF), 3-4
duplicate keys, 4-10, 4-48 End of File field
checking for when adding records, 4-49 in File Specifications, 8-10
not checking for when adding in Telecommunications File
records, 4-49 Specifications, 12-10
Duplicate Keys field in File end of file in program logic cycle (PLC), 3-4
Specifications, 8-26 end of job (EOJ)
halt indicators, 16-28
in program logic cycle (PLC), 3-6
E test in program logic cycle (PLC), 3-6
use of LR indicator, 17-14
EBCDIC character values, table of, B-3 vector output, 8-5
edit codes, 17-25 when files closed, 7-13
comma option, 17-26 when tape not rewound, 8-28
date-field format, 17-26 with data communications files, 12-10
determining the number of zeros with sequential-by-key file processing, 4-25
written, 17-26 writing vectors, 10-5
effects end of page (EOP), 17-52
of Y edit code, 17-29 ending routine in program logic cycle
on field end position, 17-28 (PLC), 3-6
on negative data with implied ENDSR operation, 16-54
decimals, 17-32 Entries per Record field in Extension
on negative zero input strings, 17-30 Specifications, 10-6
on positive data with implied Entries per Vector field in Extension
decimals, 17-31 Specifications, 10-7
on positive zero input string, 17-29 EOF (end of file), 3-4
for arrays, 17-26 EOFCLOSE compiler control option, 21-11
rules for, 17-25 EOJ, See end of job (EOJ)
specifying end position when using an EOP (end of page), 17-52
array, 17-25 equivalent data comparison
table of, 17-27 in internationalization, 5-7
zero balance option, 17-26 Error Indicator field in Telecommunications
Edit Codes field Specifications, 12-7
in Output Specifications

8600 0544–103 Index–9


Index

error messages, A-1 ERRORSOURCE compiler control


ADD TO NON-DELETED RECORD, 4-45, option, 21-12
4-47, A-2 example of
AGAIN?, A-2 *IN coding, 2-14
ATTEMPT TO MODIFY A PRIMARY KEY *INxx coding, 2-14
WITH A REWRITE, 4-10, A-3 *PLACE Specifications, 17-24
BAD COMS DESIGNATOR NAME, A-3 1P indicator use, 17-16
BEYOND EXTEND AREA, 4-47, A-4 ADD operation, 16-6
compile-time truncation warning adding records and checking for duplicate
messages, 16-5 keys, 4-50
DATACOM READ ERROR, 12-7, A-4 adding records to a BFS sequential or
DATACOM WRITE ERROR, 12-7, A-5 direct file, 4-43
DEADLOCK ERROR, A-5 adding records to end of an EFS sequential
DELETE BEFORE INPUT, A-6 file, 4-44
DELETE ERROR, A-6 adding records without checking for
DELETE INVALID, A-7 duplicate keys, 4-49
DUPLICATE KEY, 8-25, A-7 alternate collating sequence coding, 18-5,
HALT INDICATORS ON, A-8 18-9
high-order truncation warning alternate index file with a noncontiguous
messages, 16-5 key, 4-27
INPUT RECORD SEQUENCE AND and OR coding, 14-14
ERROR, 14-6, A-8 AND and OR relationship coding, 15-7
INTEGRITY ERROR, A-9 assigning and modifying file attributes, 9-9
KEY NOT FOUND, 4-40, 4-45, 4-52, 8-25, Attribute Specifications, kinds of, 9-5
A-9 binary field operations, 16-26
KEY OUT OF SEQUENCE, 4-19, 8-25, A-9 CASE operation, 16-39
low-order truncation warning CASxx and CAS operations, 16-37
messages, 16-6 CCSVSNNAME procedure, 5-40
MATCH FIELD SEQUENCE ERROR, 8-12, CCSVSNNUM procedure, 5-42
A-10 CENTRALSUPPORT Library Specifications
NO MATCHING CASE LABEL FOR file, 5-22
SELECTION VARIABLE, A-11 CENTSTATUS procedure, 5-43
OPEN/CLOSE ERROR OF FILE, A-11 CHAIN operation with sequential
programmed halts, A-8 files, 16-61
READ AT END OF FILE, 16-67, A-11 chained indexed files, 16-60
RECORD IDENTIFICATION ERROR, 14-16, CLOSE operation, 16-62
A-11 CNVCURNCY procedure, 5-46
RECORD KEY MISMATCH, A-12 CNVDATTIM procedure, 5-51
RECORDKEY MISMATCH, 4-10 CNVDSPYMDL procedure, 5-54
run-time, A-1 CNVFORMSIZ procedure, 5-56
SECURITY ERROR, A-13 CNVLIST procedure, 5-58
SQRT OPERATION ERROR, 16-9, A-13 CNVNAME procedure, 5-61
SUBSCRIPT ERROR, A-13 CNVSYMBOLS procedure, 5-62
UPDATE UNLOCKED RECORD, A-14 CNVTPLT procedure, 5-70
VECTOR LOAD ERROR, 10-14, A-14 comment line coding, 10-3, 11-3
VECTOR SEQUENCE ERROR, A-15 compiler control record use, 21-7
VECTORSEQUENCE ERROR, 10-9 compile-time vector specifications
VERSION ERROR, A-15 no sequence numbers, 20-5
error values with sequence numbers, 20-6
for internationalization (table), 5-102 compiling using a WFL job, 21-4
ERRORLIMIT compiler control option, 21-12 constants coding, 17-22
ERRORS file, See file, compiler control fields in two record types, 14-27
creating a BFS direct file, 4-15

Index–10 8600 0544–103


Index

creating a BFS indexed disk file, 4-19 using Calculation Specifications, 10-17
creating a BFS sequential disk file, 4-13 using Input Specifications, 10-16
creating an alternate index file, 4-26 look-ahead field coding, 14-13
creating an EFS delete-capable direct MCPLANGS procedure, 5-76
file, 4-16 MOVEA operation, 16-19
creating an EFS direct disk file (not delete- MULT operation, 16-6
capable), 4-18 multifile processing with matching
creating an EFS direct file, 4-5 records, 14-32
creating an EFS indexed disk file, 4-21 nested structured programming
creating an EFS sequential disk file, 4-14 operations, 16-31
data communication files, 12-12 one-vector LOKUP operation, 16-77
data structure for local data area, 14-46 output indicators coding, 17-13
data structure format with repeating overflow with skip to channel option, 17-60
subfields, 14-44 packed decimal format, 4-19
DEBUG operation, 16-72 page fields, 2-12
defining subfields in data structures to PARAM operation, 16-57
overlap, 14-44 processing a BFS direct or sequential
DEFN operation, 16-73 file, 4-23
deleting a record using the DEL entry, 4-53 processing an indexed file
deleting a record using the DELET consecutively, 4-24
operation code, 4-53 processing random file using relative
deleting records from an EFS sequential or record numbers, 4-35
direct file, 4-52 processing randomly indexed file using
designating end position on Output keys, 4-37
Specifications, 17-20 processing randomly using an addrout
determining if a file is present on disk, 9-7 file, 4-40
DIV operation, 16-6 processing sequentially by key, 4-25
DO operation, 16-42 processing sequentially within limits
DO operation with increment values, 16-43 using a limits file, 4-29
DOUxx operation, 16-44 releasing a locked record with free
DOWxx operation, 16-45 operation, 4-54
DSPLY operation, 16-65 resulting indicator coding in
duplicate coding, 14-24 Calculation Specifications, 15-15
edit word and edit codes sequence checking using matching
comparisons, 17-50 records, 14-33
edit words, 17-35 sequential-within-limits
EEXSR operation, 16-57 using the SETLL operation code, 4-32
EXCPT operation, 16-66 SORTA operation, 16-80
field record relation indicators, 14-35 split control fields, 14-28
file translation coding, 19-5, 19-7 SQRT operation results, 16-9
GOTO operation, 16-29 subroutine operations, 16-53
header-trailer specification coding, 14-39 symbolic dump during program run or
IFxx operation, 16-47 compilation, 16-76
IFxx/ELSE operations, 16-48 TPLTDATTIM procedure, 5-80
Input Specifications sequence two-vector LOKUP operation, 16-77
checking, 14-5 using remote files, 12-12
L0 indicator coding, 15-6 using the ALLOCATION and EXTEND
Library Specifications coding, 13-12 attributes, 4-5
Library Specifications program, 13-13 using the DEL entry with a direct file, 4-51
Line Counter Specifications coding, 11-4 using the RECNO field with a chained
loading a noncontiguous key using a update direct file, 4-47
CHAIN operation, 4-38 using the RECNO field with a chained
loading execution-time vectors update file, 4-46

8600 0544–103 Index–11


Index

using variable-length records, 8-13 Entries per Vector (columns 36-39), 10-7
VSNESCAPE procedure, 5-89 Form Type (column 6), 10-3
VSNGETORD1 procedure, 5-92 From Filename (columns 11-18), 10-4
VSNINSPTXT procedure, 5-95 Length of Entry (columns 40-42), 10-7
VSNTRANTXT procedure, 5-98 Packed (column 43), 10-8
zero balance output, 17-26 Program Identification
ZIP operation, 16-82 (columns 75-80), 10-10
example program for accessing a 4-digit Sequence (column 45), 10-9
year, 13-20 Sequence Number (columns 1-5), 10-3
exception output To Filename (columns 19-26), 10-5
EXCPT operation, 16-65 Vector Name (columns 27-32), 10-5
Output Specifications, 17-5 vectors in, 10-11
EXCPT operation external indicators (U1-U8), 17-15
example of, 16-66 for calculation operations, 15-10
resulting indicators in, 16-66 in File Specifications, 8-30
EXSR operation, 16-54 in Output Specifications, 17-15
EXTEND file attribute, 4-5 initializing in program logic cycle (PLC), 3-3
extended file system (EFS) files, 4-1 using to show a field record
adding record to end, sequential, 4-44 relationship, 14-36
adding records between, sequential, 4-45 External Sign Handling field
adding records, direct, 4-47 in the Control Specification, 7-8
adding records, indexed, 4-48
comparison to BFS, 4-1
creating, direct, 4-16 F
creating, direct nondelete capable, 4-18
creating, indexed, 4-20 Factor 1 field in Calculation
creating, indexed delete-capable, 4-16 Specifications, 15-11
creating, sequential, 4-13 Factor 2 field in Calculation
delete-capable entry, 8-27 Specifications, 15-12
deleting from, direct, 4-52 FAULT option, use in symbolic dump, 16-76
deleting from, indexed, 4-53 fetch overflow, 17-9
deleting from, sequential, 4-52 sequence of operations, 17-64
file attributes of, 4-4, 4-12 when printed, 17-53
format of, 8-12 Fetch Overflow field in Output
full-procedural, 8-9 Specifications, 17-8
KEYEDIOIIOUTPUT option, 21-14 Field End Position field (columns 40-43)
extending files, 8-29 in Output Specifications, 17-19
Extension Code field in File use with edit codes, 17-26
Specifications, 8-21 Field Indicators field in Input
Extension Specifications, 1-4, 10-1 Specifications, 14-37
alternating format in, 10-5 field length, 2-4
coding form, 10-1 Field Length field
determining type of vector, 10-7 in Attribute Specifications, 9-6
field definitions, 10-3 in Calculation Specifications, 15-13
Alternating Vector Format allowing correct space for result, 16-8,
(columns 46-57), 10-10 16-10
Comment (column 7), 10-3 Field Location field in Input
Comments (columns 58-74), 10-10 Specifications, 14-22
Decimal Positions (column 44), 10-9 field name, 2-4
Entries per Record Field Name field
(columns 33-35), 10-6 in Input Specifications, 14-23
in Output Specifications, 17-17

Index–12 8600 0544–103


Index

field record relation indicators, 14-34 File Organization Type field


using with the Field Name field, 14-23 in File Specifications, 8-18
using with the OR field, 14-24 in Telecommunications File
Field Record Relations field Specifications, 12-11
in Input Specifications, 14-34 file processing
figurative constants, 2-6 consecutive, 4-22
File Addition/Unordered field in File controlling with File Specifications, 8-19
Specifications, 8-24 ending of, 16-61
file attributes, assigning initial values, 9-4 in File Specifications, 4-22
file buffer space, 21-26 in program logic cycle (PLC), 3-4
File Close field in File Specifications, 8-27 limits files, 4-28
File Condition field of addrout files, 4-39
in File Specifications, 8-30 of alternate index files, 4-26
in Telecommunications File random, 4-34
Specifications, 12-12 randomly-by-key value, 4-36
file creation, 1-2 sequentially by key, 4-25
File Description Specifications, See File sequentially within limits, 4-28, 4-33
Specifications SETLL operation, 4-32
File Designation field using an alternate index file with an
in File Specifications, 8-7 addrout file, 4-41
array file, 8-8 File Specifications, 8-1
chained file, 8-8 coding form for, 8-1
demand file, 8-8 comment line coding, 8-4, 15-4
full-procedural, 8-9 DATACOM device type, 12-12
primary file, 8-7 description, 1-4
record-address, 8-9 entries to control file processing, 8-19
relationship to File Type field, 8-9 field definitions, 8-2
secondary file, 8-7 Block and Record Length
table file, 8-8 (columns 20-27), 8-14
in Telecommunications File Comment (column 7), 8-4
Specifications, 12-10 Continuation Line (column 53), 8-22
File Format field Continuation Options
in File Specifications, 8-12 (columns 54-65), 8-24
in Telecommunications File Delete-Capable File (column 69), 8-27
Specifications, 12-10 Device (columns 40-46), 8-21
file name, 2-4 Duplicate Keys (column 68), 8-26
File Open field in File Specifications, 8-22 End of File (column 17), 8-10
file organization Extension Code (column 39), 8-21
alternate index files, 4-3 File Addition/Unordered
array files, 8-8 (column 66), 8-24
chained files, 8-8 File Close (column 70), 8-27
demand files, 8-8 File Condition (columns 71-72), 8-30
direct organization, 4-8 File Continuation (column 53), 8-22
disk files, 4-6 File Designation (column 16), 8-7
full-procedural files, 8-9 File Format (column 19), 8-12
indexed organization, 4-9 File Organization Type (column 32), 8-18
primary files, 8-7 File Translation (column 67), 8-26
record-address files, 8-9 File Type (column 15), 8-5
secondary files, 8-7 Filename (columns 7-14), 8-4
sequential, 4-6 Form Type (column 6), 8-4
table files, 8-8 Index Name (columns 47-52), 8-22
Key Description
Multiple Keys (columns 15-17), 8-10

8600 0544–103 Index–13


Index

Key Field Starting Location File Type field


(columns 35-38), 8-20 in File Specifications, 8-5
Overflow Indicator combined file, 8-6
(columns 33-34), 8-20 display file, 8-6
Processing Mode (column 28), 8-16 input file, 8-5
Program Identification output file, 8-5
(columns 75-80), 8-31 relationship to File Designation field, 8-9
Record-Address Field Length update file, 8-6
(columns 29-30), 8-16 in Telecommunications File
Record-Address Type (column 31), 8-17 Specifications, 12-9
Sequence (column 18), 8-12 file, array, 8-8
Sequence Number (columns 1-5), 8-4 file, card, 8-28
File Close field file, chained, 8-8
for abnormal end, 8-30 indexed files, 4-35
for card files, 8-28 reading randomly by relative record
for disk files, 8-29 number, 4-34
for printer files, 8-28 restriction with SETLL operation, 4-32
for tape files, 8-28 when checking for duplicate keys, 4-50
File Continuation field, 8-22 when creating a direct file, 4-15
file processing, 4-22 file, compiler
controlling with field entries, 8-21 CARD, 21-1
limits files, 4-28 CODE, 21-1
random, 4-34 ERRORS, 21-1
randomly-by-key value, 4-36 ERRORSOURCE, 21-1
sequentially by key, 4-25 LINE, 21-1
sequentially within limits, 4-28, 4-33 LINE, 21-24
SETLL operation, 4-32 NEWSOURCE, 21-1
for data communication files, 12-9 SOURCE, 21-1
for file processing, consecutive, 4-22 file, demand, 8-8
processing of addrout files, 4-39 file, full-procedural, 8-9
REMOTE device type, 12-12 file, input
file translation adding records to, 4-43
reference table for, B-3 as a limits file, 4-31
using the ** Specifications, 19-6 deleting records from, 4-51
File Translation field processing by addrout file, 4-40
in Control Specification, 7-10 processing consecutively, 4-22
in File Specifications, 8-26 processing sequentially within limits, 4-30
File Translation Specifications, 19-1 processing using SETLL operation, 4-33
coding form for, 19-2 file, output
description of, 1-4 adding records to, 4-49
field definitions, 19-2 delete-capable, 4-16
Comment (column 7), 19-3 direct, 4-15
Filename (columns 7-14), 19-3 indexed, 4-19
Form Type (column 6), 19-3 sequential, 4-14
Program Identification file, primary, 8-7
(columns 75-80), 19-4 file, record-address, 8-9
Sequence Number (columns 1-5), 19-3 file, secondary, 8-7
Translation Table (columns 15-74), 19-3 file, table, 8-8
file type file, table input, 3-3
for consecutively processed files, 4-22 file, update
for file processed by an addrout file, 4-40 processing by addrout file, 4-41
for sequential-by-key file processing, 4-25 processing sequentially within limits, 4-30
processing using SETLL operation, 4-33

Index–14 8600 0544–103


Index

Filename field single-precision numeric, 14-19, 14-20


in File Specifications, 8-4 unpacked decimal, 14-17
in File Translations Specifications, 19-3 unsigned packed, 14-18
in Input Specifications, 14-4 Forms Position field
in Line Counter Specifications, 11-3 in Control Specification, 7-9
in Output Specifications, 17-5 in the program logic cycle (PLC), 3-3
in Telecommunications File forms specifications, 17-51
Specifications, 12-9 found condition, unexpected occurrence in
in Telecommunications CHAIN operation, 16-58
Specifications, 12-5 free operation, 4-6, 4-54
files, direct, See direct files From Filename field in Extension
files, disk, See disk files Specifications, 10-4
files, sequential, See sequential files full-procedural file, 8-9
first page indicator (1P), 17-15 function in library, 13-6
in program logic cycle (PLC), 3-3 FUNCTIONNAME
First-Control-Cycle switch in program logic in Attribute Specifications for libraries, 13-4
cycle (PLC), 3-3, 3-4, 3-5 in Library Name Specifications, 13-4
fixed-length records, 8-15 library attribute, 13-4
FL, See Form Length (FL) field in Line FZONE compiler control option, 21-13
Counter Specifications F-zone format in MOVEA operation, 16-19
floating dollar sign, 17-25
FORCE operation
description of, 16-67 G
in program logic cycle (PLC), 3-5
Form Length (FL) field in Line Counter GOTO operation, 16-29
Specifications, 11-4
Form Type field
in Alternate Collating Sequence H
Specifications, 18-3
in Attribute Specifications, 9-3
Half Adjust field in Calculation
in Calculation Specifications, 15-4
Specifications, 15-14
in Control Specification, 7-3
Halt Indicator field in Control
in Extension Specifications, 10-3
Specification, 7-11
in File Specifications, 8-4
halt indicators (H0-H9), 17-14
in Input Specifications, 14-4
in Calculation Specifications, 15-10
in Library Name Specifications, 13-3
in Output Specifications, 17-14
in Library Parameter Specifications, 13-7
in program logic cycle (PLC), 3-3
in Library Subroutine Specifications, 13-5
use of, 14-36
in Line Counter Specifications, 11-3
with record type change, 14-9
in Output Specifications, 17-4
HALT INDICATORS ON error message, A-8
in Telecommunications
HALT, use with symbolic dump, 16-75
Specifications, 12-4
Header-Trailer Specifications, 14-38
in Vector Data Specifications, 20-4
requirements and restrictions for, 14-39
format
specifying data records with, 14-38
packed decimal, 4-19
with record type change, 14-9
format of data, 17-21
heading for compiler listing, 21-25
format, external
Heading Output in program logic cycle
alphanumeric, 14-17
(PLC), 3-3
binary, 14-19
heap sort, recommended entry in Half Adjust
double-precision numeric, 14-20
field, 16-80
of input field, 14-16
hexadecimal literal, 2-9
packed decimal, 14-17
separate signed, 14-18

8600 0544–103 Index–15


Index

hexadecimal values of characters, table using record keys, 4-36


of, B-3 using relative record numbers, 4-34
high-order truncation warning messages, 16-5 sequential-by-key processing of, 4-25
hold area, size of, 10-12 sequential-within-limits processing, 4-28
hold pointer, 10-12 File Specifications for, 4-30
using a limits file, 4-28
using SETLL, 4-32
I sign conversion in CHAIN operation, 16-60
Indicator Summary Form, 6-1
I/O areas, 8-19 indicators
I/O operation codes, 16-58 *IN, 2-13
CHAIN, 16-58 *INxx, 2-13
CLOSE, 16-61 alphanumeric aliases, 16-55
DELET, 16-63 control level (L0-L9)
DSPLY, 16-64 in Calculation Specifications, 15-6
EXCPT, 16-65 in Input Specifications, 14-1
FORCE, 16-67 in Output Specifications, 17-14
READ, 16-67 use, conditions for, 15-9
READE, 16-68 with AND and OR lines, 15-7
READP, 16-69 external (U1-U8)
RECV, 16-69 in Calculation Specifications, 15-10
SEND, 16-69 in File Specifications, 8-30
SETLL, 16-70 in Output Specifications, 17-15
IFxx operation, 16-46 field record relation, 14-34
example of, 16-47 first page (1P), 17-15
field definitions for, 16-46 halt (H0-H9)
specifying collating sequence for, 7-7 in Input Specifications, 14-9
IFxx/ELSE operations in Output Specifications, 17-14
example of, 16-48 initialization in program logic cycle
field definitions for, 16-47 (PLC), 3-4
immediate compiler control options, 21-7 last record (LR)
Blank After field, 17-19 in Calculation Specifications, 15-9
MONTH, 17-17 in Input Specifications, 14-9
Constant or Edit Word, 17-21 matching record (MR)
INCLUDE compiler control option, 21-7, 21-13 in Calculation Specifications, 15-10
Index Name field in File Specifications, 8-22 in Input Specifications, 14-29
indexed files, 4-9, See alternate index file in Output Specifications, 17-14
adding records to, 4-48 numeric (01-99)
checking duplicate keys, 4-49 in Calculation Specifications, 15-9
without checking duplicate keys, 4-49 in Output Specifications, 17-14
best suited for, 4-10 output conditioning, 17-13
consecutive processing of, 4-22 overflow (OA-OG, OV), 8-20
creating controlling with Calculation
BFS, 4-19 Specifications, 17-55
EFS, 4-20 in Calculation Specifications, 15-10
for internationalization, 5-9 in Output Specifications, 17-15
deleting records from, 4-53 when printing reports, 17-53
if update file, 4-39 record identifying (01-99), 14-8
loading of, 4-10 referring to
organization of, 4-9 by alphanumeric aliases, 2-13
random processing of example of alphanumeric aliases, 2-14
using addrout files, 4-39 example of array elements, 2-14
example of array elements (*IN,xx), 2-14

Index–16 8600 0544–103


Index

resulting Comment (column 7), 14-4


meaning in arithmetic operations, 16-4 Control Level (column s 59-60), 14-25
with deleted records, 4-46 D (digit) (column 40), 14-16
with EXCPT operation, 16-65 Decimal Positions (columns 52), 14-23
rules for, 16-28 Field Indicators (columns 65-70), 14-37
setting field in the Control Field Location (columns 44-51), 14-22
Specification, 7-9 Field Name (Variable Name)
setting of, 16-28 (columns 53-58), 14-23
summary form of, 6-1 Field Record Relations
testing for greater than, less than, or equal (columns 63-64), 14-34
to blank, 14-37 Filename (columns 7-14), 14-4
testing for plus, minus, or zero, 14-37 Form Type (Column 6), 14-4
three subfields of, 15-8 Match Field (columns 61-62), 14-29
when zero/blank indicator is on, 17-19 Not (N) (columns 25, 32, 39), 14-15
Indicators field in Calculation Number (column 17), 14-6
Specifications, 15-8 Option (column 18), 14-7
Input Dialect field in program logic cycle Packed (column 43), 14-16
(PLC), 3-3 Position (columns 21-24, 28-31, and 35--
input file, See file, input 38), 14-15
input file look-ahead in program logic cycle Program Identification
(PLC), 3-7 (columns 75-80), 14-38
input parameters Record Identification Codes
for CENTRALSUPPORT library (columns 21-41), 14-14
procedures, 5-21 record identifying Indicator
with type values, 5-21 (columns 19-20), 14-8
INPUT RECORD SEQUENCE ERROR Sequence (columns 15-16), 14-5
message, A-8 Sequence Number (columns 1-5), 14-4
Input Specifications, 14-1 Z (zone) (column 33), 14-16
AND line, 14-14 halt indicators, 14-9
assigning control level indicators for, 14-26 header-trailer specifications, 14-9, 14-38
coding form for, 14-1 last record indicators, 14-9
control level indicators, 14-9 look-ahead field (**), 14-10
data structures, 14-40 OR line, 14-14
coding, 14-43 OR relationship, 14-24
for a local data area, 14-46 record identifying indicators (01-99), 14-36
name descriptions, 14-41 special words in, 14-25
subfield descriptions, 14-42 split control fields, 14-27
data structures in, 14-10 spread-record specifications, 14-38
external format of, 14-16 INTEGRITY ERROR message, A-9
alphanumeric, 14-17 internationalization
binary, 14-19 accessing default collating sequence, 5-8
double-precision word, 14-20 business and cultural conventions, 5-10
separate signed decimal, 14-18 ccsversion selection, 5-4
signed packed decimal, 14-17 ccsversions, 5-4
single-precision word, 14-19 CENTRALSUPPORT library procedure
unpacked decimal, 14-17 summary, 5-13
unsigned packed decimal, 14-18 CENTRALSUPPORT library procedures
field definitions CCSTRANTXT, 5-34
AND and OR Lines CCSVSNLIST, 5-37
(columns 14-16), 14-5 CCSVSNNAME, 5-39
C (character) (column 26), 14-16 CCSVSNNUM, 5-41
Character (columns 27, 34, and CENTSTATUS, 5-43
41), 14-16 CNVCURNCY, 5-46

8600 0544–103 Index–17


Index

CNVDATE, 5-48 time formats, 5-11


CNVDATTIM, 5-51 translate tables
CNVDSPYMDL, 5-54 accessing, 5-6
CNVFORMSIZ, 5-56 truthsets, 5-6
CNVLIST, 5-58 INTNAME in Attribute Specifications for
CNVNAME, 5-61 libraries, 13-4
CNVSYMBOLS, 5-62 inverted Print field in the Control
CNVTIME, 5-67 Specification, 7-5
CNVTPLT, 5-70
cross-reference (table), 5-19
CSMSG, 5-72 J
functions of (table), 5-14, 5-16
input parameters of, 5-21 JDATE, 2-10
input parameters with type values, 5-21 JTIME
library calls, 5-19 in Factor 1 field, 15-11
MCPLANGS, 5-76 in Factor 2 field, 15-11
parameter categories, 5-20 in Output Specifications, 17-17
TPLTDATE, 5-78
TPLTDATTIM, 5-80
TPLTTIME, 5-82 K
VSNCOMPTXT, 5-85
VSNESCAPE, 5-89
key description
VSNGETORD1, 5-92
for additional keys, 8-10
VSNINSPTXT, 5-95
for Duplicate Keys, 8-26
VSNTRANTXT, 5-98
for Index Name, 8-22
coded character sets, 5-4
for Key Field Starting Location, 8-20
collating sequence, 5-7
for Record-Address Field Length, 8-16
comparing text, 5-7
for Record-Address Type, 8-17
creating message arrays, 5-10
Key Description
currency displays, 5-12
Multiple Keys field
data classes, 5-6
in File Specifications, 8-10
date formats, 5-11
Key Field Starting Location field
default settings, changing, 5-2
in File Specifications, 8-20
defining collating sequence, 5-8
in Telecommunications File
definition of, 5-1
Specifications, 12-11
equivalent comparison of data, 5-7
KEY NOT FOUND error message, A-9
hierarchy, 5-2
KEY OUT OF SEQUENCE error message, A-9
indexed file localization, 5-9
KEYEDIOII, 4-1
logical data comparison, 5-8
KEYEDIOIIOUTPUT compiler control
mapping tables, 5-5
option, 21-14
message creation in application
keys, noncontiguous for alternate index
program, 5-9
files, 4-27
multilingual message creation, 5-10
natural language feature, 5-9
numeric displays, 5-12
ordering sequence value (OSV), 5-7
L
output parameters, 5-22
positioning, 5-7 L0-L9 (Control Level), 15-5, See control level
priority sequence value (PSV), 5-7 indicators (L0-L9)
result parameters, 5-22 example of, 15-6
sorting and merging, 5-7 label, 2-4
sorting with a different collating language
sequence, 5-8 run-time, establishing, 5-3

Index–18 8600 0544–103


Index

language elements, 2-1 $SETNAME, 13-10


alphanumeric aliases for indicators, 2-13 parameters for, 13-11
character set in, 2-1 library name, 2-4
data structure name in, 2-4 Library Name field in Library Name
field length in, 2-4 Specifications, 13-3
field name in, 2-4 library operations
figurative constants in, 2-6 EEXSR, 16-54
file name in, 2-4 PARAM, 16-55
label in, 2-4 Library Parameter Name field
library name in, 2-4 in Library Parameter Specifications, 13-7
library subroutine name in, 2-5 Library Specifications, 13-1, 16-54
literal Attribute Specifications for libraries, 13-4
alphanumeric, 2-8 example program using, 13-13
hexadecimal, 2-9 form for, 13-1
numeric, 2-7 Library Attribute Specifications
literals in, 2-6 alphanumeric library attributes allowed
name definition in, 2-3 for, 13-4
operation codes in, 2-15 Boolean library attribute in, 13-4
output group names in, 2-5 library linkage subroutines, 13-10
special words in, 2-10 $CANCELLIB, 13-10
*PLACE, 2-15 $DELINKLIB, 13-10
date fields, 2-10 $LINKLIB, 13-10
page fields, 2-11 $SETNAME, 13-10
UDAYNM, 2-11 parameters specifications for, 13-10
UTIME, 2-11 Library Name Specifications field
subfield name in, 2-5 definitions, 13-3
vector name in, 2-5 Form Type (columns 6-18), 13-3
LANGUAGE task attribute, 5-3 LIBACCESS (column 32), 13-3
indicators Library Name (columns 19-28), 13-3
in Output Specifications, 17-14 Sequence Number (columns 1-5), 13-3
last record (LR) indicators Title or Function Name
as record identifying indicator, 14-8 (columns 35-74), 13-4
at EOF, 8-10 Library Parameter Specifications field
in Calculation Specifications, 15-6, 15-9 definitions, 13-7
in Output Specifications, 17-14 columns 35-74, 13-9
in program logic cycle (PLC), 3-4 Form Type (columns 6-18), 13-7
with record type change, 14-9 Library Parameter Name
LIBACCESS (columns 19-28), 13-7
in Library Attribute Specifications, 13-4 Parameter Decimal Positions
in Library Name Specifications, 13-3 (column 32), 13-8
LIBPARAMETER in Attribute Specifications Parameter Length (columns 29-31), 13-7
for libraries, 13-4 Sequence Number (columns 1-5), 13-7
libraries Value/Reference (column 33), 13-8
program Vector Parameter (column 34), 13-8
accessing 4-digit year, 13-20 Library Subroutine Specifications field
library definitions, 13-5
attribute for, 1-4 Actual Name (columns 35-74), 13-6
CENTRALSUPPORT, calls in, 5-19 Form Type (columns 6-18), 13-5
definition of, 13-1 Library Subroutine Name
library linkage subroutines, 13-10 (columns 19-28), 13-5
$CANCELLIB, 13-10 Result Decimal Positions
$DELINKLIB, 13-10 (column 32), 13-6
$LINKLIB, 13-10

8600 0544–103 Index–19


Index

Result Length (columns 29-31), 13-5 loading preexecution-time vectors, 10-14


Sequence Number (columns 1-5), 13-5 local data area
Library Specifications coding, example data structure for, 14-46
of, 13-12 data structure name descriptions, 14-41
library subroutine name, 2-5 designating, 14-40
Library Subroutine Name field in Library maximum length for, 14-43
Specifications, 13-5 subfields, 14-43
limits file, 4-28, 8-18 localization, 5-1
Extension Specifications for, 4-31 establishing conventions for, 5-3
File Specifications for, 4-30 LOCK option, 16-61
Line Counter Specifications, 11-1 locked records, freeing, 4-54
example of, 11-5 logical data comparison
field definitions, 11-3 in internationalization, 5-8
Comment (column 7), 11-3 logical operators
Filename (columns 7-14), 11-3 ANDxx, 16-32
Form Type (column 6), 11-3 ORxx, 16-48
Line Number and Channel Number LOKUP operation, 16-76
(columns 25-74), 11-6 examples of, 16-77
Line Number and FL or Channel Number hold area affected by, 10-12
(columns 15-19), 11-4 one vector in, 16-78
Line Number and OL or Channel resulting indicators in, 16-77
Number (columns 20-24), 11-5 rules for, 16-78
Program Identification specifying collating sequence for, 7-7
(columns 75-80), 11-7 two vectors in, 16-79
Sequence Number (columns 1-5), 11-3 use with data structures, 14-44
form for, 11-1 use with vectors, 10-9
LINE file, See file, compiler Look-ahead field, 14-10
Line Number and Channel Number fields Look-ahead field for input files, 14-10
in Line Counter Specifications, 11-6 low-order truncation warning messages, 16-6
Line Number and FL or Channel Number LR, See last record (LR) indicators
fields LR test
in Line Counter Specifications, 11-4 bypassed, 7-12
Line Number and OL or Channel Number field in program logic cycle (PLC), 3-4
in Line Counter Specifications, 11-5
Line Number field in Line Counter
Specifications, 11-4, 11-5 M
Line Printer Skipping field in Control
Specification, 7-10 MAP compiler control option, 21-16
LINEINFO compiler control option, 21-14 mapping table
linking libraries, 13-10 definition of, 5-5
LIST compiler control option, 21-15 for internationalization, 5-5
LISTDELETED compiler control option, 21-15 MATCH FIELD SEQUENCE ERROR
LISTDOLLAR compiler control option, 21-15 message, A-10
LISTINCL compiler control option, 21-15 Match fields, 14-30
LISTOMITTED compiler control option, 21-15 for input control, 14-29
LISTP compiler control option, 21-16 for multifile processing, 14-31
literals for sequence checking, 14-34
alphanumeric, 2-8 in Input Specifications, 14-29
figurative constant, 2-6 in program logic cycle (PLC), 3-3, 3-5
hexadecimal, 2-9 specifying collating sequence for, 7-7
numeric, 2-7 matching record (MR) indicators
Loading execution-time vectors in Calculation Specifications, 15-10
example of, 10-17

Index–20 8600 0544–103


Index

in Input Specifications, 14-29 multiple keys for an indexed file, 8-10


in Output Specifications, 17-14 multiple output lines in overflow
use, for field record relations, 14-36 handling, 17-65
MCPLANGS CENTRALSUPPORT library multiplication, See MULT operation
procedure, 5-76 MVR operation, 16-8
example of, 5-76
MCS, See message control system
MERGE compiler control option, 21-16 N
merging
for internationalization, 5-7 natural language, 5-1
message control system, 12-1 natural language feature
Message Length field in Telecommunications for internationalization, 5-9
Specifications, 12-8 nested structured programming
Message Length Identification field operations, 16-31
in Telecommunications example of, 16-31
Specifications, 12-7 NEW compiler control option, 21-17
messages, multilingual NEWSOURCE file, See file, compiler
creation for application program, 5-10 NO MATCHING CASE LABEL FOR
MHHZO operation, 16-24 SELECTION VARIABLE error
MHLZO operation, 16-24 message, A-11
minimum code space, 21-26 noncontiguous fields, in alternate index file
MLHZO operation, 16-24 processing a sequential-within-limits
MLLZO operation, 16-25 file, 4-32
MLS, See MultiLingual System (MLS) reading random by key, 4-37
move operations, 16-14 noncontiguous keys for alternate index
effects of indexing with MOVEA files, 4-27
operation, 16-18 nondelete-capable file, creating EFS
example results, 16-16 direct, 4-18
f-zone display format with MOVEA nonoverlayable data space, 21-26
operation, 16-18 normal collating sequence, reference table
MOVE, 16-15 for, B-3
MOVEA, 16-18 NORWND option, 16-62
MOVEL, 16-22 Not field in Input Specifications, 14-15
using arrays with MOVEA operation, 16-18 NOWAIT option, 16-61
move zone operations, 16-24 Number field in Input Specifications, 14-6
MHHZO, 16-24 numeric displays
MHLZO, 16-24 for internationalization, 5-12
MLHZO, 16-24 numeric fields
MLLZO, 16-25 comparison operations, 16-12
MOVEA operation, 16-18 sign of, B-1
effects of indexing on, 16-18 numeric indicators (01-99), 17-14
examples of, 16-19 numeric literal, 2-7
using numeric elements in, 16-18
MOVEL operation, 16-22
examples of, 16-23 O
MR, See matching record (MR) indicators
MULT operation, 16-6, 16-8
Object Output field in the Control
multifile processing
Specification, 7-4
files checked for end of file, 8-10
octal character values, table of, B-3
secondary files, 8-7
OL, See Overflow Line (OL) field
with matching records, 14-31
OMIT compiler control option, 21-18
MultiLingual System (MLS), 5-1
one-vector LOKUP operation, 16-77, 16-78
multiple I/O areas, 8-19

8600 0544–103 Index–21


Index

OPEN/CLOSE ERROR OF FILE error SETOF, 16-28


message, A-11 SETON, 16-28
operation codes, 2-15, 16-1 SORTA, 16-80
ADD, 16-6 SQRT, 16-9
ANDxx, 16-32 SUB, 16-10
BEGSR, 16-54 table of, 16-1
BITOF, 16-27 TAG, 16-29
BITON, 16-27 TESTB, 16-27
CAS, 16-36 TESTN, 16-13
CASE, 16-38 TESTZ, 16-14
CASxx and CAS, 16-36 TIME, 16-81
CHAIN, 16-58 XFOOT, 16-10
CLOSE, 16-61 Z-ADD, 16-11
COMP, 16-12 ZIP, 16-81
COMS, 16-82 Z-SUB, 16-11
DEBUG, 16-71 Operation field in Calculation
DEFN, 16-72 Specifications, 15-11
DELET, 16-63 Option field
DIV, 16-7 in Input Specifications, 14-7
DMSII, 16-82 OR line, 14-5
DO, 16-42 OR relationship, 14-9
DOUxx, 16-43 ordering sequence value (OSV)
DOWxx, 16-45 in internationalization, 5-7
DSPLY, 16-64 orderly end in program logic cycle (PLC), 3-6
DUMP, 16-74 organizing a file
EEXSR, 16-54 direct, 4-8
ELSE, 16-47 disk, 4-6
ENDSR, 16-54 indexed, 4-9
EXCPT, 16-65 sequential, 4-6
EXSR, 16-54 ORxx operation, 16-48
FORCE, 16-67 OSV, See ordering sequence value (OSV)
GOTO, 16-29 output
IFxx, 16-46 detail in program logic cycle (PLC), 3-3
IFxx/ELSE, 16-47 heading in program logic cycle (PLC), 3-3
LOKUP, 16-76 sequence in relation to program logic cycle
MHHZO, 16-24 (PLC), 17-5
MHLZO, 16-24 suggestions for program
MLHZO, 16-24 maintenance, 17-6
MLLZO, 16-25 output file, See file, output
MOVE, 16-15 output group names
MOVEA, 16-18 in Output Specifications, 17-17
MOVEL, 16-22 use of in EXCPT operation, 16-65
MULT, 16-8 use of in SEND operation, 16-70
MVR, 16-8 output indicators, 17-14
ORxx, 16-48 output parameters
PARAM, 16-55 for CENTRALSUPPORT library
READ, 16-67 procedures, 5-22
READE, 16-68 Output Specifications, 17-1
READP, 16-69 *PLACE special word, 17-23
RECV, 16-69 coding form for, 17-2
SEND, 16-69 comment line coding, 17-4
SETLL, 16-70 conditioning indicators in
for file processing, 4-32 control level, 17-14

Index–22 8600 0544–103


Index

external, 17-15 overflow indicators, 17-53


first page (1P), 17-15 effects on printer operations, 17-54
halt, 17-14 skip to channel option in, 17-53
matching record (MR), 17-14 skip to line number option in, 17-54
numeric, 17-14 page formatting, 17-52
overflow, 17-15 PLC and determining when record is
constants in, 17-21 written during, 17-5
edit codes in, 17-25 printer file handling, See printing reports
comparison to edit codes, 17-33 reaching end of page, 17-52
effects of, 17-28 record addition, 17-7
edit words in, 17-33 record deletion, 17-7
comparison to edit codes, 17-33 record descriptions, 17-1
examples of, 17-35 Output Specifications conditioning indicators
field definitions, 17-4 in
AND and OR Lines last record (LR), 17-14
(columns 14-16), 17-6 Output-Format Specifications, See Output
Blank After (column 39), 17-19 Specifications
Comment (column 7), 17-4 overflow
Constant or Edit Word (columns area, 17-52
45-70), 17-21 fetched, 17-53
Edit Codes (column 38), 17-18 format output, 17-62
Field End Position handling, 17-55
(columns 40-43), 17-19 handling of multiple output lines, 17-65
Field Name (Variable Name) indicators for skip to line number
(columns 32-37), 17-17 option, 17-54
Filename (columns 7-14), 17-5 operations, 17-53
Form Type (column 6), 17-4 output during program logic cycle
Output Indicators (PLC), 3-7
(columns 23-31), 17-12 printing, 8-20
Packed (column 44), 17-20 Overflow Indicator field in File
Program Identification Specifications, 8-20
(columns 75-80), 17-21 overflow indicators (OA-OG, OV)
Record Addition/Deletion for skip to channel option, 17-53
(columns 16-18), 17-7 for skip to line number option, 17-54
Sequence Number (columns 1-5), 17-4 in Calculation Specifications, 15-10
Skip (columns 19-22), 17-10 in File Specifications, 8-20
Space (columns 17-18), 17-9 in program logic cycle (PLC), 3-4
Stacker Select/Fetch (column 16), 17-8 when printing reports, 17-53
Type (column 15), 17-5 overflow indicators (OA-OG, OV)
forms specification for, 17-51 in Output Specifications, 17-15
using the skip to line number Overflow Line (OL) field
option, 17-51 in Line Counter Specifications, 11-5
forms specification for
using the skip to channel option, 17-51
overflow fetching, 17-9 P
output, 16-28
overflow handling, 17-55 packed decimal format, 14-17
coding examples of, 17-60 example of, 4-19
fetched overflow output in, 17-64 Packed field
multiple output lines in, 17-65 in Extension Specifications, 10-8
normal overflow output in, 17-62 in Input Specifications, 14-16
printer overflow operations for, 17-59 in Output Specifications, 17-20

8600 0544–103 Index–23


Index

page page formatting, 17-52


on compiler listing, 21-25 priority sequence value (PSV)
with line printer skipping, 17-52 in internationalization, 5-7
PAGE processing a disk file, 4-11, 4-22
element of language, 2-11 alternate index file
in Input Specifications, 14-25 using addrout, 4-41
in look-ahead field, 14-10 consecutive, 4-22
PAGE compiler control option, 21-18 random, 4-34
page formatting, 17-52 sequentially by key, 4-25
PAGEn, 2-11 sequentially within limits, 4-28
PAGESIZE compiler control option, 21-18 Processing Mode field
PARAM operation, 16-55 in File Specifications, 8-16
example of, 16-57 in Telecommunications File
in Library Parameter Specifications, 13-7 Specifications, 12-11
matching parameter types, 16-55 program branching operations
parameter categories GOTO, 16-29
for internationalization, 5-20 TAG, 16-29
Parameter Decimal Positions field program dump
in Library Parameter Specifications, 13-8 setting the OPTIONS attribute, 16-76
Parameter Length field in Library Parameter Program Identification field
Specifications, 13-7 in Alternate Collating Sequence
parameter type matching in PARAM Specifications, 18-4
operation, 16-55 in Attribute Specifications, 9-6
parameters by value and by type, 16-55 in Calculation Specifications, 15-16
parent file, 4-2 in Control Specification, 7-13
patch files used for source file in Extension Specifications, 10-10
maintenance, 21-4 in File Specifications, 8-31
PLC, See program logic cycle (PLC) in File Translation Specifications, 19-4
preexecution time vectors in Input Specifications, 14-38
specifying collating sequence for, 7-7 in Line Counter Specifications, 11-7
preexecution-time vector loading in Output Specifications, 17-21
in program logic cycle (PLC), 3-3 in Telecommunications
primary file, 8-7 Specifications, 12-8
read, in program logic cycle (PLC), 3-4 in Vector Data Specifications, 20-4
primary key, 4-9 program logic cycle (PLC), 3-1, 3-5
printer files beginning of job (BOJ), 7-13
closing, 8-28 chained files, 8-8
handling, 17-51 control breaks, 3-5
printer overflow operations, sequence that control fields and record identification, 3-1
occurs, 17-59 control level indicators, 3-6
printing reports, 17-51 cycle initialization, 3-3
automatic skipping, 17-52 data extraction, 3-7
continuous printing, 17-52 demand files, 8-8
end of page (EOP), 17-52 detail calculations, 3-1, 3-7
fetched overflow, 17-53 detail output in, 3-3
forms specifications, 17-51 determining when a record is written
skip to channel option, 17-51 during, 17-5
skip to line number option, 17-51 diagram, 3-1
overflow indicators, 17-53 end of file (EOF), 3-4
overflow operations, 17-53, 17-55 end of job (EOJ), 7-13
fetched output, 17-64 end of job (EOJ) test, 3-6
multiple output lines, 17-65 ending routine, 3-6
normal output, 17-62 first page (1P) indicators, 3-3

Index–24 8600 0544–103


Index

first-control-cycle switch, 3-4 random-by-key value


FORCE operation, 3-5 file processing, 4-36
forms positions, 3-3 reading alternate index files,
full-procedural files, 8-9 noncontiguous keys, 4-37
halt indicators in, 3-3 READ AT END OF FILE error message, A-11
indicator initialization, 3-4 READ operation, 16-67
initializing external indicators, 3-3 repositioning, 16-68
input file look-ahead, 3-7 restrictions on, 16-68
last record indicator, 7-12 READE operation, 16-68
look-ahead fields, 3-5 READP operation, 16-69
LR test, 3-4 file types allowed in, 16-69
match fields in, 3-3, 3-5 repositioning, 16-69
matching record indicator, 3-7 RECNO option, 8-24
orderly end, 3-6 EFS disk files, 8-24
output files, 8-5 example of use, 4-16, 4-46
Output Specifications and, 17-5 Record Addition/Deletion field in Output
overflow output, 3-7 Specifications, 17-7
preexecution-time vector loading, 3-3 record descriptions in Output
primary and secondary files read, 3-4 Specifications, 17-1
printer file, 3-6 Record Identification Codes field
record identification indicators, 3-4 in Input Specifications, 14-14
record selection logic, 3-5 in program logic cycle (PLC), 3-4
restart, 3-8 RECORD IDENTIFICATION ERROR
Source Input Dialect field in, 3-3 message, A-11
stop, 3-8 record identification in program logic cycle
table and array files, 8-8 (PLC), 3-5
total calculations, 3-1, 3-6 record identifying indicators, 14-8
total output, 3-6 RECORD KEY MISMATCH error
using the first-control-cycle switch in, 3-3 message, A-12
Zero/Blank Indicator Setting field in, 3-3 Record Length field
program-dependent required memory, 21-26 default values for, 8-15
programming operations, structured, 16-30 fixed-length records, 8-15
protocols, data communications, in File Specifications, 8-14
international, 5-1 in Telecommunications File
pseudo file attribute Specifications, 12-11
in localized index file, 5-9 minimum and maximum values for, 8-14
PSV, See priority sequence value (PSV) resulting values, table, 8-15
PURGE option, 16-62 variable-length records, 8-15
record selection in program logic cycle
(PLC), 3-5
Q Record-Address Field Length field
in File Specifications, 8-16
quick sort, recommended entry in Half Adjust in Telecommunications File
field, 16-80 Specifications, 12-11
record-address files, 8-9
entries required in Extension
R Specifications, 10-4
Record-Address Type field
in File Specifications, 8-17
random file processing, 4-34
in Telecommunications File
of addrout files, 4-39
Specifications, 12-11
using record keys, 4-36
record-level locking
using relative record numbers, 4-34
for disk files, 4-3

8600 0544–103 Index–25


Index

freeing records, 4-54 RPG source program, 1-2, 1-5


RECORDLEVELLOCK file attribute, 4-6 specifications in, 1-3
RECV operation RPGSUPPORT library, use in symbolic
programmed control of I/O, 16-69 dump, 16-74
REEL option, 16-62 RSIGN compiler control option, 21-19
reference tables, B-1 Run-Time Error field
character representation, B-1 in Control Specification, 7-11
of character values and graphics, B-3 in program logic cycle (PLC), 3-5
signs of numeric fields, B-1 run-time error messages, See error
relative record numbers, 4-8 messages
for random file processing, 4-34
releasing locked records in disk files, 4-54
REMOTE device type, 12-12 S
remote files, example of, 12-12
Remote Station Identification field secondary file, See file, secondary
in SEND operation, 16-70 SECURITY ERROR message, A-13
in Telecommunications security, encrypting data, 19-1
Specifications, 12-6 SEND operation, 16-69
Remote Stations Location Identification field separate signed data format, 14-18
in Telecommunications SEQ compiler control option, 21-19
Specifications, 12-5 SEQ field in Vector Data Specifications, 20-4
Report Program Generator (RPG), 1-2 SEQUENCE BASE compiler control
reserved words, 2-10 option, 21-20
operation codes, 2-15 sequence checking of records, 14-33
special words, 2-10 Sequence field
RESET, 21-7 in Extension Specifications, 10-9
restart in program logic cycle (PLC), 3-8 in File Specifications, 8-12
Result Decimal Positions field in Input Specifications, 14-5
in Library Subroutine Specifications, 13-6 in program logic cycle (PLC), 3-4
Result Field in Calculation SEQUENCE INCREMENT compiler control
Specifications, 15-12 option, 21-20
Result Length field in Library Subroutine Sequence Number field
Specifications, 13-5 in Alternate Collating Sequence
result types, 13-5 Specifications, 18-3
result parameters in Attribute Specifications, 9-3
for CENTRALSUPPORT library in Calculation Specifications, 15-4
procedures, 5-22 in Control Specification, 7-3
resulting indicators in Extension Specifications, 10-3
CASxx and CAS operations, 16-36 in File Specifications, 8-4
example of coding in Calculation in File Translation Specifications, 19-3
Specifications, 15-15 in Input Specifications, 14-4
list of, 15-14 in Library Name Specifications, 13-3
operation codes with, 15-15 in Library Parameter Specifications, 13-7
use with deleted records, 4-45, 4-46 in Library Subroutine Specifications, 13-5
Resulting Indicators field in Calculation in Line Counter Specifications, 11-3
Specifications, 15-14 in Output Specifications, 17-4
REWIND option, 16-62 in Telecommunications
right f-zone format in the MOVEA Specifications, 12-4
operation, 16-19 in Vector Data Specifications, 20-3
RPG (Report Program Generator), 1-2 Sequence Specifications field
RPG I, specifying, 7-12 in Alternate Collating Sequence
RPG II, specifying, 7-12 Specifications, 18-4

Index–26 8600 0544–103


Index

sequential files setting indicators


accessing, 4-7 indicator operations, 16-28
adding records to, 4-8 sign handling
adding records to end of in the Control Specification, 7-8
BFS, 4-43 Sign Position field
EFS, 4-44 in the Control Specification, 7-5
alternate index file for, 4-3 signed packed decimal format, 14-17
attributes of, 4-2 signs of numeric fields, 14-16
BFS single-precision numeric format, 14-19
adding records to end of, 4-43 size of program
creating, 4-12 use of multiple I/O buffers, 8-19
deleting records from, 4-51 Skip field
consecutive processing of, 4-22 in Output Specifications, 17-10
creating skip to channel option, 17-51
BFS, 4-12 skip to line number option, 17-51
EFS, 4-13 skipping
deleting records from automatic, 17-52
BFS, 4-51 to a line number, 17-10
EFS, 4-52 SORT program, 8-17
EFS SORTA operation, 16-80
adding records between, 4-45 choosing the best sort method, 16-80
adding records to end of, 4-44 example of, 16-80
creating, 4-13 sorting
deleting records from, 4-52 choosing the most effective
normal processing of, 4-22 method, 16-80
organization of, 4-6 for internationalization, 5-7
random processing of, 4-34 with different collating sequence, 5-8
with an addrout file, 4-39 using SORTA operation, 16-80
with relative record numbers, 4-34 source file
when to use, 4-7 organization and requirements, 1-3
sequential-by-key file processing, 4-25 specifications, 1-3
of alternate index files, 4-25 SOURCE file, See file, compiler
of indexed files, 4-25 Source Input Dialect field
sequential-by-key reading in the Control Specification, 7-12
alternate index files, 4-25 in the program logic cycle (PLC), 3-3
sequential-within-limits file processing, 4-28, source program, See RPG source program
4-33 source-file maintenance, 21-4
of alternate index files sample jobs, 21-4
noncontiguous fields, 4-32 Space field
of indexed files, 4-28 in Output Specifications, 17-9
using a limits file, 4-28 spacing
using the SETLL operation, 4-32 of compiler listing, 21-25
SET, 21-7 special words
SETLL operation, 16-70 *IN, 2-13
File Specifications for, 4-33 *INxx, 2-13
programmed control of I/O, 16-70 *PLACE, 2-15
used with index name in Result Field, 8-22 JDATE, 2-10
SETLL operation PAGE, 2-11, 14-25
for sequential-within-limits file PAGEn, 2-11, 14-25
processing, 4-32 reserved for variable names, 17-17
SETOF operation, 16-28 UDATE, 2-10
SETON operation, 16-28 UDAY, 2-10
UDAYNM, 2-11

8600 0544–103 Index–27


Index

UMONTH, 2-10 SUBSCRIPT ERROR message, A-13


UTIME, 2-11 subtraction, See SUB operation
UYEAR, 2-10 SUMMARY compiler control option, 21-21
Specifications Continuation field SW1 through SW8
in Attribute Specifications, 9-4 in program logic cycle (PLC), 3-3
split control fields, 14-27 to set external indicators, 8-31, See
Spread-Record Specifications, 14-38 external indicators (U1-U8)
SQRT operation, 16-9 symbolic dump, 16-74
example of results, 16-9 system error messages, See error messages
SQRT OPERATION ERROR message, A-13 SYSTEM/CCSFILE data file, 5-4
square root, See SQRT operation SYSTEM/KEYEDIOII/UTILITY, 4-2
SR, See subroutine
stacker selection
in Output Specifications, 17-8 T
Stacker-Select/Fetch Overflow field
in Output Specifications, 17-8 table file, 8-8
Station Type field tables, See vectors
in Telecommunications TAG operation, 16-29
Specifications, 12-5 control level indicator for, 16-29
STATISTICS compiler control option, 21-20 tape file closing
status reporting using edit codes, 17-26 options for, 8-28
stop in program logic cycle (PLC), 3-8 TARGET compiler control option, 21-21
structured programming operations TASKFILE, use in symbolic dump, 16-75
ANDxx, 16-32 TASKSTRING attribute, 14-46
Boolean operators in, 16-31 in a WFL job, 21-5
CAS, 16-36 Telecommunications File Specifications, 12-9
CASE, 16-38 field definitions
CASxx, 16-36 Block Length (columns 20-23), 12-10
DO, 16-41 Device (columns 40-46), 12-12
DOUxx, 16-41, 16-43 End of File (column 17), 12-10
DOWxx, 16-41, 16-45 File Condition (columns 71-72), 12-12
IFxx, 16-46 File Designation (column 16), 12-10
IFxx/ELSE, 16-47 File Format (column 19), 12-10
nesting, 16-31 File Organization Type
ORxx, 16-48 (column 32), 12-11
SUB operation, 16-10 File Type (column 15), 12-9
example of, 16-8 Filename (columns 7-14), 12-9
subfield name Key Field Starting Location
defined, 2-5 (columns 35-38), 12-11
in data structure, 14-42 Processing Mode (column 28), 12-11
subfields Record Length (columns 24-27), 12-11
for data structures, 14-40 Record-Address Field Length
in Field Location field, 14-22 (columns 29-30), 12-11
subroutine Record-Address Type
calling with Library Subroutine (column 31), 12-11
Specifications, 13-5 Telecommunications Specifications, 12-1
entry in Calculation Specifications, 15-6 coding form for, 12-2
for library linkage, 13-10 field definitions, 12-3
subroutine operations, 16-52 Comment (column 7), 12-4
BEGSR, 16-54 Error Indicator (columns 53-54), 12-7
coding example of, 16-53 Filename (columns 7-14), 12-5
ENDSR, 16-54 Form Type (column 6), 12-4
EXSR, 16-54

Index–28 8600 0544–103


Index

Message Length (columns 64-70), 12-8 two-vector LOKUP operation, 16-77, 16-79
Message Length Identification type values
(column 63), 12-7 used in input parameters, 5-21
Program Identification
(columns 75-80), 12-8
Remote Station Identification U
(columns 41-47), 12-6
Remote Station Location Identification U1-U8 indicators, See external indicators
(column 40), 12-5 (U1-U8)
Sequence Number (columns 1-5), 12-4 UDATE, 2-10
Station Type (column 16), 12-5 in Factor 1 field, 15-11
termination routines in program logic cycle in Factor 2 field, 15-11
(PLC), 3-6 in Output Specifications, 17-17
TESTB operation, 16-27 UDAY, 2-10
TESTN operation, 16-13 in Factor 1 field, 15-11
TESTZ operation, 16-14 in Factor 2 field, 15-11
text comparison in Output Specifications, 17-17
in internationalization, 5-7 UDAYNM, 2-11
time formats in Factor 1 field, 15-11
for internationalization, 5-11 in Factor 2 field, 15-11
Time of File Close field in Output Specifications, 17-17
in the Control Specification, 7-13 UMONTH, 2-10
Time of File Open field in the Control in Factor 1 field, 15-11
Specification, 7-13 in Factor 2 field, 15-11
TIME operation, 16-81 unpacked format, 14-17
TITLE UNSEQ compiler control option, 21-23
compiler control option, 21-22 in ** Specifications, 19-6
in Attribute Specifications for libraries, 13-4 unsigned packed decimal format, 14-18
library attribute, 13-4 update file, See file, update
Title or Function Name field UPDATE UNLOCKED RECORD error
in Library Name Specifications, 13-4 message, A-14
titles on compiler listing, 21-25 USERDEBUG compiler control option, 21-23
TITLESPERFILE compiler control utility, SYSTEM/KEYEDIOII/UTILITY, 4-3
option, 21-23 UTIME, 2-11
To Filename field in Factor 1 field, 15-11
in Extension Specifications, 10-5 in Factor 2 field, 15-11
in program logic cycle (PLC), 3-6 in Output Specifications, 17-17
total calculations, 15-1 UYEAR, 2-10
in program logic cycle (PLC), 3-1, 3-6 in Factor 1 field, 15-11
total output in program logic cycle (PLC), 3-6 in Factor 2 field, 15-11
TPLTDATE CENTRALSUPPORT library in Output Specifications, 17-17
procedure, 5-78
TPLTDATTIM CENTRALSUPPORT library
procedure, 5-80 V
example of, 5-80
TPLTTIME CENTRALSUPPORT library
value compiler control options, 21-7
procedure, 5-82
value reference in PARAM operation, 16-55
translate table, See mapping table
Value/Reference field
translating data, 19-1
in Library Parameter Specifications, 13-8
Translation Table field
Variable Name field
in File Translation Specifications, 19-3
in Attribute Specifications, 9-5
truthset, 5-6
in Input Specifications, 14-23
definition of, 5-6

8600 0544–103 Index–29


Index

variable names names of, 2-5


reserved special words, 17-17 output, 10-18
Vector Data Elements output from DEBUG operation, 16-72
description of, 1-4 preexecution-time, 10-14
Vector Data Specifications specifying an index for, 10-13
coding form for, 20-3 table or array files, 8-8
description of, 1-4 two-vector LOKUP, 16-79
field definitions types of, 10-11
Comment (column 7), 20-4 updating tables, 10-12
Form Type (column 6), 20-4 use of LOKUP operation, 10-12
Program Identification use with data structures, 14-42
(columns 75-80), 20-4 Vector Data Specifications, 20-3
SEQ (columns 14-16), 20-4 with DEFN operation, 16-73
Sequence Number (columns 1-5), 20-3 writing, 10-5
Vector Specifications VERSION ERROR message, A-15
(columns 7-12), 20-4 VSNCOMPTXT CENTRALSUPPORT library
VECTOR LOAD ERROR message, A-14 procedure, 5-85
vector name, 2-5 VSNESCAPE CENTRALSUPPORT library
Vector Name field, 10-5 procedure, 5-89
in Extension Specifications, 10-5 example of, 5-89
Vector Parameter field VSNGETORD1 CENTRALSUPPORT library
in Library Parameter Specifications, 13-8 procedure, 5-92
VECTOR SEQUENCE ERROR message, A-15 example of, 5-92
Vector Specifications field VSNINSPTXT CENTRALSUPPORT library
in Vector Data Specifications, 20-4 procedure, 5-95
vectors example of, 5-95
alternating format, 10-17 VSNTRANTXT CENTRALSUPPORT library
compile-time, 20-1 procedure, 5-98
declaration, 10-12 example of, 5-98
designator and COMS-time type, 10-11
differences between tables and
arrays, 10-11 W
dynamic properties of, 10-13
editing of arrays, 17-26 WARNFATAL compiler control option, 21-24
effect on zero/blank indicators, 17-19 warning for truncation
end of job output, 8-5 high-order, 16-5
execution-time, 10-16 low-order, 16-6
Extensions Specifications for WARNSUPR compiler control option, 21-24
alternating entries, 10-10 WFL, See Work Flow Language (WFL)
at execution time, 10-16 Work Flow Language (WFL)
decimal positions, 10-9 using to compile, 21-4
entries per vector, 10-7 writing vectors, 10-18
external format, 10-8
length, 10-7
number of record entries, 10-6 X
sequence of elements, 10-9
vector name, 10-5
XFOOT operation, 16-10
initializing short vectors, 20-1
XREF compiler control option, 21-24
loading
XREFFILES compiler control option, 21-24
at compile time, 20-1
at preexecution time, 10-14

Index–30 8600 0544–103


Index

Y Symbols
year value, with 4 digits, accessing, 13-20 $CANCELLIB for library linkage control, 13-10
$DELINKLIB for library linkage control, 13-10
$KEYEDIOIIOUTPUT file attribute in disk
Z files, 4-4
$LINKLIB for library linkage control, 13-10
Z (zone) portion of C/Z/D field in Input $RSIGN option for sign conversion in CHAIN
Specifications, 14-16 operation, 16-60
Z-ADD operation, 16-11 $SETNAME for library linkage control, 13-10
Zero balance option, 17-26 ** Specifications
ZERO figurative constant, 2-6 use for vector loading, 20-7
zero suppression with edit words, 17-35 use in alternate collating, 18-8
Zero/Blank Indicator Setting field use with File Translation, 19-6
in Control Specification, 17-19 use with UNSEQ, 19-6
in program logic cycle (PLC), 3-3 *BLANK figurative constant, 2-6
zero/blank indicator, when on, 17-19 *BLANKS figurative constant, 2-6
ZEROS figurative constant, 2-6 *ELSE label, 16-38
ZIP operation, 16-81 *IN alias, 2-14
Z-SUB operation, 16-11 *INxx alias, 2-13
*LIKE field in DEFN operation, 16-73
*PLACE, 2-15, 17-23
*ZERO figurative constant, 2-6
*ZEROS figurative constant, 2-6
/EJECT, 21-25
/SPACE, 21-25
/TITLE, 21-25
1P indicator, 17-15
in program logic cycle (PLC), 3-3

8600 0544–103 Index–31


Index

Index–32 8600 0544–103


.
© 2008 Unisys Corporation.
All rights reserved.

*86000544-103*
8600 0544–103

You might also like