HP RPG/iX Reference Manual 900 Series HP 3000 Computers ABCDE HP Part No. 30318-90003 Printed in U.S.A.
NOTICE The information contained in this document is subject to change without notice. HEWLETT-PACKARD MAKES NO WARRANTY OF ANY KIND WITH REGARD TO THIS MATERIAL, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. Hewlett-Packard shall not be liable for errors contained herein or for incidental or consequential damages in connection with the furnishing, performance or use of this material.
Printing History New editions are complete revisions of the manual. Update packages, which are issued between editions, contain additional and replacement pages to be merged into the manual by the customer. The dates on the title page change only when a new edition or a new update is published. No information is incorporated into a reprinting unless it appears as a prior update; the edition does not change when an update is incorporated.
Preface The HP RPG/iX Reference Manual explains all of the language features of RPG. It is written in a reference style, assuming the reader is familiar with RPG. This manual is directed to experienced RPG programmers, who may or may not be familiar with Hewlett-Packard computers. The manual discusses the language features available with the MPE iX operating system. This manual is organized as follows: Chapter 1 Explains the general steps involved in writing and testing an RPG program.
Related Documentation Refer to the following documents for further information on features available in the RPG programming language: HP RPG/iX Programmer's Guide (30318-90001) - This manual describes how to use the RPG language elements to contruct an RPG program. This manual contains many examples and programs. HP RPG/iX Utilities Reference Manual (30318-90006) - This manual explains how to use these RPG utilities: XSORT, RISE, SIGEDITOR, and RPGINIT.
Example Conventions Example Conventions Throughout this manual, examples of RPG program code are shown using gures similar to the one below. The rst two lines are a ruler to help you quickly see the column positions for the code. The shaded numbers on the left are not sequence numbers. Rather, they are used as reference numbers for comments in the text. Lines are referenced only to highlight speci c concepts. Additionally, some examples show lines containing dots only.
Example Conventions Syntax Conventions NOTATION DESCRIPTION UPPERCASE Within syntax statements, characters in uppercase must be entered in exactly the order shown, though you can enter them in either uppercase or lowercase. For example: SHOWJOB italics Valid entries are: showjob ShowJob SHOWJOB Invalid entries are: shojwob Shojob SHOW_JOB Within syntax statements, a word in italics represents a formal parameter or argument that you must replace with an actual value.
Example Conventions NOTATION DESCRIPTION [ . .. ] Within syntax statements, a horizontal ellipsis enclosed in brackets indicates that you can repeatedly select elements that appear within the immediately preceding pair of brackets or braces. In the following example, you can select itemname and its delimiter zero or more times, each instance of itemname preceded by a comma: [,itemname][...
Example Conventions NOTATION DESCRIPTION base pre xes The pre xes %, #, and $ specify the numerical base of the value that follows: %num speci es an octal number #num speci es a decimal number $num speci es a hexadecimal number Bit (bit:length ) When no base is speci ed, decimal is assumed.
Contents 1. Introduction to RPG The Components of RPG . . . . . . . . . . . . Using RPG . . . . . . . . . . . . . . . . . . Step 1: Analyze the Task . . . . . . . . . . . Step 2: Plan the Program . . . . . . . . . . . Step 3: Create the Source Program . . . . . . . Step 4: Compile the Source Program . . . . . . Step 5: Prepare the Object Program for Execution Step 6: Execute the Object Program . . . . . . . . . . . . . . 1-2 1-2 1-4 1-6 1-6 1-9 1-9 1-9 2.
Cross-Reference Listing (Column 52) . . Carriage Control Type (Column 53) . . . Text le Sequence Check (Column 54) . . Error Log (Column 55) . . . . . . . . Error Response (Columns 56-71) . . . . Program Name (Columns 75-80) . . . . The Header Speci cation Default Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-25 3-26 3-27 3-27 3-28 3-29 3-30 4.
WORKSTN Interface Fields (Columns 54-74) . . . . . . . . . . . . . Program Name (Columns 75-80) . . . . . . . . . . . . . . . . . . . The File Description Speci cation Default Summary . . . . . . . . . . . . 5. File Extension Speci cations The File Extension Speci cation Fields . . . . . . . . . . . . . . Sequence Number (Columns 1-5) . . . . . . . . . . . . . . . . Speci cation Type (Column 6) . . . . . . . . . . . . . . . . . Chaining File Record Sequence (Columns 7-8) . . . . . . . . . .
6. Line Counter Speci cations The Line Counter Speci cation Fields . . . . . . . Sequence Number (Columns 1-5) . . . . . . . . Speci cation Type (Column 6) . . . . . . . . . File Name (Columns 7-14) . . . . . . . . . . . Channel Number Fields (Columns 15-74) . . . . Line Number (Columns 15-17) . . . . . . . . Channel Number/OL (Columns 18-19) . . . . . Line Number and Channel Number/OL (Columns Line Number Fields (Columns 15-24) . . . . . . Line Number (Columns 15-17) . . . . . . . . OL/FL (Columns 18-19) .
Move Operations . . . . . . . . . Move Zone Operations . . . . . . . Compare and Test Operations . . . Branching Operations . . . . . . . Internal Subroutine Operations . . . External Subroutine Operations . . Structured Programming Operations Indicator and Bit Setting Operations Table and Array Operations . . . . File Operations . . . . . . . . . . Display Operations . . . . . . . . Debugging Operation . . . . . . . System Operations . . . . . . . . Operation De nitions . . . . . . . . ADD . . . . . . . .
MOVEL . . . . . . . . . . . . . . . . . . MSG . . . . . . . . . . . . . . . . . . . MULT . . . . . . . . . . . . . . . . . . . MVR . . . . . . . . . . . . . . . . . . . PARM . . . . . . . . . . . . . . . . . . . PUTJW . . . . . . . . . . . . . . . . . . READ . . . . . . . . . . . . . . . . . . . READE . . . . . . . . . . . . . . . . . . READP . . . . . . . . . . . . . . . . . . RESET . . . . . . . . . . . . . . . . . . RLABL . . . . . . . . . . . . . . . . . . SET . . . . . . . . . . . . . . . . . . . .
9. Output Speci cations The Output Speci cation Fields . . . . . . . Sequence Number (Columns 1-5) . . . . . . Speci cation Type (Column 6) . . . . . . . Record Description Fields (Columns 7-31) . . File Name (Columns 7-14) . . . . . . . . AND/OR (Columns 14-16) . . . . . . . . Type (Column 15) . . . . . . . . . . . Record Addition/Deletion (Columns 16-18) Fetch Over ow/Release (Column 16) . . . Space (Columns 17-18) . . . . . . . . . Skip (Columns 19-22) . . . . . . . . . .
11. RPG Screen Interface (RSI) Using the RPG Screen Interface (RSI) . . . . . . Using SIGEDITOR . . . . . . . . . . . . . Rede ning Function Key Labels . . . . . . . Using the RSI Application Help Facility . . . . Entering File Description Speci cations . . . . Using the STATUS Array . . . . . . . . . . Entering Input and Output Speci cations . . . Entering Calculation Speci cations . . . . . . Executing an RSI Program . . . . . . . . . . Using Messages with RSI . . . . . . . . .
A. RPG Compiler Messages Message Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . Message Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-1 A-2 B. Run-Time Messages RPG Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . USWITCH Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . BUFCHK Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . B-2 B-9 B-10 C.
Figures 1-1. 1-2. 1-3. 1-4. 3-1. 3-2. 3-3. 3-4. 3-5. 3-6. 4-1. 4-2. 4-3. 4-4. 5-1. 5-2. 5-3. 5-4. 5-5. 5-6. 6-1. 6-2. 6-3. 7-1. 7-2. 7-3. 7-4. 7-5. 7-6. 7-7. 7-8. 7-9. 7-10. 7-11. 7-12. 7-13. 7-14. 7-15. 7-16. 7-17. 7-18. 7-19. Steps in Preparing and Running an RPG Program . . . . . . A Report De ned on the Printer Spacing Chart . . . . . . . . An RPG Source Program . . . . . . . . . . . . . . . . . Output From an RPG Program . . . . . . . . . . . . . . . The Header Speci cation . . . . . . . . . . . . .
7-20. 7-21. 8-1. 8-2. 8-3. 8-4. 8-5. 8-6. 8-7. 8-8. 8-9. 8-10. 8-11. 8-12. 8-13. 8-14. 8-15. 8-16. 8-17. 8-18. 8-19. 8-20. 8-21. 8-22. 8-23. 8-24. 8-25. 8-26. 8-27. 8-28. 8-29. 8-30. 8-31. 8-32. 8-33. 8-34. 8-35. 8-36. 8-37. 8-38. 8-39. 8-40. 8-41. 8-42. 8-43. 8-44. 8-45. 8-46. 8-47. 8-48. Using Indicators to Associate Fields with Record Types . . . . . . . . Using Field Indicators to Test Input Data . . . . . . . . . . . . . . The Calculation Speci cation . . . . . . . . . . . . . . . . . . . .
8-49. 9-1. 9-2. 9-3. 9-4. 9-5. 9-6. 9-7. 9-8. 9-9. 9-10. 9-11. 10-1. 10-2. 10-3. 10-4. 10-5. 10-6. 10-7. 11-1. 11-2. 11-3. 11-4. 11-5. 11-6. 11-7. 11-8. 11-9. 11-10. 11-11. 11-12. 11-13. 12-1. Using Resulting Indicators . . . . . . . . . . . . . . . . . . The Output Speci cation . . . . . . . . . . . . . . . . . . Entering Output Speci cation for Two Files . . . . . . . . . . Using AND or OR Lines to Condition Record Output . . . . . . Output Record Types As They Appear on a Report . . . . . . .
Tables 3-1. 3-2. 3-3. 3-4. 3-5. 3-6. 3-7. 3-8. 4-1. 4-2. 4-3. 5-1. 5-2. 5-3. 5-4. 6-1. 7-1. 8-1. 8-2. 8-3. 8-4. 8-5. 8-6. 8-7. 8-8. 8-9. 8-10. 8-11. 8-12. 8-13. 8-14. 8-15. 8-16. 8-17. 8-18. 8-19. 8-20. 8-21. 8-22. 8-23. 9-1. 9-2. Results of the Inverted Print Options . . . . . . . . . . . . . . . . . ALTSEQ Record Description for Octal Format . . . . . . . . . . . . . ALTSEQ Record Description for Hexadecimal Format . . . . . . . . . . Sign Processing Options . . . . . . . . . . . . . . . . . . . . . . .
9-3. 9-4. 9-5. 9-6. 9-7. 10-1. 10-2. 10-3. 10-4. 10-5. 11-1. 11-2. 11-3. 11-4. 11-5. 12-1. 12-2. 12-3. C-1. Editing Date Fields . . . . . . . . . . . . . . . . . E ects of the Edit Codes . . . . . . . . . . . . . . Edit Word Characters . . . . . . . . . . . . . . . . Examples of Edit Words . . . . . . . . . . . . . . . Output Speci cation Defaults . . . . . . . . . . . . Entering Error Responses Using the Function Keys . . . VPLUS Event Codes . . . . . . . . . . . . . . . . VPLUS Input Record Formats . . .
1 Introduction to RPG The HP Report Program Generator (RPG) language is a machine-independent, task-oriented language that enables you to easily create programs that print reports, update les, and perform many other general le functions. RPG is available on non-HP computers and programs running on these computers require little or no conversion to run on HP 3000 Series 900 computers.
Example Conventions The Components of RPG The RPG language subsystem consists of the following components: The RPG symbolic programming language. The rules of language syntax that you use when entering RPG programs. The RPG compiler. The RPG compiler translates source statements into a format that can be executed. In addition, it helps to detect errors at the source level with extensive diagnostic messages.
Example Conventions Figure 1-1.
Example Conventions Step 1: Analyze the Task Analyze the data to be processed by the program. Determine the calculations and other operations that must be performed on the data. Decide what data should be output and in what format. Also decide what devices to use for input and output les. For example, Figure 1-2 shows the layout of a new report that needs to be produced. The report is detailed on a printer spacing chart. The chart shows all of the elds on the report along with headings.
Example Conventions Figure 1-2.
Example Conventions Step 2: Plan the Program Plan the general program steps required to produce the desired output. In doing this, you may want to prepare a owchart of the program. Step 3: Create the Source Program Create RPG speci cations for the program. You can enter them using any line editor or word processor that produces a standard ASCII le. For example, you may want to use EDITOR or TDP. Alternatively, you can use the RPG Interactive System Environment (RISE) to enter the speci cations.
Example Conventions Figure 1-3 shows how speci cations are used in an RPG program.
Example Conventions 1 2 3 4 5 6 7 678901234567890123456789012345678901234567890123456789012345678901234 475 OREPORT H O O O O O H 6 O O O H 33 O OR O O O O O O O O D 1 O O O 1P 0F 1P 0F 15 24 "TEXTBOOK SALES" UDATE Y 50 100 "PAGE" PAGE 106 PAGE 100 "PAGE" 106 18 26 40 68 77 95 112 "STOCK NO." "AUTHOR" "TITLE" "EDN" "NO. SOLD" "PRICE/COPY" "SALES/BOOK" . . . Figure 1-3. An RPG Source Program (Continued) Comments 415 425 435 445 455 465 475 This line is the Header Speci cation for the program.
Example Conventions Step 4: Compile the Source Program Once you enter the speci cations for a program and desk-check it, you can compile it. The following command compiles the program, SALES: :RPGXL SALES.SOURCE, SALEO.SOURCE The RPG compiler translates the source program into an object program assigning storage areas and creating routines to handle input and output. The object program is saved as the relocatable object le, SALEO.SOURCE. Optionally, the compiler prints a Cross-Reference listing.
Example Conventions Figure 1-4.
2 General Specifications This chapter discusses the elds that are used in all of the RPG Speci cations. They are: Sequence Number Field (columns 1-5). This eld is optional. Speci cation Type Field (column 6). This eld is required. Program Name Field (columns 75-80). This eld is optional. If you're using RISE to enter source programs, eld names appear on the terminal screen to help you enter information in the correct positions.
Example Conventions Sequence Number (Columns 1-5) This eld lets you assign a unique sequence number to each line in your source program. You can use sequence numbers to help you locate lines in the source program listing or lines that have been added or changed. Enter values into this eld as follows: Columns 1-5 00000 - 99999 Description The sequence number of the speci cation. You can omit leading zeros (leading, trailing, or embedded blanks are treated as zeros).
Example Conventions Specification Type (Column 6) This eld identi es the type of speci cation or statement this line contains.
Example Conventions Program Name (Columns 75-80) This eld gives identifying information about the program. You can enter a name to be printed on each page of the source program listing. You can also enter documentary information on individual speci cation lines that will be printed along with the speci cation in the source program listing. Follow these rules when using this eld: Columns 75-80 Description Header Speci cation: Valid program name.
3 Header Specifications The Header Speci cation is the rst speci cation in a program. (If you do not enter a Header Speci cation, the compiler warns you in the compiler listing and uses the default values shown in the section \The Header Speci cation Default Summary"). The only statements which can precede the Header Speci cation are comment lines and the $COPY and $CONTROL compiler subsystem commands. The Header Speci cation lets you: Enable the RPG DEBUG feature.
Example Conventions The Header Specification Fields The elds you can use in the Header Speci cation are described in the sections which follow in this chapter. Each eld has a unique name and occupies speci c positions (columns) in the speci cation. Sequence Number (Columns 1-5) The Sequence Number Field contains the source record sequence number, described in Chapter 2. Specification Type (Column 6) This eld contains an H to identify this line as a Header Speci cation.
Example Conventions USWITCH Source (Column 16) This eld lets you specify where to get the initial values for the user indicators (U1-U8). You only need to specify the source for those indicators actually used in the program. When the program ends, it updates the JCW to re ect the condition of the indicators that were actually used; the others are left unchanged. Column 16 Description F Initialize user indicators from USWITCH records contained in the le whose formal designator is USWITCH.
Example Conventions Long Format USWITCH Records Long Format records are used with USWITCH Source codes F and blank (job stream). You can use as many Long Format records as necessary. Enter them in the following format: 8 9 < ON = 8 9 < ON = 8 9 < ON = USWITCH: [Ui= OFF ],[Ui= OFF ] . . . [Ui= OFF ] : ; : ; : ; JCW JCW JCW Start USWITCH: in column 1 and end it in column 8. The Ui parameters can appear in any order (for instance, U3=ON,U4=ON,U1=ON . . . ).
Example Conventions Examples The following example shows how to enter a job le containing a program that reads user indicators from a USWITCH le (the contents of the USWITCH le are listed after the job le): !JOB USER.ACCT . . .
Example Conventions The last example shows how to enter the Short Format USWITCH record in a job le: !JOB USER.ACCT . . . !RUN PROG2 USWITCH: 1X000001 !EOJ (Begin job) (Execute PROG2: Header column 16 = blank) (Set U1, U8 ON; U2 to previous setting) (No ** record after Short Format record) (Terminate job) J (JCW) Entering a J in column 16 initializes the user indicators with the values in the system JCW.
Example Conventions Blank (Interactive) If column 16 contains a blank and the program is run from a session, RPG prompts you as follows to enter the initial user indicator settings: PLEASE INPUT USER SWITCH Ui=? Enter ON, OFF, or JCW (typing 4RETURN5 is the same as OFF). JCW directs RPG to get the user indicator settings from the JCW (see the discussion of the value J for this eld). Entering some other value turns the user indicator OFF. The above prompt is repeated for each user indicator in the program.
Example Conventions UDATE Source (Column 17) This eld lets you determine where to get the initial values for the prede ned elds: UDATE, UDAY, UMONTH, and UYEAR. Column 17 Description F Initialize UDATE, UDAY, UMONTH, and UYEAR using the date record in the le whose formal designator is RPGUDATE. blank Initialize UDATE, UDAY, UMONTH, and UYEAR using the system date.
Example Conventions Example The following job le executes the program, MYPROG, which reads the current date from the job le. The date is 041088: !FILE RPGUDATE = $STDIN !RUN MYPROG USWITCH: U1 = ON ** //DATE 041088 Line Number Option (Column 20) This eld determines whether the source program line number is displayed when run-time errors occur. When this option is enabled, RPG keeps track of each source line number that is executed.
Example Conventions I (European Format) Commas are used as decimal points; the thousands positions are separated by periods. Leading zeros are suppressed. Dates are printed as dd.mm.yy. J (European Format with Leading Zero) Commas are used as decimal points; the thousands positions are separated by periods. Leading zeros are suppressed up to one position before a decimal point. Dates are printed in the format dd.mm.yy. Blank (Domestic Format) This format is used in the United States.
Example Conventions Column 22 Description 1 RPG subtracts one from all relative record numbers obtained from an ADDROUT le, chaining le, or chaining operation before using the numbers for direct le access. This option is ignored for KSAM les built with the FIRSTREC=1 option. + RPG adds one to all relative record numbers obtained from an ADDROUT le, chaining le, or chaining operation before using the numbers for direct le access. This option does not apply to KSAM les built with the FIRSTREC=1 option.
Example Conventions Alternate Collating Sequence (Column 26) This eld lets you use a collating sequence other than the ASCII Collating Sequence (or JIS-Japanese Industrial Standard-Katakana) for certain comparison operations. Alternate collating sequences do not a ect control levels, numeric comparisons, table look-up operations, or the SORTA operation. Column 26 Description E EBCDIC (Extended Binary Coded Decimal Interchange Code) collating sequence applies. K EBCDIK collating sequence applies.
Example Conventions Table 3-2. ALTSEQ Record Description for Octal Format Column Value Description 1-6 ALTSEQ This is an ALTSEQ record. 7-8 blank None. 9-14 Two ASCII (JIS) characters, The rst character (columns 9-11) replaces the speci ed by sequence number second character (columns 12-14) in the ASCII (JIS) Collating Sequence. in octal. 15-80 Two ASCII (JIS) characters, Same meaning as columns 9-14, repeated as speci ed by sequence number needed. in octal.
Example Conventions S (Alternate Collating Sequence - Hexadecimal) You must enter one or more ALTSEQ records that specify (in hexadecimal) the alternate sequences for speci c characters. (Refer to Appendix D for ASCII and hexadecimal equivalences.) You can enter ALTSEQ records in a job stream or in a separate disk le. Placing them in a separate le means that other programs can use them also. Table 3-3 shows the format for ALTSEQ records in hexadecimal. Table 3-3.
Example Conventions 1 2 3 4 5 6 7 678901234567890123456789012345678901234567890123456789012345678901234 415 H 425 AFILEA . . . S Figure 3-3.
Example Conventions BUFCHK Defaults (Column 28) This eld lets you specify the BUFCHK options to apply to all les. The options are: Current Data Checking (CDC), No-Read Checking (NRC), and Update-Protect Checking (UPC). You can override these values for individual les by using the Option Type Field of the File Description Continuation line (see the BUFCHK entry for the Option Type Field in Chapter 4). Column 28 Description B Enable both CDC and NRC.
Example Conventions Column 39 Description E Convert the record identi cation codes (de ned as types Z and D in the Record Identi cation Codes Field (columns 21/41) of the Input Speci cation) to EBCDIC before comparing them. Do not enter E if the record identi cation codes contain packed numeric data. blank Use the original ASCII character representation for record identi cation code testing.
Example Conventions Table 3-4.
Example Conventions Column 42 Description B Do not alter the indicator settings at program initialization or following Blank-After operations. S Turn ON the indicators at program initialization and following Blank-After operations. T Turn ON the indicators at program initialization, but not following Blank-After operations. blank Do not alter the indicators at program initialization; turn them ON following Blank-After operations.
Example Conventions Table 3-5. File Translation Records in Hexadecimal Columns 1-8 Value Description *FILES Translate all les used in the program. or A valid le name used in a File Description Speci cation. File names can contain up to eight characters and must begin with a letter A-Z. The remaining characters can be letters or digits. Do not embed blanks in the name. Translate the named le. 9-12 Two ASCII characters speci ed in hexadecimal.
Example Conventions O (Octal) Enter one or more le translation records that speci es (in octal) the characters to be translated and the translated equivalents. (Refer to Appendix D for ASCII and octal equivalents.) You can enter le translation records in a job stream or in a separate disk le. Placing them in a separate le allows others to use them also. Table 3-6 shows the format for le translation records in octal format. Table 3-6.
Example Conventions 1 2 3 4 5 6 7 678901234567890123456789012345678901234567890123456789012345678901234 415 H 425 AFILED O . . . Figure 3-5. Specifying File Translation in Octal Non-Numeric Digits (Column 44) This eld lets you move special characters, such as ! and %, to unpacked numeric elds. When you do this, the special characters are converted to digits using their numeric bit values (this usually results in the value zero). You can also convert invalid packed decimal digits to zero.
Example Conventions Dollar Sign Substitute (Column 46) This eld lets you substitute another character for the dollar sign ($) during output editing (see the Edit Code Field, column 38, and the Constant/Edit Word Field, columns 45-70, in the Output Speci cation). Column 46 Description A special character (not a letter or Use this character as a dollar sign during output editing. (Be sure to this character in edit words instead of $.) digit) blank Use $ for the dollar sign.
Example Conventions DSPLY Options (Column 48) This eld speci es how the Calculation Speci cation operations, DSPLY and DSPLM, are performed. Column 48 Description B Display the Factor 1 Field and the Result Field value; prompt for a new Result Field value on the next line, below the displayed value. D Display \DSPLY" and the Factor 1 Field on the same line; display the Res Field and prompt for a new Result Field value on the same line.
Example Conventions Column 50 Description P Page over ow occurs when the next print line is beyond the de ned over ow line. This option provides compatibility with other implementations of RPG. blank Page over ow occurs when the next print line is on or beyond the de ned over ow line. *PLACE Method (Column 51) This eld determines how *PLACE (see the Field Name Field (columns 32-37) in the Output Speci cation) is processed in the program.
Example Conventions Carriage Control Type (Column 53) This eld selects the method by which printer forms are advanced in response to a skip request (see the Skip Field (columns 19-22) of the Output Speci cation). RPG determines whether a le is a printer le by the use of vertical spacing controls, such as space and skip, in the Output Speci cations. Column 53 1 Description **LINE OPTION** (Simulates other implementations of RPG) Skip requests use actual line numbers. The initial forms position is line 1.
Example Conventions Textfile Sequence Check (Column 54) This eld is used for compatibility with RPG V. It lets you compile a program, without errors, that contains an S or N in this eld (S and N are sequence-checking options). Ensure that this eld contains one of these RPG V values: Column 54 S N or blank Description Sequence-check records in the text le using the sequence numbers in columns 1-5. Print a message if a sequence error occurs. Do not sequence-check the text le.
Example Conventions Error Response (Columns 56-71) This eld lets you enter responses to one or more RPG run-time errors. The responses are executed automatically when the errors occur. The responses provide an alternative to operator intervention for the errors. When you use this eld, you must leave the Error Log Field (column 55) blank or enter an N into it. There are 17 possible RPG run-time errors. They are listed in Appendix B.
Example Conventions Example The following Header Speci cation directs RPG to log the \divide by zero" run-time error message to the standard list device, print an Error Dump and terminate the program immediately. 1 2 3 4 5 6 7 678901234567890123456789012345678901234567890123456789012345678901234 H 5 Figure 3-6. Entering an RPG Run-time Pre-Response Program Name (Columns 75-80) This eld contains the program name. The format of this eld is discussed in Chapter 2.
Example Conventions The Header Specification Default Summary If you leave the optional elds of the Header Speci cation blank, the default speci cations shown in Table 3-8 apply. Table 3-8. Header Specification Defaults Columns Field Default Values 1-5 Sequence Number No sequence number applies. 7-14 Error Dump File Name Error Dump directed to the standard list device ($STDLIST). 15 Debug Suppress all DEBUG operations.
Example Conventions Table 3-8. Header Specification Defaults (continued) Columns Field Default Values 42 Indicator Setting Turn on the 1P and L0 indicators. 43 File Translation Do not translate les. 44 Non-Numeric Digits Do not allow non-numeric data to be moved to numeric elds. 46 Dollar Sign Substitute Do not substitute a character for $ during output editing. 47 Skip-Suppress Skip to Channel 1 (new page) of the printer's carriage control tape.
4 File Description Specifications The File Description Speci cation describes the general characteristics of les used in a program. These characteristics include: The le name. The type of le (such as input, output, or combined). The size of the logical records in the le. The format of the records in the le ( xed-length or variable-length). The class name of the device where the le resides (disk, tape, or other media).
Example Conventions The File Description Specification Fields The elds you can use in the File Description Speci cation are described in the sections which follow in this chapter. Each eld has a unique name and occupies speci c positions (columns) in the speci cation. Sequence Number (Columns 1-5) The Sequence Number Field contains the source record sequence number, described in Chapter 2. Specification Type (Column 6) This eld contains an F to identify this line as a File Description Speci cation.
Example Conventions RPG supports all TurboIMAGE input modes (except Re-read) of the DBGET operation. Since some operations use DBFIND, RPG provides an additional input mode. It lets you read down a chain until the search key changes. You can enter a TurboIMAGE data set name in either this eld or in a DSNAME line (see the Data Set Name (DSNAME) Line in the File Description Continuation line). You must also enter the database name in a Database Name (IMAGE) File Description Continuation line.
Example Conventions I (Input File) Input les contain data that is read by the program. An input le can reside on tape or disk. Input les include preexecution time (but not compile-time) table and array les and Record Address Files (RAFs). You must include one or more Input Speci cations for each input le. If the input le contains a preexecution-time table or array or is a Record Address File, enter a File Extension Speci cation for it.
Example Conventions C (Chained File) Chained les are input, output, and update disk les that are accessed randomly via Input Speci cation chaining elds or that are read directly by the Calculation Speci cation CHAIN operation. When you use CHAIN, input and update les are read and output les are written. You can write update les using Output Speci cations or the Calculation Speci cation EXCPT operation. Chained les cannot reside on devices with the device class name SPECIAL.
Example Conventions until a record that matches or exceeds the upper limit is read or until end-of- le is encountered in the KSAM le. Since you can enter any number of upper and lower limit lines in a RAF, you can process the same records more than once, if necessary. If you want to use the RAF to access records randomly, enter a record key in the rst position of a RAF line. You can enter more than one key per line but do not separate them with spaces (spaces causes RPG to read the next RAF line).
Example Conventions Input Sequence (Column 18) This eld determines whether matching les are sequence-checked. Use this eld only for update, combined, primary, and secondary input les. This eld is ignored if you do not use matching elds in the Input Speci cation. Column 18 Description A or blank If this is a matching le, check the records for ascending sequence. D If this is a matching le, check the records for descending sequence.
Example Conventions Block Length (Columns 20-23) This eld determines the length of the blocks (physical groups of records) read from or written to tape les or written to disk les. This eld is ignored for disk input les; records are blocked according to the blocking information in the le label. It is also ignored for line printer and terminal les. In these cases, the block length is determined by the device type. The block length for a line printer le is one line (either 80 or 132 characters).
Example Conventions Processing Mode (Column 28) This eld determines whether records are processed sequentially from beginning to end, sequentially between speci ed limits or randomly. Column 28 Description L Sequential processing between limits. R Random processing (by relative record number or record key). blank Sequential processing for the entire le. L (Sequential Processing Between Limits) You can process portions of KSAM les by processing them sequentially within limits.
Example Conventions KSAM les have key les containing indexes that let you access records directly. KSAM indexes are updated automatically when you process the le. Record keys can be alphanumeric, packed, or unpacked numeric elds. De ne the key eld type using the Record Address Type Field (column 31). Specify the length of the key eld and its starting position using the Record Address or Key Field Length Field (columns 29-30) and the Key Field Starting Location Field (columns 35-38).
Example Conventions Record Address Type (Column 31) This eld describes the key eld used for accessing a le by key. This eld is required for MPE direct les and KSAM and TurboIMAGE les that are chained les or are accessed by a RAF. Column 31 Description A This le is a KSAM or TurboIMAGE le processed by alphanumeric or numeric keys. Numeric elds are unpacked before chaining.
Example Conventions File Organization/Additional I/O Area (Column 32) This eld speci es how the le is organized (for example, KSAM or TurboIMAGE) and it lets you select the number of bu ers to use. Column 32 Description C This is an input (only) KSAM le. The records are read chronologically. D This is an MPE direct le; assign two bu ers to the le. (This entry is not required; it is provided for compatibility with other RPG systems.) I or X This is a KSAM le.
Example Conventions Table 4-1.
Example Conventions 1. If the over ow indicator is ON, records associated with the indicator in the Output Speci cations are printed at the bottom of the current page or at the top of the next page, or both. Associating the over ow indicator with output records in this manner is often used to condition the printing of totals and subtotals at the bottom of a page, or to print headings at the top of the following page. 2.
Example Conventions 1 2 3 4 5 6 7 678901234567890123456789012345678901234567890123456789012345678901234 415 425 435 FFILE1 FFILE2 FFILE3 IS F 80 10PI IP F 120 40L 6AX UP F 104R 2AI 4 1 10 Figure 4-2. File Description Specifications for KSAM Files Extension Code (Column 39) This eld indicates whether File Extension and Line Counter Speci cations are used for this le. Column 39 Description E File Extension Speci cations are included for the le.
Example Conventions Device Class Name (Columns 40-46) This eld associates a device class name or device identi er to the le. (Device class names and device identi ers are assigned during system con guration by systems personnel. Contact these individuals for speci c assignments.) This eld is optional for display les, since the terminal is always used in session mode and the job le in job mode. Columns 40-46 Description Device identi er.
Example Conventions Interface Type (Column 47) This eld de nes the WORKSTN Interface to be used in the program. Column 47 Description C This is an RPG Screen Interface (RSI) WORKSTN CONSOLE le. R This is an RPG Screen Interface (RSI) WORKSTN le. blank This is an RPG VPLUS Interface WORKSTN le. Interface Control (Columns 48-52) This eld is used for options relating to WORKSTN le interfaces.
Example Conventions Name of Label Exit (Columns 54-59) This eld names the user-written routine that processes user labels or les for SPECIAL devices. Columns 54-59 Description The name of the user-written routine that processes user labels or Routine name. (This name contains up to six characters, SPECIAL les. beginning with a letter; the remaining characters can be letters or digits.) blank The program does not process user labels or SPECIAL les.
Example Conventions The following code shows how to enter a C language procedure to process a SPECIAL le: struct file_table { . . }; void exitname (ptr,type,returncode); struct file_table *ptr; int *type, *returncode; { . . (procedure body) . . } Note When coding in C, the procedure name must be in lowercase. If coding in Pascal, FORTRAN, or COBOL, the compilation process will do any downshifting necessary.
Example Conventions Column 66 Description A Append new records to the end of MPE sequential les; add new records to KSAM and TurboIMAGE les. blank Write new records to the beginning of MPE sequential and KSAM les; add new records to TurboIMAGE update les. Do not add records to other update les or to TurboIMAGE output les. A (Append) When you enter an A in this eld, also enter ADD in Record Addition/Deletion Field (columns 16-18) of the eld with the same name in the Output Speci cation.
Example Conventions U1-U8 When you enter a user indicator in this eld, it must be ON at run time to read or write this le. You can enter a user indicator for any le except display, WORKSTN, and SPECIAL les. This eld is commonly used to assign a user indicator to an optional le. By turning the user indicator OFF before the program begins, you can bypass (not process) the le. You turn user indicators ON and OFF by setting them interactively or by using USWITCH records or the system Job Control Word (JCW).
Example Conventions The File Description Continuation Line When you use KSAM, TurboIMAGE, or WORKSTN les in a program, you must enter one or more File Description Continuation lines for them. The Continuation lines give additional information about the les, such as le locking requirements and database and data set names. The remaining sections of this chapter give details about the Continuation lines that you can use.
Example Conventions Continuation Code (Column 53) This eld identi es this as a File Description Continuation line. It is required. Column 53 K Description This is a File Description Continuation line. General Fields (Columns 54-74) There are two general elds: the Option Type Field (columns 54-59) and the Option Target Field (columns 60-65). The entries in the Option Type Field determines the values that you can enter in the Option Target Field.
Example Conventions Option Type (Columns 54-59) Description Option Target (Columns 60-65) Description EBCDIC The le is in EBCDIC P (in column 60) format. If it is an input le, it is translated into ASCII before processing. If it is an output le, it is translated into EBCDIC before being written. A partial eld translation is performed; input and output packed decimal and binary elds are not translated. EBCDIK The le is in EBCDIK P (in column 60) format.
Example Conventions Option Type (Columns 54-59) Description Option Target (Columns 60-65) Description NOLOCK (Not applicable) Open this le so that concurrent users of the le can use LOCK. This option does not dynamically lock and unlock the le. (NOLOCK applies only to KSAM and MPE les.) (Not applicable) PARTTR (Not applicable) When you use le translation records to translate a record containing packed decimal or binary elds, those elds are not translated. (A partial le translation occurs.
Example Conventions Option Type (Columns 54-59) The following paragraphs describe certain options that you can enter in this eld: BUFCHK If the Option Target Field contains a value other than blank or N, a compiler warning (2086W, 2087W, or 2089W) is displayed and the corresponding option is enabled. If you do not enter a BUFCHK Continuation line, the bu er option is determined by the BUFCHK Defaults Field (column 28) of the Header Speci cation.
Example Conventions ERROR, RDEXIT The ERROR and RDEXIT routines must have a procedure head and body format similar to that shown below. The procedure shown below is written in the C language: struct file_table { . . }; void exitname (ptr,returncode); struct file_table *ptr; int *returncode; { . . (procedure body) . . } The procedure name is exitname. The pointer to the pertinent File Table (File Table formats are discussed in the HP RPG/iX Programmer's Guide ) for this le is ptr.
Example Conventions RPG will also post an \F" to the *ERROR eld when a fatal le error occurs. You may wish to use this feature in conjunction with the STATUS array in your calculation speci cations. Note that the FATAL option is e ective once your program enters the RPG cycle and not during RPG initialization time. FATAL allows you to catch and take action on le errors that occur once a program has begun execution (for example, I/O errors, IMAGE errors, etc.).
Example Conventions When you use a DSNAME Continuation line (see the File-Sharing Fields (columns 54-74)) to link les to one physical le, enter one LOCK Continuation line following the rst le that uses a DSNAME Continuation line (the rst DSNAME line determines how the le is opened at run time and whether or not the dynamic locking facility is enabled).
Example Conventions File-Sharing Fields (Columns 54-74) The File-Sharing Fields in the Continuation line let you assign the same le name to two or more les. You can then process the same physical le more than one way in the program. For instance, you can process it randomly by relative record number and sequentially by key. To do this, enter two File Description Speci cations in the program and specify the appropriate type of access for each.
Example Conventions Table 4-2. How Access Type for KSAM Files Affects the Record Pointer Input/Output Type Current Record Pointer Setting Next Update Applies To Sequential read Record read Record read Random access by relative record number Not a ected Record read Random access by record key Record read Record read Write Record written Record written Update Record updated Record previously updated; each successive update updates the same record.
Example Conventions 1 2 3 4 5 6 7 678901234567890123456789012345678901234567890123456789012345678901234 415 425 435 445 FFILEA F FFILEB F IP F 80 AI 10 DISK IC F 80R II DISK KDSNAMEFILEK KDSNAMEFILEK Figure 4-4. KSAM File Sharing Database Fields (Columns 54-74) The Database Fields require several Continuation lines. They give information about how KSAM les are locked and accessed. For TurboIMAGE databases, they give the database name, locking and access information.
Example Conventions Database Name (IMAGE) Line This line names TurboIMAGE databases and speci es how they are accessed. It also speci es whether the database or data set is used concurrently by other programs and whether locking is used. Column Value Description Record Type: (columns 54-50) IMAGE This is a TurboIMAGE database name line. Database Name: (columns 60-65) Database name Name of the database being accessed. The name can be six characters long. B Read/Write Shared Mode.
Example Conventions Column Input/Output Mode: (column 67) Value Description 2 Serial read. Records are read in their physical sequence (not key sequence). 3 Backward serial read (the reverse of mode 2). 4 Directed read. Records are read by relative record numbers. 5 Chained read. 6 Backward chained read. 7 Calculated read. 8 Primary calculated read. C Chained sequential read. R Backward chained sequential read. blank Write, Output File. Data is written to the output le.
Example Conventions R (Read/Write Shared Mode) When you use R, enter 5, 6, C, or R in the Input/Output Mode Field (column 67). If you do not, the database is opened with Open Mode 1 (database locking per record). You must also enter an ITEM Continuation line for the le. An input le (or record) is locked before the record is read, and unlocked after it is read. An output le (or record) is locked before the record is written, and unlocked after it is written.
Example Conventions Locking Precedence If you de ne a database or data set more than once in a program, you must use the same locking precedence level (Open Modes B, S, 1, 9, R, and L) for each de nition. For example, if a database is rst de ned with database locking for duration (Open Mode B) and later de ned with record-level locking (Open Mode R), a con ict occurs.
Example Conventions 6 (Backward Chained Read) This is the same as Input/Output Mode 5 except that if duplicate keys exist, the last record having this key is read. You must enter an ITEM Continuation line. If you want to read up a chain, use Input/Output Mode R. 7 (Calculated Read) This was formerly Associative Read. Use it with master data sets only. The record with a matching key is read. 8 (Primary Calculated Read) This was formerly Primary Associative Read. It applies to master data sets only.
Example Conventions Password (LEVEL) Line This Continuation line speci es the passwords that permit access to the database. Since RPG processes TurboIMAGE records, not individual elds, the password must include permission to read and write entire records. Record Type (Columns 54-59) LEVEL Description This is a password line Password (Columns 60-67) Password. (Maximum length of eight characters.
Example Conventions Input/Output Status Array (STATUS) Line This Continuation line lets you use TurboIMAGE status arrays. Status arrays let you control processing for certain input TurboIMAGE errors. When you use this Continuation line, RPG does not automatically terminate the program when the positive errors 10, 11, and 14-17 are encountered. These errors are treated as exceptions; they turn ON the H0 indicator. You must process these errors yourself or leave the H0 indicator ON.
Example Conventions Key File Name (KEYFL) Line This Continuation line de nes the name of the KSAM key le and, if the KSAM le is being created, the duplicate key options for the le. Column Value Record Type: (columns 54-59) KEYFL Key File Name: (columns 60-67) Key le name First Record Option: (column 68) Duplicate Key Option: (column 69) Name to be given to the KSAM key le. Enter an 8-character name that conforms to MPE le naming conventions. The rst record is 1. 0 or blank The rst record is 0.
Example Conventions WORKSTN Interface Fields (Columns 54-74) This Continuation line speci es control parameters, les, and eld names associated with WORKSTN (terminal) les. See Chapters 10 and 11 and the HP RPG Programmer's Guide for examples of how to use WORKSTN (VPLUS and RSI) les.
Example Conventions Option Type (Columns 54-59) Description Option Target (Columns 60-74) Description LOADFM The array name in the Option Target Field contains the names of forms to download using the LOADFM VPLUS action (Do not use it for RPG Screen Interface les). The array is prede ned as an alphanumeric compile-time array. Each entry is 16 characters long and the number of entries is determined by the number of forms that you enter in the FORMDS File Description Continuation line. Array name.
Example Conventions Option Type (Columns 54-59) Description Option Target (Columns 60-74) Description STATUS The array name speci ed in the Option Target Field is used by the RPG Screen and VPLUS Interfaces to return status information. The eld is prede ned as a six-element, ten-digit array with zero decimal places. Array name. (This may be a name up to six characters beginning with a letter or @, $, or #; the remaining characters can be letters or digits.
Example Conventions The File Description Specification Default Summary If you leave the optional elds in the File Description Speci cation blank, the default speci cations shown in Table 4-3 apply. Table 4-3. File Description Specification Defaults Columns Field Default Values 1-5 Sequence Number No sequence number applies. 16 File Designation None; the le is a sequential output or display le.
5 File Extension Specifications You must enter a File Extension Speci cation for every compile-time table and array, execution-time array, Record Address File (RAF), and chaining le used in a program. You enter the following information in a File Extension Speci cation: Table or array names, descriptions of entries in the table or array, and the names of les in which they reside or to which they are written. Chaining elds (used to process chained les) and the chaining and chained le names.
Example Conventions The File Extension Specification Fields The elds you can use in the File Extension Speci cation are described in the sections which follow in this chapter. Each eld has a unique name and occupies speci c positions (columns) in the speci cation. Sequence Number (Columns 1-5) The Sequence Number Field contains the source record sequence number, described in Chapter 2. Specification Type (Column 6) This eld contains an E to identify this line as a File Extension Speci cation.
Example Conventions Chaining Code Identifier (Columns 9-10) This eld identi es the chaining eld used for chaining. Use this eld only for chaining les. Columns 9-10 Description C1-C9 The chaining eld code that identi es the chaining eld in the Matching/Chaining Field of the Input Speci cation. blank The le is not a chaining le. A chaining eld is a eld containing a record number or key that points to a related record in another le.
Example Conventions From File Name (Columns 11-18) This eld contains the name of a chaining le, preexecution-time table or array, or a Record Address File. Columns 11-18 Valid le name. (File names can contain from one to eight characters, beginning with a letter. The remaining characters can be letters or digits. Embedded blanks are not allowed. The le name must be de ned in the File Name Field of a File Description Speci cation.
Example Conventions Execution-time arrays These arrays can reside in separate disk les or you can create them in the program. If they reside on disk, they are loaded at execution time the same way input data is loaded. You de ne them using Input Speci cations. To create them in the program, use Calculation Speci cation operations. There are no execution-time tables in RPG. For information about creating and loading tables and arrays, see the last section in this chapter titled \Tables and Arrays".
Example Conventions Table/Array Name (Columns 27-32) This eld names a table or array used in the program. Columns 27-32 Description Table or array name. (Table names can contain from three The name of an array or table that is searched in the program. to six characters, beginning with TAB; array names can contain from one to six characters, beginning with a letter or one of the special characters @, $, or #. For both table and array names, the remaining characters can be letters, digits, or @, $, or #.
Example Conventions TABLEA TABLEB A1 A2 A3 A4 B1 B2 B3 B4 Each pair of corresponding entries (for example, A1 and B1) must appear in the same input record in alternating form; you cannot split them between records. Entries in the alternating pair are treated as one table entry. Entries in TABLEA and TABLEB are entered on an input record as shown below: A1B1A2B2A3B3A4B4 For TABLEA and TABLEB, the number of entries per record is 4.
Example Conventions Entry Length (Columns 40-42) This eld speci es the length of entries in a table or array. Columns 40-42 1-256 (right-justi ed, leading zeroes are not required) blank Description The entry length (space allocated for each item). The maximum length for alphabetic entries is 256 characters; for numeric entries, 15 digits This is not a table or array. Entries in each table or array must be the same length.
Example Conventions Decimal Positions (Column 44) This eld contains the number of decimal positions (positions to the right of the decimal) in each entry of a table or array. Column 44 Description 0-9 This is a numeric table or array with the speci ed number of decimal positions in each eld. (The number of decimal positions cannot exceed the number of digits in the eld.) blank This is an alphanumeric table or array.
Example Conventions Table/Array Sequence (Column 45) This eld lets you sequence-check compile-time and preexecution-time tables and arrays. Sequence-checking is not a ected by the Alternate Collating Sequence Field (column 26) of the Header Speci cation. Column 45 Description A Sequence-check the table or array for ascending order. D Sequence-check the table or array for descending order.
Example Conventions Entry Length (Columns 52-54) This eld speci es the length of entries in an alternating table or array. The length you enter in this eld applies to the table or array named in the Alternating Table/Array Name Field (columns 46-51). Columns 52-54 Description 1-256 (right-justi ed, leading zeroes are not required) The entry length (space allocated for each item).
Example Conventions Decimal Positions (Column 56) This eld contains the number of decimal positions (positions to the right of the decimal) in each entry of an alternating table or array. This eld applies to the table or array named in the Alternate Table/Array Name Field (columns 46-51). Column 56 Description 0-9 This is a numeric table or array with the speci ed number of decimal positions in each eld. (The number of decimal positions cannot exceed the number of digits in the eld.
Example Conventions Comments (Columns 58-74) You can enter comments of any kind in this eld. Program Name (Columns 75-80) This eld contains the program name. The format of this eld is discussed in Chapter 2.
Example Conventions Tables and Arrays The table and array sections which follow in this chapter explain how to create and use tables and arrays in an RPG program. Creating Tables and Arrays Compile-time and preexecution-time tables and arrays reside in disk les and are loaded before a program begins execution. Execution-time arrays can reside in les on disk or you can create them with Calculation Speci cation operations at run time.
Example Conventions When entering input records for tables and arrays and their alternating tables and arrays, start with the rst entry of the table or array (named in columns 27-32 of the File Extension Speci cation) and follow it by the rst entry in the alternating table or array (named in columns 46-51 of the File Extension Speci cation). End all records, including the last, with an entry from the alternating table or array. The table or array le has xed-length records and is a sequential le.
Example Conventions Example Figure 5-4 shows how to de ne two arrays using File Extension Speci cations. ARRA is a compile-time array containing 10 entries (2 per record). Each entry is 12 digits long, has two decimal places, and is in unpacked decimal format. ARRB is a preexecution-time array, residing in the disk le DISKER. It contains 300 entries (10 per record). Each entry is 6 positions long, has no decimal places, and is in unpacked decimal format.
Example Conventions Loading Tables and Arrays The next three sections describe how RPG loads table and arrays. (Tables and arrays must be loaded before you can access them in the program.) Loading Compile-Time Tables and Arrays The RPG compiler makes compile-time tables and arrays an integral part of the object program and they are loaded along with it at run time. You can place compile-time tables and arrays at the end of the source program, keep them in les on disk, or any combination of the two.
Example Conventions Example The following source program le contains two alternate collating sequence records, four array records and a le translation record. . . .
Example Conventions Loading Compile-Time Tables and Arrays from Disk Files When you want to place ALTSEQ records, compile-time tables and arrays, and le translation records into a disk le, enter them as follows: 1. Enter the ALTSEQ records, tables, arrays, and le translation records into a disk le according to the instructions in the preceding section \Loading Compile-Time Tables and Arrays Appended to the Source Program". Use separator records as needed but do not start the le with a separator record. 2.
Example Conventions Example The following lines show how to place two ALTSEQ records, four compile-time array records and one le translation record in a disk le.
Example Conventions Loading Preexecution-Time Tables and Arrays Preexecution-time tables and arrays can reside on the same device or on di erent devices. They are loaded before the program is executed and in the order in which they are listed in the File Extension Speci cations. When you create table and array les, observe these rules: If you're sequence-checking a table or array, ensure that the last record in the table or array is not blank.
Example Conventions If you indicated in the Decimal Position Field of the File Extension Speci cation that the entries have one or more decimal positions, enter the same value in the Decimal Position Field of the Input Speci cation (column 52). Otherwise, leave the Decimal Position Field blank. Enter the name of the array in the Field Name Field (columns 53-58). This must be the same name entered in the Table/Array Name Field (columns 27-32) of the File Extension Speci cation.
Example Conventions 1 2 3 4 5 6 7 678901234567890123456789012345678901234567890123456789012345678901234 E E E ARR1 ARR2 ARR3 . . . IFILEA I IFILEA I I I I I IFILEA I I AA 01 AA 01 AA 01 8 10 5 5 30 10 1 1 7 13 19 25 1 3 80 ARR1 5 11 17 23 29 ARR2,1 ARR2,2 ARR2,3 ARR2,4 ARR2,5 20X 72 ARR3,X Figure 5-6. Loading Execution-Time Arrays Searching Tables The Calculation Speci cation LOKUP operation lets you search tables for speci c values.
Example Conventions When you want to access a speci c entry in an array using a Calculation Speci cation, enter the array name followed by a comma and an index. The index can be a number or the name of a numeric eld containing the number of the entry you want to access. The index value for the rst entry is 1 (not zero). An index eld must not have decimal positions and can be no longer than 9 digits.
Example Conventions Changing Table and Array Entries During Execution You can temporarily change table or array values by entering the table or array name in the Result Field of an arithmetic or move Calculation Speci cation operation. Additionally, you can add or modify table or array values using Input or Calculation Speci cations. Changes that you make remain in e ect for the duration of the program; when the program ends, they are lost.
Example Conventions The File Extension Specification Required Entries Certain entries in the File Extension Speci cation are required, optional, or cannot be used, depending upon the type of le you are describing. The rules governing entries for each type of le are summarized in Table 5-3.
Example Conventions Table 5-3.
Example Conventions The File Extension Specification Default Summary If you leave the optional elds of the File Extension Speci cation blank, the defaults shown in Table 5-4 apply: Table 5-4. File Extension Specification Defaults Columns Field Default Values 1-5 Sequence Number No sequence number applies. 7-8 Chaining File Record Sequence None. 9-10 Chaining Code Identi er This le is not a chaining le.
6 Line Counter Specifications This speci cation lets you change the defaults used during skipping operations (see the Skip Field (columns 19-22) in the Output Speci cation). If you do not use a Line Counter Speci cation, the defaults are those shown in Table 6-1. Use the Line Counter Speci cation for print les and for disk les that you want to keep in printable format.
Example Conventions The Line Counter Specification Fields The elds you use in the Line Counter Speci cation are described in the sections which follow in this chapter. Each eld has a unique name and occupies speci c positions (columns) in the speci cation. Use the Channel Number Fields (columns 15-74) when you want to simulate the use of channels in the printer carriage control tape. Use the Line Number Fields (columns 15-24) when the lines to which you need to skip vary.
Example Conventions Channel Number/OL (Columns 18-19) This eld identi es the channel number to which the line number in the preceding eld applies. Or, it identi es the line number (in the previous eld) as the over ow line. Columns 18-19 1-12 (right-justi ed, leading zeros are not required) OL Description The channel number to which the line number in the preceding eld is assigned. The line number in the preceding eld is the over ow line.
Example Conventions Line Number Fields (Columns 15-24) The next three elds let you specify the number of lines per printed page and the line that signals page over ow. Line Number (Columns 15-17) This eld identi es the last line number on the page or the line at which page over ow occurs. This eld is used in conjunction with the next eld, OL/FL (columns 18-19).
Example Conventions Example Figure 6-3 de nes line 68 as the over ow line for the le PRINTY. It also speci es that line 74 is the last line on a page. 1 2 3 4 5 6 7 678901234567890123456789012345678901234567890123456789012345678901234 LPRINTY 068OL074FL Figure 6-3. Using the Line Number Fields Program Name (Columns 75-80) This eld contains the program name. The format of this eld is discussed in Chapter 2.
Example Conventions The Line Counter Specification Default Summary If you leave the optional elds of the Line Counter Speci cation blank, the defaults shown in Table 6-1 apply. Table 6-1. Line Counter Specification Defaults Columns 1-5 Fields Default Values Sequence Number No sequence number applies. Line Number, Channel Number/OL Channel Number elds: line 6 is assigned to Channel 1; other line numbers equal the channel numbers multiplied by 5; line 60 (Channel 12) is the over ow line.
7 Input Specifications This speci cation gives additional information about input, update, and combined les. If you're using any of those les, you must enter one or more Input Speci cations for them. The Input Speci cation: Identi es the types of records in the le and shows how they relate to one another. (Use the File and Record Description Fields in columns 7-42 to enter this information.
Example Conventions The Input Specification Fields The elds you can use in the Input Speci cation are described in the sections which follow in this chapter. Each eld has a unique name and occupies speci c positions (columns) in the speci cation. Sequence Number (columns 1-5) This eld contains the source record sequence number, described in Chapter 2. Specification Type (Column 6) This eld contains an I to identify this line as an Input Speci cation.
Example Conventions File Name (columns 7-14) This eld names the le to which this and subsequent Input Speci cations apply. Enter the name of an input, combined, or update le de ned by a File Description Speci cation. Do not enter the name of an output or display le. Columns 7-14 Description Valid le name. (File names contain from one to eight characters, Name of an input, update, or beginning with a letter. The remaining characters can be letters combined le being described by this Input Speci cation.
Example Conventions To enter OR lines, follow these steps: 1. Make sure that from one to three characters of the record identi cation code are described by the previous speci cation. 2. Enter OR in columns 14-15 with up to three additional record identi cation code character descriptions in columns 21-41. Leave columns 16-18 blank.
Example Conventions Group Sequence (Columns 15-16) This eld lets you specify the order of record types, if any, in a le. Records types (see the Record Identi cation Codes Field (columns 21-41)) identify di erent data record formats in a le. This eld is required. Columns 15-16 Description 01-99 (right-justi ed, leading zeros are not required) Assign this sequence number to the record type speci ed in the Record Identi cation Codes Field (columns 21-41), and verify this sequence on input.
Example Conventions To specify that record type A is rst for each sales person followed by record types B and C, enter the numbers 01, 02, and 03 in the Group Sequence Field on consecutive Input Speci cations. On the group 01 sequence line, enter an A in column 27. On the group 02 sequence line, enter B in column 27 and on the group 03 sequence line, enter C in column 27.
Example Conventions Column 18 Description O Records of this type are optional and may or may not be present in each group. (Prevents sequence errors when a record is absent.) U The data structure de ned in this speci cation is the Local Data Area. blank At least one record with this record type must be present in each group, or alphabetic characters are entered in the Group Sequence Field. Do not enter this eld on speci cations containing AND or OR in columns 14-16.
Example Conventions The following steps show how Program A uses a Local Data Area to pass information to Program B. (Assume that the Local Data Area has already been created using the RPGINIT utility.) 1. Program A loads the Local Data Area File into its User Data Structure. 2. Program A modi es the User Data Structure during calculations. 3. At end-of-job, Program A updates the contents of the Local Data Area. 4. Program B loads the Local Data Area File into its User Data Structure. 5.
Example Conventions Record Indicator/Look-Ahead/Trailer/Data Structure (Columns 19-20) This eld assigns a record-identifying indicator to the record type. It also lets you specify whether the record type contains look-ahead elds, whether the next lines de ne the trailer portion of a spread record, or whether they de ne a data structure. Columns 19-20 Description Record-Identifying Indicators: 01-99 Assign this general indicator. F0-F9 Assign this function key indicator.
Example Conventions Record-Identifying Indicators When a le contains several types of records and you want to perform di erent operations on each type, use this eld to assign a di erent record-identifying indicator to each type. At the beginning of each logic cycle, all assigned record-identifying indicators are turned OFF. Each time a record is read and selected for processing, the indicator assigned to it is turned ON and remains on for the entire logic cycle.
Example Conventions Example Line 1 in Figure 7-6 shows how to assign general indicator 03 to the rst record type in le READX. Every time a record is processed for this record type, the ADD Calculation Speci cation operation (line 2) is executed. 1 2 3 4 5 6 7 678901234567890123456789012345678901234567890123456789012345678901234 415 425 IREADX I I I I I I I I C 03 011O03 021O 031O 05 CX . . 05 CY . . 05 CZ . . STOREA ADD STOREB RESF Figure 7-6.
Example Conventions KA-KN, KP-KY (Command Key Indicators) You can use command key indicators the same way you use general indicators. When you use an RPG Screen Interface (RSI) le, the command keys may have a special meaning. A user at a terminal keyboard presses 4f15 followed by a key from the top row of the keyboard to turn on one of the twenty-four command key indicators. The RPG Screen Interface then performs the appropriate action.
Example Conventions 1P (First-Page Indicator) Normally, you use this indicator in Output Speci cations to print headings on the rst page of a report. After the headings are printed, however, you can use it the same way you use a general indicator (the 1P indicator is turned OFF after each detail-time output). ** (Look-Ahead) Place ** in columns 19-20 when the record contains one or more look-ahead elds. Look-ahead elds let you examine the contents of a record before the record is available for processing.
Example Conventions TR (Trailer Records) When a le consists of a header record followed by one or more records that contain information related to that header, you can condense the le by formatting the records in a spread format. When you use a spread record, place the header and related information on the same record. You can use spread records with primary and secondary les. You cannot use spread records with update or combined les or les that have look-ahead elds.
Example Conventions Example A hardware and carpentry supply house uses a le that contains a header record for each general class of item stocked (such as saws, hammers, and screwdrivers). Each header record is followed by records that show the quantity of each speci c type of item on hand, one record for each type. For instance, one item record might show 63 cross-cut saws, another might indicate 15 rip saws. The three records below show how to format the header and item information into spread records.
Example Conventions DS (Data Structure) Data structures let you break a eld or an array into sub elds that can be referenced in Calculations and Output Speci cations. Data structures can also be used to group individual elds together so that they can be used as a unit. Whenever a data structure is modi ed its sub elds are automatically modi ed. Conversely, if a sub eld is changed, its data structure is also changed. Data structure speci cations follow all other Input Speci cations.
Example Conventions De ne data structure sub elds, using the Field Description Fields (columns 43-70), as follows: 1. Enter an I in column 6. 2. Leave columns 7-43 blank. 3. Enter the starting position of the eld in columns 44-47. The starting position is relative to the rst position of the data structure. The starting position can overlap other sub elds in the data structure. 4. Enter the ending position of the eld in columns 48-51.
Example Conventions Example Figure 7-9 shows how to use a data structure to de ne sub elds of the input eld PRODID. The sub elds are CATALOG, VENDOR, and PRD#. Changes to any of the sub elds will automatically be re ected in the data structure. If, for example, a calculation changes the sub eld VENDOR, PRODID also changes.
Example Conventions Record Identification Codes (Columns 21-41) When a le contains more than one record type and the program processes each type di erently, you must assign a unique code to each type using this eld. The code that you assign must exist in one or more data records in the le. (When a le contains just one type of record or when each type is processed the same way, leave this eld blank.
Example Conventions Portion (Columns 26, 33, 40) This eld lets you specify which portion of the record identi cation code character to use in identifying the record type. You can use the entire character, the zone portion, or the digit portion. Normally, RPG compares record identi cation codes in ASCII. If you want to compare using the EBCDIC character set, enter an E in the EBCDIC Zone/Digit Tests Field (column 39) of the Header Speci cation. (Appendix D lists the ASCII and EBCDIC collating sequences.
Example Conventions Field Description Fields (Columns 43-70) These elds describe the data elds within the records de ned by the File and Record Description Fields (columns 7-41). Data elds include arrays and array elements. Enter elds on separate lines, starting with the line immediately following the line that contains the File and Record Description Fields for the record. Leave columns 7-42 blank. You only need to de ne those elds actually used in the program.
Example Conventions For example, the number -256 looks like this when represented in alphanumeric (ASCII) format: bits: 0 0 1 1 0 0 1 0 --------|-------<---- byte ----> 0 0 1 1 0 1 0 1 --------|-------<---- byte ----> 0 1 0 0 1 1 1 1 --------|-------<---- byte ----> 2 5 0 Since the ASCII representation of the low-order character is O, the eld is assumed to be negative and looks like this when converted to packed decimal: bits: 0 0 1 0 0 1 0 1 --------|-------<---- byte ----> 2 5 0 1 1 0 1 1 0 1 -
Example Conventions P (Packed Decimal Format) Each byte of the eld is divided into two parts - each holding one digit. This format saves memory because only four bits are required for each digit. The low-order four bits of the low-order byte contains the sign. If the number is negative, the sign bits are 1101 (the character D in hexadecimal). If the number is positive, the sign bits are 1100 (the character C in hexadecimal), though any bit con guration except 1101 is considered positive.
Example Conventions From Field Position (Columns 44-47) This eld de nes where the data eld starts in the input record. This eld is required. Columns 44-47 1-9999 (right-justi ed, leading zeros are not required) Description The beginning position of the eld in the input record. To Field Position (Columns 48-51) This eld de nes the last position of the data eld. This eld is required.
Example Conventions Field Name (Columns 53-58) This eld names the eld, array or array element de ned by the speci cation. Every eld must have a name; you use this name in the program to reference the eld. Columns 53-58 Description Field name. (This can be a name of up to six characters, beginning with a letter or @, $, or #; the remaining characters can be letters, digits, or @, $, or #. Embedded blanks are not allowed.) The name of the input eld. Array name.
Example Conventions Example Figure 7-12 shows how to assign the names FIELD1, FIELD2 and FIELD3 to three elds in the le FILEX (the names start in line 1). The example also shows how to use the same eld names for elds in two di erent record types in the le FILEX. The eld names are FIELDA, FIELDB, and FIELDC and their de nitions begin with line 3. The OR line is used to avoid de ning the elds twice. The elds have the same length on both record types and are located in the same positions.
Example Conventions PAGE, PAGE1-PAGE7 Using the eld PAGE in an Input Speci cation lets you change the length and initial value of the eld PAGE. PAGE is a prede ned four-digit eld which is set to zeros. It is used for printing page numbers in report les. Normally, you use the eld PAGE only in Output Speci cations for printing the page number (see the Field Name Field (columns 32-37). Page numbering starts with one and continues to 9999. De ning PAGE in an Input Speci cation lets you override these defaults.
Example Conventions Control Level (Columns 59-60) This eld assigns a control-level indicator to the eld. You can assign control-level indicators to elds in primary and secondary les. Do not assign them to look-ahead or trailer elds or to elds in chained or demand les. Column 59-60 Description L1-L9 Assign this control-level indicator to the eld. blank The eld is not a control eld. A control-level indicator identi es a control eld in the le.
Example Conventions You can assign the same control-level indicator to elds in di erent les. Control breaks occur the same as if the elds were in the same le. For example, if L3 is assigned to a eld in one le and L3 is assigned to a eld in another le, a change in either of these elds turns ON L3 and causes a control break. Example Figure 7-14 shows how to enter the Input Speci cations for a program that prints a voter count by county, city and precinct.
Example Conventions Matching/Chaining Fields (Columns 61-62) This eld contains either a matching or a chaining code for the eld. If you're not using matching or chaining elds, leave this eld blank. Columns 61-62 Description C1-C9 This is a chaining eld identi ed by this code. M1-M9 This is a matching eld identi ed by this code. blank The eld is neither a matching nor a chaining eld.
Example Conventions Figure 7-15.
Example Conventions You can have up to nine chaining elds per record type. (This lets you access more than one chained le for each record.) The chaining eld codes do not have a rank based on their number. You determine the order of the chaining elds by the sequence in which you enter the Input Speci cations. For example, if you assign C3 to the rst eld in a record and C2 to the next eld and C5 to the third, the chained les are read in this order: C3, C2, C5.
Example Conventions Example Figure 7-16 shows the speci cations that perform the chaining illustrated in Figure 7-15. The customer names and charge amounts are stored in the chaining le TRANSAC. The customer mailing addresses and other information are contained in the KSAM le MASTER. The rst eld in TRANSAC, CUST, contains the customer name and it is identi ed as the chaining eld by the code C3. When MASTER is read, the record whose CUST eld matches the name in CUST (TRANSAC) is selected.
Example Conventions M1-M9 (Matching elds) You can use matching elds with sequential primary and secondary les having any le organization (when you do, these les are called matching les ). Matching eld codes perform two functions in a program, depending on the number of les to which you assign them.
Example Conventions When you assign matching eld codes to elds in more than one le, the elds are used as control elds for matching-record processing. Normally (when you do not specify matching-record processing), records are not matched; all records in the primary le are processed rst, then records from each secondary le are processed in the order in which you enter them in the File Description Speci cations (this is called the \primary/secondary processing order").
Example Conventions Figure 7-18.
Example Conventions When you use matching eld codes, follow these rules: 1. For each matching le, enter the same sequence in the Input Sequence Field (column 18) of the File Description Speci cation. 2. Assign matching eld codes to at least one record type in two or more les. If you do not, matching-record processing does not take place. When you use more than one matching eld code, all elds in the control group must match before the MR indicator is turned ON.
Example Conventions 1 2 3 4 5 6 7 678901234567890123456789012345678901234567890123456789012345678901234 IALPHA I I IBETA I I AA 01 80 CA BB 021 80 CB 1 6 5 DATA1 10 DATA2 M1 M2 21 31 25 DATA3 35 DATA4 M2 M1 Figure 7-19. Assigning Matching Field Codes Field Record Relation (Columns 63-64) When you use OR lines to de ne record types, and some of the elds are not contained in all types, you can enter an indicator in this eld to associate those input elds with the appropriate record type.
Example Conventions Programmer's Guide for details on how the indicators are used.) For example, you can use the general indicator 10 in this eld. This associates the eld with the record type having indicator 10 in columns 19-20. When two control elds (or matching elds) have the same control-level indicator (or matching eld code), you can enter an indicator in one of these elds or both of them. Only the eld associated with the indicator that is ON is used.
Example Conventions Field Indicators (Columns 65-70) This eld lets you test for positive values, negative values, zeros or blanks in the eld.
Example Conventions Example Figure 7-21 shows how to use eld indicators to test input data. The eld POSDAT is tested for positive values. NEGDAT is tested for negative numbers and the eld NODAT is tested for zeros or blanks. When any of the conditions are true, calculations and output conditioned by the indicators are performed.
Example Conventions The Input Specification Default Summary If you leave the optional elds of the Input Speci cation blank, the default speci cations shown in Table 7-1 apply: Table 7-1. Input Specification Defaults Columns Field Default Values 1-5 Sequence Number No sequence number applies. 17 Number of Records No restrictions on types per group; sequencing is not requested.
8 Calculation Specifications Introduction The Calculation Speci cation lets you perform arithmetic operations and other types of operations such as searching tables and arrays, moving data internally, performing subroutines, and using system intrinsics. (See \Operation Field" in this chapter for a list of the Calculation Speci cation operations.
Example Conventions When you enter Calculation Speci cation operations, enter them in this order: 1. Detail-time operations. 2. Total-time operations. 3. Subroutine operations. The Calculation Speci cation is identi ed by a C in column 6: 1 2 3 4 5 6 7 678901234567890123456789012345678901234567890123456789012345678901234 C Figure 8-1. The Calculation Specification The Calculation Specification Fields The Calculation Speci cation elds are described in the sections that follow in this chapter.
Example Conventions Control Level (Columns 7-8) The Control Level eld determines when the operation entered in columns 28-32 of this speci cation is performed. Calculation speci cations can be executed at detail time, total time, at the end of the program, or as a subroutine (see the HP RPG Programmer's Guide for information on when these events occur in the RPG logic cycle). Table 8-1.
Example Conventions Example Figure 8-2 shows two operations conditioned by control-level indicators. Line 1 is conditioned by L2 and line 2 is conditioned by L1. When a control break occurs for the control eld associated with L2, L1 and L2 are both turned ON and both operations are performed. 1 2 3 4 5 6 7 678901234567890123456789012345678901234567890123456789012345678901234 415 425 CL2 CL1 ALPHA ADD BETA MOVE RES RES1 100 OUTPT 10 Figure 8-2.
Example Conventions When entering AN(D) and OR lines, follow these steps: 1. Precede the AN(D) or OR line with a speci cation that contains L0-L9, LR, SR, or blanks in the Control Level Field (columns 7-8), or from one to three indicators in the Indicators Field (columns 9-17). Leave columns 18-59 blank. 2. Enter the AN(D) or OR line by placing AN or OR in the Control Level Field and the indicators in the Indicators Field. If this is not the last AN(D) or OR line, leave columns 18-59 blank.
Example Conventions Indicators (Columns 9-17) The Indicator eld is composed of sub elds that let you enter up to three indicators for conditioning the operation. These indicators are used in addition to the indicators entered in the Control Level Field (columns 7-8). Table 8-2. Indicators (Columns 9-17) Column Value Not: (columns 9, 12, 15) N The indicator in the indicators sub eld (below) must be OFF to condition the operation.
Example Conventions When conditioning operations with indicators, be sure you understand how they are used in the RPG logic cycle (see the HP RPG Programmer's Guide ). When using the Indicator Field, you can: Use any indicator entered in the Record Indicator/Look-Ahead/Trailer/Data Structure Field (columns 19-20) of the Input Speci cations to condition operations for certain record types.
Example Conventions U1-U8 (User Indicators) The user indicators indicators cause the operation to be executed when they are turned ON. You can turn the user indicators on yourself with the SETON operation. You get the initial settings (ON or OFF) of these indicators in three di erent ways. By prompting the operator. By taking values from the system job control word (JCW). By taking values from a le.
Example Conventions Figure 8-5 shows how an indicator is turned ON, then used to condition a Calculation Speci cation operation. When the eld CLASS is blank, the general indicator 01 turns ON (line 1). Line 2 performs the ADD operation only when CLASS is not blank (indicator 01 is turned OFF). 1 2 3 4 5 6 7 678901234567890123456789012345678901234567890123456789012345678901234 415 IINFILE AA I I I 425 C C C N01 . . 21 25 CLASS SUMA . . ADD SUMB SUMC 01 50 Figure 8-5.
Example Conventions You must de ne eld names that you enter in this eld somewhere in the program. Some eld names, however, are prede ned; you can use them without de ning them. These elds are UDATE, UMONTH, UDAY, UYEAR, PAGE, PAGE1-PAGE7, and *ERROR. Alphanumeric Literals Alphanumeric literals are constants that consist of ASCII characters. They can also specify a message identi cation number in a User Message Catalog (see the MSG operation). Do not use alphanumeric literals in arithmetic operations.
Example Conventions Figurative Constants Figurative constants are prede ned names that, when used, produce one or more identical characters. The gurative constants *BLANK and *BLANKS produce one or more blanks and are normally used with alphanumeric elds. *ZERO and *ZEROS produce one or more zeros and are used with either numeric or alphanumeric elds. The number of blanks or zeros produced depends on the size of the Factor 2 Field (or, if the Factor 2 Field is not used, the Result Field).
Example Conventions Operation (Columns 28-32) This eld contains a word that directs RPG to perform a certain action. Each type of operation is discussed in this section of this chapter. The operations are further broken down in the next section with a detailed alphabetical description of every RPG calculation speci cation operation.
Example Conventions are converted to packed decimal format. The Factor 2 Field must contain numeric data only, except for the sign position which can contain a digit 0-9 or a letter A-R. The move operations are listed below and are described in the pages which follow: MOVE, MOVEA, MOVEL Move Zone Operations These operations move the sign bits from the high-order (leftmost) or low-order (rightmost) position of the Factor 2 Field to the high-order or low-order position of the Result Field.
Example Conventions Internal Subroutine Operations When a program performs the same operations under di erent conditions, you can code the operations once as an internal subroutine and then branch to the subroutine to perform the operations. You code internal subroutines as part of the RPG program. (External subroutines are not part of the program. They are generally routines that are used by many programs.) Figure 8-7 shows how to enter an internal subroutine.
Example Conventions Within a subroutine, you can condition an operation by entering indicators in the Indicators Field (columns 9-17). You cannot use control-level indicators in the Control Level Field (columns 7-8) to condition them; however, you can use them to condition the EXSR operation that performs the subroutine. You can de ne elds inside or outside of an internal subroutine. Fields that you de ne within the subroutine can be referenced outside of it also.
Example Conventions When compiling COBOL external subroutines to be run in MPE/iX compatibility mode, include the ANSIPARM parameter in the $CONTROL compiler directive. This parameter aligns parameters on byte boundaries, which RPG expects. (When compiling COBOL external subroutines in MPE/iX native mode, byte alignment is automatic.) Note When coding in C, the procedure name must be in lowercase. If coding in Pascal, FORTRAN, or COBOL, the compilation process will do any downshifting necessary.
Example Conventions Table and Array Operations The table and array operations let you search an array, a single table, or alternating tables. To ensure that arrays are in ascending or descending sequence before you search them, you can use the SORTA operation. The table and array operations are listed below and are described in the pages which follow: LOKUP, SORTA File Operations The le operations let you perform all le handling functions.
Example Conventions Operation Definitions The de nitions in this section are listed in alphabetical order, not by type of operation. ADD This arithmetic operation adds Factor 1 to Factor 2 and places the sum in the Result Field. If Factor 1 is blank, it adds Factor 2 to the Result Field and places the sum in the Result Field. BEGSR This internal subroutine operation marks the entry point to an internal subroutine (see gures 8-7 and 8-26). Enter the name (label) of the subroutine in the Factor 1 Field.
Example Conventions BITON This indicator and bit setting operation turns ON bits in the Result Field. The bits that are turned ON are determined by the Factor 2 Field. The Result Field must be a one-character alphanumeric eld. You can enter an alphanumeric literal, a eld, a table, or an array element in the Factor 2 Field. In all these cases, Factor 2 must be a single character.
Example Conventions CABxx This structured programming operation (Compare And Branch) compares Factor 1 to Factor 2. If the results of the comparison match the condition speci ed by xx, control branches to the TAG label entered in the Result Field. Table 8-4. CABxx Operations Enter this operation: To test if Factor 1 is: CAB No test takes place; the branch is unconditional. CABEQ Equal to Factor 2. CABGE Greater than or equal to Factor 2. CABGT Greater than Factor 2.
Example Conventions Example Figure 8-9 shows how to enter the CABGE operation. The eld CODE is compared to the literal 21. If CODE is greater than or equal to 21, control skips to the label SELECT. Indicator 20 is turned ON when CODE is less than 21. 1 2 3 4 5 6 7 678901234567890123456789012345678901234567890123456789012345678901234 415 425 C C C C C C CODE SELECT CABGE21 . . TAG . . SELECT 20 Figure 8-9.
Example Conventions CASxx This structured programming operation (CASe) compares Factor 1 to Factor 2. If the results of the comparison match the condition speci ed by xx, control branches to the internal subroutine named in the Result Field. Table 8-5. CASxx Operations Enter this operation: CAS To test if Factor 1 is: No test takes place; the subroutine is performed unconditionally. CASEQ Equal to Factor 2. CASGE Greater than or equal to Factor 2. CASGT Greater than Factor 2.
Example Conventions becomes \12345". To avoid problems when comparing the numeric eld, make sure it does not have decimal places, is the same length and is not negative. When you compare a numeric eld to an alphanumeric eld, you see this compiler message: 9016I NUMERIC FIELD TEMPORARILY CONVERTED TO ALPHANUMERIC FOR ALPHANUMERIC COMPARE You may enter one or more resulting indicators in the Resulting Indicators Field (columns 54-59).
Example Conventions CHAIN This operation reads a record from a KSAM, TurboIMAGE, or MPE direct-access le. CHAIN lets you retrieve records randomly; you enter identifying information for the record you want to read. Similarly, you can use CHAIN to write records randomly to these les. There are two ways to access records with CHAIN. You can access a le by relative record number or record key. A relative record number is a record number that is \relative" to the rst record in the le.
Example Conventions Enter the indicator in the High Sub eld (columns 54-55) that you want to turn ON when a record is not found. For TurboIMAGE les, enter the indicator in the Low Sub eld that you want to turn ON when the end-of-chain is reached. (A chain is a group of records having the same key value.) When you leave either or both the High and Low Sub elds blank, H0 is turned ON.
Example Conventions Example Figure 8-11 shows how to use the CHAIN operation to read records from the direct-access le CHAINFL (line 2). Records are read by record number. The CHAIN operation in line 4 reads records in CHAINFL using the eld ID (line 3) to identify the record numbers. The record numbers in ID are obtained from the input le INFILE (line 1).
Example Conventions Figure 8-12 shows how to create a direct-access chained le CHFILE from a sequential input le INFILE. During each logic cycle, a record is read from INFILE (line 1). When the CHAIN operation (line 3) is executed the eld DATA is written to CHFILE (line 4) using the record number in the eld RECNO (see line 2). The rst time CHAIN is executed, it sets the ve extents allocated for the chained le to blanks. The HP RPG/iX Programmer's Guide gives additional examples on chaining to a KSAM le.
Example Conventions CLOSE This le operation closes an open le. It performs normal end-of- le actions before the program actually ends. Use CLOSE to release a le so that others can gain access to it or to release system resources used by a le that you've nished processing. You can also use CLOSE to release printer les for printing. Once you use CLOSE for a le, you cannot use the le in subsequent input/output operations.
Example Conventions Example Figure 8-13 shows two COMP operations. The COMP operation in line 1 compares FIELD1 to FIELD2. If they are equal, indicator 03 turns ON. If FIELD1 is greater than FIELD2, indicator 01 turns ON. If FIELD1 is less than FIELD2, indicator 03 turns ON. The COMP operation in line 2 compares the eld STATUS to the word EXEMPT. If they are equal, indicator 05 turns ON.
Example Conventions DEBUG This debugging operation assists you in debugging a program by showing the indicators that are turned ON and optionally, a eld in the program. Place the DEBUG operation at one or more points in the Calculation Speci cations where you want to capture DEBUG information. The captured information is saved in a le that you name. To enable DEBUG, enter 1 in the Debug Field (column 15) of the Header Speci cation.
Example Conventions Table 8-8. Output from the DEBUG Operation Position Contents Indicator lines: 1-8 DEBUG= 9 - 12 The source program sequence number assigned to this DEBUG Calculation Speci cation. Along with the Factor 1 Field, this number helps to identify this particular DEBUG operation. 13 - 14 Blank. 15 - 22 The contents of the eld literal entered in the Factor 1 Field. 23 A minus sign if the Factor 1 Field is negative; a blank if it is zero or positive. 24 Blank.
Example Conventions Example Figure 8-14 shows how to use DEBUG to display the indicators that are ON and to display the contents of an array element. This information is written to a le rather than being displayed on the terminal. The DEBUG operation writes the debug information to the le BADFILE and tags this output with the word FIRST. The contents of the third array element of ARR1 is also written.
Example Conventions DIV This arithmetic operation divides Factor 1 (dividend) by Factor 2 (divisor), and places the quotient in the Result Field. If Factor 1 is blank, the Result Field is divided by Factor 2 and the quotient is placed in the Result Field. If Factor 1 is zero, the result is zero. If Factor 2 is zero, an error occurs (you can determine the action to take by entering the appropriate code in column 66 of the Header Speci cation).
Example Conventions DO This structured programming operation executes the Do Block following it until a speci ed condition is met. With the DO operator you specify the initial value for the loop variable in Factor 1 and the limit value in Factor 2. These values must be numeric if speci ed. You may leave Factor 1 or Factor 2 blank. RPG will assume a value of 1 for either or both Factors which are left blank. In the Result Field you specify the name of a numeric eld to control the loop.
Example Conventions DOUxx This structured programming operation (DO Until) performs the block of operations (Do Block) immediately following it until Factor 1 and Factor 2 meet the criteria speci ed by xx. The Do Block is performed at least once. Table 8-9. DOUxx Operations Enter this operation: To perform the Do Block until Factor 1 is: DOUEQ Equal to Factor 2. DOUGE Greater than or equal to Factor 2. DOUGT Greater than Factor 2. DOULE Less than or equal to Factor 2. DOULT Less than Factor 2.
Example Conventions To conditionally execute the DOUxx operation, enter one or more indicators in the Indicators Field (columns 9-17). You can prematurely end execution of a Do Block by entering one or more indicators in the Indicators Field of the END operation. When the indicator conditions are no longer satis ed, control skips to the operation following END. You can enter a eld name or a literal in the Factor 1 and Factor 2 Fields. Numeric elds are aligned by decimal point before they are compared.
Example Conventions DOWxx This structured programming operation (DO While) performs the block of operations (Do Block) immediately following it as long as Factor 1 and Factor 2 meet the criteria speci ed by xx. Table 8-10. DOWxx Operations Enter this operation: To perform the Do Block while Factor 1 is: DOWEQ Equal to Factor 2. DOWGE Greater than or equal to Factor 2. DOWGT Greater than Factor 2. DOWLE Less than or equal to Factor 2. DOWLT Less than Factor 2. DOWNE Not equal to Factor 2.
Example Conventions becomes \12345". To avoid problems when comparing the numeric eld, make sure it does not have decimal places, is the same length and is not negative. When you compare a numeric eld to an alphanumeric eld, you see this compiler message: 9016I NUMERIC FIELD TEMPORARILY CONVERTED TO ALPHANUMERIC FOR ALPHANUMERIC COMPARE Do not use the Result Field or the Resulting Indicators Field (columns 54-59). Example Figure 8-18 shows how to use the DOWxx operation.
Example Conventions DSPLM This display operation displays messages on the terminal from a User Message Catalog. You can also use it to display a eld on the terminal and accept changes to it from the user. If you enable the function keys (4f15 through 4f85) using the SET operation, DSPLM automatically turns the function key indicators ON or OFF when the user presses the function keys on the keyboard. When you run a program containing DSPLM from a job le, data is read and displayed using the system console.
Example Conventions When you use the Result Field, enter a eld name into it. If the eld is alphanumeric, the maximum number of characters it can contain is 256. If it is numeric, the maximum number of digits is 15. If you're using the system console, the eld must not exceed 31 characters for input and 56 characters for output. If you're using a user terminal, the eld must not exceed the terminal record length de ned at system con guration.
Example Conventions 1 2 3 4 5 6 7 678901234567890123456789012345678901234567890123456789012345678901234 415 425 435 E KEYLBL C C C C C C C C C C C C C C C C C C C C C C C C C SETOF SETOF SETOF DSPLM DSPLM DSPLM DSPLM DSPLM DSPLM DSPLM DSPLM SET DSPLM . . .
Example Conventions DSPLY This display operation displays data on the terminal and reads data from it. You can also use DSPLY to turn the function key indicators ON or OFF when the user presses the function keys on the keyboard. When running in batch mode, DSPLY uses the system console. When running in session mode, it uses the user terminal. Use the Factor 1 and Result Fields in one of three ways shown below. These elds determine how DSPLY works.
Example Conventions You can use the Header Speci cation to alter the way data is displayed on the terminal and read from it. The DSPLY Options Field (column 48) lets you suppress the display of \DSPLY". It also lets you determine whether the user updates the Result Field on the same line where it is displayed, or on the next line. Example Figure 8-21 illustrates the three ways to use DSPLY. The rst line (line 1) displays the contents of the eld MESSAGE.
Example Conventions ELSE This structured programming operation is used with the IF operation. It marks the beginning of the operations that are performed when the comparison criteria of the IF test are not met. Enter ELSE in the Operation Field and leave all other elds on the speci cation blank. Example Figure 8-22 shows how to use the ELSE operation. The operation in line 2 is executed when the eld CODE is equal to zero (line 1).
Example Conventions END This structured programming operation marks the end of a Do Block of operations. (See the IFxx or DOUxx operations for examples of Do Blocks.) When used with IFxx, ELSE and CASxx, it terminates execution of the Do Block. When used with the DO, DOUxx, or DOWxx operations, it transfers control to the beginning of the Do Block. You can prematurely end execution of a Do Block by entering one or more indicators in the Indicators Field (columns 9-17) of the END operation.
Example Conventions ENDSR This internal subroutine operation ends an internal subroutine (see gures 8-7 and 8-26). Execution continues in the main program immediately after the EXSR operation that called the subroutine. If you want to branch to ENDSR within the subroutine (do not branch to it from outside the subroutine), enter a label in the Factor 1 Field. The label can be the same as a eld name. Do not use the Factor 2 and Result Fields and do not enter indicators in the Indicators Field (columns 9-17).
Example Conventions 1 2 3 4 5 6 7 678901234567890123456789012345678901234567890123456789012345678901234 415 425 435 445 ICUST I I I I I C C C C C C C C C C C AA NAMEA REPEAT 50 50 50 60 OMAILER O O O O O 1 21 31 41 46 1 COUNT RES1 E . . COMP NAME TAG EXCPT ADD COUNT COMP 5 GOTO REPEAT ADD RES2 . . NAME STREET CITY STATE ZIP 20 30 40 45 50 NAME STREET CITY STATE ZIP 50 COUNT 10 RES3 52 60 20 30 40 45 50 Figure 8-24.
Example Conventions same EXCPT Name for more than one record. The maximum number of EXCPT Names that you can use in a program is 245. When EXCPT is executed, the exception lines are written only if the conditioning indicators are satis ed and if the record belongs to the le named in the Factor 2 Field (if Factor 2 is used). Example Figure 8-25 shows how to use le and EXCPT Names to write additional records to the output les LIST and OUTFILE.
Example Conventions EXIT This external subroutine operation executes an external subroutine. When the subroutine nishes, control returns to the next executable operation in sequence. Enter the external subroutine name in the Factor 2 Field. It can contain up to six characters. Do not use the Factor 1 and Result Fields. The RPG program can share data with the external subroutine in two ways.
Example Conventions EXSR This internal subroutine operation starts the execution of an internal subroutine (see gures 8-7 and 8-26) You can enter this operation anywhere in the program. When the subroutine is nished, control returns to the operation following EXSR. Enter the name of the subroutine to execute in the Factor 2 Field. This name must be de ned in the Factor 1 Field of the BEGSR operation in the subroutine. Do not use the the Factor 1 and Result Fields.
Example Conventions FNDJW This system operation locates a JCW in the system JCW table and returns its value. This operation uses the system intrinsic FINDJCW. To use FNDJW, leave the Factor 1 Field blank and enter the name of the JCW you want to locate in the Factor 2 Field. The name can be contained in an alphanumeric variable or literal. It must begin with a letter. In the Result Field, enter the eld where you want to store the returned JCW value. The eld must be numeric with no decimal positions.
Example Conventions FORCE This le operation lets you name the le from which the next record is selected for processing. The record is selected at the beginning of the next logic cycle (the FORCE operation is in e ect only for that cycle). You can use FORCE to alter the normal multi le processing sequence. Do not use FORCE for the rst record read by the program. To use the FORCE operation, enter the name of the le you want to process next in the Factor 2 Field. Leave the Factor 1 and Result Fields blank.
Example Conventions IFxx This structured programming operation performs the associated block of operations (Do Block) immediately following it if Factor 1 and Factor 2 meet the criteria speci ed by xx. Table 8-11. IFxx Operations Enter this operation: To perform the Do Block if Factor 1 is: IFEQ Equal to Factor 2. IFGE Greater than or equal to Factor 2. IFGT Greater than Factor 2. IFLE Less than or equal to Factor 2. IFLT Less than Factor 2. IFNE Not equal to Factor 2.
Example Conventions You can enter a eld name or a literal in the Factor 1 and Factor 2 Fields. Numeric elds are aligned by decimal point before they are compared. Shorter elds are padded with zeros (to the left and right) to make them the same size. Blanks in numeric elds are treated as zeros. The maximum numeric eld length is 15 digits. Alphanumeric elds are aligned starting with their high-order (leftmost) characters. Shorter elds are padded with blanks (on the right) to make them the same size.
Example Conventions INTR This system operation lets you call MPE intrinsics directly from an RPG program. Specify the name of the intrinsic beginning in the Factor 2 eld, continuing through the Result Field (columns 33-48) if necessary. You can call only intrinsics whose names are 16 characters long or less. To pass parameters to the intrinsic, follow the INTR operation statement with an IPARM operation statement for each parameter.
Example Conventions Alpha-Binary Data Even though a parameter for an intrinsic may be de ned in the MPE/iX Intrinsics Reference Manual as a numeric data type (i.e. integer, double, or real), you do not have to assign a numeric eld to hold the data in your RPG program unless you want to use it in an arithmetic calculation. When you assign a numeric eld, RPG automatically converts the values from binary format (which the intrinsics use) to packed decimal (which RPG uses).
Example Conventions RPG/iX does not support the following: intrinsics that require passing pointers to a procedure user-supplied addresses of items (RPG/iX determines all reference addresses) parameters de ned as sets Examples Following are examples of RPG source segments that use the INTR and IPARM operations to call intrinsics.
Example Conventions 1 2 3 4 5 6 7 678901234567890123456789012345678901234567890123456789012345678901234 H FOUTPUT E E E C C C C C C C C C C C C C C C C C C C C C C C C C C C 22 C C C C C C C OOUTPUT O O D F 80 $STDLST DATERR 2 5 0 CMND 6 1 DATBUF 28 1 MOVE *ZERO DATE SETON DATE INTR CALENDAR DATE DSPLY Z-ADD0 YEAR Z-ADD0 MONTH Z-ADD0 DAY Z-ADD0 WKDAY INTR ALMANAC IPARM DATE IPARM DATERR IPARM YEAR IPARM MONTH IPARM DAY IPARM WKDAY DATE DSPLY DATERR,1 DSPLY YEAR DSPLY MONTH DSPLY DAY DSPLY WKDAY DSPLY MO
Example Conventions LOCK, UNLCK These le operations let you conditionally or unconditionally lock and unlock TurboIMAGE, KSAM, and MPE les. You can lock TurboIMAGE les at the database, data set, or record level. You can lock KSAM and MPE les at the le level. (For all of these le types, MPE/iX performs page level locking automatically.
Example Conventions (not enclosed in quotes) in the Result Field. This is the name entered in columns 60-65 of the Database Name (IMAGE) line of the File Description Speci cation Continuation line. Enter a number from 1 to 256 in the Field Length Field (columns 49-51). This number is required for compatibility with other RPG implementations but is not used. Enter an indicator in the High Resulting Indicators Field (columns 54-55) to perform conditional locking.
Example Conventions Table 8-13. How Resulting Indicators Are Set For LOCK/UNLCK (TurboIMAGE Files) Resulting Indicator Turned ON High (conditional locking only). LOCK Database Database locked or contains locks (TurboIMAGE status 20). LOCK Data Set LOCK Record UNLCK Database locked or contains locks (TurboIMAGE status 20). Exceptional error Database locked or (TurboIMAGE contains locks (TurboIMAGE status status > 0). 20). Data set locked by another process (TurboIMAGE status 22).
Example Conventions KSAM Files You can lock KSAM les at the le level. To monitor the locking and unlocking of KSAM les from a terminal, use the KSAM utility, KSAMUTIL. For complete information about KSAMUTIL, see the KSAM/3000 Reference Manual . You can lock a KSAM le at the le level only if you have speci ed LOCK or NOLOCK in the Option Type Field (columns 54-59) of a File Description Speci cation Continuation line for the le. Use LOCK to lock the le and UNLCK to unlock it. Leave the Factor 1 Field blank.
Example Conventions LOKUP This table and array operation retrieves an element from a table or array and makes it available for use in subsequent operations. The element is retrieved when it satis es the search criteria that you enter. Enter the search argument (the element you're looking for) in the Factor 1 Field. It can be an alphanumeric or numeric constant, a eld name, an array element, or a table name. Enter the table or array to search in the Factor 2 Field.
Example Conventions Searching A Table To search a table that has no alternating table, use the Factor 1, Factor 2, and Resulting Indicator Fields. To condition the LOKUP operation, enter indicators in the Control Level (columns 7-8) or Indicators Fields (columns 9-17), or both. When an element is found, use the table name in subsequent operations to reference it.
Example Conventions Searching Alternating Tables This section explains how to search a table along with its alternating table. The alternating table is not actually searched, although you name it in the LOKUP operation. However, when an element is found in a table, its corresponding alternating table values become available. To search a table and its alternating table, enter the table in the Factor 2 Field and the alternating table in the Result Field.
Example Conventions Searching An Array To search an array, enter the search argument in Factor 1 and use the Resulting Indicators Fields as you would in searching a table. Do not use the Result Field. Unlike with tables, the last element in an array cannot be referenced by using the array name alone; it can, however, be referenced as noted below. Enter the name of the array to be searched in Factor 2. If you use the array name alone, the search begins at the rst element of the array.
Example Conventions MHHZO This move zone operation (Move High to High ZOne) moves the zone bits of the high-order position of Factor 2 to the high-order position of the Result Field. Both elds must be alphanumeric. The following illustration shows how this operation works. Z stands for the zone bits of each character and D stands for the digit portion. The shaded area shows the a ected characters in the Factor 2 and Result Fields.
Example Conventions MLHZO This move zone operation (Move Low to High ZOne) moves the zone portion of the low-order position of Factor 2 to the high-order position of the Result Field. Factor 2 can be alphanumeric or numeric. The Result Field must be alphanumeric. The illustrations below show how MLHZO works. The letter Z stands for the zone portion of the character, D stands for the digit portion, and S stands for the sign portion.
Example Conventions Example Table 8-15 gives examples of how MHHZO, MHLZO, MLHZO, and MLLZO work. In these examples, \|" indicates that the type of move does not apply and t stands for a blank. Table 8-15. Move Zone Operations Type of Move Factor 2 Contents Result Field before Move MHHZO Result Field after Move: MHLZO MLHZO MLLZO Alphanumeric to alphanumeric AH5SR S51T B51T S51L S51C K51T Alphanumeric to numeric AH5SR 12.3 | 12.3- 12.3+ Numeric to numeric 852.4+ 06.282- | 06.
Example Conventions MOVE This move operation moves characters from Factor 2 to the Result Field. Characters are moved beginning at the rightmost (low-order) position, continuing to the leftmost (high-order) position. If Factor 2 is longer than the Result Field, excess characters are not moved. If Factor 2 is shorter that the Result eld, excess characters in the Result Field remain unchanged. You can use this operation to convert an alphanumeric eld or constant to packed decimal format.
Example Conventions Example Figure 8-32 shows three ways to use the MOVE operation. Line 1 moves the value 12492 to each element of the array ARY. If the elements of the ARY array were de ned as ve characters long or more (the size of the value 12492), then the entire value 12492 is moved into the rightmost positions of each element. If the element size is only 1 character, then only the number 2 is moved to each element.
Example Conventions MOVEA This move operation moves the Factor 2 Field to the Result Field. Data is moved beginning at the leftmost (high-order) position, continuing to the rightmost (low-order) position. Both elds must be alphanumeric and at least one of them must be an array. Do not use the same array for both the Factor 2 and Result Fields. MOVEA lets you: Move contiguous elements from one array to contiguous elements of another. Move contiguous array elements to a single eld.
Example Conventions MSG This display operation retrieves a message from a User Message Catalog le (created by the Native Language Support, NLS or by MAKECAT) and places it in the eld that you specify. You may want to use MSG to tailor corporate report headings contained in a User Message Catalog, for example, to t a particular division's requirements. The name of the User Message Catalog le is CATALOG and it is assumed to be in your logon group and account.
Example Conventions MULT This arithmetic operation multiplies Factor 1 by Factor 2 and places the product in the Result Field. Be sure that the Result Field is large enough to hold the largest possible result. Excess digits are truncated. If Factor 1 is blank, the Result Field is multiplied by Factor 2 and the product is placed in the Result Field. MVR This arithmetic operation moves the remainder from the previous DIV operation to the Result Field.
Example Conventions 1 2 3 4 5 6 7 678901234567890123456789012345678901234567890123456789012345678901234 FTERMIN IDE V FOUTFLE O F ITERMIN AA I I I 415 425 435 445 C C C C C C C C 01 14 50 DISK 1 CO 3 9 15 READ TERMIN EXIT EXSUB PARM PARM PARM EXIT EXSUB2 PARM PARM NLR NLR OOUTFLE D O O O O O O O O 01 FLD1 FLD2 RESLT1 RESLT2 80FLD1 140FLD2 20 FLD3 LR FLD1 FLD2 RESLT1 70 FLD3 RESLT2 6 5 11 17 23 31 38 44 50 "FLD1=" "FLD2=" "RESULT=" "FLD3=" Figure 8-33.
Example Conventions $CONTROL SUBPROGRAM IDENTIFICATION DIVISION. PROGRAM-ID. EXSUB. ENVIRONMENT DIVISION. DATA DIVISION/ LINKAGE SECTION. * *NUMERIC PARAMETER DATA TYPED AS COMP-3 * 01 FLD-1 PIC S9(6) COMP-3. 01 FLD-2 PIC S9(6) COMP-3. 01 RESULT PIC S9(7) COMP-3. PROCEDURE DIVISION USING FLD-1 FLD-2 RESULT. START-LINK. ADD FLD-1 FLD-2 GIVING RESULT. DISPLAY "FLD-1= " FLD-1 " FLD-2 " FLD-2 " GOBACK. RESULT= " RESULT. Figure 8-34.
Example Conventions PUTJW This system operation locates a JCW in the system JCW table and changes its value. If the JCW does not exist, a new one is created. PUTJW uses the system intrinsic PUTJCW. To use PUTJW, enter the value to place in the JCW in the Factor 1 Field. You can use a numeric literal or eld. It must be no more than 8 digits long with no decimal places. It must contain a number in the range, 0-65,535.
Example Conventions READ This le operation reads a record from a sequential demand le (that may or may not reside on a SPECIAL device) or a full procedural le. The record is made available during the present cycle instead of the next one (FORCE makes a record available during the next cycle). READ is similar to CHAIN except that CHAIN processes les randomly. To use READ, leave the Factor 1 Field blank and enter the name of the demand or full procedural le in the Factor 2 Field.
Example Conventions READE This le operation reads the next record from an indexed demand le or a full procedural le. If the record key matches the Factor 1 Field, the record is made available for processing. To use READE, enter the name of the eld that contains the key value in the Factor 1 Field. Enter the name of the demand or full procedural le in the Factor 2 Field. Leave the Result Field blank. You can enter an indicator in the Equal Sub eld (columns 58-59).
Example Conventions RESET This le operation sets a le to its initial open condition. This operation allows you to process a le more than once without restarting the program. The le must be speci ed in the File Speci cation as an INPUT or UPDATE type with a designation of DEMAND or FULL PROCEDURAL. The le can be an MPE ( at) le, a KSAM le, or a TurboIMAGE le.
Example Conventions RLABL This external subroutine operation names a eld, table, array, or indicator to be passed to an external subroutine. RLABL is used in conjunction with the EXIT operation. Note that you cannot use or set indicators in external procedures such as user-trap routines that are not executed with the EXIT operation. Enter the eld, table, array, or general indicator (01-99) in the Result Field. To pass an indicator, enter it in this format: INxx.
Example Conventions 1 2 3 4 5 6 7 678901234567890123456789012345678901234567890123456789012345678901234 415 425 435 445 FINFILE FOUTFLE IP F O F IINFILE I I I I C C C C C C C C C C 22 AA 01 OOUTFLE O O O O O O O O D 80 50 DISK DISK 1 CO NS "MOVED" 3 9 15 RLABL RLABL RLABL RLABL RLABL RLABL SETOF EXIT EXSUB EXIT EXSUB2 DSPLY 01 FLD1 FLD2 RESLT1 RESLT2 FLD1 FLD2 RESLT1 IN22 FLD3 RESLT2 5 11 17 23 31 38 44 50 80FLD1 140FLD2 20 FLD3 70 6 22 "FLD1=" "FLD2=" "RESULT=" "FLD3=" Figure 8-37.
Example Conventions 001000$CONTROL SUBPROGRAM 001100 IDENTIFICATION DIVISION. 001200 PROGRAM-ID. EXSUB. 001300 ENVIRONMENT DIVISION. 001400 DATA DIVISION. 001500 WORKING-STORAGE SECTION. 001520 01 FLD1 EXTERNAL PIC S9(6) COMP-3. 001530 01 FLD2 EXTERNAL PIC S9(6) COMP-3. 001532 01 RESLT1 EXTERNAL PIC S9(7) COMP-3. 001534 01 FLD3 EXTERNAL PIC X(6). 001540 01 IN22 EXTERNAL PIC S9(9) COMP. 001550 88 IND-22-ON VALUE 1. 001600 PROCEDURE DIVISION. 001700 START-IT. 001800 ADD FLD1 FLD2 GIVING RESLT1.
Example Conventions SET This display operation enables the function keys (4f15 through 4f85) on the keyboard. Once enabled, they can be used with the DSPLY and DSPLM operations to set the function key indicators. If you have a terminal that supports the function key labeling feature, you can also use this operation to label the function keys. See Chapter 11, \The RPG Screen Interface (RSI)", for information about setting function key labels for RSI applications.
Example Conventions SETLL This le operation sets the lower record limit for sequential read operations in KSAM and TurboIMAGE demand les. To condition the operation, enter indicators in either or both the Control Level Field (columns 7-8) and the Indicators Field (columns 9-17). Enter a literal or eld name in the Factor 1 Field that gives the value of the lower limit. The length of Factor 1 must be the same as the key eld length for the le except when you're using partial keys.
Example Conventions Example Figure 8-41 shows how to use the SETLL operation to set the lower record limit for the le named IFILE. The lower limit is any key value greater than the value in the eld LOWLIM. 1 2 3 4 5 6 7 678901234567890123456789012345678901234567890123456789012345678901234 C LOWLIM SETLLIFILE *GT Figure 8-41.
Example Conventions SETOF This indicator and bit setting operation turns OFF the indicators that you enter in the Resulting Indicators Field (columns 54-59). You can enter from one to three indicators in the eld. Do not use the Factor 1 and Factor 2 Fields. SETON This indicator and bit setting operation turns ON the indicators that you enter in the Resulting Indicators Field (columns 54-59). You can enter from one to three indicators in the eld. Do not use the Factor 1 or Factor 2 Fields.
Example Conventions SORTA This array operation arranges array elements into ascending or descending sequence in both alphanumeric and numeric arrays. Enter the array to be sorted in the Factor 2 Field. To condition the operation, enter indicators in the Control Level Field (columns 7-8) or the Indicators Field (columns 9-17), or both. Leave all other columns blank.
Example Conventions 1 2 3 4 5 6 7 678901234567890123456789012345678901234567890123456789012345678901234 E E E ARSEQ ARSEQA ARSEQD IANYFILE NS I 415 425 C C C C 01 01 01 01 6 6 6 01 6 6 A 6 D 1 MOVE ARSEQ SORTAARSEQA MOVE ARSEQ SORTAARSEQD 36 ARSEQ ARSEQA ARSEQD Figure 8-43.
Example Conventions SQRT This arithmetic operation computes the square root of Factor 2 and places it in the Result Field. You can enter an array name in the Factor 2 and Result Fields. When you do this, the square root of each element in the Factor 2 array is placed in the corresponding element of the Result Field array. You can use half-adjust with this operation. But do not use Factor 1, and do not enter a negative value in Factor 2.
Example Conventions The suspend feature is designed for programs that are called from menu programs and the PROCMON menu processing system. Suspending saves time when switching back and forth between a menu program (or PROCMON) and an RPG program because les remain open and the RPG program does not have to be reloaded when execution starts again. When an RPG program ends or is suspended, control returns to the menu or parent process (the menu program or PROCMON).
Example Conventions TAG This branching operation labels the operation immediately following it. This allows you to skip to the operation from other places in the program. To use TAG, enter it immediately before the operation to which you want to branch. Enter a label in the Factor 1 Field. Do not enter a label that is used in another TAG operation. A TAG label can be the same as a eld name. Do not use the Factor 2 and Result Fields.
Example Conventions TESTB This compare and test operation (TEST Bit) tests the bits in a one-character, alphanumeric eld to determine if they are ON or OFF. Enter the one-character eld to test in the Result Field. Enter the bit pattern to use for testing in the Factor 2 Field. When TESTB is executed, the indicators in the Resulting Indicators Field (columns 54-59) are turned ON and OFF according to the results of the test.
Example Conventions TESTN This compare and test operation (TEST Numeric) tests an alphanumeric eld for numeric characters. You can use this operation before arithmetic or editing operations to avoid unpredictable results or program termination. When TESTN is executed, the indicators in the Resulting Indicators Field (columns 54-59) are turned ON and OFF according to the results of the test.
Example Conventions TIME This system operation returns the time of day (system) and, optionally the current date. TIME uses the system intrinsics CLOCK and optionally, CALENDAR. To use TIME, leave the Factor 1 and Factor 2 Fields blank. Enter the name of the numeric eld where you want to save the time (and optionally, the date) in the Result Field. The length of the eld that you enter determines whether the date is also returned.
Example Conventions Example Figure 8-46 shows the two ways to use TIME. Line 1 returns the time in the eld TIMEA. Line 2 returns the time and date in the eld TIMEB. 1 2 3 4 5 6 7 678901234567890123456789012345678901234567890123456789012345678901234 415 425 C C C TIME TIMEA 60 TIME TIMEB 120 Figure 8-46.
Example Conventions TIME2 This system operation extracts all or part of a formatted system date and time string and stores it in a eld in the program. TIME2 uses the DATELINE and CALENDAR intrinsics. To use TIME2, leave the Factor 1 Field blank and, in the Factor 2 Field, enter the position where extraction begins. You can use a numeric literal or eld for Factor 2. If Factor 2 is a numeric literal, it must be an unsigned number from 1 to 40 (entered in columns 33-34).
Example Conventions UNLCK See the LOCK operation. XFOOT This arithmetic operation sums all elements of a numeric array and places the sum in the Result Field. Factor 2 names the array to sum and it must be numeric. The Result Field can be a eld or an array element. If it is an element of the array entered in Factor 2, the element's value (before the XFOOT operation) is used during summing. Do not use the Factor 1 eld. You can half adjust the total in the Result Field.
Example Conventions Factor 2 (Columns 33-42) The Factor 2 eld names an operand to use in the operation. What you enter in this eld depends on the operation you're using (see the description for the operation in this chapter). Columns 33-42 Description The name of a eld, table, array, The eld containing the data or (if this is a le) the name of the le. array element, or le. Subroutine name. The internal subroutine to execute. A label. The label for a TAG, ENDSR, or GOTO operation.
Example Conventions Figurative Constants Figurative constants are prede ned names that, when used, produce one or more identical characters. The gurative constants *BLANK and *BLANKS produce one or more blanks and are used with alphanumeric elds only. *ZERO and *ZEROS produce one or more zeros and are used with either numeric or alphanumeric elds. The number of blanks or zeros produced depends on the size of the Result Field.
Example Conventions Result (Columns 43-48) The Result Field identi es the eld that contains the result of the operation. You may use a eld name that is not de ned elsewhere in the program (if you do this, enter the length of the eld in the Field Length Field (columns 49-51). Table 8-19. The Result Field Columns Value 43-48: Name of a eld, table, array, or indexed array element 43-45: Description The area where the result is stored. blank The Result Field is not used by this operation.
Example Conventions Field Length (Columns 49-51) The eld length eld speci es the number of characters in the Result Field. This eld is optional when the Result Field is de ned elsewhere in the program. (If it is already de ned, the number that you enter must be the same as the original de nition.) Table 8-20. The Field Length Field Columns 49-51 Description The length of the alphanumeric Result Field. 1-256 (right-justi ed, leading zeros are not required) The length of the numeric Result Field.
Example Conventions Decimal Positions (Column 52) The decimal positions eld speci es the number of decimal positions in the Result Field. This eld is optional when the Result Field is de ned elsewhere in the program. (If it is already de ned, the number that you enter must be the same as the original de nition.) Table 8-21. The Decimal Positions Field Column 52 0-9 blank Description The number of decimal positions in the Result Field.
Example Conventions Half Adjust (Column 53) The half adjust eld rounds numeric data when it is placed in the Result Field. Do not half adjust alphanumeric elds or use half adjusting with the MVR operation or with a DIV operation followed by an MVR operation. Table 8-22. The Half Adjust Field Column 53 Description H Half adjust data. blank Do not half adjust data. Half adjusting is only performed when the Result Field has fewer decimal positions that the result of the operation.
Example Conventions Resulting Indicators (Columns 54-59) The resulting indicators eld lets you set one to three indicators to reveal the outcome of the operation. At a later point in the program, you can then use the indicators to direct program execution. Column High Sub eld (54-55): Value 01-99, F0-F9, H0-H9, The indicator that is turned ON when KA-KN, KP-KY, L0-L9, a high condition exists (see the LR, MR, OA-OG, OV, operation for speci c information).
Example Conventions High Subfield (Columns 54-55) An indicator entered in the high sub eld is turned ON: When an arithmetic operation produced a positive (greater than zero) Result Field. In a COMP operation, when Factor 1 is greater than Factor 2. In a LOKUP operation, when the Factor 2 table or array element is greater than Factor 1. During a CHAIN operation, when a record was not found. When a TESTB operation reveals that the bits in a eld are zero.
Example Conventions Equal Subfield (Columns 58-59) An indicator entered in the equal sub eld is turned ON: In arithmetic operations, when the Result Field is zero. During the COMP operation, when Factor 1 equals Factor 2. During the LOKUP operation, when the Factor 2 table or array element equals Factor 1. When a TESTB operation reveals that the bits in a eld are all ON.
Example Conventions Comments (Columns 60-74) Enter comments of any kind in the comments eld. Program Name (Columns 75-80) The program name eld contains the program name. The format for this eld is discussed in Chapter 2. The Calculation Specification Default Summary If you leave the optional elds of the Calculation Speci cations blank, the defaults shown in Table 8-18 apply: Table 8-23.
9 Output Specifications For each output, update, and combined le in a program, you must enter an Output Speci cation. The Output Speci cation describes: The records to be written to the output le. (Use the Record Description Fields, columns 7-31, to enter record information.) The formats and locations of elds in the output records. (Use the Field Description Fields, columns 23-70, to enter eld information.
Example Conventions The Output Specification Fields The elds you can use in the Output Speci cation are described in the sections which follow in this chapter. Each eld has a unique name and occupies speci c columns in the speci cation. Sequence Number (Columns 1-5) The sequence number eld contains the source record sequence number, described in Chapter 2. Specification Type (Column 6) The speci cation type eld contains an O to identify this as an Output Speci cation.
Example Conventions File Name (Columns 7-14) The le name eld names the le to which this and subsequent Output Speci cations apply. Enter the name of an output, combined, or update le de ned by a File Description Speci cation. Columns 7-14 Description Valid le name. (File names contain from one to eight characters, beginning with a letter. The remaining characters can be letters or digits. Embedded blanks are not allowed.
Example Conventions Table 9-1. Output File Characteristics (Continued) Multirecord Access: No (0). Dynamic Locking: No (0) if no LOCK File Description Continuation line; otherwise, yes (1). Exclusive: Default (00) if no LOCK File Description Continuation line; otherwise, share (11). Inhibit Bu ering: No (0). Record Size: As speci ed in columns 24-27 of the File Description Speci cation. Default: 80 bytes. Device Name: As speci ed in columns 40-46 of the File Description Speci cation.
Example Conventions AND/OR (Columns 14-16) The AND/OR eld lets you specify additional indicators that determine whether the output record is written. (Without using AND and OR lines, the maximum number of indicators that you can use is 3.) You cannot use this eld to condition individual elds in the output record. Columns 14-16 AND OR Description Identi es this Input Speci cation as an AND line. Identi es this Input Speci cation as an OR line. You can intermix AND and OR lines.
Example Conventions Example Figure 9-3 shows how to use AND and OR lines to condition an output record. The record beginning in line 5 is written when: Indicators 01, 02, and 03 are ON (line 1). or Indicators 06, 07, 08, and 09 are ON (lines 2, 3). or Indicators 10 and 11 are ON (line 4). 1 2 3 4 5 6 7 678901234567890123456789012345678901234567890123456789012345678901234 415 425 435 445 455 O O O O O T 2 OR AND OR 01 02 03 06 07 08 09 10 11 PAYTOT 10 Figure 9-3.
Example Conventions Type (Column 15) The type eld speci es when the record is written in the logic cycle. You can enter one of the following four values: Column 15 Description D Detail record. E Exception record. H Heading record. T Total record. Within each of the above record types, records are written in the same order as their speci cations are entered.
Example Conventions Example Figure 9-4 shows heading, detail, and total records as they appear on a report. The rst two lines are heading records containing the date, a report title, a page number, and column headings. The detail records are the unshaded lines containing the division, department, name, and days absent for each employee. Total records are shaded and start with DEPARTMENT and DIVISION. They list the total number of days employees were absent within each department and division.
Example Conventions Record Addition/Deletion (Columns 16-18) The record addition/deletion eld speci es whether the record is to be added to the output le (ADD) or deleted from it (DEL). Use this eld only with output and update disk les. Columns 16-18 Description ADD Add this record to an update or output le. DEL Delete this record from an update le. Use DEL with KSAM and TurboIMAGE les only.
Example Conventions F (Fetch Over ow) When the over ow line is reached, this option immediately suspends the printing of pending detail and total records for the le until all over ow records (those conditioned by over ow indicators) are printed. Use this eld only for print les and les whose output is controlled by Line Counter Speci cations and that contain an indicator in the Over ow Indicator Field (columns 33-34) of the File Description Speci cation.
Example Conventions Space (Columns 17-18) The space eld lets you space up to three lines before and after printing the record. Use this eld only for printer or terminal records or records controlled by Line Counter Speci cations. Column Description Before (17): blank Do not space a line before printing. If this is a terminal le, or if the Skip Field (columns 19-22) is blank, single space before printing. 0 Do not space a line before printing. If this is terminal le, single space before printing.
Example Conventions If you use this eld and the Skip Field (columns 19-22) for a le, the le is assumed to be a print le and is written with forms control information (such as auto page eject). Additionally, to be considered a print le, the le must be an output, update, or combined le whose File Organization Field (column 32 of the File Description Speci cation) is not Indexed (I, S, or M) and that is blank in the AND/OR Field (columns 14-16).
Example Conventions Skip (Columns 19-22) The skip eld lets you skip to a particular line or logical printer channel before and after printing the record. Column Description Before (19-20): 01-12 Skip to this line number before printing when the Carriage Control Type Field (column 53) of the Header Speci cation contains L or 1. Skip to this Channel Number before printing when the Carriage Control Type Field (column 53) of the Header Speci cation is blank.
Example Conventions Output Indicators (Columns 23-31) The output indicators eld speci es the indicators that must be ON or OFF for the record to be written. You can condition an entire record or a eld in the record using this eld. To condition a record, enter the indicators in the record description line (see the Record Description Fields). To condition a eld, enter the indicators in the eld description line (see the Field Description Fields).
Example Conventions N (Not) The not value speci es that, for the record or eld to be written, the indicator in the associated eld (columns 24-25, 27-28, or 30-31) must be OFF. If this is a Header or Detail record (the le type is H or D), make sure that at least one indicator does not have an N associated with it; otherwise, the record is written at the beginning of the logic cycle after records conditioned by the 1P indicator.
Example Conventions L1-L9, L0 (Control-Level Indicators) Control-level indicators are turned ON when they are assigned to input elds and control breaks occur in those elds. Use them with elds and records that you want to write when control breaks occur. The L0 indicator is always ON. Use it for records or elds that you want to write at total time regardless of whether a control break occurs. If you enter both a control-level and an over ow indicator, the record is written when the over ow line is reached.
Example Conventions U1-U8 (User Indicators) These indicators, when turned ON and OFF automatically by the Job Control Word (JCW), let you condition the output of an entire le. Otherwise, you can use them like general indicators to condition the output of records and elds (you must turn them ON yourself via the SETON Calculation Speci cation operation). 1P (First-Page Indicator) The rst-page indicator is normally used to print headings on the rst page of a report.
Example Conventions Field Description Fields (Columns 32-70) The eld description elds describe the data elds within the records de ned by the Record Description Fields (columns 7-31). Enter elds on separate lines, starting with the line following the Record Description line. Leave columns 7-22 blank. You only need to de ne those elds that you want to write in the program. See Figure 9-2 for an example of how to enter Field Description Fields.
Example Conventions Columns 32-37 Description PAGE, PAGE1-PAGE7 A prede ned eld that contains the current page number for print les. *PLACE A prede ned eld that repeats the output elds de ned previously within the record description. UDATE A prede ned eld that contains the current date. UDAY A prede ned eld that contains the current day of the month. UMONTH A prede ned eld that contains the current month. UYEAR A prede ned eld that contains the current year.
Example Conventions PAGE This prede ned eld contains a number that is written whenever PAGE is used. You may use PAGE, for example, to print page numbers in a report heading. You can also use it to stamp records with a number. Normally, PAGE is set to zero during pre-cycle processing and incremented by one before it is used in an Output Speci cation. PAGE is a four-digit eld with no decimal positions. You can rede ne it so that is contains from 1-15 digits, if you wish.
Example Conventions Example The contents of four output elds (DATA1, DATA2, DATA3, and DATA4) are shown below (the character t is a blank): Field Name: DATA1 DATA2 DATA3 DATA4 Contents: ttAAA ttBBB ttCCC ttDDD Figure 9-6 shows how to use *PLACE to produce the output shown below. The elds, DATA1, DATA2, and DATA3 are repeated in the output record. Since DATA4 follows *PLACE, it is not repeated.
Example Conventions UDATE, UDAY, UMONTH, and UYEAR These elds let you include the current date, in various formats, in the utput record. Table 9-3 shows what each of the formats look like. Table 9-3. Editing Date Fields Field Name Contents Unedited Example Edited Example Description UDATE Current date. 101188 10/11/88 October 11, 1988 (Domestic Format) 111088 11/10/88 October 11, 1988 (United Kingdom Format) 111088 11.10.88 October 11, 1988 (European Format) UDAY Current day of month.
Example Conventions Edit Code (Column 38) The edit code eld lets you edit numeric output elds. You can suppress leading zeros and arithmetic signs and you can insert characters. Column 38 Description 1 Insert commas and do not zero suppress. 2 Insert commas and zero suppress. 3 Do not insert commas or zero suppress. 4 Zero suppress and do not insert commas. A Insert commas and do not zero suppress. For negative elds, append the CR (credit) sign. B Insert commas and zero suppress.
Example Conventions Column 38 Y Description Insert slashes or periods into numeric elds (normally used for date elds). Slash marks can be used with elds having three to six digits as follows: Field length: 3 4 5 6 Edited output: nn/n nn/nn nn/nn/n nn/nn/nn If the rst digit is zero, it is suppressed. If the Inverted Print Field (column 21) of the Header Speci cation contains an I or J, a period is inserted instead of a slash.
Example Conventions Examples Table 9-4 gives examples of various numbers and the e ects that the edit codes have on them. The character t represents a blank. The right brace (g) is a zero with a negative sign. Table 9-4.
Example Conventions Blank After (Column 39) The blank after eld resets the contents of a eld to blanks or zeros after it is written. Column 39 Description B Reset the contents of the eld after output. Reset numeric elds to zero and alphanumeric elds to blanks. blank Do not reset the contents of the eld after output. This eld is often used to clear control totals when control breaks occur. Subtotals can be cleared after being rolled forward to the next control level total eld.
Example Conventions End Position (Columns 40-43) The end position eld speci es the last position of the output eld. If this speci cation follows the record description speci cation for an RSI WORKSTN le, this eld may specify the length of the RSI form name. Columns 40-43 1-9999 (right-justi ed, leading zeros are not required) Description The rightmost character position of the output eld. blank The compiler calculates the end position of the output eld. (This is called the relative end position.
Example Conventions Figure 9-7 shows how to enter end positions for elds in two output records. The elds in both records are the same. The spacing between them is di erent. The elds in the disk record (DISCREC) are adjacent to each other while the elds in the print record (REPORT) are separated by intervening spaces.
Example Conventions Blank The end position of the eld is calculated by the compiler. It is calculated by adding this eld's edited length to the previous eld's end position. If the end position is blank, the compiler calculates it. (The rst character of each output record is assumed to be 1.) You can use the RSPACE option of the $CONTROL compiler subsystem command to provide xed spacing between elds.
Example Conventions ODISCREC D 01 O O O O $CONTROL RSPACE=4 OREPORT D 01 O O O O O QTY PROD DESC COST 5 13 38 41P R R R R QTY 1 PROD DESC COST J 6 18 47 58 63 "***" R R R R +002 Figure 9-9. How Relative End Positions Appear in a Compiler Listing K and RSI Form Name Length Enter a K in columns 40, 41, or 42 to indicate that this speci cation names an RSI WORKSTN le. Enter the number of characters (1-8) in the RSI form le name in column 43.
Example Conventions Packed/Binary (Column 44) The packed/binary eld speci es the format in which numeric elds are written. Do not use this eld for elds that you're going to edit. Column 44 Description 2 Write the eld in binary format, two bytes long. 4 Write the eld in binary format, four bytes long. 8 Write the eld in binary format, eight bytes long. B Write the eld in binary format.
Example Conventions Constant/Edit Word (Columns 45-70) The constant/edit word eld lets you use either a constant or an edit word when formatting a numeric eld for output. Columns 45-70 Description From 1 to 24 characters (any letters, digits, or special characters) surrounded by quotation marks. A constant (if a eld name does not appear on this line) or an edit word (if a eld name does appear on this line).
Example Conventions Example Figure 9-11 shows several constants. The constant de ned in line 1 contains quotation marks. The constant starting in line 2 is continued to line 3. 1 2 3 4 5 6 7 678901234567890123456789012345678901234567890123456789012345678901234 415 425 435 OPRINTT H O O H O O O O O O 3 01 3 02 50 "REPORT ON ""PROSPECTS""" 9 20 25 35 50 72 "LAST NAME" "FIRST NAME" "AGE" "OCCUPATION" "PERSONNEL EVALUATION BAS" "ED ON BACKGROUND CHECK" Figure 9-11.
Example Conventions Edit Words Edit words let you insert and replace characters in numeric output elds. They provide greater exibility than edit codes see the Edit Code Field, column 38). You can specify the format of the output eld, character by character. You can insert commas, decimal points, dollar signs, and other punctuation into the eld. For negative elds, you can insert a minus sign or CR and you can use a oating dollar sign and an asterisk for check protection.
Example Conventions 0 Normally, leading zeros in a data eld are replaced by blanks on output. You can stop suppression at any point by entering a zero as a replaceable character in the edit word. The zero is replaced by a character from the corresponding position of the source data eld, unless that character is also zero (in which case a blank is substituted). Any zeros in the source data eld that appear to the right of the zero suppression character are printed unaltered.
Example Conventions Other character Enter any ASCII character (not listed above) to insert into the eld. Example Several edit word examples appear in Table 9-6. The rst column shows the numbers to be edited (the numbers are positive and negative). The second column shows the edit words and the third column shows the edited results. t represents a blank. Table 9-6. Examples of Edit Words Input Edit Word 0042 "0tHRS.ttMINS.&0""CLOCK" 000000 "t,tt0.tt" 000000 "t,ttt.
Example Conventions Table 9-6. Examples of Edit Words (continued) Input Edit Word Edited Result -0000000000 "tt,ttt,tt*.tt-" **********.00 t -0000000000 "ttttttttt*&CR" **********ttt -0000000000 "ttttttt*tt&CR" -0000000000 "ttttttttt$0" -0000000000 "ttttttt$0tt&CR&GROSS" -0000000000 "$ttttttt0tt&CR&GROSS" -0000000000 "ttttttttt0&-&TOTAL" -0000000000 "tttttttttt$-&TOTAL" 0000000005 "ttt,ttt,t$9.tt" 0000000005 "ttt,ttt,&0t.tt&NET" +0000000005 "ttt,ttt,$0t.tt-*" -0000000005 "tt,ttt,tt0.
Example Conventions Table 9-6. Examples of Edit Words (continued) Input Edit Word -0000135678 "ttttttttt0" -0000135678 "tttttttttt&CR&NET" -0000135678 "tttttttttt&-&&NET" 0000135678 "tttttttttt&NET&CR" -0000135678 "tttttttttt&NET&CR" -0000135678 "$tttttttttt&-&NET" -0000135678 "ttttttt&0tt&CR" -0000135792 "tt,ttt,t*t.tt&-" -0000135678 "tt,ttt,ttt.tt&CR&&NET" -0001356789 "ttt,tttt&0.ttCR" -0034567890 "ttt,ttt,t&0.
Example Conventions The Output Specification Default Summary If you leave the optional elds of the Output Speci cations blank, the default speci cations shown in Table 9-7 apply. Table 9-7. Output Specification Defaults Columns Field 1-5 Sequence Number 16 - 18 Default Values No sequence number applies. Record For sequential or KSAM output les, write new records Addition/Deletion to beginning of the le. For TurboIMAGE output les, insert new records in the le.
10 RPG Interface to VPLUS The RPG interface to VPLUS provides functions similar to those provided by the VPLUS procedures for other languages. You can use the VPLUS interface to: Retrieve a form from a VPLUS forms le and display it at the terminal. Display a message in the window area of the terminal screen. Display initial eld values speci ed when the form was created. Accept input from the terminal. Determine if the input elds contain errors and, if so, ag them and display an error message.
Example Conventions Figure 10-1. How VPLUS Works With RPG For complete information about VPLUS, see the Data Entry and Forms Management System VPLUS/3000 manual. This manual lists an RPG general purpose data entry program that uses VPLUS. Use that program along with the one at the end of this chapter to understand how to tailor a VPLUS program to meet your speci c requirements.
Example Conventions Using the RPG Interface to VPLUS To use VPLUS in an RPG program, perform the following steps (each of the steps is explained in detail in the following sections in this chapter): 1. Create the VPLUS forms le using the VPLUS utility, FORMSPEC. 2. Specify screen-related options using the Header Speci cation. 3. Specify screen-related options and de ne the VPLUS forms le using File Description Speci cations. Optionally, you can use this speci cation to de ne VPLUS batch and trace les. 4.
Example Conventions Using FORMSPEC Before you can use VPLUS to process data from the terminal, you must create the VPLUS forms le. The forms le de nes the data elds on the screen and constants such as eld names. Create the forms le using the VPLUS utility, FORMSPEC. FORMSPEC is described in the Data Entry and Forms Management System VPLUS/3000 manual.
Example Conventions Entering File Description Specifications The next six sections explain how to de ne VPLUS les and how RPG screen-related options work with the RPG interface to VPLUS. Defining VPLUS Files To use VPLUS in an RPG program, you must de ne a terminal WORKSTN le. (You can use only one WORKSTN le in a program.) Use this le for all communication with VPLUS. To de ne a WORKSTN le, enter a le type of update in the File Type Field (column 15) of the File Description Speci cation.
Example Conventions Enabling the BREAK Key On some terminals, the 4BREAK5 key is physically positioned near the 4ENTER5 key. As a result, it is easy to press 4BREAK5 by accident. Since it is di cult to recover from a break, the 4BREAK5 key is disabled when a WORKSTN le is being used. If you need to use the 4BREAK5 key, enable it by entering a B in the Interface Control Field (column 52) of the File Description Speci cation for the WORKSTN le.
Example Conventions Using the STATUS Array The STATUS array (declared in a STATUS File Description Continuation line) is prede ned as a 6-element, 10-digit array with zero decimal places. VPLUS returns the error status in the rst element of the array. This status comes from the rst word of the VPLUS COMAREA. When you use the LOADFM action, the number of downloaded forms is returned in the second element of the array.
Example Conventions VPLUS Event Codes When the VPLUS Interface reports an event, it places the event code in the rst eld of the WORKSTN input record. Event codes 00-08 indicate that the terminal operator pressed a function key. Event code 00 indicates that the operator entered data and pressed 4ENTER5. In response to events 01-08, you must enter an action. Event codes 09-12 are responses to previous actions in the program.
Example Conventions VPLUS Input Record Formats Depending on the event, input records have one of four possible formats (as shown in Table 10-3). Each of them contains a unique code for the event and the current form name in the rst two elds. (The current form name lets you associate the data with the form in which it is entered.
Example Conventions Table 10-3. VPLUS Input Record Formats Event Code 00-08, 10 Input Field Event code (1-2) Input Field Description 00-08 and 10. Current form name (3-17) 09 Data length (18-21) The total number of characters required by all elds in the current form. Data (22-end of record) This eld is separated into sections according to the de nition of the current form. Only events 0 and 10 use this eld. Event code (1-2) 09.
Example Conventions Table 10-3. VPLUS Input Record Formats (continued) Event Code 12 Input Field Event code (1-2) Input Field Description 12. Current form name (3-17) Field number (18-22) This eld contains a unique identi er for the eld being retrieved. It does not change if the eld position in the form changes. Field length (23-26) Data (27-end of record) This eld contains the data in the returned record.
Example Conventions Entering Calculation Specifications For demand WORKSTN les, you display a VPLUS form and read the data entered into it at the terminal by entering Calculation Speci cation operations. Initiate a VPLUS action by placing its action code or mnemonic in a WORKSTN output record, then perform exception output to execute the action. When an action results in more than one VPLUS response, you must retrieve the event code for them in an input record.
Example Conventions Returning VPLUS Events You learn of an event by performing a READ Calculation Speci cation operation for the WORKSTN le. The data returned for the event is either from the terminal or is returned in response to a previous action code. Data that is returned is placed in an input record de ned for the WORKSTN le. Example Figure 10-5 shows how to return the number of edit errors encountered by VPLUS during an EDITS (59) action (see Figure 10-4).
Example Conventions Entering Output Specifications The next two sections describe the VPLUS action codes and how to de ne the output records used with them. VPLUS Action Codes The rst eld in the WORKSTN output record is the VPLUS action code (or action mnemonic). Table 10-4 lists all of the action codes that you can use with the RPG VPLUS Interface. If you're doing your own input editing (not using VPLUS FORMSPEC edits), you only need to use actions 50-57.
Example Conventions Table 10-4. VPLUS Action Codes (Continued) Action Code Mnemonic Description Corresponding VPLUS Intrinsic 55 SHOMSG Display a message in the program (with any enhancements) in the error/status line of terminal. If data in the VPLUS bu er has changed, the new data is displayed. This action is a combination of PUTMSG (action 52) and SHOW (action 53). VPUTWINDOW VSHOWFORM 56 CORERR Identify the eld that failed user edits.
Example Conventions Table 10-4. VPLUS Action Codes (Continued) Action Code Mnemonic Description Corresponding VPLUS Intrinsic 63 PUTDTA Replace the data in the VPLUS data bu er with the data that you specify. The output record contains the new data for the VPLUS bu er and the length of that data. VPUTBUFFER 64 GETDTA Move the data in the VPLUS data bu er to the program bu er. Follow this action by a READ Calculation Speci cation operation to access the data (event 10).
Example Conventions Table 10-4. VPLUS Action Codes (Continued) Action Code Mnemonic Description Corresponding VPLUS Intrinsic 72 RDBTNU Read the batch record identi ed by its record number. None 73 CLRMSG Clear the message window and, optionally, the message bu er. VPUTWINDOW VSHOWFORM 74 GETFLD Locate the speci ed eld in the VPLUS data bu er. Follow this action by a READ Calculation Speci cation operation. The returned record (event 12). contains the eld and its length.
Example Conventions VPLUS Output Record Formats The output records for actions must contain the action code (or action mnemonic). Depending on the action that you use, you may need to enter other elds as well. The output record formats and the elds used with them are described in Table 10-5. Table 10-5. VPLUS Output Record Formats Action Code 50(CHGNXT) Output Field Output Field Description Action code/Mnemonic (1-6) 50 in columns 1-2 or CHGNXT in columns 1-6.
Example Conventions Table 10-5. VPLUS Output Record Formats (Continued) Action Code 53(SHOW) Output Field Output Field Description Action code/Mnemonic (1-6) 53 in columns 1-2 or SHOW in columns 1-6. Preload option (7) P If the form is not already loaded into terminal memory, it is loaded before being displayed. blank The form is not loaded into terminal memory before being displayed. 54(RDTERM) Action code/Mnemonic (1-6) 54 in columns 1-2 or RDTERM in columns 1-6.
Example Conventions Table 10-5. VPLUS Output Record Formats (Continued) Action Code 56(CORERR) 62(BADFLD) Output Field Output Field Description Action code/Mnemonic (1-6) 56 or 62 in columns 1-2; or CORERR or BADFLD in columns 1-6. Field number (7-11) This eld identi es the eld in error so that you can enhance it. Message length (12-13) This eld speci es the number of characters in the message which is to be displayed in the message window. The length should not exceed 79 displayable characters.
Example Conventions Table 10-5. VPLUS Output Record Formats (Continued) Action Code 60(PRINT) Output Field Output Field Description Action code/Mnemonic (1-6) 60 in columns 1-2; or PRINT in columns 1-6. Print control (7) Y Underline the data eld. blank Do not underline the data eld. Page control (8) + Do not space a line. - Triple space. 0 Double space. 1 Skip to the next page. % Use the control code in columns 9-11.
Example Conventions Table 10-5. VPLUS Output Record Formats (Continued) Action Code 74(GETFLD) 75(PUTFLD) 76(LOADFM) Output Field Output Field Description Action code/Mnemonic (1-6) 74 or 75 in columns 1-2; or GETFLD or PUTFLD in columns 1-6. Field number (7-11) This eld identi es the eld to read or write. The number is assigned by FORMSPEC and does not change even when the eld is moved to another position on the screen. Field length (12-15) This eld speci es the number of characters in the eld.
Example Conventions Table 10-5. VPLUS Output Record Formats (Continued) Action Code Output Field 77(UNLDFM) Other actions Output Field Description Action code/Mnemonic (1-6) 77 in columns 1-2 or UNLDFM in columns 1-6. Form name (7-21) This eld names the form to be removed from the forms storage directory. This releases space in terminal memory. (Forms that have not recently been used are automatically removed to make room for new ones.
Example Conventions Sample VPLUS Program This section shows a program that uses the RPG VPLUS Interface. The program is a typical data entry program. Data collected from it is written to a batch le that can be used by other programs and applications. The program, shown in Figure 10-7, does the following: Displays a VPLUS form with its initial values. Reads data entered into the form by the terminal operator. Performs VPLUS and program edits on the input data. Writes the edited data to a VPLUS batch le.
Example Conventions 1 2 3 4 5 6 7 678901234567890123456789012345678901234567890123456789012345678901234 47 5 48 5 49 5 4105 4115 4125 4135 I I I I I*** EXIT KEYS (01 - 08) I BB 18 1 C0 2 I OR 1 C0 2 I OR 1 C0 2 I OR 1 C0 2 I OR 1 C0 2 I OR 1 C0 2 I OR 1 C0 2 I OR 1 C0 2 I*** NUMBER OF EDIT ERRORS I CC 19 1 C0 2 I I C1 C2 C3 C4 C5 C6 C7 C8 C9 42 62 72 74 61 71 73 78 ADDR CITY ST ZIP 3 18 17 FORMB 220NUMERR (09) C* GET NEXT FORM C START TAG C MOVEL"GETNXT" C SETON C EXCPT C* SET INITIAL VALUES
Example Conventions 1 2 3 4 5 6 7 678901234567890123456789012345678901234567890123456789012345678901234 4145 4155 4165 4175 4185 4195 4205 C* IF ENTER - EDIT DATA C 10 MOVEL"EDITS " ACTION C 10 SETON 35 C 10 EXCPT C 10 SETOF 35 C* DETERMINE NO.
Example Conventions 1 2 3 4 5 6 7 678901234567890123456789012345678901234567890123456789012345678901234 4215 4225 4235 4245 4255 C* WRITE DATA FROM BUFFER TO BATCH FILE C MOVEL"WRTBAT" ACTION C SETON 35 WRTBAT - 66 C EXCPT C SETOF 35 C* C* CHECK NEXT FORM FOR STATUS CHANGE C MOVE " "NXTFRM 15 C MOVEL" "NXTFRM C MOVELFORMB NXTFRM C MOVE "0" RPTAPP 1 C MOVE "0" FRZAPP 1 C SETON 38 CHGNXT - 50 C EXCPT C SETOF 38 C* C* RETURN TO STEP 1 C SETOF 011018 C SETOF 19 C GOTO START C* C* END OF PROCESSING C EXIT T
Example Conventions 1 2 3 4 5 6 7 678901234567890123456789012345678901234567890123456789012345678901234 O O O O O E 38 NXTFRM RPTAPP FRZAPP 6 "CHGNXT" 21 22 23 Figure 10-7. A Program that Uses VPLUS (Continued) Comments 4 15 4 25 This Header Speci cation directs RPG to save dump information in the le DUMPFILE if run-time errors occur. This line de nes the WORKSTN (terminal) le TRANSFIL. Column 15 is U to specify an update le type. You must use this le type with VPLUS.
Example Conventions 4 45 This line de nes the VPLUS batch le used in the program. (This line is optional.) Columns 54-59 specify that this is a BATCH File Description Continuation line. 4 55 Columns 60-74 name the batch le BATCHA. This line de nes the VPLUS trace le used in the program. (This line is optional.) Columns 54-59 specify that this is a TRACE File Description Continuation line. 4 65 4 75 4 85 4 95 4105 4115 4125 4135 4145 4155 4165 4175 4185 Columns 60-74 name the trace le TRACEFL.
Example Conventions 4195 4205 4215 4225 4235 4245 4255 Using CORERR (action 56) indicate which elds failed the user edits and display the form with these elds. If the program bu er contains a message for the window, display it with the form. Action 56 is followed by a demand READ. If the event returned is 00, terminal operator entered corrections and pressed 4ENTER5. Repeat Steps 18 and 19 until all data passes the user edits. Transfer the edited data to the VPLUS bu er using PUTDTA (action 63).
11 RPG Screen Interface (RSI) The RPG Screen Interface (RSI) lets you read and display data on a terminal using the entire screen. RSI is an alternative to the RPG interface to VPLUS. To use the RPG interface to VPLUS, you must enter action and event operations in the Calculation Speci cations which may seem di erent and cumbersome. RSI lets you use the screen in a way that is similar to performing other RPG input and output functions and it requires just a small amount of additional code to use.
Example Conventions Using the RPG Screen Interface (RSI) To use RSI in an RPG program, perform the following steps (each of the steps is explained in detail in the following sections in this chapter): 1. Create the RSI forms le using the RPG utility, SIGEDITOR. 2. Specify screen-related options and de ne the RSI forms le using File Description, Input and Output Speci cations. 3. If necessary, you can enter Calculation Speci cations to perform auxiliary processing for the RSI le.
Example Conventions Using the RSI Application Help Facility The RSI application help facility consists of \help areas" and \help forms." Both are created using the SIGEDITOR. (See the RPG Utilities Reference Manual .) The SIGEDITOR can also create help areas from IBM \H" speci cations. Help areas are imaginary boundaries that are overlayed on the application form. Up to 256 help areas are allowed on an individual application form.
Example Conventions Table 11-1. RSI File Description Specifications Speci cation Type File Descriptionn(F) Field Value File Name(columns 7-14) The name of the RSI le. File Type (column 15) U (update). File Designationn(column 16) P (primary) or D (demand). Record Format (column 19) V (variable-length records). Logical Record Length (columns 24-27) The length of the longest record de ned in the Input and Output Speci cations. Device Class Name (columns 40-46) WORKSTN.
Example Conventions Example Figure 11-1 shows how to de ne an RSI forms le in the File Description Speci cation. Line 1 de nes the le WORKSTN as an RSI WORKSTN le. Line 2 de nes the RSI STATUS array #WSTN#. Line 3 names the RSI forms le, NEWLIB. 1 2 3 4 5 6 7 678901234567890123456789012345678901234567890123456789012345678901234 415 425 435 FWORKSTN UP V F F 91 WORKSTNR B KSTATUS#WSTN# KFORMS NEWLIB Figure 11-1.
Example Conventions Entering Input and Output Specifications There are two ways to enter Input and Output Speci cations for an RSI le: You can enter the speci cations yourself. You can have SIGEDITOR generate the speci cations when you de ne the form. Once the speci cations are generated, you may need to tailor them for additional requirements. Table 11-2 describes the elds in the Input and Output speci cations that relate to an RSI forms le. The elds that are optional are followed by an asterisk (*).
Example Conventions Table 11-2. RSI Input and Output Specifications (continued) Speci cation Type Output (O) (Record Description line) (First Field Description line) (Remaining Field Description lines) Field Value File Name (columns 7-14) The name associated with the WORKSTNR device. AND/OR* (columns 14-16) AND or OR to relate output indicators on consecutive lines. Type (columns 15) H (heading), D (detail), T (total), or E (exception).
Example Conventions Entering Calculation Specifications You may include Calculation Speci cations to condition operations related to RSI form processing. You can condition operations using any of the RPG indicators including the command key indicators enabled in SIGEDITOR (see the previous section \Using SIGEDITOR"). The command key indicators are turned ON when the user presses the corresponding command key. (See the next section for a description of the command keys.
Example Conventions Table 11-3 lists the command keys and the command key indicators that correspond to them. When the user presses a command key, the corresponding command key indicator is turned ON and all other command keys indicators are turned OFF. Table 11-3.
Example Conventions Using Messages with RSI If you're using messages with an RSI form and you're accessing them by message identi cation numbers or you did not merge them with the forms le in SIGEDITOR, RSI will access the message le CATALOG at run time. If CATALOG is not the le you want to use, enter an MPE FILE command to equate CATALOG to that le.
Example Conventions Sample RSI Programs This section shows two versions of a program that uses RSI. One version, shown in Figure 11-7, de nes the RSI forms le as a primary le and lets RPG process it normally in the logic cycle. The second version, shown in Figure 11-8, de nes the RSI forms le as a demand le and contains Calculation Speci cations to read and write screen data using the forms le. The sample program updates a customer information le that uses social security numbers as its key.
Example Conventions SOC. SEC. NO. 306-46-7778 NAME MARY Q. QUAIL ADDRESS MORSE GROVE, FLA ZIP CODE 339080000 PHONE NO. 813-672-1212 PRESS :ENTER: COMMAND *PRINT SCREEN f3 f4 f5 *HELP f7 f8 Figure 11-5. Form22 (Contained in RSI Forms File SAMPLIB) $SET 1 1 RECORD ALREADY EXISTS 2 RECORD DOES NOT EXIST 3 CUSTOMER INFORMATION FORM Figure 11-6.
Example Conventions 1 2 3 4 5 6 7 678901234567890123456789012345678901234567890123456789012345678901234 HDUMPFILE JF X B B N P1 1 415 FWORKSTN UP V 90 WORKSTNR B F KFORMS SAMPLIB FCUSTMASTUC F 128R 9AI 1 DISK A F KKEYFL KCUSTMST F* F* SAMPLE RSI PROGRAM USING THE WORK STATION AS A PRIMARY FILE F* 425 IWORKSTN NS 01 I* FORM21 I I I NS 02 I* FORM22 I I I I I I NS ICUSTMASTNS I I I I I 435 445 455 465 C C* C C C* C C C C C C C* C C 1 C1 1 C2 1 2 1 FLD1 100SSN 1 2 28 64 73 1 FLD1 27 NAME 63 A
Example Conventions 1 2 3 4 5 6 7 678901234567890123456789012345678901234567890123456789012345678901234 475 485 495 4105 C* SET INDICATORS FOR ERRORS C 80N42 SETON C N80 42 SETON C EOF TAG OWORKSTN D 1P O OR 02 O OR 01 60 O OR 01 81 O O 70 O 65 O** O D 01 80 42 O OR 01 82N42 O O SSN O NAME O ADDR O ZIP O PHONE# O* UPDATE DISK RECORD OCUSTMASTD 02 82 O SSN O NAME O ADDR O ZIP O PHONE# O* ADD DISK RECORD O DADD 02 80 O SSN O NAME O ADDR O ZIP O PHONE# O* DELETE DISK RECORD O DDEL 01 81N42 O SSN O NAME O
Example Conventions Comments 415 425 435 445 455 465 475 485 495 4105 This line and the next one de ne the RSI le called WORKSTN. It is a primary le having the forms le name SAMPLIB. This line begins the description of the record identi cation codes and input elds for the two RSI forms shown in Figures 11-4 and 11-5. This line begins the description of the input record for the le CUSTMAST. This line turns o the indicators that are used during each cycle.
Example Conventions 1 2 3 4 5 6 7 678901234567890123456789012345678901234567890123456789012345678901234 HDUMPFILE JF X B B N P1 1 415 FWORKSTN UD V 90 WORKSTNR B F KFORMS SAMPLIB FCUSTMASTUC F 128R 9AI 1 DISK A F KKEYFL KCUSTMST F* F* SAMPLE RSI PROGRAM USING THE WORK STATION AS A DEMAND FILE F* 425 IWORKSTN NS 01 I* FORM21 I I I NS 02 I* FORM22 I I I I I I NS ICUSTMASTNS I I I I I 435 445 455 465 475 1 C1 1 C2 C START TAG C SETOF C* DISPLAY & READ FIRST FORM C EXCPT C READ WORKSTN C* DETERMI
Example Conventions 1 2 3 4 5 6 7 678901234567890123456789012345678901234567890123456789012345678901234 48 5 49 5 4105 4115 4125 4135 4145 4155 C* C C* C C C C* C C C* C C C* C C C C READ RECORD FROM CUSTOMER MASTER SSN CHAINCUSTMAST SET INDICATORS FOR ERRORS; LOOP 80 N42 SETON N80 42 SETON 60 GOTO START DELETE ONLY REQUIRES FIRST FORM, 81 EXCPT 81 GOTO START DISPLAY AND READ SECOND FORM EXCPT READ WORKSTN EXECUTE REQUESTED ACTION & LOOP 82 EXCPT 80 EXCPT GOTO START EOF TAG OWORKSTN E O O 70 O 65
Example Conventions 1 2 3 4 5 6 7 678901234567890123456789012345678901234567890123456789012345678901234 O* DELETE DISK RECORD O EDEL DELREC O SSN O NAME O ADDR O ZIP O PHONE# O* END OF SOURCE STATEMENTS B B B B B 9 35 71 80 90 Figure 11-8. Processing an RSI Demand File (Continued) Comments 415 425 435 445 455 465 475 485 495 This line and the next one de ne the RSI le called WORKSTN. It is a demand le having the forms le name SAMPLIB.
Example Conventions 4105 4115 4125 4135 4145 4155 This line and the next one perform the DELETE action using exception output and an EXCPT name. Once processing is complete for this action, control skips to the beginning of the Calculation Speci cations (START). This and the next line display and read FORM22 using the EXCPT and READ operations. The EXCPT Name is used instead of indicators to control exception output.
Example Conventions Using RSI CONSOLE Files A CONSOLE le is a special RSI le that you can use for simple data collection applications, such as entering timecard data. When you use a CONSOLE le, the compiler uses SIGEDITOR to generate a forms le from the CONSOLE le's Input Speci cations. Since CONSOLE les are used for input only, do not enter Output Speci cations for them. At run time, RPG performs all of the input and output for CONSOLE les.
Example Conventions Table 11-4. RSI CONSOLE File Description and Input Specifications Speci cation Type File Description (F) Field Value File Name (columns 7-14) The name of the RSI CONSOLE le. File Type (column 15) I (input). File Designation (column 16) P (primary) or D (demand). Record Format (column 19) V (variable-length records). Logical Record Length (columns 24-27) The length of the longest record de ned in the Input Speci cations. Device Class Name (columns 40-46) WORKSTN.
Example Conventions Table 11-4. RSI CONSOLE File Description and Input Specifications (continued) Speci cation Type Field Value Input (I) (File and Record Description line) (Field Description lines) Option* (column 18) Blank if the Group Sequence Field is alphabetic; 0 if the record type is optional. Record Indicator (columns 19-20) The record-identifying indicator that identi es the form. It must be in the range 01-10 and cannot be used with more than one record type in the program.
Example Conventions Example Figure 11-9 shows how to de ne an RSI CONSOLE le. Line 1 de nes the le SCRNFL as an RSI WORKSTNC le. The lines beginning with line 2 de ne the elds in SCRNFL.
Example Conventions Entering Calculation Specifications You may include Calculation Speci cations to condition operations related to a CONSOLE le. For example, Figure 11-10 shows an ADD operation that counts the number of transactions (screens of data) entered by the data entry operator (user). Do not condition Calculation Speci cations with command key indicators (you cannot use command key indicators with RSI CONSOLE les).
Example Conventions Executing an RSI CONSOLE Program When a program that uses CONSOLE les is executed, the data entry operator (user) selects the form to display by pressing one of 10 command keys. They are the unshifted keys 1-0 and = on the top row of the keyboard as shown in Figure 11-11. Figure 11-11. RSI CONSOLE Command Keys When the user presses a command key, the form whose record indicator matches the command key is displayed.
Example Conventions Sample RSI CONSOLE Program The sample program in this section shows how to use an RSI CONSOLE le to collect weekly payroll information. For each eld in the le, the user is prompted to enter the corresponding piece of data. The program writes the payroll data to a disk le for later processing. Figure 11-12 shows what the CONSOLE le elds look like when displayed on the screen. The program itself is shown in Figure 11-13.
Example Conventions 1 2 3 4 5 6 7 678901234567890123456789012345678901234567890123456789012345678901234 415 425 435 445 455 465 $CONTROL NAME=TIMECD,GEN HDUMPFILE JF X B B N P1 1 F* F* SAMPLE CONSOLE FILE PROGRAM - TIMECARD DATA ENTRY F* FSCRNFL IP V 48 WORKSTNC B FOUTPUT O F 48 DISK ISCRNFL I I I I I I I I I I I I I C* C* C* NS 01 1 CT 2 CC 1 3 9 15 19 23 27 30 33 36 39 42 45 2 RECID 8 WEDATE 140EMPNUM 182PYRATE 22 ACCTCD 261TOTHRS 291MONHRS 321TUEHRS 351WEDHRS 381THUHRS 411FRIHRS 441SATHRS 4
Example Conventions Comments 4 15 4 25 4 35 4 45 4 55 4 65 This subsystem command gives the program name and directs RPG to generate an RSI forms le from the Input Speci cations. The forms le name is TIMECDFM which is the program name with an FM appended. (You can also enter the program name in the Program Name Field (columns 75-80) of the Header Speci cation.) This line de nes the CONSOLE le SCRNFL. It is an input primary le with a record length of 48.
Example Conventions Using Different Terminals If the terminal that you're using is not a 239x, 262x or 264x terminal or if you're using a non-English keyboard, you must de ne the characters that represent the command keys. Enter one character for each command key into the rst 24 characters of the rst record in the le CMDKEYS. Enter the ASCII representation of the key(s) on the keyboard. You can create or modify CMDKEYS using any text editor, such as EDITOR.
Example Conventions To set suspend mode and leave both the forms and function keys unaltered when the program resumes (to perform all of the functions discussed above), enter this command: :SETJCW RPGSUSP=7 For additional information on the JCW RPGSUSP, see \Suspending an RPG Program" under the SUSP Calculation Speci cation operation. Note If your program behaves abnormally when running with RPGSUSP = 3, 5 or 7, the forms or function keys may have been altered while the program was suspended.
12 RPG Compiler When you compile an RPG program, the compiler reads the source program le and produces either a relocatable object le (intermediate form of an object program that must be converted to executable form by HP Link Editor/iX) or an executable program le (the form of an object program that is directly executable). When a program is compiled, a list le is produced which contains the source program listing and informational, error and warning messages.
Example Conventions 1 2 3 4 5 6 7 678901234567890123456789012345678901234567890123456789012345678901234 $CONTROL (Compiler subsystem command optional) H (Header Specification optional) F F F (File Description Specifications optional) E (File Extension Specification optional) L (Line Counter Specification optional) I I I (Input Specifications optional) C C C (Calculation Specifications optional) O O O (Output Specifications optional) Figure 12-1.
Example Conventions The Compiler Commands The compiler commands are MPE/iX commands that compile and execute RPG programs. You can use the compile commands in a job le (job mode) or interactively (session mode). They are used at the MPE/iX system prompt (:). The compiler commands are listed below and are described later in this chapter: Compiler Command Description :RPGXL :RPGXLGO :RPGXLLK Compiles an RPG source program.
Example Conventions Listing the Compiler Version Number You can list the compiler version number (number of the currently installed RPG compiler and run-time library) by entering a RUN command with the following format: 2 2 :RUN RPGXLC .PUB .SYS 33 G ; INFO="VERSION" [;LIB= ] P If you omit the LIB parameter, the RPG run-time library in the system XL (Segmented Library in PUB.SYS) is used.
Example Conventions Table 12-1. Source Program File Characteristics FOPEN Formal File Designator: RPGTEXT. Foptions: (%7) Domain: New le (00) or old user le (11). ASCII/BINARY: ASCII (1). Default File Designator: Formal le designator (000). Record Format: Fixed length (00). Carriage Control: No (0). Label Option: Standard label processing (0). Disallow File Equation: Disallow (1) if not speci ed; allow (0) if speci ed. Aoptions: Access Type: Input only (0000). Multirecord Access: No (0).
Example Conventions The Relocatable Object File When you compile a program using the :RPGXL command, RPG produces a relocatable object le. Relocatable object les are not directly executable. You must use the MPE/iX LINK command (see the HP Link Editor/iX Reference Manual ) to create an executable program le for it. You must produce a relocatable object le when you want to save the program as a permanent le.
Example Conventions Table 12-2. Relocatable Object File Characteristics (Continued) Dynamic Locking: No (0). Exclusive: Exclusive (0). Inhibit Bu ering: No (0). Record Size: 128 words. Device Name: MPE default. Forms Message: None. User labels: None written. Block Factor: MPE default calculations. Number of Bu ers: 2. File Size: 400 (if $NEWPASS) or 4000. Number of Extents: 2 (if $NEWPASS) or 8. Initial Allocation of Extents: 1 extent. File Code: 1461 (NMOBJ).
Example Conventions The List File The compiler uses the list le for all listing output. This includes source, symbol table and Cross-Reference listings, input prompts (in session mode) and error and warning messages. If the list le is not assigned to $STDLIST (the standard listing device), the following information is written to it: The HP product number, version letter, update and x levels of the compiler (beginning of compilation).
Example Conventions Table 12-3. List File Characteristics (Continued) Dynamic Locking: No (0). Exclusive: Default (00). Inhibit Bu ering: No (0). Record Size: Device record size. Device Name: MPE default. Forms Message: None. User labels: None written. Block Factor: MPE default calculation. Number of Bu ers: 2. File Size: 5000 (if device is disk). Number of Extents: 8. Initial Allocation of Extents: 1 extent. File Code: 0. FCLOSE Disposition: Permanent File (1).
Example Conventions :RPGXL This command compiles an RPG source program, producing a compiler listing and a relocatable object le. Use this command when you want to compile but not produce an executable program le. To create an executable program le from a relocatable object le, use the LINK command of HP Link Editor/iX. Syntax :RPGXL source le [,relocatable object le] [,list le] Parameters source le The name of the source program le (this can be any ASCII le).
Example Conventions :RPGXLGO This command compiles an RPG source program, producing a relocatable object le; links the relocatable object le creating an executable program le; then executes the executable program le. The executable program le is temporary and is purged when you log o . Syntax :RPGXLGO source le [,list le] Parameters source le list le The name of the source program le (this can be any ASCII le). The formal le designator for this le is RPGTEXT.
Example Conventions :RPGXLLK This command compiles an RPG source program, producing a relocatable object le. It then links the relocatable object le, producing an executable program le. Syntax :RPGXLLK source le [,executable program le] [,list le] Parameters source le The name of the source program le (this can be any ASCII le). executable program le The formal le designator for this le is RPGTEXT. The name of the le to which the executable program code is written.
Example Conventions The Compiler Subsystem Commands Compiler subsystem commands are compiler directives that let you alter the normal defaults used during compilation. For example, you can suppress the listing of warning messages. Compiler subsystem commands are part of the source program le and they are identi ed by a $ in column 6.
Example Conventions Entering Subsystem Command Parameters Most of the compiler subsystem commands have one or more parameters. They specify various command options. You can enter parameters in any order. Separate them by commas (spaces are ignored). You can enter parameters in columns up to and including column 72. If you need more space, continue the parameters on another line (see the section \Entering Subsystem Command Continuation Lines").
Example Conventions Entering Subsystem Command Continuation Lines When a subsystem command and its parameters won't t on one line, continue it onto the next line. Follow the last parameter on the line with an ampersand (&). Start the next line with a $ in column 6 and continue the parameters starting in column 7. When you use continuation lines, the compiler concatenates them beginning with the character following the $. The $ and & are replaced by spaces.
Example Conventions $CONTROL This subsystem command lets you override one or more of the listing and compiler defaults. You can place the $CONTROL subsystem command at the beginning of the source program le and also interspersed within it. You can use $CONTROL to: Restrict compiler access to the list le. Request or suppress the source program and a Symbol Table listing. De ne the number of lines per page for listing output. Print a Cross-Reference listing.
Example Conventions LINES=nnnn LIST MAP NAME=source NEWSAVE NOGEN NOINFO NOLIST NOMAP NOOVFLOCHK remains in e ect until a NOINFO parameter is encountered. If this parameter is omitted, informational messages are listed. Limits the number of lines printed on each list le page to nnnn . When page over ow occurs, the paper is advanced to top-of-form, the standard page heading is printed (followed by two blank lines) then the line that caused page over ow is printed.
Example Conventions NOSOURCE NOWARN NOVALD OVFLOCHK QUOTE= " ' Stops the listing of source text. This parameter cancels a previous SOURCE parameter. Stops the listing of warning messages. This parameter cancels a previous WARN parameter and remains in e ect until another WARN parameter is encountered. Disables numeric validation. This allows nonnumeric characters to be mixed in with digits in numeric items. Beware, since this can cause strange things to happen to your program.
Example Conventions $COPY This subsystem command enables you to copy source statements into the program from other source les or libraries. Place this command at the beginning of the program when the program contains one or more $INCLUDE or $INCLUDENOW compiler subsystem commands. See the $INCLUDE and $INCLUDENOW compiler subsystem commands for rules on using source libraries. The HP RPG/iX Programmer's Guide gives an example of how to use $COPY and $INCLUDE. Syntax $COPY Parameters None.
Example Conventions $IF This subsystem command lets you compile parts of a program rather than all of it. Place this command before and after sections of source code to turn compilation ON and OFF. $IF and $SET are used together. $SET turns up to ten software switches ON or OFF. The $IF command tests these switches and compiles subsequent code when they match. When they do not match, subsequent source code is not compiled.
Example Conventions Example The $SET subsystem command in the code below turns ON switches X4 and X5. Subsequent $IF statements turn compilation ON and OFF depending on the status of X4 and X5. Source code block 1 is compiled because the $IF test is true (X4 is turned ON). Source code block 2 is not compiled because the result of the second $IF test is false. Source code block 3 is compiled because the third $IF has no parameters. $SET $IF $IF $ $IF $ . . X4=ON,X5=ON <> . .
Example Conventions $INCLUDE This subsystem command copies source code from a source library into the source program before compilation. Place this command at the point in the source program where you want the source library facility to begin processing statements from another le. To use $INCLUDE, you must enable the source library facility by entering a $COPY subsystem command at the beginning of the main program.
Example Conventions Syntax 2 2 $INCLUDE le name .group .account 33 Parameters le name group account Names the source library le containing the source statements to be inserted. Identi es the MPE/iX group where the source library resides. Identi es the MPE/iX account where the source library resides. Example Imagine a program with the following statement in the middle of its detail Calculation Speci cations: $INCLUDE PAF105.
Example Conventions $INCLUDENOW This subsystem command copies source code from a source library into the source program before compilation. Place this command at the point in the source program where you want the library source code inserted. Unlike the $INCLUDE command, the records in the source library le named in the $INCLUDENOW command must all be of the same speci cation type. The entire le is added at the point the command appears.
Example Conventions $PAGE This subsystem command advances the compiler listing to top-of-form, then prints a heading followed by two blank lines. If you wish, you can enter a title for the heading line of the new page (and for subsequent pages). This command makes a program easier to read because it isolates blocks of code and assigns descriptive titles to them. If you do not enter a $PAGE or $TITLE command, the title is blank.
Example Conventions $SET This subsystem command enables you to compile parts of a program rather than all of it. Use this command to turn (up to 10) software switches ON or OFF. $IF and $SET are used together. $SET turns up to ten software switches ON or OFF. The $IF command tests these switches and compiles subsequent code when they match. When they do not match, subsequent source code is not compiled. Syntax $SET [Xn= Parameters OFF Xn = ON OFF [,Xn= ON OFF ] . ..
Example Conventions Example The $SET subsystem command in the code below turns ON switches X4 and X5. Subsequent $IF statements turn compilation ON and OFF depending on the status of X4 and X5. Source code block 1 is compiled because the $IF test is true (X4 is turned ON). Source code block 2 is not compiled because the result of the second $IF test is false. Source code block 3 is compiled because the third $IF has no parameters. $SET $IF $IF $ $IF $ . . X4=ON,X5=ON <> . .
Example Conventions $TITLE This subsystem command lets you specify the title to print in the heading line of the compiler listing. The title is printed on each heading line until another $TITLE command (or $PAGE command containing a new title) is encountered. This command lets you tailor the compiler listings by printing appropriate titles for them. If you do not enter a $PAGE or $TITLE command, the title is blank.
A RPG Compiler Messages This appendix lists the messages that you may encounter when compiling a program. The next two sections explain how to nd messages in this appendix and how to determine their severity. Message Numbers Messages are listed in this appendix in order by their assigned numbers. Numbers are grouped in blocks, where most blocks correspond to a di erent speci cation type. The remaining blocks indicate general, miscellaneous, compiler, and compiler subsystem errors.
Example Conventions Message Types There are three types of compiler messages: informational, warning, and terminal error messages. They are identi ed by a letter code appended to the error number. For example, the message number 1026W is a warning message because it has the letter code W (warning) appended to the message number. Message Type Description I (Informational) Reminds you that, although coding may be valid, it may not produce intended results.
Example Conventions 0001W 0002T 0003T 0004T 0011T 0012T 0013T 0014T MESSAGE EXPECTS $ CONTINUATION, RECORD IGNORED CAUSE ACTION You did not enter a complete compiler subsystem command on this record. The compiler ignores this record. If necessary, correct the record. MESSAGE SEQUENCE NUMBER ERROR CAUSE ACTION You did not enter the records making up the source program in the proper sequence (as indicated by the Sequence Number Field, columns 1-5).
Example Conventions 0030W 0040T 0041T 0042T 0049T 0050T 0051T 0052T 0053T MESSAGE UNABLE TO CREATE RPGCOPY PROCESS. NO PREPROCESSING DONE CAUSE ACTION RPGCOPY.PUB.SYS could not be run by the compiler. Ensure that a current version of RPGCOPY exists in the PUB group of the SYS account and recompile. MESSAGE CANNOT CLOSE SOURCE FILE FOR $COPY PROCESSING CAUSE ACTION Compiler error. Contact HP Support Engineering. MESSAGE CANNOT RE-OPEN SOURCE FILE AFTER $COPY PROCESSING.
Example Conventions 0058T 0060T 0061T 0063T 0070T MESSAGE ERROR OPENING COMPILER 'RPGTAB' FILE CAUSE ACTION File system error occurred when opening the RPGTAB le. Refer to the File Information Display for the actual le system error that occurred and take appropriate action. MESSAGE END OF FILE FOR COMPILER COPYLIB FILE CAUSE ACTION Compiler error. Contact HP Support Engineering. MESSAGE END OF FILE FOR COMPILER 'RPGLIST' FILE CAUSE ACTION RPGLIST is too small to hold all output records.
Example Conventions 0078T 0080T 0081T 0082T 0083T 0088T 1001W 1002W MESSAGE ERROR ACCESSING COMPILER 'RPGTAB' FILE CAUSE ACTION File system error occurred during the use of the RPGTAB le. Refer to the File Information Display for the actual le system error that occurred and take appropriate action. MESSAGE ERROR CLOSING COMPILER COPYLIB FILE CAUSE ACTION File system error occurred when closing a le speci ed on the $INCLUDE line.
Example Conventions 1003W 1004W 1005W 1006W MESSAGE COLUMN 15 (DEBUG OPTION) NOT BLANK OR 1, ASSUME 1. CAUSE ACTION You speci ed a character other than 1 in the Debug Field (column 15). The compiler ignores your entry and assumes you entered a 1, specifying execution of DEBUG operations. If you do not want DEBUG operations, correct this record. MESSAGE COLUMNS 18-19 NOT BLANK, ASSUME BLANK. CAUSE ACTION You entered data in columns 18-19 (not used in RPG).
Example Conventions 1011W 1012W MESSAGE COLUMN 40 (SIGN CHECK) NOT BLANK, B, S, I, O, OR N, ASSUME BLANK. CAUSE ACTION You entered a character other than a blank or B, S, I, O, or N in the Sign Process Field (column 40). The compiler ignores your entry and assumes you left the eld blank, specifying sign-forcing on output. If you want other sign-forcing or no sign-forcing, specify S, I, O, or N. MESSAGE COLUMN 41 (1P FORMS POSITIONING) NOT BLANK OR 1, ASSUME 1.
Example Conventions 1018W 1019W MESSAGE COLUMN 52 (CROSS REFERENCE) NOT BLANK OR X, ASSUME X. CAUSE ACTION You entered a character other than X in the Cross-Reference Listing Field (column 52). The compiler ignores your entry and assumes you entered an X, for printing a Cross-Reference listing. If you do not want a Cross-Reference listing, enter a blank in column 52. MESSAGE COLUMN 53 (CARRIAGE CONTROL TYPE) NOT BLANK OR L, ASSUME L.
Example Conventions 1024W 1025W MESSAGE COLUMN 58 (RUN TIME ERROR OPTION) NOT BLANK OR 1-5. CAUSE ACTION You entered a character other than 1-5, in the Error Response Field (column 58). The compiler ignores the entry and assumes you entered a 5, for redirecting or suppressing error messages, printing a dump and ending the program. MESSAGE COLUMN 59 (RUN TIME ERROR OPTION) NOT BLANK, 0 OR 2-5. CAUSE You entered a character other than 0 or 2-5 in the Error Response Field (column 59).
Example Conventions 1030W 1031W MESSAGE COLUMN 64 (RUN TIME ERROR OPTION) NOT BLANK OR 0-5. ASSUME 5. CAUSE ACTION You entered a character other than 0-5, in the Error Response Field (column 64). The compiler ignores your entry and assumes you entered a 5, for redirecting or suppressing error messages, printing a dump and ending the program. MESSAGE COLUMN 65 (RUN TIME ERROR OPTION) NOT BLANK, 0, OR 2-5. CAUSE You entered a character other than 0 or 2-5, in the Error Response Field (column 65).
Example Conventions 1036W MESSAGE COLUMN 70 (RUN TIME ERROR OPTION) NOT BLANK, 0, OR 2-5, ASSUME 5. CAUSE You entered a character, other than 0 or 2-5, in the Error Response Field (column 70). The compiler ignores your entry and assumes you entered a 5, for redirecting or suppressing error messages, printing a dump and ending the program. ACTION 1037W MESSAGE COLUMN 71 (RUN TIME ERROR OPTION) NOT BLANK OR 0-5, ASSUME 5.
Example Conventions 1044W MESSAGE COLUMN 27 NOT BLANK, ASSUME BLANK. CAUSE You entered a character other than a blank in column 27 (not used by RPG). The compiler assumes that the entry is blank. ACTION 1045W 1046W 1047W 1048W MESSAGE COLUMN 28 (BUFCHK DEFAULTS) NOT BLANK, C, N, B, U, OR X, ASSUME BLANK. CAUSE ACTION You speci ed an incorrect entry for column 28. The compiler assumes that the entry is blank. MESSAGE COLUMN 25 (NAME LOGGING ) NOT BLANK OR L, ASSUME BLANK.
Example Conventions 1053W 2001T 2002T MESSAGE COLUMN 20 (SAVE SOURCE LINE NO'S) NOT BLANK OR N. ASSUME BLANK. CAUSE ACTION You speci ed an incorrect entry for column 20. The compiler assumes that the entry is blank. MESSAGE FILE NAME PREVIOUSLY DEFINED IN COLUMNS 7-14, SPEC IS DROPPED. CAUSE ACTION You assigned the le name used in the File Name Field (columns 7-14) in a previous File Description Speci cation. The compiler ignores the speci cation. Correct the le name and recompile.
Example Conventions 2006W MESSAGE FILE FORMAT IN COLUMN 19 IS INVALID, ASSUME F. CAUSE You entered an invalid le format in the Record Format Field (column 19). The compiler ignores your entry and assumes the records in the le are xed-length. ACTION 2007W MESSAGE INVALID BLOCK LENGTH IN COLUMNS 20-23, ASSUME EQUAL TO RECORD LENGTH. CAUSE You entered a block length in the Block Length Field (columns 20-23) other than 1-9999 or blank.
Example Conventions 2012W MESSAGE INVALID ENTRY IN COLUMN 32, ASSUME BLANK. CAUSE You entered a character other than I, X, S, T, M, 1-9, D, or C in the File Organization/Additional I/O Area Field (column 32). The compiler ignores your entry and assumes you left it blank, requesting two bu ers. ACTION 2013W MESSAGE INVALID OVERFLOW INDICATOR IN COLUMNS 33-34, ASSUME BLANK. CAUSE You entered an invalid over ow indicator in the Over ow Indicator Field (columns 33-34).
Example Conventions 2020W 2021W 2022W 2023W 2024W MESSAGE COLUMN 67 IS NOT BLANK. CAUSE ACTION This column is not used, but you entered a character in it. The compiler assumes that this column is blank. MESSAGE COLUMN 70 IS NOT BLANK. CAUSE ACTION This column is not used, but you entered a character in it. The compiler assumes that this column is blank. MESSAGE COLUMN 73-74 ARE NOT BLANK. CAUSE ACTION This column is not used, but you entered a character in it.
Example Conventions 2028W MESSAGE END OF FILE ENTRY IN COLUMN 17 INVALID FOR FILE TYPE. CAUSE You entered a character in the End-of-File Field (column 17) for le type O or D, or for le designation C, T, or D. The compiler assumes you entered a blank. ACTION 2029W MESSAGE ENTRY IN COLUMN 18 INVALID FOR TYPE OF FILE OR MODE OF PROCESSING, ASSUME BLANK.
Example Conventions 2035I MESSAGE NO FILE DESCRIPTION SPECIFICATION FOUND. CAUSE You did not enter a File Description Speci cation in the source program. The compiler assumes that no le I/O will be used by the program. ACTION 2036W MESSAGE NO PRIMARY FILE SPECIFIED IN COLUMN 16, ASSUME FIRST SECONDARY FILE AS PRIMARY. CAUSE You didn't specify a primary le in the File Designation Field (column 16). The compiler assumes that the rst secondary le is the primary le.
Example Conventions 2043W 2044I MESSAGE A RECORD ADDRESS FILE CANNOT BE A 'SPECIAL' FILE. CAUSE ACTION You speci ed a Record Address File as a SPECIAL le. The compiler assumes this le is not a special le. MESSAGE NO PRIMARY OR SECONDARY FILE SPECIFICATION IN COLUMN 16. CAUSE In a program that uses multi le input, you de ned no primary or secondary input les. Make the appropriate le de nitions and recompile the program.
Example Conventions 2051T MESSAGE MODE OF PROCESSING IN COLUMN 28 MUST BE 'R' FOR DIRECT FILE, ASSUME R. CAUSE The TurboIMAGE le is a direct-access le, but you speci ed a processing mode other than R (random). The compiler assumes you entered R. Enter the correct mode if necessary. ACTION 2052T MESSAGE RECORD ADDRESS TYPE IN COLUMN 31 MUST BE BLANK FOR SEQUENTIAL OR TAG FILE, ASSUME BLANK.
Example Conventions 2060T 2061W 2062W 2063W 2064W 2065W 2066W 2067W 2068W 2069W MESSAGE TRACE FILE NAME MUST BE NON-BLANK AND BEGIN IN COLUMN 60. CAUSE ACTION The TRACE le name is missing or does not begin in column 60. Enter the name beginning in column 60. MESSAGE WORKSTN FILE MUST BE UPDATE OR COMBINED. ASSUME UPDATE. CAUSE ACTION A le on device WORKSTN is not declared as update or combined. The compiler assumes the WORKSTN le is an update le.
Example Conventions 2070W 2071W 2072I MESSAGE KEY FIELD/RECORD ADDRESS FIELD LENGTH MUST BE ENTERED FOR THIS FILE. CAUSE ACTION No key eld length is entered for a chaining type le. Correct the program and recompile. MESSAGE KEY FIELD STARTING LOCATION MUST BE ENTERED FOR THIS FILE. CAUSE ACTION No key eld starting location is entered for a chaining le. Correct the program and recompile. MESSAGE DEVICE NAME NOT LEFT-JUSTIFIED IN FIELD, ASSUME JUSTIFIED.
Example Conventions 2077W MESSAGE LOCKING MODE INCONSISTENT, MODE FOLLOWING FIRST LOCK MODE ARE DIFFERENT; ASSUME FIRST MODE. CAUSE You speci ed di erent locking modes following an initial locking mode. This sequence is invalid. Correct the program for locking mode consistency and recompile. ACTION 2078T MESSAGE LOCKING MODE IS INCONSISTENT, FIRST MODE IS S, THE FOLLOWING MODE IS B. CAUSE You speci ed di erent locking modes following an initial locking mode.
Example Conventions 2085W MESSAGE BUFCHK SPEC ONLY ALLOWED FOR SEQUENTIAL, DIRECT, AND INDEXED FILES, SPEC IS DROPPED. CAUSE You speci ed a BUFCHK Continuation line for a le that is not a sequential, direct, or indexed le. The compiler ignores the BUFCHK Continuation line. ACTION 2086W MESSAGE BUFCHK SPEC COLUMN 60 (CURRENT DATA CHECK) MUST BE BLANK OR N, ASSUME BLANK. CAUSE You speci ed an incorrect entry for column 60. The compiler assumes blank.
Example Conventions 2093W 2094I MESSAGE FORMS DOWN-LOAD VALUE IN COLUMNS 60-62 MUST BE 1-255, ASSUME 1. CAUSE ACTION You speci ed an incorrect entry for columns 60-62 (the entry may not be right-justi ed). The compiler assumes 1. MESSAGE BUFCHK 'CURRENT DATA CHECK' DISABLED FOR IMAGE FILE. CAUSE You speci ed a BUFCHK Continuation line for a TurboIMAGE le. This sequence is invalid. The compiler disables the CURRENT DATA CHECK option for this le speci cation.
Example Conventions 3002T 3003W 3004T MESSAGE FROM FILENAME (COLUMNS 11-18) INVALID OR UNDEFINED - RECORD IGNORED. CAUSE ACTION You entered an invalid or unde ned le name in the From File Name Field (columns 11-18). (An unde ned le name is one that does not appear in the File Description Speci cations.) De ne the correct From File Name and recompile. MESSAGE E NOT SPECIFIED ON FILE DESCRIPTIONS FOR FROM FILE.
Example Conventions 3009T MESSAGE TO FILE NOT A CHAINED OR RANDOM FILE - RECORD IGNORED. CAUSE You did not specify a chained or direct-access le in the To File Name Field. Specify the correct type of le and recompile. ACTION 3013T MESSAGE RECORD ADDRESS FILE PREVIOUSLY SPECIFIED ON EXTENSION SPECIFICATION - RECORD IGNORED. CAUSE You speci ed a record address le in a previous File Extension Speci cation. Set up program so that there is only one record address le.
Example Conventions 3019W MESSAGE FIELD SIZE OF 1 NOT ALLOWED WITH L OR R SPECIFIED IN COLUMN 43 - 2 ASSUMED. CAUSE You speci ed a eld size of 1 in the Entry Length Field (column 40-42) with an L or R format in the Data Format Field (column 43). The compiler ignores your entry and assumes you speci ed a eld size of 2 characters. Specify a eld size of at least 2 characters. ACTION 3020T MESSAGE FIELD SIZE (COLUMNS 40-42) BLANK OR INVALID - 1 ASSUMED.
Example Conventions 3025T 3026T 3027T MESSAGE FIELD NAME (COLUMNS 27-32) BLANK OR INVALID - ENTRY IGNORED. CAUSE ACTION You entered an invalid table or array name or left the Table/Array Field (column 27-32) blank. The compiler ignores your entry. Enter a valid eld name and recompile. MESSAGE BINARY FIELD NOT LENGTH 5 OR 10. CAUSE ACTION You speci ed a binary eld which is neither 5 or 10 digits long. Rede ne the eld so that it is either 5 or 10 digits long.
Example Conventions 3032T MESSAGE NUMERIC FIELD SIZE GREATER THAN 15 - ASSUME 15. CAUSE You entered a numeric eld size in the Entry Length Field (columns 40-42 or columns 52-54) greater than 15 digits. The compiler ignores your entry and assumes you entered 15 digits. Either de ne this eld as an alphanumeric eld or change the number of digits to 15 or less. ACTION 3033W MESSAGE DECIMAL POSITIONS (COLUMN 56) INVALID - ASSUME NUMERIC WITH ZERO DECIMAL POSITIONS.
Example Conventions 3038T MESSAGE TABLE/ARRAY NAME (COLUMNS 46-51) PREVIOUSLY DEFINED - RECORD IGNORED. CAUSE You previously used this table or array name in the Alternating Table/Array Name Field (columns 46-51). The compiler ignores the record entry; change the name and recompile. ACTION 3039W 3040W MESSAGE NO EXTENSION SPECIFICATION FOR FILE WITH E IN COLUMN 39 OF FILE SPECIFICATION.
Example Conventions 4001W 4002W MESSAGE INVALID, MISSING, OR UNDEFINED FILENAME IN COLUMNS 7-14, SPEC IS DROPPED. CAUSE ACTION You speci ed a le name in the File Name Field (columns 7-14) that was invalid or unde ned or you omitted this le name completely. Include the correct le name and recompile. MESSAGE FILENAME IN COLUMNS 7-14 DOES NOT REFER TO 'L' EXTENSION CODE.
Example Conventions 4007W 4008W 4009W 4011W 4012W MESSAGE OVERFLOW LINE EXCEEDS FORM LENGTH; ASSUME FORM LENGTH. CAUSE ACTION You speci ed an over ow line in the Line Number Field (column 20-22) that exceeds the form length in the previous Line Number Field (columns 15-17). The compiler assumes that the form length line and over ow line are equal. MESSAGE LINE NUMBER ENTRY IS INVALID, PREVIOUS SPEC. OR DEFAULT IS USED. CAUSE ACTION You speci ed an invalid line number.
Example Conventions 4017W 4018W 5001T 5002T 5003T 5004T 5005W MESSAGE MULTIPLE FL USAGE; ASSUME COLS 23-24 ARE OL. CAUSE ACTION Columns 18-19 and 23-24 both contain FL. The line number in columns 20-22 is used as the OL line. MESSAGE MULTIPLE OL USAGE; ASSUME COLS 18-19 ARE FL. CAUSE ACTION Columns 18-19 and 23-24 both contain OL. The line number in columns 15-17 is used as the FL line. MESSAGE INVALID OR UNDEFINED FILENAME - DISK FILE ASSUMED.
Example Conventions 5006W MESSAGE AND/OR LINE AND NUMBER/OPTION (COLUMNS 17-18) NOT BLANK. CAUSE You entered AND or OR in columns 14-16 and on the same speci cation line you entered a value in the Number of Records Field (column 17) or Option Field (column 18). Enter the Number of Records or Option Fields on a di erent speci cation line from the AND/OR line, then recompile. ACTION 5007W MESSAGE AND LINE AND RECORD INDICATOR (COLUMNS 19-20) NOT BLANK.
Example Conventions 5014W MESSAGE NUMBER/OPTION FIELDS (COLUMNS 17-18) NOT BLANK FOR ALPHA SEQUENCE ASSUME BLANK. CAUSE You entered an option in the Option Field (column 17) or indicated the number of records in the Number of Records Field (column 18) and also speci ed an alphabetic sequence in the Group Sequence Field (column 15-16). The compiler ignores your entry and assumes you left the Number of Records Field blank.
Example Conventions 5021T MESSAGE INVALID RECORD IDENTIFICATION INDICATOR. CAUSE You used an invalid indicator in the Record Indicator Field (columns 19-20). In columns 19-20, enter one of the indicators: 01-99, F0-F9, H0-H9, KA-KN, KP-KY, L1-L9, LR, MR, OA-OG, OV, 1P, U1-U8. ACTION 5023T MESSAGE INVALID RECORD IDENTIFICATION CODE POSITION FIELD (COLUMNS 21-24, 28-31, OR 35-38) - ASSUME 1.
Example Conventions 5029T MESSAGE COLUMN 43 NOT P, B, L, R, 1-9, OR BLANK - ASSUME BLANK. CAUSE You entered a character other than a P, B, L, R, or 1-9 in the Data Format Field (column 43). The compiler ignores your entry and assumes you left the eld blank. Enter P, B, L, R, 1-9, or blank in column 43. ACTION 5030T MESSAGE FROM FIELD LOCATION INVALID - ASSUME 1. CAUSE You speci ed invalid numeric characters or embedded blanks in the From Field Position (column 44-47).
Example Conventions 5037T MESSAGE VARIABLE ARRAY INDEX (COLUMNS 53-58) IS NOT NUMERIC VARIABLE. CAUSE You speci ed a value other than a numeric variable for the variable array index in the Field Name Field (columns 53-58). Specify a numeric variable with zero decimal positions for the array index. ACTION 5038W MESSAGE VARIABLE ARRAY INDEX (COLUMNS 53-58) DOES NOT HAVE ZERO DECIMAL POSITIONS - ASSUME 0. CAUSE You speci ed a variable array index without specifying zero decimal positions for it.
Example Conventions 5043 5044T MESSAGE FIELD SIZE IS NOT A MULTIPLE OF THE NUMBER OF ELEMENTS - NEXT LOWEST MULTIPLE ASSUMED. CAUSE ACTION You speci ed an array name, and the eld size allows for several array elements plus a fraction of an array element. Correct the eld size to contain an integral number of array elements. MESSAGE ARRAY SIZE EXCEEDED - ASSUME TO END OF ARRAY. CAUSE You speci ed an array name and the eld size allows for more array elements than the array can hold.
Example Conventions 5049T 5050T MESSAGE DECIMAL FIELD LENGTH EXCEEDS 15 DIGITS - ASSUME 15. CAUSE ACTION You entered a decimal eld length that exceeds 15 digits. The compiler ignores your entry and assumes you speci ed 15 digits. Correct the From Field Position or the To Field Position Fields to re ect a digit length of 15 or less. MESSAGE DECIMAL POSITIONS EXCEED NUMBER OF DIGITS - ASSUME EQUAL TO DIGITS.
Example Conventions 5055T MESSAGE CONTROL OR MATCHING FIELD (COLUMNS 59-62) USED FOR TRAILER OR LOOK-AHEAD RECORD - ASSUME BLANK. CAUSE You assigned a control-level or matching-record indicator to a spread record trailer or a look-ahead record. The compiler ignores your entry and assumes that you left this eld blank. Change these columns to blank. ACTION 5056T MESSAGE INVALID MATCHING OR CHAINING ENTRY (COLS 61-62) - ASSUME BLANK.
Example Conventions 5061T MESSAGE COMPLETE SET OF MATCHING FIELDS NOT DEFINED FOR LAST GROUP. CAUSE When you previously speci ed matching elds in this program, you speci ed more levels of matching elds than the current de nition. Either delete the extra matching levels speci ed earlier or add levels to the current de nition. ACTION 5063T MESSAGE CHAINING (COLUMNS 61-62) SPECIFIED WITH LOOK-AHEAD FIELD - CHAINING IGNORED. CAUSE You requested chaining with a look-ahead record.
Example Conventions 5068T 5069T 5070T 5071T MESSAGE FIELD RECORD RELATION PREVIOUSLY USED IN THIS RECORD FOR CHAINING. CAUSE ACTION All chaining elds for one eld record relation were not together. Move the record so that it is among the others of the same eld record relation or delete the chaining entry (C1-C9) from this record. MESSAGE INVALID PLUS RESULT INDICATOR (COLUMNS 65-66) - ASSUME BLANK.
Example Conventions 5075T 5076T MESSAGE FIRST INPUT SPECIFICATION DOES NOT HAVE FILE NAME. CAUSE ACTION You omitted the le name from the File Name Field (columns 7-14) of the rst Input Speci cation or entered a eld description with no preceding record description. Include the le name on a record description speci cation. MESSAGE FILENAME ALREADY USED FOR INPUT SPECIFICATIONS.
Example Conventions 5082T 5083T MESSAGE INDEX SPECIFIED FOR NON-ARRAY - IGNORE INDEX. CAUSE ACTION You speci ed an index for a data eld that is not an array. The compiler ignores the index. Either include an array de nition (File Extension Speci cation) for this eld name or delete the index. MESSAGE MATCHING RECORD FILE NOT IN SAME SEQUENCE AS LAST. CAUSE A le containing matching records has a di erent sequence than the last matching record le previously speci ed.
Example Conventions 5089W MESSAGE CHAINING FIELD NUMERIC BUT ALPHA KEYS SPECIFIED ON FILE SPEC. CAUSE You speci ed a numeric chaining eld in con ict with alphanumeric searching keys for the TurboIMAGE le. Either change the eld type or the Record Address Type Field (column 31) of the File Description Speci cation. ACTION 5090W MESSAGE CHAINING FIELD LENGTH NOT SAME AS KEY FIELD LENGTH FROM FILE SPEC. CAUSE You speci ed di erent lengths for the chaining and key elds; they must be the same.
Example Conventions 5095T 5096W 5097T 5098T 5099T 5100T 5101T 5102T 5103T 6001T MESSAGE NESTED NUMERICS IN DS NOT SUPPORTED. CAUSE ACTION A numeric eld named as a data structure contains numeric sub elds. Do not use numeric sub elds in this case. Correct the program and recompile. MESSAGE FIELD ALREADY DEFINED AS PART OF A DS-RECORD IGNORED. CAUSE ACTION This eld name has already been used in this or a previous data structure. The compiler ignores this eld.
Example Conventions 6002W 6003T MESSAGE AN/OR LINE OUT OF ORDER OR INVALID, IGNORE AN/OR LINE. CAUSE ACTION You entered an AN or OR line, and the preceding line has an entry in the Operation Field or the preceding line did not have an entry in the Indicators Field. The compiler ignores this line. Put AN/OR line in proper sequence. MESSAGE EXCEEDED 24 INDICATORS OR 7 '0R' LINES. CAUSE You entered more than seven OR lines or more than 24 indicator lines in one grouping, which is not permitted.
Example Conventions 6009W MESSAGE INVALID RESULTING INDICATOR, IGNORE INDICATOR GROUP. CAUSE You entered an invalid indicator in the Resulting Indicators Field (columns 54-59). The compiler ignores this indicator and all others in the group to which it belongs. Correct the indicator and recompile. ACTION 6010W MESSAGE INVALID FACTOR 1 ENTRY IN COL. 18-27. CAUSE You entered an invalid name, label, or literal in the Factor 1 Field (columns 18-27). The compiler ignores this operation.
Example Conventions 6016T 6017W MESSAGE INVALID FILE NAME ENTRY FOR FACTOR 2 (COL. 33-42). CAUSE ACTION You entered an improper le name in the Factor 2 Field. The compiler ignores the operation. Correct the le name so that it appears as de ned in the File Description Speci cations. MESSAGE INVALID DIGIT IN RESULT FIELD LENGTH ENTRY (COL. 49-51). CAUSE You entered one or more characters other than 0-9 in the Field Length Field. Embedded blanks are illegal. The compiler ignores the eld length.
Example Conventions 6023T MESSAGE FILE NAME IN FACTOR 2 NOT DEFINED BY FILE DESC SPECS. CAUSE You entered a le name in the Factor 2 Field (columns 33-42) that is not described in the File Description Speci cations. The compiler ignores the operation. Either de ne this le name in a File Description Speci cation or use another le name. ACTION 6024W 6025W 6026W 6027W 6028W 6030W 6031W MESSAGE SET OPERATOR USAGE NOT CONSISTENT WITH WORKSTATION OPERATION. OPERATOR IGNORED.
Example Conventions 6032W MESSAGE INDICATORS IN COL. 9-17 NOT ALLOWED FOR THIS OPERATION. ASSUME BLANK. CAUSE You entered one or more indicators in columns 9-17, but this operation cannot be conditioned with indicators. The compiler assumes that you left columns 9-17 blank and performs the operation under all conditions. ACTION 6033W 6034W 6035W 6036W 6037W MESSAGE INDICATORS IN COL. 54-59 NOT ALLOWED FOR THIS OPERATION. ASSUME BLANK.
Example Conventions 6040T 6041W 6042T MESSAGE GOTO OPERATION MAY NOT BRANCH INTO OR OUT OF SUBROUTINE. CAUSE ACTION You speci ed a GOTO operation in a subroutine that transfers to an operation outside of it or vice versa. The compiler ignores the operation. Correct and recompile. MESSAGE DEC POS ENTRY GREATER THAN FIELD LENGTH. ASSUME ZERO POS. CAUSE ACTION The number of decimal positions in the eld exceeds the length of the eld. The compiler assumes that the eld contains no decimal positions.
Example Conventions 6048W 6049W 6050W 6051W 6052W 6053W MESSAGE DEC POS ENTRY (COL 52) SHOULD BE BLANK. ASSUME BLANK. CAUSE ACTION You speci ed a decimal position that should not be speci ed. The compiler ignores this speci cation. MESSAGE HALF ADJUST ENTRY (COL 53) SHOULD BE BLANK. ASSUME BLANK. CAUSE ACTION You speci ed a half adjust that should not be speci ed. The compiler ignores this speci cation. MESSAGE BEGSR STATEMENT SHOULD HAVE SR OR BLANK IN COL. 7-8; ASSUME SR.
Example Conventions 6056T 6057W 6058W 6059W MESSAGE SYMBOL NOT DEFINED. CAUSE ACTION You referenced the name of a data area or label of an operation that is not de ned in the program. De ne the symbol by naming it in the Result Field with a de ned length, by specifying it as a eld name on Input Speci cations, or by de ning it as an array. Recompile the program. MESSAGE FIELD 1 SHOULD BE ALPHANUMERIC FOR THIS OPERATION.
Example Conventions 6063W MESSAGE RESULT FIELD SHOULD BE NUMERIC FOR THIS OPERATION. CAUSE You entered an alphanumeric eld for the Result Field (columns 43-48), but a numeric eld is required. The compiler uses the eld as speci ed. Change the Result Field type and recompile. ACTION 6064W 6065W 6066W 6067W 6068W MESSAGE RESULTING INDICATOR REQUIRED IN COL 54-55; ASSUME H0. CAUSE ACTION You did not enter the required indicator in the Resulting Indicators Field (columns 54-55).
Example Conventions 6071T 6072W 6073T 6074T 6081T MESSAGE CURRENT FIELD USE INCONSISTENT WITH PREVIOUS USE. CAUSE ACTION You either used an alphanumeric eld as a numeric eld or vice-versa. Change speci cations to make all references consistent. MESSAGE FILE SPECIFIED IN FACTOR 2 NOT A CHAINING FILE. CAUSE ACTION A CHAIN operation was attempted to a le that is not a chaining le. Correct the program and recompile. MESSAGE CAN'T FORCE READ A FILE DESIGNATED BY BLANK IN COL 16 OF FILE SPEC.
Example Conventions 6085T MESSAGE LENGTH OF A VARIABLE USED TO INDEX AN ARRAY MUST BE 1 TO 9 DIGITS. CAUSE You speci ed an incorrect entry for the length of a variable. Correct the program and recompile. ACTION 6087I 6088T 6089T 6090T 6091T MESSAGE NO INDICATOR IN COL 58-59. H0 WILL BE SET ON FOR ERRORS NOT FLAGGED BY INDICATORS IN COL. 54-57.
Example Conventions 6098W 6099T MESSAGE INVALID RESULT INDICATORS FOR 'CLOSE', 'READ', OR 'MSG' OPERATOR. CAUSE ACTION One or more indicators were used in invalid locations in the Resulting Indicators Field (columns 54-59). Delete the incorrect indicator(s). MESSAGE EXTRANEOUS OR MISPLACED ELSE STATEMENT. CAUSE There are too many ELSE statements for the number of IF statements in your program. Or the ELSE statement might be after the END statement.
Example Conventions 6106T MESSAGE COULD NOT FIND THIS INTRINSIC IN SYSINTR.PUB.SYS. CAUSE The intrinsic named in an INTR operation of a Calculation Speci cation was not found the intrinsic mechanism le SYSINTR.PUB.SYS. Check the spelling of the intrinsic name used in the INTR operation. If this is a user-created intrinsic, verify that it was added to the SYSINTR.PUB.SYS le. ACTION 6107T MESSAGE TYPE MISMATCH IN IPARM OR FACTOR 1 OF INTR.
Example Conventions 6115T 6116T MESSAGE RESET OP FILE TYPE MUST BE I OR U, DESIG MUST BE D OR F. CAUSE ACTION The le named in a RESET operation does not have the proper type or designation or both. Make sure the File Speci cation type is I or U, and the designation is D or F. MESSAGE RESET OPERATOR MUST HAVE INDICATOR IN COLS 54-55. CAUSE The compiler found no indicator speci ed in columns 54-55 of a Calculation Speci cation using the RESET operation.
Example Conventions 7006T 7007I MESSAGE FILE AND RECORD ENTRIES IN COL 7-31 AND FIELD ENTRIES IN COLS 32-74 ON SAME LINE. CAUSE ACTION You entered both a record description and a eld description on the same line. Correct this error and recompile. MESSAGE NO FIELD DESCRIPTION ENTRIES FOR PREVIOUS RECORD. CAUSE You entered a record description speci cation that is not followed by eld description speci cations. Supply a eld description speci cation and recompile.
Example Conventions 7013W 7014W 7015W 7016W 7017W MESSAGE EDIT CODE INVALID WITH CONSTANT OTHER THAN '*' OR '$'. CAUSE ACTION You paired the wrong edit code with the constant that appears in columns 45-70. Correct this error and recompile. MESSAGE INVALID FIELD NAME IN COL 32-37. CAUSE ACTION You used an invalid or unde ned eld name in the Field Name Field (columns 32-37). Correct the eld name and recompile. MESSAGE INVALID LINE TYPE IN COL 15, ASSUME D.
Example Conventions 7022W 7023W MESSAGE INVALID OUTPUT INDICATOR IN COL. 24-25, 27-28, 30-31; ASSUME BLANK. CAUSE ACTION You entered an invalid indicator in the Output Indicators Field (columns 24-25, 27-28, or 30-31). Enter a valid indicator and recompile. MESSAGE INVALID FIELD LENGTH FOR Y EDIT CODE. CAUSE You speci ed a eld less than 3 or greater than 6 digits long for the Y edit code. Rede ne the eld length to 3-6 digits.
Example Conventions 7031W 7032W MESSAGE INVALID PACKED/BINARY OUTPUT ENTRY IN COL 44, ASSUME BLANK. CAUSE ACTION You made an entry to this eld that applies to alphanumeric data but the entry should apply to numeric data; or you entered a character other than P, B, L, R, 2, or 4. Correct this entry and recompile. MESSAGE OVERFLOW INDICATOR INVALID FOR AN EXCPT RECORD. CAUSE You entered an over ow indicator in the Output Indicators Field (columns 23-31) on an exception record.
Example Conventions 7039T MESSAGE END POSITION ENTRY IN COL. 40-43 FOR CONSTANT, EDIT WORD, FIELD, OR ARRAY EXCEEDS RECORD LENGTH. CAUSE You speci ed an end position for an output record that exceeds the maximum length possible for that record. (For instance, position 150 for a printer record that has 132 characters per line. Correct the end position to conform with the maximum length possible and recompile. ACTION 7040W 7041W 7042W 7043T 7044W MESSAGE CONSTANTS IN COL.
Example Conventions 7047I 7048W 7049W 7050W 7053W MESSAGE FORMS POSITIONING SPECIFIED ON CONTROL RECORD, BUT MISSING A RECORD CONDITIONED BY 1P. CAUSE ACTION You entered a 1 in the Form Positioning Field (column 41) of the Header Speci cation, but did not specify an output record conditioned by the rst-page indicator (1P). This is an informational message only, no action is necessary. MESSAGE 'ADD' IN COL 16-18 NOT ALLOWED ON AND/OR LINES, ASSUME BLANK.
Example Conventions 7057W MESSAGE TARGET LENGTH SPECIFIED BY PACKED/BINARY IN COLUMN 44 MAY BE TOO SMALL TO CONTAIN THE DATA. CAUSE You may have speci ed an output eld too short to hold the output data. Specify the proper output eld length and recompile. ACTION 7058W 7059W MESSAGE THE SKIP IN COLUMNS 19-22 MUST NOT BE BEYOND THE FORM LENGTH DEFINED ON THE LINE COUNTER SHEET. CAUSE ACTION You requested a skip to a line beyond the form length but still on the current page.
Example Conventions 7067W 7068I 7069W MESSAGE COL 16-18 NOT BLANK, 'ADD' OR 'DEL' FOR UPDATE FILE, ASSUME UPDATE OPERATIONS - NOT ADD. CAUSE ACTION You did not enter a blank, ADD or DEL in columns 16-18 for an update le. The compiler performs update operations on the le, not add operations. Correct the program and recompile. MESSAGE PREVIOUS RECORD CONTAINS NO INDICATORS FOR 'AND' RECORD. CAUSE ACTION The previous record does not have indicators in this AND sequence.
Example Conventions 8005W 8006W 8007W 8008W 8009W 8010W 8012W 8013W 8014W MESSAGE MISSING COMMA CAUSE ACTION You did not include a comma, which is expected as a separator. The compiler assumes that a comma is present. Correct and recompile. MESSAGE MISSING EQUAL SIGN CAUSE ACTION You did not include an equal sign expected after a keyword. The compiler assumes that an equal sign is present. Correct and recompile.
Example Conventions 8016I 8019W 8020W 8021W 8022W 8023W 9001I 9002W 9003T MESSAGE $SECOND '$' IGNORED. CAUSE ACTION There is a $ in column 7 of a command line. This column is not used. None, the entry is ignored. MESSAGE CONTINUATION RECORD MUST HAVE '$' IN COLUMN 6. CAUSE ACTION A Continuation line for a compiler subsystem command was found that does not have $ in column 6. The Continuation line is ignored. Correct the program and recompile. MESSAGE INVALID 'IF' PARAMETER.
Example Conventions 9004T MESSAGE CANNOT OPEN FILE SPECIFIED BY 'A' SPEC. CAUSE The system could not open the le named on the Array/Table File Name (A) Speci cation. Check to see if the le exists and determine the reason for this le error. Correct the error and recompile. ACTION 9005T 9006W 9007T 9008T MESSAGE CANNOT OPEN TEMPORARY FILE TO PROCESS COMPILE-TIME TABLE. CAUSE ACTION The compiler cannot open the temporary le for processing a compile-time table.
Example Conventions 9011W 9012W MESSAGE ILLEGAL HEXADECIMAL DIGIT IN COMPILE-TIME TABLE. CAUSE ACTION You entered an invalid hexadecimal value (other than 0-9 or A-F) in the compile-time table. This value does not represent an ASCII character. The compiler assumes that this character is zero. Correct and recompile. MESSAGE ILLEGAL OCTAL DIGIT IN COMPILE-TIME TABLE. CAUSE You entered an invalid octal value (other than 0-7) in a compile-time table. This value does not represent an ASCII character.
Example Conventions 9019W 9020W MESSAGE COMPILE-TIME TABLE ERROR - BAD DATA (INVALID DIGIT). CAUSE ACTION You speci ed invalid digits in a numeric table or array. Correct the program and recompile. MESSAGE COMPILE-TIME TABLE ERROR - TOO MANY ITEMS FOR TABLE/ARRAY. CAUSE You speci ed too many items in the compile-time table. Correct the program and recompile. ACTION 9021T 9022I MESSAGE FOR LOKUP OPERATION, STORAGE LENGTHS OF FACTOR 1 AND FACTOR 2 ARE NOT THE SAME.
Example Conventions 9030T 9031T MESSAGE RESULT FIELD LENGTH IN COLUMN 49-51 OF C SPEC MUST BE 6 OR 12 FOR TIME OPERATION. CAUSE ACTION You speci ed an incorrect entry in columns 49-51 for this operation. Correct the program and recompile. MESSAGE DECIMAL POSITIONS FOR FNDJW, PUTJW, TIME, TIME2, OR FNUM MUST BE 0. CAUSE An incorrect decimal position was speci ed for a eld in one or more of the above operations. Correct the program and recompile.
B Run-Time Messages This chapter lists the errors that you may encounter when running an RPG program. There are four types of errors. They are summarized below and are listed (except for TurboIMAGE errors) in the same order in this appendix: RPG errors These errors are detected and reported by compiler-generated code. They are displayed on the operator's console (for batch jobs) or on the terminal (for interactive sessions). The program then pauses while the operator decides what action to take.
Example Conventions RPG Errors RPG errors are detected and reported by compiler-generated code. You can specify in the program what action to take when an error occurs. You can redirect or suppress the error action. To do this, enter the appropriate values in both of these Header Speci cation elds: 1. The Error Log Field (column 55). 2. The Error Response Field (columns 56-71). The messages listed in this appendix explain the cause of the RPG error and the action you must take to correct it.
Example Conventions 1 MESSAGE FATAL FILE ERROR, FILENAME = xxxx CAUSE An operating system error (see ERROR NUMBER in the File Information Display) or an TurboIMAGE error. Determine the cause of the error from the text displayed with it and correct the program. If you need additional information, look up the error in the operating system manual or the TurboIMAGE/iX Database Management System manual. NONE (this error is processed with error number 5).
Example Conventions 4 MESSAGE INPUT SEQUENCE ERROR, FILENAME = xxxx, RECORD NUMBER = nnn CAUSE Record number nnn on the input le named xxxx is not in the proper sequence. Put the record in the proper sequence and execute the program. 58. ACTION ERROR RESPONSE COLUMN *ERROR ERROR RESPONSE ENTRIES 5 MESSAGE INDEX INVALID, LINE NUMBER =nnn, INDEX = nnn NOT EVALUATED CAUSE The array index is less than 1 or greater than the number of array elements.
Example Conventions 7 MESSAGE TABLE/ARRAY {SEQUENCE, BAD DATA, OVERFILL} FILE = xxxx, LINE NUMBER = nnn, VALUE = xxx CAUSE The table or array on le xxxx with a line number = nnn and value = xxx had a sequence, bad data or over ll error. Choose one of the error response options and correct the table or array. 61. ACTION ERROR RESPONSE COLUMN *ERROR ERROR RESPONSE ENTRIES 8 MESSAGE RECORD NOT FOUND, FILENAME = xxx, STATUS = xxx CAUSE The record sought was not found.
Example Conventions 10 MESSAGE RDEXIT ERROR, FILENAME =xxxx CAUSE The Read Exit le processing routine returned an error. Check the processing routine and make the appropriate changes. 64. ACTION ERROR RESPONSE COLUMN *ERROR ERROR RESPONSE ENTRIES 11 MESSAGE ARITHMETIC OVERFLOW, LINE NUMBER = nnn, VALUE = nnn CAUSE The arithmetic result exceeded the number of digits the eld can hold. Correct the program (make the eld size larger). 65.
Example Conventions 13 MESSAGE INVALID NUMERICAL DATA, LINENUM = nnn, FILENAME = xxxx, RECORD NUMBER = nnn, COLUMN = nnn, VALUE = nnn CAUSE Either an input eld or an alphanumeric eld, being moved to a numeric eld, contained characters other than numeric characters or embedded blanks. (FILENAME, RECORD NUMBER, COLUMN and VALUE are printed only when applicable.) Choose one of the error response options and correct the program. 67.
Example Conventions 16 MESSAGE REL REC# INVALID, FILENAME = xxxx CAUSE An attempt was made to read or write a relative record number past the end of the le or before the beginning of the le. Choose one of the error response options and correct the program. 70. ACTION ERROR RESPONSE COLUMN *ERROR ERROR RESPONSE ENTRIES 17 M. 0, 2, 3, 4, 5.
Example Conventions USWITCH Errors If you're running a program that uses the USWITCH feature (F in the USWITCH Source Field (column 16) of the Header Speci cation), you may encounter one of the following errors. Each USWITCH error is preceded by the message: ERROR IN USER SWITCH INITIALIZATION. MESSAGE I/O ERROR ON $STDLIST CAUSE An attempt to write output to a standard list device failed (this occurs when the display of a user prompt fails). The job or session terminates.
Example Conventions BUFCHK Errors The following errors may occur when you use the BUFCHK option (see the Option Type Field (columns 54-59) of the File Description Continuation line). In addition to showing the cause of the error and remedy for it, an *ERROR entry is listed for each message. *ERROR is a one-character prede ned eld that contains the error code. You can test it in Calculation Speci cations. 0-10 MESSAGE INTERNAL OR INTRINSIC ERROR CAUSE *ERROR Internal RPG error.
C ASCII and EBCDIC Character Sets Table C-1, which follows, lists the ASCII and EBCDIC character sets along with the decimal, octal, and hexadecimal values that correspond to them. The ASCII and EBCDIC characters are listed in ascending sequence according to their binary value.
Example Conventions Table C-1.
Example Conventions Table C-1.
Example Conventions Table C-1.
Example Conventions Table C-1.
Example Conventions Table C-1.
Example Conventions Table C-1.
Index A action (VPLUS), 10-3, 10-12, 10-14 code, 10-12, 10-14 output record format, 10-12, 10-18 ADD, 3-18, 8-12, 8-18 adding records to output les, 4-19, 9-9 ADDROUT le, 4-9, 4-12 alpha-binary data, 8-56 alphanumeric elds input data format, 7-21 in tables, arrays, 5-8, 5-11 testing input for blanks, 7-40 alphanumeric literal, 8-9, 8-99 Alternate Collating Sequence (ALTSEQ) records, 3-12, 4-1, 5-17, 5-19, 5-20 alternating tables de ning, 5-6, 5-10 searching, 8-65 AN(D) lines Calculation Speci cation, 8-3 I
chain, 8-25 CHAIN, 4-4, 7-30, 8-17, 8-24 chained le, 4-4, 5-5, 7-30, 8-24 chaining eld, 7-30 chaining eld code (C1-C9), 5-3, 7-30 chaining le, 5-1, 5-3, 7-30 chaining (input), 7-30 channels (printer), 3-26, 6-2 character set, C-1 ASCII, C-1 EBCDIC, C-1 CLOSE, 8-17, 8-28 CMDKEYS le, 11-9, 11-25, 11-29 coding, 4-19 collating sequence, 3-12, C-1 ASCII, C-1 EBCDIC, 3-12, C-1 EBCDIK, 3-12 JIS, 3-12 combined le type, 4-3, 4-6, 4-7, 7-2 command key indicator (KA-KN, KP-KY), 7-9, 7-38, 7-40, 9-14, 11-1, 11-2, 11-8,
ELSE, 8-16, 8-44 enabling the BREAK key (for VPLUS), 10-6 enabling the function keys (for VPLUS), 10-6 END, 8-16, 8-45 ENDSR, 8-9, 8-14, 8-46 *EQ, 8-85, 8-101 equating les, 4-30 *ERROR, 7-25, 8-9, 8-99, 9-18, 9-22 Error Dump the le used for, 3-2 when using VPLUS, 10-4 ERROR File Description Continuation line, 4-23 error message display interval (VPLUS), 10-5 errors input/output run-time, 4-23, 10-4, B-1 European format (editing), 3-9 event (VPLUS), 10-3, 10-7, 10-12, 10-13 code, 10-7, 10-12, 10-13 input rec
command key (KA-KN, KP-KY), 7-9, 7-38, 7-40, 9-14, 11-1, 11-2, 11-8, 11-24 command key (KA-KN,KP-KY), 8-6, 8-105 control-level (L0-L9), 7-9, 7-28, 7-38, 7-40, 8-3, 8-6, 8-16, 8-105, 9-14 eld, 3-18, 7-40, 9-14 rst-page (1P), 7-9, 7-38, 7-40, 8-6, 8-105, 9-14 function key (F0-F9), 7-9, 7-38, 7-40, 8-6, 8-105, 9-14 general (01-99), 7-9, 7-38, 7-40, 8-6, 8-105, 9-14 halt (H0-H9), 7-9, 7-38, 7-40, 8-6, 8-73, 8-78, 8-79, 8-105, 9-14 last-record (LR), 7-9, 7-38, 7-40, 8-3, 8-6, 8-105, 9-14 matching-record (MR), 7-
eld code (M1-M9), 7-30 les, 4-7, 7-34 matching-record indicator (MR), 7-9, 8-6, 8-105, 9-14 matching-record processing order, 7-35 message le (User Message Catalog), 8-73, 11-10, 11-11 message identi cation (User Message Catalog), 8-73, 11-10 MHHZO, 8-13, 8-67 MHLZO, 8-13, 8-67 MLHZO, 8-13, 8-68 MLLZO, 8-13, 8-68 MOVE, 8-12, 8-70 MOVEA, 8-12, 8-72 MOVEL, 8-12, 8-72 move operations, 8-12 move zone operations, 8-13 MPE le number, 8-51 MPE les, 8-62 adding records to, 4-19 direct, 4-9, 4-11, 4-12 locking and u
process (system), 8-90 PROCMON menu processing system, 8-90, 11-29 Program Name Field (columns 75-80), 2-1, 2-4 PUTJW, 8-17, 8-77 R random processing, 4-9 RDEXIT File Description Continuation line, 4-24 RDSEQ File Description Continuation line, 4-24 READ, 4-4, 8-17, 8-78, 11-8 READE, 8-17, 8-79 READP, 8-17, 8-79 record identi cation code, 3-16, 7-3, 7-19 key, 4-9, 4-10, 4-11, 4-14 length, 4-7, 4-8 length error, 3-24, 4-8 pointer, 4-30 Record Address File (RAF), 4-4, 4-9, 4-10, 4-11, 5-1 record-identifying i
SQRT, 8-12, 8-90 START File Description Continuation line, 4-41, 11-3 STATUS array RSI, 11-3, 11-5 VPLUS, 10-7 STATUS File Description Continuation line, 4-39, 4-41, 10-7, 11-3, 11-5 $STDIN (device class name), 4-16 $STDLIST, 12-8 $STDLST (device class name), 4-16 structured programming operations, 8-16 SUB, 3-18, 8-12, 8-90 subroutines, 8-1 external, 8-15 internal, 8-3, 8-9, 8-14, 8-99 SUSP, 8-17, 8-90 suspending an RPG program, 8-90 suspend mode, 8-91, 11-29 Symbol Table listing, 12-16 system date and tim
event code, 10-8 function keys used with, 7-11, 9-15 input record format, 10-7 output record format, 10-18 W warning messages (compiler), A-2 WORKSTN le, 4-16, 4-17, 4-41, 8-90 CONSOLE, 4-16, 4-17, 4-41, 11-1, 11-20 RSI, 4-16, 4-17, 4-41, 9-27, 11-3, 11-6 Index-8 VPLUS, 4-16, 4-17, 4-41, 10-3, 10-5 X XFOOT, 3-18, 8-12, 8-98 Z Z-ADD, 3-18, 8-12, 8-98 *ZERO(S), 8-9, 8-99 Z-SUB, 3-18, 8-12, 8-98