═══ 1. RPG/400 Help ═══  Introduction to RPG/400  Control Specifications  File Description Specifications  Extension Specifications  Line Counter Specifications  Input Specifications  Calculation Specifications  Output Specifications  Operation Codes  RPG/400 Words with Special Functions  RPG/400 Restrictions  The Structured Query Language  RPG/400 Reserved Fields ═══ 1.1. How This Product Has Changed ═══  Optional factor 1 on CAT and SUBST. For details and examples see String Operations, CAT (Concatenate Two Character Strings), and SUBST (Substring).  CHEKR provides the same function as CHECK but in the reverse direction (right to left). This function can be used to determine the length of a string. For details and examples see CHEKR (Check Reverse).  P in the operation extender field for MOVE, MOVEA, and MOVEL allowing padding of the result after the operation. For details and examples see Move Operations, MOVE (Move), MOVEA (Move Array), and MOVEL (Move Left).  Support for hexadecimal literals. For details and examples see Bit Operations.  Support for a 4-digit year. For details and examples see User Date Special Words, and TIME (Time of Day). ═══ 1.2. Introduction to RPG/400 ═══ The valid character set for the RPG/400 language consists of:  The letters A B C D E F G H I J K L M N O P Q R S T U V W X Y Z  The numbers 0 1 2 3 4 5 6 7 8 9  The characters + - * , . ' & / $ # : @  The blank character RPG/400 code is written on a variety of specifications. Each specification has a specific set of functions. See Common Entries for details on specification types. The RPG/400 language is a position-dependent language. Each entry must start in a specific column. To represent this, each illustration of RPG/400 code will be in listing format with a scale drawn across the top. You may find it helpful to use your RPG/400 Debugging Template (GX21-9129). This help contains a detailed description of the individual RPG/400 specifications. Each field and its possible entries are described. Operation Codes describes the operation codes that are coded on the Calculation specification, which is described in Calculation Specifications. In addition, there is information on indicators, the logic cycle, arrays and tables, edit codes and edit words, file translation, multifile processing, and match fields. ═══ 1.2.1. Compiler Directives ═══ The compiler directive statements /TITLE, /EJECT, /SPACE, and /COPY allow you to specify heading information for the compiler listing, to control the spacing of the compiler listing, and to insert records from other file members during a compile. The compiler directive statements must precede any arrays, tables, translation records, and alternate collating sequence records (that is, ** records). ═══ 1.2.1.1. /TITLE (Positions 7-12) ═══ Use the compiler directive /TITLE to specify heading information (such as security classification or titles) that is to appear at the top of each page of the compiler listing. The following entries are used for /TITLE: Positions Entry 7-12 /TITLE 13 Blank 14-74 Title information A program can contain more than one /TITLE statement. Each /TITLE statement provides heading information for the compiler listing until another /TITLE statement is encountered. A /TITLE statement must be the first RPG/400 specification encountered to print information on the first page of the compiler listing. The information specified by the /TITLE statement is printed in addition to compiler heading information. The /TITLE statement causes a skip to the next page before the title is printed. The /TITLE statement is not printed on the compiler listing. ═══ 1.2.1.2. /EJECT (Positions 7-12) ═══ Enter /EJECT in positions 7 through 12 to indicate that subsequent specifications are to begin on a new page of the compiler listing. Positions 13 through 74 of the /EJECT statement must be blank. /EJECT is not printed on the compiler listing. ═══ 1.2.1.3. /SPACE (Positions 7-12) ═══ Use the compiler directive /SPACE to control line spacing within the compiler listing. The following entries are used for /SPACE: Positions Entry 7-12 /SPACE 13 Blank 14-16 A positive integer value from 1 through 112 that defines the number of lines to space on the compiler listing. The number must be left-adjusted. If the number specified in positions 14 through 16 is greater than the number of lines remaining on the current page, subsequent specifications begin on a new page. /SPACE is not printed on the compiler listing, but is replaced by the specified line spacing. The line spacing caused by /SPACE is in addition to the two lines that are skipped between specification types. If position 6 is blank, it is considered to be equal to the preceding specification and the two lines are not skipped. ═══ 1.2.1.4. /COPY (Positions 7-11) ═══ The /COPY compiler directive causes records from other files to be inserted, at the point where the /COPY occurs, with the file being compiled. The inserted files may contain any valid specification except /COPY. The /COPY statement is entered in the following way: Positions Entry 7-11 /COPY 12 Blank 13-44 Identifies the location of the member to be copied (merged). The format is: libraryname/filename,membername (RPG/400 AS/400 environment)  A member name must be specified.  If a file name is not specified, QRPGSRC is assumed.  If a library is not specified, the library list is searched for the file. All occurrences of the specified source file in the library list are searched for the member until it is located or the search is complete.  If a library is specified, a file name must also be specified. 45-49 Blank 50-80 Comments Examples of the /COPY Compiler Directive Statement shows some examples of the /COPY directive statement. Note: Programs compiled under the AS/400 environment can use the extended naming convention. If extended names are used, each part of the qualified name must be enclosed in quotation marks. For more information see How the Compiler Recognizes a Compiler /COPY, Conditions on the Members That Are Copied, Sequence Numbering of the Listing after a Compile, and Results of the /COPY during Compile. ═══ 1.2.1.4.1. How the Compiler Recognizes a Compiler /COPY ═══ Use the rules for RPG/400 symbolic names, to specify the library files and member. 1. The CRTRPGPGM command will treat any /COPY directive encountered in the source code as a compiler copy and does not accept the sorting or string replacement functions. Examples of the /COPY Compiler Directive Statement C/COPY MBR1 1 I/COPY SRCFIL,MBR2 2 O/COPY SRCLIB/SRCFIL,MBR3 3 O/COPY "SRCLIB!"/"SRC>3","MBR^3" 4 1 Copies from member MBR1 in source file QRPGSRC. The current library list is used to search for file QRPGSRC. 2 Copies from member MBR2 in file SRCFIL. The current library list is used to search for file SRCFIL. Note that the comma is used to separate the file name from the member name. 3 Copies from member MBR3 in file SRCFIL in library SRCLIB. 4 Copies from member "MBR^3" in file "SRC>3" in library "SRCLIB!" ═══ 1.2.1.4.2. Conditions on the Members That Are Copied ═══ If the member being copied from is not a source type file, meaning that the file was not created with the filetype *SRC, then a message is issued. This condition does not stop compilation and the copy function is still processed. The members being copied can contain any valid RPG/400 specifications except another /COPY directive. The member being copied can contain a control specification (form type H), which is then processed as if it were part of the source code. Therefore, the first statement in the program can be a /COPY directive pointing to the member containing the control specification. The H specification must still follow the rules governing its use (refer to Control Specifications) and precede any other RPG/400 specification. ═══ 1.2.1.4.3. Results of the /COPY during Compile ═══ During compilation, the specified file members are merged into the program at the point where the /COPY statement occurs. Any overrides defined that apply to the specified file and member are ignored. ═══ 1.2.1.4.4. Sequence Numbering of the Listing after a Compile ═══ For an RPG/400 compile, the low-order 6 digits of the 8-character sequence number in the listing reflect the original source sequence number of the /COPY member. In this way you can correlate the compiler listing sequence numbers (the last 6 digits) to the source member sequence numbers (in SEU). The high order 2 digits of the sequence number are made up of the characters A through Z and 0 through 9 in the following order: A, B, C, ..., Z, 1, 2, ..., 9, A0, AA, AB, ..., AZ, A1, A2, ..., A9, B0, BA, ..., ZZ, ..., Z9, 10, ..., 99. This structure allows for up to 1295 different increments of the high order sequence number. Each /COPY directive causes the high order 2 characters of the sequence number for all the code lines brought in by this /COPY to be incremented in value. If the copied code contains specifications for externally defined files, each externally defined file may cause the high-order characters of the sequence number to be incremented in value two more times: once for input specifications, and once for output specifications. If more than 1295 increments result from /COPY directives and/or externally defined files, a message is issued. A message is also issued if more than 50 externally defined files are specified. Remember that one externally defined file can take up two increments: for input and output specifications. The low order 6 digits of the sequence number is incremented by one for each I specification generated for an externally defined file. If the program is compiled by RPG/400, records that are copied into the program in this way contain a "+" adjacent to the sequence number field on the left side of the listing, between the sequence number and the form type field. If the Program Verifier is used, the lines from the copied file are identified on the listing by line numbers which start at 100001. For example, the third line in the first copied file would be 100003 and the seventh line of the fourth copied file would be 400007. Note: The /COPY directive is treated as a comment line. Because the compiler may have to read ahead to gather sufficient information about specifications, comments, or /COPY directives, certain lines may appear on the listing out of sequence. ═══ 1.2.2. Common Entries ═══ The following entries are common to all RPG specifications:  Page (positions 1-2) and Line (positions 3-5). These are the equivalent of source line number.  Specification type (position 6). The following letter codes can be used: Entry Specification Type H Control F File description E Extension L Line counter I Input C Calculation O Output  Program Identification (positions 75-80). Must be blank or program name on the Control specification.  Comment Statements (* in position 7). On a comment statement or a compiler directive, position 6 may be blank. ═══ Specification Type Not Known ═══ The entry in position 6 of your specification is not valid. Select from the following valid types.  Specification type. The following letter codes can be used: Entry Specification Type H Control F File description E Extension L Line counter I Input C Calculation O Output  Comment Statements (* in position 7). On a comment statement or a compiler directive, position 6 may be blank.  Compiler Directive (blank in position 6). Select from the following entries for positions 7-12. - /COPY - /EJECT - /SPACE - /TITLE  SQL delimeters (blank in position 6). You may use the following starting and ending delimeters in positions 7-15. - /EXEC SQL - /END-EXEC ═══ 1.3. Control Specifications ═══ The control specification statement, identified by an H in column 6, provides information about generating and running programs. Only one control specification is allowed per program. In the OS/400 system, you can create a data area named RPGHSPEC to contain the information to be used for all RPG/400 programs that do not contain a control specification. The data area must be a character string 80 positions long. Use the CL command CRTDTAARA (Create Data Area) to create the data area. Specify as the initial value of the data area the entries for the control specification that are to be used. For example, if the DEBUG operation is to be used for all RPG/400 programs, place an initial value of 1 in position 15 of the data area. (See the Programming: Control Language Reference for a description of the Create Data Area command.) The library in which the data area is placed must be in the library list when the program is compiled. If you are using Program Verifier on a program which uses the data area RPGHSPEC you must create a file called RPGHSPEC.RPG and place it in the CODE base directory. The installation default for that directory is D:|CODE. The file should contain the same specifications as are in the RPGHSPEC data area you would be using on the host. The RPG/400 language uses the control specification that is present in the program. In the OS/400 system, if a control specification is not present, the RPG/400 compiler checks for the data area RPGHSPEC in *LIBL. If the data area is not found, the RPG/400 compiler checks for the data area DFTHSPEC in QRPG. If it is not found, a default specification with blanks in positions 7 through 74 is used, (no data area is created). Since QRPG is the product library for the CRTRPGPGM command, if a data area called RPGHSPEC exists in QRPG it will always be found. Use the data area DFTHSPEC in QRPG to create a common control specification for your installation, and use RPGHSPEC in your library to override this specification. If a control specification is not present, Program Verifier will search for the file RPGHSPEC.RPG in the CODE base directory. If that file is not found, a default blank H specification will be used. See the description of the individual entries for the meaning of blank entries and for an explanation of the program name. If the default blank specification is used, asterisks are printed on the compiler listing under the Page/Line heading. Compiler-generated symbols are placed in the symbol table. ═══ 1.3.1. Control Specification Statement ═══  Position 6 (Form Type)  Positions 7-14 (Reserved)  Position 15 (Debug)  Positions 16-17 (Reserved)  Position 18 (Currency Symbol)  Position 19 (Date Format)  Position 20 (Date Edit)  Position 21 (Decimal Notation)  Positions 22-25 (Reserved)  Position 26 (Alternate Collating Sequence)  Positions 27-39 (Reserved)  Position 40 (Sign Handling)  Position 41 (Forms Alignment)  Position 42 (Reserved)  Position 43 (File Translation)  Positions 44-56 (Reserved)  Position 57 (Transparency Check)  Positions 58-74 (Reserved)  Positions 75-80 (Program Identification) ═══ 1.3.1.1. Position 6 (Form Type) ═══ An H must appear in position 6 to identify this line as the control specification (or header) statement. ═══ 1.3.1.2. Positions 7-14 (Reserved) ═══ Positions 7 through 14 must be blank. ═══ 1.3.1.3. Position 15 (Debug) ═══ Entry Explanation Blank DEBUG and DUMP operations are not done. Compiler-generated symbols are not placed in the symbol table. 1 DEBUG and DUMP operations are done. Compiler-generated symbols are placed in the symbol table. Use position 15 to indicate whether the DEBUG (Debug Function) and DUMP (Program Dump) operations will be done. A 1 in position 15 when the source program is compiled causes the compiler to generate the object code for these operations. When the program is run, DEBUG and DUMP are performed. The DEBUG entry also controls the contents of the symbol table that is produced with the program. If position 15 contains a 1, the compiler-generated symbols, starting with a period (.), are placed in the symbol table. If position 15 is blank, the compiler-generated symbols are not placed in the symbol table. The symbol table is printed with a program dump. You can then use the compiler-generated symbols in debugging a program. See the DEBUG and DUMP operations in Operation Codes for more information. ═══ 1.3.1.4. Positions 16-17 (Reserved) ═══ Positions 16 and 17 must be blank. ═══ 1.3.1.5. Position 18 (Currency Symbol) ═══ Entry Explanation Blank A dollar sign is used as the currency symbol in editing (edit words and edit codes). Currency Symbol Any character except zero (0), asterisk (*), comma (,), period (.), ampersand (&), minus sign (-), the letter C, or the letter R may be specified as the currency symbol. The specification of a currency symbol does not affect the user-defined edit codes 5 through 9. ═══ 1.3.1.6. Position 19 (Date Format) ═══ The entry in this position specifies the format of the RPG/400 user dates. Entry Explanation Blank Defaults to month/day/year if position 21 is blank. Defaults to day/month/year if position 21 contains a D, I, or J. M Month/day/year. D Day/month/year. Y Year/month/day. ═══ 1.3.1.7. Position 20 (Date Edit) ═══ Entry Explanation Ampersand (&) Blank is used as the separator character Any nonblank character The character entered is used as a separator character Blank The separator character follows the specification in position 21. The entry in this position specifies the separator character to be used with the Y edit code. ═══ 1.3.1.8. Position 21 (Decimal Notation) ═══ The entry in this position specifies the notation for the user date. It also specifies the decimal notation and the separator used for numeric literals and edit codes. The term decimal notation refers to the character that separates whole numbers from decimal fractions. The word separator refers to the character that separates the hundreds position from the thousands position, the hundred thousands position from the millions position, and so on. Below is an example of a number using a period for the decimal notation character and commas for the separator characters. 12,342,343.00    │ │ └──Decimal Notation Separators An entry in this position does not affect the edit words. Entry Explanation Blank Uses a period for the decimal notation, and a comma for the separator. If position 19 is blank, uses the month/day/year format for user date. If position 20 is blank, uses a slash as the separator for the Y edit code. I Uses a comma for the decimal notation, and a period for the separator. If position 19 is blank, uses the day/month/year format for user date. If position 20 is blank, uses a period as the separator for the Y edit code. J Uses a comma for the decimal notation, and a period for the separator. If position 19 is blank, uses the day/month/year format for user date. If position 20 is blank, uses a period as the separator for the Y edit code. When you use edit codes that cause zero balances to be printed, zero is written to the left of the decimal notation (comma): 0,00. If the number of decimal positions in the field is equal to the length of the field, the decimal notation (comma) is the leftmost character printed. D Uses a period for the decimal notation, and a comma for the separator. If position 19 is blank, uses the day/month/year format for user date. If position 20 is blank, uses a slash as the separator for the Y edit code. ═══ 1.3.1.9. Positions 22-25 (Reserved) ═══ Positions 22 through 25 must be blank. ═══ 1.3.1.10. Position 26 (Alternate Collating Sequence) ═══ Entry Explanation Blank Normal collating sequence is used. S Alternate collating sequence is used. Use position 26 to indicate whether an alternate collating sequence is to be used for character compare operations or match fields. ═══ 1.3.1.11. Positions 27-39 (Reserved) ═══ Positions 27 through 39 must be blank. ═══ 1.3.1.12. Position 40 (Sign Handling) ═══ Entry Explanation Blank The sign is always forced on input and output of zoned numeric fields. Position 40 must be blank to ensure a consistent + or - sign when data is extracted or moved from or to numeric input or output fields. When data is moved to unpacked numeric fields in output records, the valid external signs are forced. ═══ 1.3.1.13. Position 41 (Forms Alignment) ═══ Entry Explanation Blank First line is printed only once. 1 First line can be printed repeatedly allowing the operator to adjust the printer forms. If the program contains more than one printer file, the entry in position 41 applies to each printer file that has 1P (first-page) output. This function may also be specified by the CL command OVRPRTF (Override to Print File) or in the printer device file and can be affected by the ALIGN option on the STRPRTWTR command. Use column 41 only when the first output line is written to a printer file. When forms are first put in the printer, they may not be in the correct position. Sometimes several lines must be printed to determine the correct position. If you specify the 1P forms position, the system prints the first line of output and issues a message. The operator can then line up the forms and select the option from the message to print the line again or to continue printing. The 1P forms specification is also valid if the output is spooled. The page counter is not increased until the forms are positioned correctly. ═══ 1.3.1.14. Position 42 (Reserved) ═══ Position 42 must be blank. ═══ 1.3.1.15. Position 43 (File Translation) ═══ Entry Explanation Blank No file translation is requested. F Files are to be translated. An entry of F indicates that a file translation table is to be used to translate all data in specified files. ═══ 1.3.1.16. Positions 44-56 (Reserved) ═══ Positions 44 through 56 must be blank. ═══ 1.3.1.17. Position 57 (Transparency Check) ═══ Entry Explanation Blank No check for transparency. 1 Check for transparency. If you specify 1 in position 57 of the control specification, the RPG/400 compiler scans literals and constants for DBCS characters. It does not check hexadecimal literals. For more information on transparency and DBCS data, see Where You Can Use DBCS Data in RPG/400 Programs, Transparent Literals and Constants, and Additional Considerations for Using DBCS Data in RPG/400 Programs. ═══ 1.3.1.18. Positions 58-74 (Reserved) ═══ Positions 58 through 74 must be blank. ═══ 1.3.1.19. Positions 75-80 (Program Identification) ═══ The symbolic name entered in these positions is the name of the program that can be run. You can override this name with the PGM parameter in the CL command CRTRPGPGM (Create RPG Program). If you do not specify a name in positions 75 through 80 of the control specification or on the CRTRPGPGM command, but the source is from a database file, the member name is used as the program name. If the source is not from a database file, the program name defaults to RPGOBJ. If you specify the program name on the control specification, its maximum length is 6 characters. If you specify the program name in the CRTRPGPGM command, its maximum length is 10 characters. Note: Names entered here must follow the RPG/400 symbolic name rules. Extended names are not allowed. However, the name specified on the CRTRPGPGM command can follow the extended naming rules. ═══ 1.4. File Description Specifications ═══ File description specifications identify each file used by a program. One file-description specification statement is required for each file in the program. A maximum of 50 files can be described per program. Only one primary file can be specified; however, the presence of a primary file is not required. Only one record-address file is allowed per program. You can specify a maximum of eight PRINTER files. The maximum number of other file types is limited only by the maximum number of files allowed for the program. Program-described files require more entries on the file-description specifications than externally described files. Many of the entries required for a program-described file are part of the external description for an externally described file. Enter the file-description specifications on the RPG/400 Control and File Description Specifications. You can specify the following file types:  Input  Output  Update  Combined (input/output). You enter file-description specifications on the main file description line. Additional details can be entered on the continuation lines. ═══ 1.4.1. File Description Specification Statement ═══  Position 6 (Form Type)  Positions 7-14 (File Name)  Position 15 (File Type) - Input Files - Output Files - Update Files - Combined Files  Position 16 (File Designation) - Primary File - Secondary File - Record Address File - Array or Table File - Full Procedural File  Position 17 (End of File)  Position 18 (Sequence)  Position 19 (File Format)  Positions 20-23 (Reserved)  Positions 24-27 (Record Length)  Position 28 (Limits Processing)  Positions 29-30 (Length of Key or Record Address)  Position 31 (Record Address Type) - Blank = Non-keyed Processing - A = Character Keys - P = Packed Keys - K = Key  Position 32 (File Organization) - Indexed Files - Nonkeyed Program-Described File - Record Address File  Positions 33-34 (Overflow Indicator)  Positions 35-38 (Key Field Starting Location)  Position 39 (Extension Code)  Positions 40-46 (Device)  Positions 47-52 (Reserved)  Position 53 (Continuation Lines)  Positions 54-59 (Routine)  Positions 60-65 (Reserved)  Position 66 (File Addition)  Positions 67-70 (Reserved)  Positions 71-72 (File Condition)  Positions 73-74 (Reserved)  Positions 75-80 (Comments)  Continuation Line  Continuation Line Summary Chart  Continuation Line Options Summary Chart  PRTCTL Data Structure ═══ 1.4.1.1. Position 6 (Form Type) ═══ An F must be entered in this position for file-description specifications. ═══ 1.4.1.2. Positions 7-14 (File Name) ═══ Entry Explanation A valid file name Every file used in a program must have a unique name. The file name can be from 1 to 8 characters long, and must begin in position 7. Each file used in the program is identified by a unique symbolic name in positions 7 through 14. The file name specified in positions 7 through 14 must be an existing file name that has been defined to the OS/400 system, or one of the OS/400 system override commands must be used to associate the RPG/400 file name to the file name defined to the OS/400 system. For an externally-described file, the file must exist at both compilation time and at run time. For a program-described file, the file need exist only at run time. The file name specified in these positions, rather than the device name specified in positions 40 through 46, is used to point to the file. When the files are opened at run time, they are opened in the reverse order to that specified in the file-description specifications. The RPG/400 device name defines the functions that can be processed on the associated file. You can specify file names in positions 7 through 14 that correspond to predefined device-file definitions supplied by IBM. ═══ 1.4.1.2.1. Program Described File ═══ For program-described files, the file name entered in positions 7 through 14 must also be entered on:  Input specifications if the file is a primary, secondary, or full procedural file  Output specifications or an output calculation operation line if the file is an output, update, or combined file, or if the file is an input file and records are also being added to the file  Extension specifications if the file is a table, array, or record address file, or a file processed by a record-address file  Calculation specifications if the file name is required for the operation code specified  Line counter specifications if the device is a printer and default values are to be overridden. ═══ 1.4.1.2.2. Externally Described File ═══ For externally described files, the file name entered in positions 7 through 14 is the name used to locate the record descriptions for the file. The following rules apply to externally described files:  Input and output specifications for externally described files are optional. They are required only if you are adding RPG/400 functions, such as control fields or record identifying indicators, to the external description retrieved.  When an external description is retrieved, the record definition can be referred to by its record format name on the input, output, or calculation specifications.  A record format name must be a unique symbolic name.  A logical file with two record formats of the same name cannot have the duplicate format names renamed and cannot be externally described. However, such a file can be accessed if it is program described. ═══ 1.4.1.3. Position 15 (File Type) ═══ Entry Explanation I Input file O Output file U Update file C Combined (input/output) file. ═══ 1.4.1.3.1. Input Files ═══ An input file is one from which a program reads information. It can contain data records, arrays, or tables, or it can be a record-address file. ═══ 1.4.1.3.2. Output Files ═══ An output file is a file to which information is written. ═══ 1.4.1.3.3. Update Files ═══ An update file is an input file whose records can be updated. Updating alters the data in one or more fields of any record contained in the file and writes that record back to the same file from which it was read. If records are to be deleted, the file must be specified as an update file. ═══ 1.4.1.3.4. Combined Files ═══ A combined file is both an input file and an output file. When a combined file is processed, the output record contains only the data represented by the fields in the output record. This differs from an update file, where the output record contains the input record modified by the fields in the output record. A combined file is valid for a SPECIAL or WORKSTN file. A combined file is also valid for a DISK or SEQ file if position 16 contains T (an array or table replacement file). ═══ 1.4.1.4. Position 16 (File Designation) ═══ Entry Explanation Blank Output file P Primary file S Secondary file R Record address file T Array or table file F Full procedural file ═══ 1.4.1.4.1. Primary File ═══ When several files are processed by cycle processing, one must be designated as the primary file. In multifile processing, processing of the primary file takes precedence. Only one primary file is allowed per program. ═══ 1.4.1.4.2. Secondary File ═══ When more than one file is used during cycle-controlled programming, secondary files are input files. The processing of secondary files is determined by the order in which they are specified in the file-description specifications and on the rules of multifile logic. ═══ 1.4.1.4.3. Record Address File ═══ A record-address file is a sequentially organized file used to select records from another file. Only one file in a program can be specified as a record-address file. This file is described on the file-description and extension specifications and not on the input specifications. The file processed by the record-address file must also be specified on the extension specifications and must be a primary, secondary, or full procedural file. You cannot specify a record-address file for the device SPECIAL. You cannot specify an externally described file as a record-address file; however, you can use a record-address file to process a program described file or an externally described file. A record-address file that contains relative-record numbers must also have a T specified in position 32 and an F in position 19. ═══ 1.4.1.4.4. Array or Table File ═══ Array and table files specified by a T in position 16 are loaded at program initialization time. The array or table file can be input or combined. Leave this entry blank for array or table output files. You cannot specify SPECIAL as the device for array and table input files. You cannot specify an externally described file as an array or table file. If T is specified in position 16, you can specify C in position 15 for a DISK or SEQ file. This C allows an array or table file to be read from or written to the same file (an array or table replacement file). The To and From file names on the extension specifications must specify this file name. ═══ 1.4.1.4.5. Full Procedural File ═══ This entry is used when the input is controlled by calculation operations. File operation codes such as CHAIN or READ are used to do input functions. ═══ 1.4.1.5. Position 17 (End of File) ═══ Entry Explanation E All records from the file must be processed before the program can end. This entry is not valid for files processed by a record-address file. Blank If position 17 is blank for all files, all records from all files must be processed before end of program (LR) can occur. If position 17 is not blank for all files, all records from this file may or may not be processed before end of program occurs in multifile processing. Use position 17 to indicate whether the program can end before all records from the file are processed. An E in position 17 applies only to input, update, or combined files specified as primary, secondary, or record-address files. If the records from all primary and secondary files must be processed, position 17 must be blank for all files or must contain E's for all files. For multiple input files, the end-of-program (LR) condition occurs when all input files for which an E is specified in position 17 have been processed. If position 17 is blank for all files, the end-of-program condition occurs when all input files have been processed. When match fields are specified for two or more files and an E is specified in position 17 for one or more files, the LR indicator is set on after:  The end-of-file condition occurs for the last file with an E specified in position 17.  The program has processed all the records in other files that match the last record processed from the primary file.  The program has processed the records in those files without match fields up to the next record with nonmatching match fields. When no file or only one file contains match field specifications, no records of other files are processed after end of file occurs on all files for which an E is specified in position 17. ═══ 1.4.1.6. Position 18 (Sequence) ═══ Entry Explanation A or blank Match fields are in ascending sequence. D Match fields are in descending sequence. Position 18 specifies the sequence of input fields used with the match fields specification (positions 61 and 62 of the input specifications). Position 18 applies only to input, update, or combined files used as primary or secondary files. Use positions 61 and 62 of the input specifications to identify the fields containing the sequence information. If more than one input file with match fields is specified in the program, a sequence entry in position 18 can be used to check the sequence of the match fields and to process the file using the matching record technique. The sequence need only be specified for the first file with match fields specified. If sequence is specified for other files, the sequence specified must be the same; otherwise, the sequence specified for the first file is assumed. If only one input file with match fields is specified in the program, a sequence entry in position 18 can be used to check fields of that file to ensure that the file is in sequence. By entering one of the codes M1 through M9 in positions 61 and 62 of the input specifications, and by entering an A or D in position 18, you specify sequence checking of these fields. Sequence checking is required when match fields are used in the records from the file. When a record from a matching input file is found to be out of sequence, the RPG/400 exception/error handling routine is given control. ═══ 1.4.1.7. Position 19 (File Format) ═══ Entry Explanation F Program described file E Externally described file An F in position 19 indicates that the records for the file are described within the RPG/400 program on input/output specifications. An E in position 19 indicates that the record descriptions for the file are external to the RPG/400 source program. The compiler obtains these descriptions at compilation time and includes them in the source program. An entry is required in position 19. ═══ 1.4.1.8. Positions 20-23 (Reserved) ═══ Positions 20 through 23 must be blank. (Block length, if allowed, is specified outside the RPG/400 program.) ═══ 1.4.1.9. Positions 24-27 (Record Length) ═══ Use positions 24 through 27 to indicate the length of the logical records contained in a program-described file. The maximum record size that can be specified is 9999; however, record-size constraints of any device may override this value. This entry must be blank for externally described files. If the file being defined is a record-address file and the record length specified is 3, it is assumed that each record in the file consists of a 3-byte binary field for the relative-record numbers starting at offset 0. If the record length is 4 or greater, each relative-record number in the record-address file is assumed to be a 4-byte field starting at offset 1. If the record length is left blank, the actual record length is retrieved at run time to determine how to handle the record-address file. If the file opened at run time has a primary record length of 3, then 3-byte relative-record numbers (one per record) are assumed; otherwise, 4-byte relative-record numbers are assumed. This support can be used to allow RPG/400 programs to use System/36 environment SORT files as record-address files. ┌────────────────────────────────────────────────────────────────┐ │ Valid Combinations for a RAF Table File │ ├───────────────┬────────────────┬───────────────────────────────┤ │ RECORD LENGTH │ RAF LENGTH │ TYPE OF SUPPORT │ │ POSITIONS │ POSITIONS │ │ │ 24-27 │ 29-30 │ │ ├───────────────┼────────────────┼───────────────────────────────┤ │ Blank │ Blank │ Support determined at run │ │ │ │ time. │ ├───────────────┼────────────────┼───────────────────────────────┤ │ 3 │ 3 │ System/36 support. │ ├───────────────┼────────────────┼───────────────────────────────┤ │ > = 4 │ 4 │ Native support. │ └───────────────┴────────────────┴───────────────────────────────┘ ═══ 1.4.1.10. Position 28 (Limits Processing) ═══ Entry Explanation L Sequential-within-limits processing by a record-address file Blank Sequential or random processing Use position 28 to indicate whether the file is processed by a record-address file that contains limits records. A record-address file used for limits processing contains records that consist of upper and lower limits. Each record contains a set of limits that consists of the lowest record key and the highest record key from the segment of the file to be processed. Limits processing can be used for keyed files specified as primary, secondary, or full procedural files. The L entry in position 28 is valid only if the file is processed by a record-address file containing limits records. Random and sequential processing of files is implied by a combination of positions 16 and 31 of the file-description specifications, and by the calculation operation specified. The operation codes SETLL (Set Lower Limit) and SETGT (Set Greater Than) can be used to position a file; however, the use of these operation codes does not require an L in position 28. For more information on limits processing, refer to the RPG/400* User's Guide. ═══ 1.4.1.11. Positions 29-30 (Length of Key or Record Address) ═══ Entry Explanation 1-99 The number of positions required for the key field in a program described file or the length of the entries in the record-address file (which must be a program-described file). If the program-described file being defined uses keys for record identification, enter the number of positions occupied by each record key. This entry is required for indexed files. If the keys are packed, the key field length should be the packed length; this is the number of digits in DDS divided by 2 plus 1 and ignoring any fractions. If the file being defined is a record-address file, enter the number of positions that each entry in the record-address file occupies. Blank These positions must be blank for externally described files. (The key length is specified in the external description.) For a program-described file, a blank entry indicates that keys are not used. Positions 29-30 can also be blank for a record-address file with a blank in positions 24-27 (record length). ═══ 1.4.1.12. Position 31 (Record Address Type) ═══ Entry Explanation Blank Relative record numbers are used to process the file. Records are read consecutively. Record address file contains relative-record numbers. Keys in record-address-limits file are in the same format as keys in the file being processed. A Character keys (valid only for program-described files specified as indexed files or as a record-address-limits file). P Packed keys (valid only for program-described files specified as indexed files or as a record-address-limits file). K Key values are used to process the file. This entry is valid only for externally described files. ═══ 1.4.1.12.1. Blank = Non-keyed Processing ═══ A blank indicates that the file is processed without the use of keys, that the record-address file contains relative-record numbers (a T in position 32), or that the keys in a record-address-limits file are in the same format as the keys in the file being processed. A file processed without keys can be processed consecutively or randomly by relative-record number. Input processing by relative-record number is determined by a blank in position 31 and by the use of the CHAIN, SETLL, or SETGT operation code. Output processing by relative-record number is determined by a blank in position 31 and by the use of the RECNO keyword on the file description specifications. ═══ 1.4.1.12.2. A = Character Keys ═══ The indexed file (I in position 32) defined on this line is processed by character-record keys. (A numeric field used as the search argument is converted to zoned decimal before chaining.) The A entry must agree with the data format of the field identified as the key field (length in positions 29 and 30 and starting position in positions 35 through 38). The record-address-limits file (R in position 16) defined on this line contains character keys. The file being processed by this record address file can have an A, P, or K in position 31. ═══ 1.4.1.12.3. P = Packed Keys ═══ The indexed file (I in position 32) defined on this line is processed by packed-decimal-numeric keys. The P entry must agree with the data format of the field identified as the key field (length in positions 29 and 30 and starting position in positions 35 through 38). Note: The sign of all decimal numeric input fields is forced to F or D. All numeric result fields specified by calculation specifications also have an F or D sign. Therefore, if the sign of the key field in the file is not F or D, a record-not-found error occurs when you retrieve that file. The record-address-limits file defined on this line contains record keys in packed decimal format. The file being processed by this record address file can have an A, P, or K in position 31. ═══ 1.4.1.12.4. K = Key ═══ A K entry indicates that the externally described file is processed on the assumption that the access path is built on key values. If the processing is random, key values are used to identify the records. If this position is blank for a keyed file, the records are retrieved in arrival sequence. For more information on record address type, refer to the RPG/400* User's Guide. ═══ 1.4.1.13. Position 32 (File Organization) ═══ Entry Explanation Blank The program-described file is processed without keys, or the file is externally described. I Indexed file (valid only for program-described files). T Record address file that contains relative-record numbers (valid only for program-described files). Use position 32 to identify the organization of program described files. ═══ 1.4.1.13.1. Indexed Files ═══ An indexed file can be processed:  Randomly or sequentially by key  By a record-address file (sequentially within limits). Position 28 must contain an L. ═══ 1.4.1.13.2. Nonkeyed Program-Described File ═══ A program-described file that is processed without keys can be processed:  Randomly by relative-record numbers, positions 28 and 31 must be blank.  Entry Sequence, positions 28 and 31 must be blank.  As a record-address file, position 28 must be blank. ═══ 1.4.1.13.3. Record Address File ═══ A record-address file (indicated by an R in position 16) that contains relative-record numbers must be identified by a T in position 32. (A record-address file must be program described.) Each record retrieved from the file being processed is based on the relative record number in the record-address file. (Relative record numbers cannot be used for a record-address-limits file.) Each relative-record number in the record-address file is a 4-byte binary field; therefore, each 4-byte unit of a record-address file contains a relative-record number. A minus one (-1 or hexadecimal FFFFFFFF ) relative-record number value causes the record to be skipped. End of file occurs when all record-address file records have been processed. For more information on how to handle System/36 Environment record-address files, see the RPG/400* User's Guide. ═══ 1.4.1.14. Positions 33-34 (Overflow Indicator) ═══ Entry Explanation Blank No overflow indicator is used. OA-OG, OV Specified overflow indicator conditions the lines to be printed when overflow occurs. 01-99 Set on when a line is printed on the overflow line, or the overflow line is reached or passed during a space or skip operation. Indicators OA through OG, and OV are not valid for externally described files. Use positions 33 and 34 to specify an overflow indicator to condition which lines in each PRINTER file will be printed when overflow occurs. This entry is valid only for a PRINTER device. Overflow only occurs if defined. Only one overflow indicator can be assigned to a file. If more than one PRINTER file in a program is assigned an overflow indicator, that indicator must be unique for each file. ═══ 1.4.1.15. Positions 35-38 (Key Field Starting Location) ═══ Entry Explanation Blank Key fields are not used for this program-described file, or the file is externally described. 1-9999 Record position in a program described indexed file in which the key field begins. Use positions 35 through 38 to identify the record position in which the key field for a program described indexed file begins. An entry must be made in these positions for a program described indexed file. The key field of a record contains the information that identifies the record. The key field must be in the same location in all records in the file. The entry in these positions must be right-adjusted. Leading zeros can be omitted. ═══ 1.4.1.16. Position 39 (Extension Code) ═══ Entry Explanation Blank No extension or line-counter specifications are used. E Extension specifications further describe the file. L Line counter specifications further describe the file. Use position 39 to indicate whether the program-described file is further described on the extension specifications or on the line counter specifications. An E in position 39 applies only to array or table files or to record-address files; an L in position 39 applies to files assigned to the PRINTER device. ═══ 1.4.1.17. Positions 40-46 (Device) ═══ Entry Explanation PRINTER File is a printer file, a file with control characters that can be sent to a printer. DISK File is a disk file. This device supports sequential and random read/write functions. These files can be accessed on a remote system by Distributed Data Management (DDM). WORKSTN File is a workstation file. Input/output is through a display or ICF file. SPECIAL This is a special file. Input or output is on a device that is accessed by a user-supplied routine. The name of the routine must be specified in positions 54 through 59. A parameter list is created for use with this routine, including an option code parameter and a status code parameter. The file must be a fixed unblocked format. SEQ File is a sequentially organized file. The actual device is specified in a CL command or in the file description, which is accessed by the file name. Use positions 40 through 46 to specify the RPG/400 device name to be associated with the file. On the AS/400 system the file name in positions 7 through 14, rather than the device name specified in positions 40 through 46, is used to point to the file. The RPG/400 device name defines the RPG/400 functions that can be done on the associated file. Certain functions are valid only for a specific RPG/400 device name, such as the EXFMT operation for WORKSTN. The file name specified in positions 7 through 14 can be overridden at compilation time or run time, allowing you to change the input/output device used in the program. Note that the RPG/400 device names are not the same as the system device names. ═══ 1.4.1.18. Positions 47-52 (Reserved) ═══ Positions 47 through 52 must be blank. ═══ 1.4.1.19. Position 53 (Continuation Lines) ═══ A K in position 53 indicates a continuation line. See Continuation Line for more information. ═══ 1.4.1.20. Positions 54-59 (Routine) ═══ When SPECIAL is the device entry (positions 40 through 46), the routine named in positions 54 through 59 handles the support for the special I/O device. The routine name must be left-adjusted. The name is used by the compiler to produce the linkage to the routine. ═══ 1.4.1.21. Positions 60-65 (Reserved) ═══ Positions 60 through 65 must be blank. ═══ 1.4.1.22. Position 66 (File Addition) ═══ Position 66 indicates whether records are to be added to a DISK file. Entry Explanation Blank No records can be added to an input or update file (I or U in position 15). For an output file (O in position 15), a blank is equivalent to an A. A Add records to the file. Positions 16 through 18 of the output record specifications for this file must contain ADD, or the WRITE operation code must be used in the calculation specifications. ┌────────────────────────────────────────────────────────────────┐ │ Processing Functions for Files │ ├─────────────────────────┬────────────┬────────────┬────────────┤ │ │ FILE │ FILE │ │ │ │ DESCRIPTION│ DESCRIPTION│ OUTPUT │ │ │ SPECIFICA- │ SPECIFICA- │ SPECIFICA- │ │ FUNCTION │ TIONS │ TIONS │ TIONS │ │ │ POSITION │ POSITION │ POSITIONS │ │ │ 15 │ 66 │ 16-18 │ ├─────────────────────────┼────────────┼────────────┼────────────┤ │ Create new file(1) │ O │ Blank │ Blank │ │ │ │ │ │ │ or │ │ │ │ │ │ │ │ │ │ Add records to existing │ O │ A │ ADD │ │ file │ │ │ │ ├─────────────────────────┼────────────┼────────────┼────────────┤ │ Process file │ I │ Blank │ Blank │ ├─────────────────────────┼────────────┼────────────┼────────────┤ │ Process file and add │ I │ A │ ADD │ │ records to the existing │ │ │ │ │ file │ │ │ │ ├─────────────────────────┼────────────┼────────────┼────────────┤ │ Process file and update │ U │ Blank │ Blank │ │ the records (update or │ │ │ │ │ delete) │ │ │ │ ├─────────────────────────┼────────────┼────────────┼────────────┤ │ Process file and add │ U │ A │ ADD │ │ new records to an │ │ │ │ │ existing file │ │ │ │ ├─────────────────────────┼────────────┼────────────┼────────────┤ │ Process file and delete │ U │ Blank │ DEL │ │ an existing record from │ │ │ │ │ the file │ │ │ │ ├─────────────────────────┴────────────┴────────────┴────────────┤ │ (1)Within RPG, the term create a new file means to add records │ │ to a newly created file. Thus, the first two entries in this │ │ table perform the identical function. Both are listed to show │ │ that there are two ways to specify that function. │ └────────────────────────────────────────────────────────────────┘ ═══ 1.4.1.23. Positions 67-70 (Reserved) ═══ Positions 67 through 70 must be blank. ═══ 1.4.1.24. Positions 71-72 (File Condition) ═══ Entry Explanation Blank The file can be used by the program, and, if it is an input file, the file is opened. U1-U8 The file can be used by the program when the indicator is on; it is ignored when the indicator is off. UC Programmer control of first open. If a file is to be initially opened by the OPEN operation in the calculation specifications, then a UC entry causes the file not to be opened at program initialization. This entry is not valid for input files designated as primary, secondary, table, or record-address files, or for output files conditioned by the 1P indicator. An entry of U1 through U8 in positions 71 and 72 lets the programmer control the operation of input, output, update, and combined files at run time. If the specified indicator is on at program initialization, the file is opened. If the indicator is not on, the file is not opened and is ignored during processing. The U1 through U8 indicators can be set as follows:  By the OS/400 control language.  When used as a resulting indicator for a calculation operation or as field indicators on the input specifications. Setting the U1 through U8 indicators in this manner has no effect on file conditioning. The UC entry is required for programmer control of only the first file opening. If a file is opened and later is closed by the CLOSE operation, the programmer can reopen the file (by the OPEN operation) and the UC entry is not required in positions 71 and 72. ═══ 1.4.1.25. Positions 73-74 (Reserved) ═══ Positions 73 and 74 must be blank. ═══ 1.4.1.26. Positions 75-80 (Comments) ═══ Positions 75 to 80 can be used for comments, or left blank. These positions are not printed contiguously with positions 6-74 on the compiler listing. ═══ 1.4.2. File Types and Processing Methods ═══ The following table shows the valid entries for positions 28, 31, and 32 of the file-description specifications for the various file types and processing methods. The methods of disk file processing include:  Relative-record-number processing  Consecutive processing  Sequential-by-key processing  Random-by-key processing  Sequential-within-limits processing. ┌────────────────────────────────────────────────────────────────┐ │ Processing Methods for DISK Files │ ├───────┬───────┬───────┬────────┬───────┬───────┬───────────────┤ │ ACCESS│ METHOD│ OPCODE│ POSI- │ POSI- │ POSI- │ EXPLANATION │ │ │ │ │ TION │ TION │ TION │ │ │ │ │ │ 28 │ 31 │ 32 │ │ ├───────┼───────┼───────┼────────┼───────┼───────┼───────────────┤ │ Random│ RRN │ CHAIN │ Blank │ Blank │ Blank │ Access by │ │ │ │ │ │ │ │ physical │ │ │ │ │ │ │ │ order of │ │ │ │ │ │ │ │ records │ ├───────┼───────┼───────┼────────┼───────┼───────┼───────────────┤ │ Sequen│iKey │ READ │ Blank │ Blank │ I │ Access by key │ │ │ │ READE │ │ │ │ sequentially │ │ │ │ READP │ │ │ │ │ │ │ │ REDPE │ │ │ │ │ │ │ │ cycle │ │ │ │ │ ├───────┼───────┼───────┼────────┼───────┼───────┼───────────────┤ │ Sequen│iWithin│ READ │ L │ A or │ I │ Access by key │ │ │ Limits│ READE │ │ P │ │ sequentially │ │ │ │ READP │ │ │ │ controlled by │ │ │ │ REDPE │ │ │ │ record- │ │ │ │ cycle │ │ │ │ address- │ │ │ │ │ │ │ │ limits file │ ├───────┼───────┼───────┼────────┼───────┼───────┼───────────────┤ │ Sequen│iRRN │ READ │ Blank │ Blank │ T │ Access │ │ │ │ READE │ │ │ │ sequentially │ │ │ │ READP │ │ │ │ restricted to │ │ │ │ REDPE │ │ │ │ RRN numbers │ │ │ │ cycle │ │ │ │ in RAF file │ └───────┴───────┴───────┴────────┴───────┴───────┴───────────────┘ ═══ 1.4.2.1. Random-by-Key Processing ═══ For the random-by-key method of processing, you specify a search argument that identifies the key of the record to be read in factor 1 of the calculation specifications for the CHAIN operation. See the section on "Keyed Processing Examples" in Chapter 7 of the RPG/400* User's Guide for an example of an externally described DISK file being processed randomly by key. The specified record can be read from the file either during detail calculations or during total calculations. The random-by-key method of processing is valid for a full-procedural file designated as an input file or an update file. For an externally described file, position 31 of the file description specifications must contain K, which indicates that the file is processed according to an access path that is built on keys. The data description specifications for the file specifies the field that contains the key value (the key field). Position 32 of the file-description specifications must be blank. You must designate a program-described file as an indexed file (I in position 32), and position 31 of the file-description specifications must contain an A or a P. The length of the key field is identified in positions 29 and 30 of the file-description specifications, and the starting location of the key field is identified in positions 35 through 38. Data description specifications must be used to create the access path for a program-described input file. Refer to the section "Indexed File" in chapter 7 of the RPG/400* User's Guide. ═══ 1.4.3. Continuation Line ═══ Continuation lines can be specified on the file description specification to provide additional information about the file being defined. Any number of continuation lines can be specified. A continuation line is indicated by a K in position 53. A continuation line can be specified on the main file-description specification line if the functions use positions 54 through 65 for their definition; however, the keywords SFILE, RENAME, IGNORE, and PLIST cannot be defined there. To specify the continuation line information on the main file description specification line, enter K in position 53 and the valid entries in positions 54 through 67. See Continuation Line Summary Chart for more information. ═══ 1.4.3.1. Continuation Line Summary Chart ═══ ┌────────────────────────────────────────────────────────────────┐ │ Continuation Line Summary Chart │ ├──────────┬──────────┬──────────┬───────────────────────────────┤ │ POSI- │ NAME │ ENTRY │ EXPLANATION │ │ TIONS │ │ │ │ ├──────────┼──────────┼──────────┼───────────────────────────────┤ │ 1-2 │ Page │ Page │ Entry assigns a page number │ │ │ │ number │ to each specification form. │ ├──────────┼──────────┼──────────┼───────────────────────────────┤ │ 3-5 │ Line │ Line │ Entry numbers the specifica- │ │ │ │ number │ tion line. │ ├──────────┼──────────┼──────────┼───────────────────────────────┤ │ 6 │ Form │ F │ Identification for a file │ │ │ type │ │ description specification. │ ├──────────┼──────────┼──────────┼───────────────────────────────┤ │ 7-18 │ │ Blank │ These positions must be blank │ │ │ │ │ for a separate continuation │ │ │ │ │ line. │ ├──────────┼──────────┼──────────┼───────────────────────────────┤ │ 19-28 │ │ External │ These positions are used to │ │ │ │ name of │ specify the external name of │ │ │ │ record │ the record format that is to │ │ │ │ format │ be renamed ("RENAME") or │ │ │ │ │ ignored ("IGNORE"). │ ├──────────┼──────────┼──────────┼───────────────────────────────┤ │ 29-46 │ │ Blank │ These positions must be blank │ │ │ │ │ for a separate continuation │ │ │ │ │ line. │ ├──────────┼──────────┼──────────┼───────────────────────────────┤ │ 47-52 │ Record │ Numeric │ For the "SFILE" options, │ │ │ number │ field │ these positions must specify │ │ │ field │ name │ the name of a Relative Record │ │ │ for │ │ Number ("RECNO") field. For │ │ │ "SFILE" │ │ other continuation line │ │ │ │ │ options, these positions must │ │ │ │ │ be blank. │ ├──────────┼──────────┼──────────┼───────────────────────────────┤ │ 53 │ Contin- │ K │ Indicates a continuation │ │ │ uation │ │ line. │ │ │ line │ │ │ ├──────────┼──────────┼──────────┼───────────────────────────────┤ │ 54-59, │ │ │ These positions are used │ │ 60-67 │ │ │ together. Positions 54 │ │ │ │ │ through 59 specify the │ │ │ │ │ option, while positions 60 │ │ │ │ │ through 67 provide further │ │ │ │ │ explanation of the option. │ ├──────────┼──────────┼──────────┼───────────────────────────────┤ │ 68-74 │ │ Blank │ These positions must be blank │ │ │ │ │ for a separate continuation │ │ │ │ │ line. │ ├──────────┼──────────┼──────────┼───────────────────────────────┤ │ 75-80 │ │ Optional │ This space is available for │ │ │ │ │ comments. │ └──────────┴──────────┴──────────┴───────────────────────────────┘ ═══ 1.4.3.2. Continuation Line Options Summary Chart ═══ The valid entries for positions 54 through 67 are: ┌────────────────────────────────────────────────────────────────┐ │ Continuation Line Options │ ├──────────┬──────────┬──────────────────────────────────────────┤ │ OPTION │ ENTRY │ EXPLANATION │ │ (54-59) │ (60-67) │ │ ├──────────┼──────────┼──────────────────────────────────────────┤ │ "COMIT" │ Blank │ This file is specified for commitment │ │ │ │ control. Use the "COMIT" and "ROLBK" │ │ │ │ operation codes to group changes to this │ │ │ │ file so that the changes all happen │ │ │ │ together, or do not happen at all. │ ├──────────┼──────────┼──────────────────────────────────────────┤ │ "ID" │ Field │ Positions 60-65 contain the left- │ │ │ name │ justified name of a 10-character alpha- │ │ │ │ numeric field which need not be further │ │ │ │ defined. This field contains the name │ │ │ │ of the program device that supplied the │ │ │ │ record processed in the file. The field │ │ │ │ is updated each time a record is read │ │ │ │ from a file. Also, you may move a │ │ │ │ program device name into this field to │ │ │ │ direct an output or device-specific │ │ │ │ input operation (other than a │ │ │ │ "READ"-by-file-name or an implicit cycle │ │ │ │ read) to a different device. When │ │ │ │ moving a literal into the field, blank │ │ │ │ the field first, and use the "MOVEL" │ │ │ │ operation to place the literal left- │ │ │ │ justified in the field. Initially, the │ │ │ │ field is blank. A blank field indicates │ │ │ │ the requester device. If the requester │ │ │ │ device is not acquired for your file, │ │ │ │ you must not use a blank field. The │ │ │ │ "ID" field is maintained for each call │ │ │ │ to a program. If you call program B │ │ │ │ from within program A, the "ID" field │ │ │ │ for program A is not affected. Program │ │ │ │ B uses a separate "ID" field. When you │ │ │ │ return to program A, its "ID" field has │ │ │ │ the same value as it had before you │ │ │ │ called program B. If program B needs to │ │ │ │ know which devices are acquired to │ │ │ │ program A, program A must pass this │ │ │ │ information (as a parameter list) when │ │ │ │ it calls program B. When you specify │ │ │ │ "ID" but not "NUM", the RPG/400 program │ │ │ │ assumes "NUM" is present with a value of │ │ │ │ 1. To determine the name of the │ │ │ │ requester device, you may look in the │ │ │ │ appropriate area of the file information │ │ │ │ data structure. Or, you may process one │ │ │ │ of the input or output operations │ │ │ │ described above with the "ID" field │ │ │ │ blank. After the operation, the "ID" │ │ │ │ field has the name of the requester │ │ │ │ device. │ ├──────────┼──────────┼──────────────────────────────────────────┤ │ "IGNORE" │ Blank │ This option lets you ignore a record │ │ │ │ format from an externally described │ │ │ │ file. On the continuation line, posi- │ │ │ │ tions 19 through 28 specify the external │ │ │ │ name of the record format to be ignored, │ │ │ │ and positions 60 through 67 must be │ │ │ │ blank. The program runs as if the │ │ │ │ record format did not exist. │ ├──────────┼──────────┼──────────────────────────────────────────┤ │ "IND" │ Indi- │ Indicators from 01 to the number speci- │ │ │ cator │ fied are saved and restored for each │ │ │ number │ device attached to a mixed or multiple │ │ │ │ device file. Before an input operation, │ │ │ │ the indicators for the device associated │ │ │ │ with the previous input or output opera- │ │ │ │ tion are saved. After the input opera- │ │ │ │ tion, the indicators for the device │ │ │ │ associated with this current input oper- │ │ │ │ ation are restored. Specify a number │ │ │ │ from 01 through 99, right-justified, in │ │ │ │ positions 60 through 65. No indicators │ │ │ │ are saved and restored if "IND" is not │ │ │ │ specified or if the option "NUM" has the │ │ │ │ entry 1. If you specified the keyword │ │ │ │ "INDARA", the number you specify for │ │ │ │ "IND" must be less than any response │ │ │ │ indicator you use in your DDS. For │ │ │ │ example, if you specify "INDARA" and │ │ │ │ CF01(55) in your DDS, the maximum value │ │ │ │ for "IND" is 54. "IND" must not be used │ │ │ │ with shared files. When you specify │ │ │ │ "IND" but not "NUM", the RPG/400 program │ │ │ │ assumes "NUM" is present with a value of │ │ │ │ 1. │ ├──────────┼──────────┼──────────────────────────────────────────┤ │ "INFDS" │ Data │ This entry lets you define and name a │ │ │ struc- │ data structure to contain the │ │ │ ture │ exception/error information. The data │ │ │ name │ structure name is entered in positions │ │ │ │ 60 through 65 and left justified. If │ │ │ │ "INFDS" is specified for more than one │ │ │ │ file, each associated data structure │ │ │ │ must have a unique name. │ ├──────────┼──────────┼──────────────────────────────────────────┤ │ "INFSR" │ Subrou- │ The file exception/error subroutine │ │ │ tine │ named (left justified) in positions 60 │ │ │ name │ through 65 may receive control following │ │ │ │ file exception/errors. The subroutine │ │ │ │ name may be "*PSSR", which indicates the │ │ │ │ user defined program exception/error │ │ │ │ subroutine is to be given control for │ │ │ │ errors on this file. │ ├──────────┼──────────┼──────────────────────────────────────────┤ │ "NUM" │ Maximum │ The number specified must be greater │ │ │ number │ than zero and right-justified in posi- │ │ │ of │ tions 60 through 65. The lesser of this │ │ │ devices │ number and the number of devices defined │ │ │ │ for the "WORKSTN" file on the create- │ │ │ │ file command is the maximum number of │ │ │ │ devices that this file can acquire. │ │ │ │ With a shared file, the "NUM" value is │ │ │ │ not used to restrict the number of │ │ │ │ acquired devices. When you specify │ │ │ │ "ID", "IND", or "SAVDS" but not "NUM", │ │ │ │ the RPG/400 program assumes "NUM" is │ │ │ │ present with a value of 1. │ ├──────────┼──────────┼──────────────────────────────────────────┤ │ "PASS" │ "*NOIND" │ Specify "PASS *NOIND" on the file │ │ │ │ description specification continuation │ │ │ │ line for a program described "WORKSTN" │ │ │ │ file if you are taking responsibility │ │ │ │ for passing indicators on input and │ │ │ │ output. With "PASS *NOIND", the RPG/400 │ │ │ │ language does not pass indicators to │ │ │ │ data management on output and does not │ │ │ │ receive them on input. Pass indicators │ │ │ │ by describing them as fields (in the │ │ │ │ form "*INxx, *IN," or "*IN,xx") in the │ │ │ │ input or output record. They must be │ │ │ │ specified in the sequence required by │ │ │ │ the data description specifications │ │ │ │ (DDS). You can use the DDS listing to │ │ │ │ determine this sequence. If you do not │ │ │ │ specify "PASS *NOIND" and you use the │ │ │ │ keyword "INDARA" in the DDS for the │ │ │ │ "WORKSTN" file, indicators are not │ │ │ │ passed to data management on output nor │ │ │ │ received from data management on input. │ ├──────────┼──────────┼──────────────────────────────────────────┤ │ "PLIST" │ Param- │ This entry is valid only when the device │ │ │ eter │ specified in positions 40 through 46 of │ │ │ list │ the main file-description line is │ │ │ name │ "SPECIAL". Positions 60 through 65 give │ │ │ │ the left-justified name of the parameter │ │ │ │ list to be passed to the special │ │ │ │ routine. The parameters identified by │ │ │ │ this entry are added to the end of the │ │ │ │ parameter list passed by the program. │ ├──────────┼──────────┼──────────────────────────────────────────┤ │ "PRTCTL" │ Data │ The dynamic printer control option is │ │ │ struc- │ being used. The data structure speci- │ │ │ ture │ fied left-justified in positions 60 │ │ │ name │ through 65 refers to the forms control │ │ │ │ information and line count value. The │ │ │ │ "PRTCTL" option is valid only for a │ │ │ │ program described file. │ ├──────────┼──────────┼──────────────────────────────────────────┤ │ "RECNO" │ Field │ This entry is optional for disk files to │ │ │ name │ be processed by relative-record number. │ │ │ │ A "RECNO" field must be specified for │ │ │ │ output files processed by relative- │ │ │ │ record number, output files that are │ │ │ │ referenced by a random "WRITE" calcu- │ │ │ │ lation operation, or output files that │ │ │ │ are used with "ADD" on the output spec- │ │ │ │ ifications. │ │ │ │ │ │ │ │ "RECNO" can be specified for │ │ │ │ input/update files. The relative-record │ │ │ │ number of the record retrieved is placed │ │ │ │ in the field named, left justified, in │ │ │ │ positions 60 through 65 for all oper- │ │ │ │ ations that reposition the file (such as │ │ │ │ "READ, SETLL", or "OPEN"). It must be │ │ │ │ defined as numeric with zero decimal │ │ │ │ positions. │ │ │ │ │ │ │ │ The field length must be sufficient to │ │ │ │ contain the longest record number for │ │ │ │ the file. "RECNO" is valid for "DISK" │ │ │ │ files only. The contents of positions │ │ │ │ 60 through 65 may be not valid when the │ │ │ │ RPG/400 compiler does the blocking and │ │ │ │ unblocking of records. │ ├──────────┼──────────┼──────────────────────────────────────────┤ │ "RENAME" │ Record │ This entry, which is optional, allows │ │ │ format │ you to rename record formats in an │ │ │ name │ externally described file. Positions 19 │ │ │ │ through 28 of the continuation line │ │ │ │ specify the external name of the record │ │ │ │ format that is to be renamed. Positions │ │ │ │ 60 through 67 specify the left-justified │ │ │ │ name of the record as it is used in the │ │ │ │ program. The external name is replaced │ │ │ │ by this name in the program. │ ├──────────┼──────────┼──────────────────────────────────────────┤ │ "SAVDS" │ Data │ Positions 60-65 contain the left- │ │ │ struc- │ justified name of the data structure │ │ │ ture │ saved and restored for each device. │ │ │ name │ Before an input operation, the data │ │ │ │ structure for the device operation is │ │ │ │ saved. After the input operation, the │ │ │ │ data structure for the device associated │ │ │ │ with this current input operation is │ │ │ │ restored. This data structure cannot be │ │ │ │ a data area data structure, file infor- │ │ │ │ mation data structure, or program status │ │ │ │ data structure, and it cannot contain a │ │ │ │ compile-time array or prerun-time array. │ │ │ │ │ │ │ │ If "SAVDS" is not specified, no saving │ │ │ │ and restoring is done. "SAVDS" must not │ │ │ │ be specified for shared files. When you │ │ │ │ specify "SAVDS" but not "NUM", the │ │ │ │ RPG/400 program assumes "NUM" is present │ │ │ │ with a value of 1. │ ├──────────┼──────────┼──────────────────────────────────────────┤ │ "SFILE" │ Record │ If the main file-description line con- │ │ │ format │ tains E in position 19 and "WORKSTN" in │ │ │ name │ positions 40 through 46, this option │ │ │ │ must be used to define any subfiles to │ │ │ │ be used in the file. Positions 60 │ │ │ │ through 67 must specify, left justified │ │ │ │ the RPG/400 name of the record format to │ │ │ │ be processed as a subfile. │ │ │ │ │ │ │ │ Positions 47 through 52 must specify the │ │ │ │ name of the relative-record number field │ │ │ │ for this subfile. The relative-record │ │ │ │ number of any record retrieved by a │ │ │ │ "READC" or "CHAIN" operation is placed │ │ │ │ into the field named in positions 47 │ │ │ │ through 52. This field is also used to │ │ │ │ specify the record number that RPG/400 │ │ │ │ uses for a "WRITE" operation to the │ │ │ │ subfile or for output operations that │ │ │ │ use "ADD". The field name specified in │ │ │ │ positions 47 through 52 must be defined │ │ │ │ as numeric with zero decimal positions. │ │ │ │ The field must have enough positions to │ │ │ │ contain the largest record number for │ │ │ │ the file. (See the "SFLSIZ" keyword in │ │ │ │ the Data Description Specifications Ref- │ │ │ │ erence.) │ │ │ │ │ │ │ │ Relative record number processing is │ │ │ │ implicitly defined as part of the │ │ │ │ "SFILE" definition. If multiple sub- │ │ │ │ files are defined, each subfile requires │ │ │ │ a separate continuation line. Do not │ │ │ │ use SFILE with SLN. │ ├──────────┼──────────┼──────────────────────────────────────────┤ │ "SLN" │ Field │ Positions 60-65 contain the left- │ │ │ name │ justified name of a start line number │ │ │ │ ("SLN") field. The "SLN" field deter- │ │ │ │ mines where a record format is written │ │ │ │ to a display file. The main file- │ │ │ │ description line must contain "WORKSTN" │ │ │ │ in positions 40 through 46 and a C or O │ │ │ │ in positions 15. The data description │ │ │ │ specifications for the file must specify │ │ │ │ the keyword "SLNO(*VAR)" for one or more │ │ │ │ record formats. When you specify "SLN" │ │ │ │ on the continuation line, the "SLN" │ │ │ │ field will automatically be defined in │ │ │ │ the program as a numeric field with │ │ │ │ length of 2 and with 0 decimal posi- │ │ │ │ tions. Do not use SLN with SFILE. │ └──────────┴──────────┴──────────────────────────────────────────┘ ═══ 1.4.3.3. PRTCTL Data Structure ═══ Data Structure Positions Subfield Contents 1 A one-position character field that contains the space-before value 2 A one-position character field that contains the space-after value 3-4 A two-position character field that contains the skip-before value 5-6 A two-position character field that contains the skip-after value 7-9 A three-digit numeric field with zero decimal positions that contains the current line count value. The values contained in the first four subfields of the data structure are the same as those allowed in positions 17 through 22 (space and skip entries) of the output specifications. If the space and skip entries (positions 17 through 22) of the output specifications are blank, and if subfields 1 through 4 are also blank, the default is to space 1 after. If the PRTCTL option is specified, it is used only for the output records that have blanks in positions 17 through 22. You can control the space and skip value (subfields 1 through 4) for the PRINTER file by changing the values in these subfields while the program is running. Subfield 5 contains the current line count value. The RPG/400 compiler does not initialize subfield 5 until after the first output line is printed. The RPG/400 compiler then changes subfield 5 after each output operation to the file. ═══ 1.5. Extension Specifications ═══ Extension specifications describe all record address files, arrays, and tables. A maximum of 200 arrays and tables can be used in a program. ═══ 1.5.1. Extension Specification Statement ═══  Position 6 (Form Type)  Positions 7-10 (Reserved)  Positions 11-18 (From File Name)  Positions 19-26 (To File Name)  Positions 27-32 and 46-51 (Array or Table Name)  Positions 33-35 (Entries per Record)  Positions 36-39 (Entries per Array or Table)  Positions 40-42 and 52-54 (Length of Entry)  Positions 43 and 55 (Data Format)  Positions 44 and 56 (Decimal Positions)  Position 45 and 57 (Sequence)  Positions 46-57 (Second Array Description)  Positions 58-74 (Comments)  Positions 75-80 (Comments) ═══ 1.5.1.1. Position 6 (Form Type) ═══ An E must appear in position 6 to identify this line as an extension specifications statement. ═══ 1.5.1.2. Positions 7-10 (Reserved) ═══ Positions 7 through 10 must be blank. ═══ 1.5.1.3. Positions 11-18 (From File Name) ═══ Entry Explanation Blank The array or table is loaded at compilation time, or the array is loaded by input or calculation specifications. Record address file name Name of the record address file. Array or table file name Name of the array or table file loaded at prerun time. Use positions 11 through 18 to name an array file, table file, or record address file. File names must begin in position 11. The record address file name must always be entered in these positions. The file name of every prerun-time array or table used in the program must be entered in these positions. Leave positions 11 through 18 blank for compile-time arrays or tables and for run-time arrays loaded with input and/or calculation specifications. Table "From and To File Name Entries" shows the relationship between positions 11 through 18 and positions 19 through 26. When an array or table is loaded at compilation time, it is compiled along with the source program and included in the program. Such an array or table does not need to be loaded separately every time the program is run. Only those arrays and tables that contain constant data should be compiled with the program. ═══ 1.5.1.4. Positions 19-26 (To File Name) ═══ Entry Explanation Blank The array or table is not written at end of program. Input or update file with data File processed with the record address file named in positions 11 through 18. Output or combined file Output file to which an array or table is to be written, or the same file name (must be a combined table file) specified in positions 11 through 18 if the output array or table is to replace input in the same file. The file should be externally described as a physical file. If a record address file is named in positions 11 through 18, the name of the input or update file that contains the data records to be processed must be entered in positions 19 through 26. If an array or table is to be written, enter the file name of the output or combined file in positions 19 through 26. This file must also be named in the file description specifications. An array or table can be written to only one output device. Leave positions 19 through 26 blank if the array or table is not to be written. If an array or table is assigned to an output file, it is automatically written if LR is on. The array or table is written after all other records are written in the format used when it was entered. If an array or table is to be written to the same file from which it was read, the same file name must be entered in positions 11 through 18 and in positions 19 through 26. This file must be specified as a combined file (C in position 15) in the file description specifications. Table "From and To File Name Entries" describes the possible entries. ═══ 1.5.1.4.1. From and To File Name Table ═══ ┌────────────────────────────────────────────────────────────────┐ │ From and To File Name Entries │ ├───────────────┬────────────────┬───────────────────────────────┤ │ TYPE OF FILE │ FROM FILE NAME │ TO FILE NAME (POSITIONS │ │ │ (POSITIONS │ 19-26) │ │ │ 11-18) │ │ ├───────────────┼────────────────┼───────────────────────────────┤ │ Array or │ If an array or │ If the array or table being │ │ table files │ table loaded │ defined is being written out │ │ loaded at │ at prerun time │ after it is updated, enter │ │ prerun time │ is being │ the name of the output file │ │ │ defined (posi- │ or the combined array file if │ │ │ tions 27 │ it is to be written to the │ │ │ through 57), │ same file that was assigned │ │ │ enter the name │ to it in the file description │ │ │ of the file │ specifications.(1) If the │ │ │ that contains │ array or table is not being │ │ │ the array or │ written out, leave these │ │ │ table.(1) │ positions blank. │ ├───────────────┼────────────────┼───────────────────────────────┤ │ Arrays or │ Blank. │ Enter the name of the output │ │ tables loaded │ │ file if the array or table is │ │ at compile │ │ to be written out at the end │ │ time │ │ of the program.(1) │ ├───────────────┼────────────────┼───────────────────────────────┤ │ Arrays loaded │ Blank. │ Blank. │ │ by input or │ │ │ │ calculation │ │ │ │ specifica- │ │ │ │ tions │ │ │ ├───────────────┼────────────────┼───────────────────────────────┤ │ Record │ Enter the name │ Enter the name of the file │ │ address file │ of the record │ that contains the data │ │ │ address │ records to be processed by │ │ │ file.(1) │ the record address file.(1) │ ├───────────────┴────────────────┴───────────────────────────────┤ │ (1)These entries must be left-adjusted. │ └────────────────────────────────────────────────────────────────┘ ═══ 1.5.1.5. Positions 27-32 and 46-51 (Array or Table Name) ═══ Entry Explanation Array or table name The name of the array or table used in the program. Use positions 27 through 32 to name the array or table. ═══ 1.5.1.6. Positions 33-35 (Entries per Record) ═══ Entry Explanation Blank The array is loaded by input or calculation specifications. 1-999 Number of array or table entries in each array or table input record. Use positions 33 through 35 to indicate the exact number of array or table entries in each array or table input record. The number must end in position 35. Every array or table input record except the last must contain the number of entries indicated in positions 33 through 35. The last record can contain fewer entries than indicated, but not more. Comments can be entered on table input records in the positions following the table entries. If two arrays or tables are in alternating format in one file, each array or table input record must contain the corresponding entries from each array or table. The corresponding entries from the two arrays or tables are considered one entry and must be on the same record. If positions 27 through 32 contain an array name, the following rules apply to the use of positions 11 through 18 and 33 through 35:  For a prerun-time array, positions 11 through 18 must contain a file name and positions 33 through 35 must have an entry.  For a compile-time array, positions 11 through 18 must be blank and positions 33 through 35 must have an entry.  For an run-time array, positions 11 through 18 and positions 33 through 35 must be blank. ═══ 1.5.1.7. Positions 36-39 (Entries per Array or Table) ═══ Entry Explanation 1-9999 Maximum number of array or table entries. Use positions 36 through 39 to indicate the maximum number of entries that can be contained in the array or table named in positions 27 through 32. This number applies to one array or table or to two arrays or tables in alternating format. The number entered must end in position 39. Because the number of entries for two arrays or tables written in alternating format must be the same, the number in these positions also gives the number of entries in the second array or table specified in positions 46 through 51. ═══ 1.5.1.8. Positions 40-42 and 52-54 (Length of Entry) ═══ Entry Explanation 1-256 Length of each element in the array or table named in positions 27 through 32. If L or R is specified in positions 43 or 55, the length includes the sign position. If two arrays or tables are entered in alternating format, the specification in positions 40 through 42 applies to the array or table whose entry appears first in the record. ═══ 1.5.1.9. Positions 43 and 55 (Data Format) ═══ Entry Explanation Blank The data for the array or table (1) is in zoned decimal format, or (2) is character data, or (3) is loaded through input or calculation specifications. P The data for the array or table is in packed decimal format. B The data for the array or table is in binary format. L The data for a numeric array or table element has a preceding (left) plus or minus sign. R The data for a numeric array or table element has a following (right) plus or minus sign. The entry in position 43 specifies the format of the data in the records in the file. This entry has no effect on the format used for internal processing of the array or table in the program. ═══ 1.5.1.10. Positions 44 and 56 (Decimal Positions) ═══ Entry Explanation Blank Character array or table. 0-9 Number of positions to the right of the decimal in numeric array or table elements. Use position 44 to indicate the number of decimal positions in a numeric array or table element. Position 44 must always have an entry for a numeric array or table. If the entries in an array or table have no decimal positions, enter a 0. If two arrays or tables are entered in alternating format, the specification in this position applies to the array or table containing the entry that appears first on the record. ═══ 1.5.1.11. Position 45 and 57 (Sequence) ═══ Entry Explanation Blank No particular sequence A Ascending sequence D Descending sequence. Use position 45 to describe the sequence (either ascending or descending) of the data in an array or table loaded at prerun time or compile time. When an entry is made in position 45, the array or table is checked for the specified sequence at the time the array or table is loaded with data. If a prerun-time array or table is out of sequence, control passes to the RPG/400 exception/error handling routine. Ascending sequence means that the array or table entries start with the lowest data entry (according to the collating sequence) and go to the highest. Descending sequence means that the array or table entries start with the highest data entry and go to the lowest. Items with equal values are allowed. If two arrays or tables are entered in alternating format, the entry in position 45 applies to the array or table containing the entry that appears first on the record. When the LOKUP operation is used to search an array or table for an entry to determine whether the entry is high or low compared with the search argument, a sequence must have been specified (A or D) for the array or table. See LOKUP (Look Up) for more information. A run-time array (loaded by input and/or calculation specifications) is not sequence checked. However, an A or D entry must be specified if a high or low LOKUP operation is processed. Sequence must be specified if the SORTA operation code is used with the array. ═══ 1.5.1.12. Positions 46-57 (Second Array Description) ═══ The fields in positions 46 through 57 have the same significance and require the same type of entries as the fields with corresponding titles in positions 27 through 32 and 40 through 45. Positions 46 through 57 can be used to describe a second array:  For compile-time and prerun-time arrays, the array described in positions 46 through 57 is loaded in alternating format with the array named in positions 27 through 32.  For run-time arrays, positions 46 through 57 can be used to describe a second run-time array that is loaded independently of the array named in positions 27 through 32. See the discussion on positions 27 through 45 for information about correct specifications. Leave positions 46 through 57 blank for a single array or table. ═══ 1.5.1.13. Positions 58-74 (Comments) ═══ Positions 58 through 74 can be used for comments. ═══ 1.5.1.14. Positions 75-80 (Comments) ═══ Positions 75 through 80 can be used for comments, or left blank. These positions are not printed contiguously with positions 6-74 on the compiler listing. ═══ 1.6. Line Counter Specifications ═══ Line counter specifications can be used for each program described PRINTER file to indicate the length of the form and the number of lines to print on a page. These entries are specified on the RPG/400 Extension and Line Counter Specifications. Line counter specifications may be used for each PRINTER file in your program. If line counter specifications are used, position 39 of the file description specifications for the PRINTER device must contain an L. A form length and an overflow line specified by the OS/400 system override commands override any program specifications. If no override commands are used for the PRINTER file, the program specification of form length and overflow line is used. If there are no overrides and no program specifications, the form length and the overflow line specified in the device file are used. ═══ 1.6.1. Line Counter Specification Statement ═══  Position 6 (Form Type)  Positions 7-14 (File Name)  Positions 15-17 (Lines Per Page)  Positions 18-19 (Form Length)  Positions 20-22 (Overflow Line Number)  Positions 23-24 (Overflow Line)  Positions 25-74 (Reserved) ═══ 1.6.1.1. Position 6 (Form Type) ═══ An L must be entered in position 6 to identify this line as a line counter specifications statement. ═══ 1.6.1.2. Positions 7-14 (File Name) ═══ Entry Explanation A valid file name File name of the program described PRINTER file as previously defined on the file description specifications. The file name must begin in position 7. ═══ 1.6.1.3. Positions 15-17 (Lines Per Page) ═══ Entry Explanation 2-112 The number of printing lines available is 2 through 112. Use positions 15 through 17 to specify the exact number of lines available on the form or page to be used. The entry must end in position 17. Leading zeros can be omitted. ═══ 1.6.1.4. Positions 18-19 (Form Length) ═══ Entry Explanation FL Form length. Use positions 18 and 19 to indicate that the preceding entry (positions 15 through 17) is the form length. Positions 18 and 19 must contain the entry FL if positions 15 through 17 contain an entry. Changing the form length does not require recompiling the program. The override to the compiled value can be specified by an OS/400 system override command. ═══ 1.6.1.5. Positions 20-22 (Overflow Line Number) ═══ Entry Explanation 2-112 The line number specified is the overflow line. Use positions 20 through 22 to specify the overflow line number. The overflow line number must be less than or equal to the form length. The entry must end in position 22. Leading zeros can be omitted. When the line that is specified as the overflow line is printed, the overflow indicator turns on. In the OS/400 system, changing the overflow line does not require recompiling the program. The override to the compiled value can be specified by an OS/400 system override command. ═══ 1.6.1.6. Positions 23-24 (Overflow Line) ═══ Entry Explanation OL Overflow line. Use positions 23 and 24 to indicate that the preceding entry (positions 20 through 22) is the overflow line number. Positions 23 and 24 must contain OL if positions 20 through 22 contain an entry. ═══ 1.6.1.7. Positions 25-74 (Reserved) ═══ Positions 25 through 74 must be blank. ═══ 1.6.1.8. Positions 75-80 (Comments) ═══ Positions 75 through 80 can be used for comments, or left blank. These positions are not printed contiguously with positions 6-74 on the compiler listing. ═══ 1.7. Input Specifications ═══ For a program described input file, input specifications describe the types of records within the file, the sequence of the types of records, the fields within a record, the data within the field, indicators based on the contents of the fields, control fields, fields used for matching records, and fields used for sequence checking. For an externally described file, input specifications are optional and can be used to add RPG/400 functions to the external description. Input specifications are also used to describe data structures and named constants. Entries on input specifications are divided into the following categories:  Record identification entries (positions 7 through 42), which describe the input record and its relationship to other records in the file.  Field description entries (positions 43 through 70), which describe the fields in the records. Each field is described on a separate line, below its corresponding record identification entry. For externally described files, entries on input specifications are divided into the following categories:  Record identification entries (positions 7 through 14, and 18 and 19), which identify the record (the externally described record format) to which RPG/400 functions are to be added.  Field description entries (positions 21 through 30, 53 through 62, and 65 through 70), which describe the RPG/400 functions to be added to the fields in the record. Field description entries are written on the lines following the corresponding record identification entries. For data structures, entries on input specifications are divided into the following categories:  Data structure statements (positions 7 through 12, 17 through 30, and 44 through 51), which define data structures.  Data structure subfield specifications (positions 8, and 21 through 58), which describe the subfields of the data structures. Data structure subfield specifications are written on the lines following the data structure statements. Detailed information for the input specifications is given in:  Entries for program described files  Entries for externally described files  Entries for data structures  Entries for named constants. ═══ 1.7.1. Program Described Files ═══  Position 6 (Form Type)  Record Identification Entries  Field Description Entries ═══ 1.7.1.1. Position 6 (Form Type) ═══ An I must appear in position 6 to identify this line as an input specification statement. ═══ 1.7.2. Record Identification Entries ═══ Record identification entries (positions 7 through 42) for a program described file describe the input record and its relationship to other records in the file.  Positions 7-14 (File Name)  Positions 14-16 (Logical Relationship)  Positions 15-16 (Sequence) - Alphabetic Entries - Numeric Entries  Position 17 (Number)  Position 18 (Option)  Positions 19-20 (Record Identifying Indicator, or **) - Indicators - Lookahead Fields  Positions 21-41 (Record Identification Codes) - Positions 21-24, 28-31, and 35-38 (Position) - Positions 25, 32, and 39 (Not) - Positions 26, 33, and 40 (Code Part) - Character (C) - Zone (Z) - Digit (D) - Positions 27, 34, and 41 (Character) - AND Relationship - OR Relationship  Position 42 (Reserved) ═══ 1.7.2.1. Positions 7-14 (File Name) ═══ Entry Explanation A valid file name Same file name that appears on the file description specifications for the input file. Enter the name of the file to be described in these positions. This name must be the same name defined for the file on the file description specifications. This file must be an input file, an update file, or a combined file. The file name must be entered on the first record identification line for each file and can be entered on subsequent record identification lines for that file. All entries describing one input file must appear together; they cannot be mixed with entries for other files. ═══ 1.7.2.2. Positions 14-16 (Logical Relationship) ═══ Entry Explanation AND More than three identification codes are used. OR Two or more record types have common fields. An unlimited number of AND/OR lines can be used. For more information see AND Relationship and OR Relationship. ═══ 1.7.2.3. Positions 15-16 (Sequence) ═══ Entry Explanation Any two alphabetic characters The program does not check for special sequence. Any two-digit number The program checks for special sequence within the group. The numeric sequence entry combined with the number (position 17) and option (position 18) entries causes the program to check the sequence of input records within a file. If the sequence is not correct, control passes to the RPG/400 exception/error handling routine. If AND or OR lines are specified, the sequence entry is made on the main record line of the group, not on the AND or OR lines. Alphabetic and numeric entries can be made for different records (different record identification lines) in the same file, but records with alphabetic entries must be specified before records with numeric entries. ═══ 1.7.2.3.1. Alphabetic Entries ═══ Enter any two alphabetic characters in these positions when no sequence checking is to be done. It is common programming practice to specify these codes in a sequence that aids in program documentation. However, it is not necessary to use unique alphabetic entries. ═══ 1.7.2.3.2. Numeric Entries ═══ Enter a unique numeric code in positions 15 and 16 if one record type must be read before another record type in a file. Numeric entries must be in ascending order, starting with 01, but need not be consecutive. When a numeric entry is used, the appropriate entries must be made in positions 17 and 18. To specify sequence checking, each record type must have a record identification code, and the record types must be numbered in the order in which they should appear. This order is checked as the records are read. If a record type is out of sequence, control passes to the RPG/400 exception/error handling routine. Sequence numbers ensure only that all records of each record type precede the records of senior sequence numbered record types. The sequence numbers do not ensure that records within a record type are in any certain order. Sequence numbers are unrelated to control levels and do not provide for checking data in fields of a record for a special sequence. Use positions 61 and 62 (matching fields) to indicate that data in fields of a record should be checked for a special sequence. ═══ 1.7.2.4. Position 17 (Number) ═══ Entry Explanation Blank The program does not check record types for a special sequence (positions 15 and 16 have alphabetic entries). 1 Only one record of this type can be present in the sequenced group. N One or more records of this type can be present in the sequenced group. This entry must be used when a numeric entry is made in positions 15 and 16. If an alphabetic entry is made in positions 15 and 16, this entry must be blank. ═══ 1.7.2.5. Position 18 (Option) ═══ Entry Explanation Blank The record type must be present if sequence checking is specified. O The record type is optional (that is, it may or may not be present) if sequence checking is specified. This entry must be blank if positions 15 and 16 contain an alphabetic entry. Sequence checking of record types has no meaning when all record types within a file are specified as optional (alphabetic entry in positions 15 and 16 or O entry in position 18). ═══ 1.7.2.6. Positions 19-20 (Record Identifying Indicator, or **) ═══ Entry Explanation Blank No indicator is used. 01-99 General indicator. L1-L9 or LR Control level indicator used for a record identifying indicator. H1-H9 Halt indicator. U1-U8 External indicator. RT Return indicator. ** Lookahead field (not an indicator). Lookahead can be used only with a primary or secondary file. The indicators specified in these positions are used in conjunction with the record identification codes (positions 21 through 41). ═══ 1.7.2.6.1. Indicators ═══ Positions 19 and 20 associate an indicator with the record type defined on this line. The normal entry is one of the indicators 01 to 99; however, the control level indicators L1 through L9 and LR can be used to cause certain total steps to be processed. If a control level indicator is specified, lower control level indicators are not set on. The halt indicators H1 through H9 can be used to stop processing. The return indicator (RT) is used to return to the calling program. When a record is selected for processing and satisfies the conditions indicated by the record identification codes, the appropriate record identifying indicator is set on. This indicator can be used to condition calculation and output operations. Record identifying indicators can be set on or set off by the programmer. However, at the end of the cycle, all record identifying indicators are set off before another record is selected. ═══ 1.7.2.6.2. Lookahead Fields ═══ The entry of ** is used for the lookahead function. This function lets you look at information in the next record in a file. You can look not only at the file currently selected for processing but also at other files present but not selected during this cycle. Field description lines must contain From and To entries in the record, a field name, and decimal positions if the field is numeric. Note that a lookahead field may not be specified as a field name or as a data structure name on Input Specifications or as a Result Field on Calculation Specifications. Positions 15 and 16 must contain an alphabetic entry. The lookahead fields are defined in positions 53 through 58 of the lines following the line containing ** in positions 19 and 20. Positions 59 through 74 must be blank. Any or all of the fields in a record can be defined as lookahead fields. This definition applies to all records in the file, regardless of their type. If a field is used both as a lookahead field and as a normal input field, it must be defined twice with different names. The lookahead function can be specified only for primary and secondary files and can be specified only once for a file. It cannot be used for full procedural files (identified by an F in position 16 of the file description specifications), or with AND or OR lines. When a record is being processed from a combined file or an update file, the data in the lookahead field is the same as the data in the record being processed, not the data in the next record. The lookahead function causes information in the file information data structure to be updated with data pertaining to the lookahead record, not to the current primary record. If an array element is specified as a lookahead field, the entire array is classified as a lookahead field. Lookahead fields are filled with nines when all records in the file have been processed so that the end of the file can be recognized. ═══ 1.7.2.7. Positions 21-41 (Record Identification Codes) ═══ Entries in positions 21 through 41 identify each record type in the input file. One to three identification codes can be entered on each specification line. More than three record identification codes can be specified on additional lines with the AND/OR relationship. If the file contains only one record type, the identification codes can be left blank; however, a record identifying indicator entry (positions 19 and 20) and a sequence entry (positions 15 and 16) must be made. Three sets of entries can be made in positions 21 through 41: 21 through 27, 28 through 34, and 35 through 41. Each set is divided into four groups: position, not, code part, and character. The following table shows which categories use which positions in each set. ┌────────────┬──────────┬──────────┬────────┐ │ CATEGORY │ 21-27 │ 28-34 │ 35-41 │ ├────────────┼──────────┼──────────┼────────┤ │ Position │ 21-24 │ 28-31 │ 35-38 │ ├────────────┼──────────┼──────────┼────────┤ │ Not │ 25 │ 32 │ 39 │ ├────────────┼──────────┼──────────┼────────┤ │ Code Part │ 26 │ 33 │ 40 │ ├────────────┼──────────┼──────────┼────────┤ │ Character │ 27 │ 34 │ 41 │ └────────────┴──────────┴──────────┴────────┘ Entries in these sets need not be in sequence. For example, an entry can be made in positions 28 through 34 without requiring an entry in positions 21 through 27. Entries for record identification codes are not necessary if input records within a file are of the same type. An input specification containing no record identification code defines the last record type for the file, thus allowing the handling of any record types that are undefined. If no record identification codes are satisfied, control passes to the RPG/400 exception/error handling routine. ═══ 1.7.2.7.1. Positions 21-24, 28-31, and 35-38 (Position) ═══ Entry Explanation Blank No record identification code is present. 1-9999 The position that contains the record identification code in the record. In these positions enter the position that contains the record identification code in each record. The position containing the code must be within the record length specified for the file. This entry must be right-adjusted, but leading zeros can be omitted. ═══ 1.7.2.7.2. Positions 25, 32, and 39 (Not) ═══ Entry Explanation Blank Record identification code must be present. N Record identification code must not be present. Enter an N in this position if the code described must not be present in the specified record position. ═══ 1.7.2.7.3. Positions 26, 33, and 40 (Code Part) ═══ Entry Explanation C Entire character Z Zone portion of character D Digit portion of character. This entry specifies what part of the character in the record identification code is to be tested. ═══ 1.7.2.7.3.1. Character (C) ═══ The C entry indicates that the complete structure (zone and digit) of the character is to be tested. ═══ 1.7.2.7.3.2. Zone (Z) ═══ The Z entry indicates that the zone portion of the character is to be tested. The zone entry causes the four high-order bits of the character entry (position 27) to be compared with the zone portion of the character in the record position specified in the position entry (positions 21 through 24). The following three special cases are exceptions:  The hexadecimal representation of an & (ampersand) is 50. However, when an ampersand is coded in the character entry, it is treated as if its hexadecimal representation were C0, that is, as if it had the same zone as A through I. An ampersand in the input data satisfies two zone checks: one for a hexadecimal 5 zone, the other for a hexadecimal C zone.  The hexadecimal representation of a - (minus sign) is 60. However, when a minus sign is coded in the character entry, it is treated as if its hexadecimal representation were D0, that is, as if it had the same zone as J through R. A minus sign in the input data satisfies two zone checks: one for a hexadecimal 6 zone, the other for a hexadecimal D zone.  The hexadecimal representation of a blank is 40. However, when a blank is coded in the character entry, it is treated as if its hexadecimal representation were F0, that is, as if it had the same zone as 0 through 9. A blank in the input data satisfies two zone checks: one for a hexadecimal 4 zone, the other for a hexadecimal F zone. ═══ 1.7.2.7.3.3. Digit (D) ═══ The D entry indicates that the digit portion of the character is to be tested. The four low-order bits of the character are compared with the character specified by the position entry. ═══ 1.7.2.7.4. Positions 27, 34, and 41 (Character) ═══ In this position enter the identifying character that is to be compared with the character in the position specified in the input record. The check for record type always starts with the first record type specified. If data in a record satisfies more than one set of record identification codes, the first record type satisfied determines the record types. When more than one record type is specified for a file, the record identification codes should be coded so that each input record has a unique set of identification codes. ═══ 1.7.2.7.5. AND Relationship ═══ The AND relationship is used when more than three record identification codes identify a record. To use the AND relationship, enter at least one record identification code on the first line and enter the remaining record identification codes on the following lines with AND coded in positions 14 through 16 for each additional line used. Positions 7 through 13, 17 through 20, and 42 through 74 of each line with AND in positions 14 through 16 must be blank. Sequence, and record-identifying-indicator entries are made in the first line of the group and cannot be specified in the additional lines. An unlimited number of AND/OR lines can be used on the input specifications. ═══ 1.7.2.7.6. OR Relationship ═══ The OR relationship is used when two or more record types have common fields. To use the OR relationship, enter OR in positions 14 and 15. Positions 7 through 13, 16 through 18, and 42 through 74 must be blank. A record identifying indicator can be entered in positions 19 and 20. If the indicator entry is made and the record identification codes on the OR line are satisfied, the indicator specified in positions 19 and 20 on that line is set on. If no indicator entry is made, the indicator on the preceding line is set on. An unlimited number of AND/OR lines can be used on the input specifications. ═══ 1.7.2.8. Position 42 (Reserved) ═══ Position 42 must be blank. ═══ 1.7.3. Field Description Entries ═══ The field description entries (positions 43 through 74) must follow the record identification entries (positions 7 through 42) for each file.  Position 43 (Data Format)  Positions 44-51 (Field Location)  Position 52 (Decimal Positions)  Positions 53-58 (Field Name)  Positions 59-60 (Control Level)  Positions 61-62 (Matching Fields)  Positions 63-64 (Field Record Relation)  Positions 65-70 (Field Indicators - Program Described)  Positions 71-74 (Reserved)  Positions 75-80 (Comments) ═══ 1.7.3.1. Position 43 (Data Format) ═══ Entry Explanation Blank The input field is in zoned decimal format or is a character field. P The input field is in packed decimal format. B The input field is in binary format. L The numeric input field has a preceding (left) plus or minus sign. R The number input field has a following (right) plus or minus sign. The entry in position 43 specifies the format of the data in the records in the file. This entry has no effect on the format used for internal processing of the input field in the program. See Chapter 9 in the RPG/400* User's Guide for information on internal field formats. ═══ 1.7.3.2. Positions 44-51 (Field Location) ═══ Entry Explanation Two 1- to 4-digit numbers Beginning of a field (from) and end of a field (to). This entry describes the location and size of each field in the input record. Positions 44 through 47 specify the location of the field's beginning position; positions 48 through 51 specify the location of the field's end position. To define a single-position field, enter the same number in positions 44 through 47 and in positions 48 through 51. Numeric entries must be right-adjusted; leading zeros can be omitted. The maximum number of positions in the input record for each type of field is as follows: Number of Positions Type of Field 30 Zoned decimal numeric (30 digits) 16 Packed numeric (30 digits) 4 Binary (9 digits) 256 Character (256 characters) 31 Numeric with leading or trailing sign (30 digits) 9999 Data structure. For arrays, enter the beginning position of the array in positions 44 through 47 and the ending position in positions 48 through 51. The array length must be an integral multiple of the length of an element. The From-To position does not have to account for all the elements in the array. The placement of data into the array starts with the first element. ═══ 1.7.3.3. Position 52 (Decimal Positions) ═══ Entry Explanation Blank Character field 0-9 Number of decimal positions in numeric field. This entry, used with the data format entry in position 43, describes the format of the field. This entry indicates whether the field described on this line is a character field or a numeric field. If the field is numeric, an entry must be made. The number of decimal positions specified for a numeric field cannot exceed the length of the field. For an array or an array element, this entry must be the same as the entry made on the extension specifications (position 44 or 56) for the array. (If this entry is blank for a numeric array or array element, the decimal positions specified in the extension specification are used.) ═══ 1.7.3.4. Positions 53-58 (Field Name) ═══ Entry Explanation Symbolic name Field name, data structure name, data structure subfield name, array name, array element, PAGE, PAGE1-PAGE7, *IN, *INxx, or *IN,xx. These positions name the fields of an input record that are used in an RPG/400 program. This name must follow the rules for symbolic names. To refer to an entire array on the input specifications, enter the array name in positions 53 through 58. If an array name is entered in positions 53 through 58, control level (positions 59 and 60), matching fields (positions 61 and 62), and field indicators (positions 65 through 70) must be blank. To refer to an element of an array, specify the array name, followed by a comma, followed by an index. The index is either a numeric field with zero decimal positions or the actual number of the array element to be used. The value of the index can vary from 1 to n, where n is the number of elements within the array. ═══ 1.7.3.5. Positions 59-60 (Control Level) ═══ Entry Explanation Blank This field is not a control field. Control level indicators cannot be used with full procedural files. L1-L9 This field is a control field. Positions 59 and 60 indicate the fields that are used as control fields. A change in the contents of a control field causes all operations conditioned by that control level indicator and by all lower level indicators to be processed. A split control field is a control field that is made up of more than one field, each having the same control level indicator. The first field specified with that control level indicator is placed in the high-order position of the split control field, and the last field specified with the same control level indicator is placed in the low-order position of the split control field. ═══ 1.7.3.6. Positions 61-62 (Matching Fields) ═══ Entry Explanation Blank This field is not a match field. M1-M9 This field is a match field. This entry is used to match the records of one file with those of another or to sequence check match fields within one file. Match fields can be specified only for fields in primary and secondary files. Match fields within a record are designated by an M1 through M9 code entered in positions 61 and 62 of the appropriate field description specification line. A maximum of nine match fields can be specified. The match field codes M1 through M9 can be assigned in any sequence. For example, M3 can be defined on the line before M1, or M1 need not be defined at all. When more than one match field code is used for a record, all fields can be considered as one large field. M1 or the lowest code used is the rightmost or low-order position of the field. M9 or the highest code used is the leftmost or high-order position of the field. Entries in position 26 (alternate collating sequence) and position 43 (file translation) of the control specification can be used to alter the collating sequence for match fields. If match fields are specified for only a single sequential file (input, update, or combined), match fields within the file are sequence checked. The MR indicator is not set on and cannot be used in the program. An out-of-sequence record causes the RPG/400 exception/error handling routine to be given control. In addition to sequence checking, match fields are used to match records from the primary file with those from secondary files. ═══ 1.7.3.7. Positions 63-64 (Field Record Relation) ═══ Entry Explanation Blank The field is common to all record types. 01-99 General indicators. L1-L9 Control level indicators. MR Matching record indicator. U1-U8 External indicators. H1-H9 Halt indicators. RT Return indicator. Field record relation indicators are used to associate fields within a particular record type when that record type is one of several in an OR relationship. This entry reduces the number of lines that must be written. The field described on a line is extracted from the record by the RPG/400 program only when the indicator coded in positions 63 and 64 is on or when positions 63 and 64 are blank. When positions 63 and 64 are blank, the field is common to all record types defined by the OR relationship. Field record relation indicators can be used with control level fields (positions 59 and 60) and matching fields (positions 61 and 62). ═══ 1.7.3.8. Positions 65-70 (Field Indicators - Program Described) ═══ Entry Explanation Blank No indicator specified 01-99 General indicators H1-H9 Halt indicator U1-U8 External indicators RT Return indicator. Entries in positions 65 through 70 test the status of a field or of an array element as it is read into the program. Field indicators are specified on the same line as the field to be tested. Depending on the status of the field (plus, minus, zero, or blank), the appropriate indicator is set on and can be used to condition later specifications. The same indicator can be specified in two positions, but it should not be used for all three positions. Field indicators cannot be used with arrays that are not indexed or look-ahead fields. Positions 65 and 66 (plus) and positions 67 and 68 (minus) are valid for numeric fields only. Positions 69 and 70 can be used to test a numeric field for zeros or a character field for blanks. The field indicators are set on if the field or array element meets the condition specified when the record is read. Each field indicator is related to only one record type; therefore, the indicators are not reset (on or off) until the related record is read again or until the indicator is defined in some other specification. ═══ 1.7.3.9. Positions 71-74 (Reserved) ═══ Positions 71 through 74 must be blank. ═══ 1.7.3.10. Positions 75-80 (Comments) ═══ Positions 75 through 80 can be used for comments, or left blank. These positions are not printed contiguously with positions 6-74 on the compiler listing. ═══ 1.7.4. Externally Described Files ═══  Position 6 (Form Type)  Record Identification Entries  Field Description Entries ═══ 1.7.4.1. Position 6 (Form Type) ═══ An I must appear in position 6 to identify this line as an input specifications statement. ═══ 1.7.5. Record Identification Entries ═══  Positions 7-14 (Record Name)  Positions 15-18 (Reserved)  Positions 19-20 (Record Identifying Indicator)  Positions 21-41 (Record Identification Code)  Positions 42-74 (Reserved)  Positions 75-80 (Comments) When the description of an externally described file is retrieved by the compiler, the record definitions are also retrieved. To refer to the record definitions, specify the record format name in the input, calculation, and output specifications of the program. Input specifications for an externally described file are required if:  Record identifying indicators are to be specified.  A field within a record is to be renamed for the program.  Control level or matching field indicators are to be used.  Field indicators are to be used. The field description specifications must immediately follow the record identification specification for an externally described file. A record line for an externally described file defines the beginning of the override specifications for the record. All specifications following the record line are part of the record override until another record format name or file name is found in positions 7 through 14 of the input specifications. All record lines that pertain to an externally described file must appear together; they cannot be mixed with entries for other files. ═══ 1.7.5.1. Positions 7-14 (Record Name) ═══ Enter one of the following:  The external name of the record format. (The file name cannot be used for an externally described file.)  The RPG/400 name specified by the RENAME option on the file description specifications continuation line if the external record format was renamed. A record format name can appear only once in positions 7 through 14 of the input specifications for a program. ═══ 1.7.5.2. Positions 15-18 (Reserved) ═══ Positions 15 through 18 must be blank. ═══ 1.7.5.3. Positions 19-20 (Record Identifying Indicator) ═══ The specification of record identifying indicators in these positions is optional but, if present, follows the rules as described under Program Described Files except for look-ahead specifications, which are not allowed for an externally described file. ═══ 1.7.5.4. Positions 21-41 (Record Identification Code) ═══ Positions 21 through 41 must be blank. Record format names are used to determine the record types used in an externally described file. ═══ 1.7.5.5. Positions 42-74 (Reserved) ═══ Positions 42-74 must be blank. ═══ 1.7.5.6. Positions 75-80 (Comments) ═══ Positions 75-80 can be used for comments, or left blank. These positions are not printed contiguously with positions 6-74 on the compiler listing. ═══ 1.7.6. Field Description Entries ═══  Positions 7-20 (Reserved)  Positions 21-30 (External Field Name)  Positions 31-52 (Reserved)  Positions 53-58 (Field Name)  Positions 59-60 (Control Level)  Positions 61-62 (Matching Fields)  Positions 63-64 (Reserved)  Positions 65-70 (Externally Described Field Indicators)  Positions 71-74 (Reserved)  Positions 75-80 (Comments) The field description specifications for an externally described file can be used to rename a field within a record for a program or to specify control level, field indicator, and match field functions. The field definitions (attributes) are retrieved from the externally described file and cannot be changed by the program. If the attributes of a field are not valid to an RPG/400 program (such as numeric length greater than 30 digits), the field cannot be used. Diagnostic checking is done on fields contained in an external record format in the same way as for source statements. ═══ 1.7.6.1. Positions 7-20 (Reserved) ═══ Positions 7 through 20 must be blank. ═══ 1.7.6.2. Positions 21-30 (External Field Name) ═══ If a field within a record in an externally described file is to be renamed, enter the external name of the field in these positions. A field may have to be renamed because the external name is longer than 6 characters or because the name is the same as a field name specified in the program and two different names are required. ═══ 1.7.6.3. Positions 31-52 (Reserved) ═══ Positions 31 through 52 must be blank. ═══ 1.7.6.4. Positions 53-58 (Field Name) ═══ The field name entry is made only when it is required for the RPG/400 function (such as control levels) added to the external description. The field name entry contains one of the following:  The name of the field as defined in the external record description (if 6 characters or less).  The name specified to be used in the program that replaced the external name specified in positions 21 through 30. The field name must follow the rules for using symbolic names. ═══ 1.7.6.5. Positions 59-60 (Control Level) ═══ This entry indicates whether the field is to be used as a control field in the program. Entry Explanation Blank This field is not a control field. L1-L9 This field is a control field. Note: For externally described files, split control fields are combined in the order in which the fields are specified on the data description specifications (DDS), not in the order in which the fields are specified on the input specifications. ═══ 1.7.6.6. Positions 61-62 (Matching Fields) ═══ This entry indicates whether the field is to be used as a match field. Entry Explanation Blank This field is not a match field. M1-M9 This field is a match field. See Positions 61-62 (Matching Fields) for more information on match fields. ═══ 1.7.6.7. Positions 63-64 (Reserved) ═══ Positions 63 and 64 must be blank. ═══ 1.7.6.8. Positions 65-70 (Externally Described Field Indicators) ═══ Entry Explanation Blank No indicator specified 01-99 General indicators H1-H9 Halt indicators U1-U8 External indicators RT Return indicator. See Positions 65-70 (Field Indicators - Program Described) for more information. ═══ 1.7.6.9. Positions 71-74 (Reserved) ═══ Positions 71 through 74 must be blank. ═══ 1.7.6.10. Positions 75-80 (Comments) ═══ Positions 75 through 80 can be used for comments, or left blank. These positions are not printed contiguously with positions 6-74 on the compiler listing. ═══ 1.7.7. Data Structure Specifications ═══ A data structure can be used to:  Allow the division of a field into subfields without using the MOVE or MOVEL operations.  Operate on a subfield and change the contents of a subfield.  Redefine the same internal area more than once using different data formats. Data structures are defined on the input specifications the same way records are defined. The record specification line contains the data structure statement (DS in positions 19 and 20) and the data structure name (optional). The field specification lines contain the subfield specifications for the data structure. Data structure specifications must follow the input specifications for records. All entries describing a data structure and its subfields must appear together. For more detail see Data Structure Specification Entries. ═══ 1.7.8. Data Structure Specification Entries ═══  Position 6 (Form Type)  Positions 7-12 (Data Structure Name)  Positions 13-16 (Reserved)  Position 17 (External Description)  Position 18 (Option)  Positions 19-20 (Record Identifying Indicator)  Positions 21-30 (External File Name)  Positions 31-43 (Reserved)  Positions 44-47 (Data Structure Occurrences)  Positions 48-51 (Length)  Positions 52-74 (Reserved)  Positions 75-80 (Comments) ═══ 1.7.8.1. Position 6 (Form Type) ═══ Position 6 must contain an I for input specifications. ═══ 1.7.8.2. Positions 7-12 (Data Structure Name) ═══ Positions 7 through 12 can contain the name of the data structure being defined. The data structure name is optional, and is limited to 6 characters. A data structure name must follow the rules for using symbolic names. A data structure name can be specified anywhere a character field can be specified. If the data structure is externally described and positions 21-30 are blank, this entry must contain the name of an externally described file. ═══ 1.7.8.3. Positions 13-16 (Reserved) ═══ Positions 13 through 16 must be blank. ═══ 1.7.8.4. Position 17 (External Description) ═══ Entry Explanation Blank Subfield definitions for this data structure follow this specification. E Subfield definitions are described externally. Positions 7 through 12 must contain the name of an externally described file if positions 21 through 30 are blank. The file name must be limited to 6 characters. ═══ 1.7.8.5. Position 18 (Option) ═══ Entry Explanation Blank This data structure is not a program status or data area data structure, and this data structure is not globally initialized. I Data structure initialization. All subfields in the data structure are initialized; characters to blank, numerics to zero, in the order in which they are defined, during program initialization. S This data structure is the program status data structure. Only one data structure can be specified as the program status data structure. U This is a data area data structure. The external data area (named in positions 7 through 12) is retrieved when the program starts and rewritten when the program ends. If you put blanks in positions 7 through 12, the local data area is used. ═══ 1.7.8.6. Positions 19-20 (Record Identifying Indicator) ═══ Positions 19 and 20 must contain DS to indicate a data structure. ═══ 1.7.8.7. Positions 21-30 (External File Name) ═══ Entry Explanation Blank The data structure subfields are defined in the program. File name This is the name of the file whose first record format contains the field descriptions used as the subfield descriptions for this data structure. ═══ 1.7.8.8. Positions 31-43 (Reserved) ═══ Positions 31 through 43 must be blank. ═══ 1.7.8.9. Positions 44-47 (Data Structure Occurrences) ═══ Entry Explanation Blank This is not a multiple-occurrence data structure. 1-9999 The number (right-adjusted) indicating the number of occurrences of a multiple-occurrence data structure. These positions must be blank if the data structure is the program status data structure (indicated by an S in position 18), a file information data structure (INFDS), or a data area data structure. ═══ 1.7.8.10. Positions 48-51 (Length) ═══ Entry Explanation Blank Length of the data structure is either the length specified on the input field specifications if the data structure is an input field or the highest To position specified for a subfield within the data structure if the data structure is not an input field. 1-9999 Length of the data structure. The length of the data structure can be specified in positions 48 through 51. This entry is optional but, if used, must be right-adjusted. If this entry is not made, the length of the data structure is one of the following:  The length specified on the input field specifications if the data structure name is an input field.  The highest To position specified for a subfield within the data structure if the data structure name is not an input field. ═══ 1.7.8.11. Positions 52-74 (Reserved) ═══ Positions 52 through 74 must be blank. ═══ 1.7.8.12. Positions 75-80 (Comments) ═══ Positions 75 through 80 may be used for comments or left blank. These positions are not printed contiguously with positions 6-74 on the compiler listing. ═══ 1.7.9. Data Structure Subfield Specifications ═══ Specifications for subfields, if used, must follow the data structure specification statement to which they apply.  Position 7 (Reserved)  Position 8 (Initialization Option)  Positions 9-20 (Reserved)  Positions 21-30 (External Field Name)  Positions 21-42 (Initialization Value)  Positions 31-42 (Reserved)  Position 43 (Internal Data Format)  Positions 44-51 (Field Location)  Position 52 (Decimal Positions)  Positions 53-58 (Field Name)  Positions 59-74 (Reserved)  Positions 75-80 (Comments) ═══ 1.7.9.1. Position 7 (Reserved) ═══ Position 7 must be blank. ═══ 1.7.9.2. Position 8 (Initialization Option) ═══ Entry Explanation Blank No subfield initialization. I Subfield is initialized to value specified in positions 21 to 42. ═══ 1.7.9.3. Positions 9-20 (Reserved) ═══ Positions 9 through 20 must be blank. ═══ 1.7.9.4. Positions 21-30 (External Field Name) ═══ To rename a subfield in an externally described data structure, specify the external name in positions 21 through 30, and specify the name to be used in the program in positions 53 through 58. The remaining positions must be blank. ═══ 1.7.9.5. Positions 21-42 (Initialization Value) ═══ If a subfield is to be initialized, specify a literal value or a named constant in these positions. If no value is specified and position 8 contains I, the subfield is initialized to zero or blanks, depending on the field type. The value may be continued on the next line. See Named Constant Continuation Specifications for more information on continuation. See the RPG/400* User's Guide for more information on how to specify the initialization value. ═══ 1.7.9.6. Positions 31-42 (Reserved) ═══ Positions 31 through 42 must be blank, if an external field name is specified in positions 21 to 30. ═══ 1.7.9.7. Position 43 (Internal Data Format) ═══ Entry Explanation Blank Subfield is in zoned decimal format or is character data if position 52 is blank. P Subfield is in packed decimal format. B Subfield is in binary format. Note: Unlike the external data format field, the entry determines the internal format of the data. ═══ 1.7.9.8. Positions 44-51 (Field Location) ═══ Entry Explanation Two 1- to 4-digit numbers Beginning of a subfield (from) and end of a subfield (to). Keywords For the program status data structure or for a file information data structure, special keywords define the location of the subfields in the data structures. Keywords for the program status data structure are *STATUS, *PROGRAM, *PARMS, and *ROUTINE. Keywords for the file information data structure are *FILE, *RECORD, *OPCODE, *STATUS, and *ROUTINE. Positions 44-47 are the From position. Positions 48-51 are the To position. Both From and To must be right-justified, and leading zeroes may be omitted. ═══ 1.7.9.9. Position 52 (Decimal Positions) ═══ Entry Explanation Blank Character subfield 0-9 Number of decimal positions in a numeric subfield. Position 52, along with position 43, determines the format of the subfield. An entry must be made in position 52 for a numeric subfield. ═══ 1.7.9.10. Positions 53-58 (Field Name) ═══ In positions 53 through 58, enter the name of the subfield that is being defined. The name can be an array name, but cannot be an array element name. ═══ 1.7.9.11. Positions 59-74 (Reserved) ═══ Positions 59 through 74 must be blank. ═══ 1.7.9.12. Positions 75-80 (Comments) ═══ Positions 75 through 80 can be used for comments, or left blank. These positions are not printed contiguously with positions 6-74 on the compiler listing. ═══ 1.7.10. Named Constant Specifications ═══  Positions 7-20 (Reserved)  Positions 21-42 (Constant)  Position 43 (Data Type)  Positions 44-52 (Reserved)  Positions 53-58 (Constant Name)  Positions 59-74 (Reserved) ═══ 1.7.10.1. Positions 7-20 (Reserved) ═══ Positions 7 through 20 must be blank. ═══ 1.7.10.2. Positions 21-42 (Constant) ═══ In positions 21-42 enter the constant or edit word being declared. The constant may be continued on subsequent lines by coding a hyphen as the last character. For character named constants the hyphen replaces the ending quote. A continued numeric constant must result in a valid decimal number with at most 30 digits, a maximum of 9 being to the right of the decimal point. Named constants can be declared anywhere in the input specifications. ═══ 1.7.10.3. Position 43 (Data Type) ═══ Entry Explanation C Type of name is constant Blank Constant continuation line ═══ 1.7.10.4. Positions 44-52 (Reserved) ═══ Positions 44-52 must be blank. ═══ 1.7.10.5. Positions 53-58 (Constant Name) ═══ Positions 53-58 contain the name of the constant. The normal rules for RPG/400 names apply. ═══ 1.7.10.6. Positions 59-74 (Reserved) ═══ Positions 59-74 must be blank. ═══ 1.7.11. Named Constant Continuation Specifications ═══  Positions 7-20 (Reserved)  Positions 21-42 (Constant)  Positions 43-74 (Reserved) ═══ 1.7.11.1. Positions 7-20 (Reserved) ═══ Positions 7 through 20 must be blank. See Named Constant Examples ═══ 1.7.11.2. Positions 21-42 (Constant) ═══ In positions 21-42 enter the constant or edit word being continued. A character or transparent literal constant may be continued over as many lines as desired so long as the total length of the constant does not exceed 256 characters. A continued numeric constant must result in a valid decimal number with at most 30 digits, a maximum of 9 being to the right of the decimal point. See Named Constant Examples ═══ 1.7.11.3. Positions 43-74 (Reserved) ═══ Positions 43-74 must be blank. See Named Constant Examples ═══ 1.7.11.3.1. Named Constant Examples ═══ Named Constant Examples *...1....+....2....+....3....+....4....+....5....+....6....+....7... I..............Namedconstant+++++++++C.........Fldnme............. I* I*The following is an example of a character constant: I 'MICKEY' C MOUSE I* I*The following is an example of a continued character constant: I* I 'ABCDEF- C CHAR I 'GHIJK' I* I*The following is an example of a numeric constant: I* I 123456789 C INTEGER I* I* I*The following is an example of a continued numeric constant: I* I 123456- C NUM I 789 I* I*The following is an example of a hexadecimal constant: I* I X'010203' C HEX1 I* I*The following is an example of a continued hexadecimal constant: I* I X'010- C HEX2 I '202' I* I*The following is an example of a continued transparent I*constant. The Shift Out (SO) and Shift In (SI) characters I*are represented by o and i. The value of the combined literal I*is 'oK1K2K3K4K5i' if the transparent literal option is specified I*(1 in position 57 of the control specification). I* I 'oK1K2K3i- C TRANS I 'oK4K5i' ═══ 1.8. Calculation Specifications ═══ Calculation specifications indicate the operations to be done on the data in a program. Two general rules govern the writing of calculation entries:  Each operation is specified on one line, except when there are AND/OR lines in the calculation.  Calculation entries must be grouped in the following order: - Detail calculations - Total calculations - Subroutines. Calculations within the groups must be specified in the order in which they are to be done. Each calculation specifications statement is divided into three parts that specify the following:  When calculations are to be done: The conditioning indicators specified in positions 7 through 17 determine when and under what conditions the calculations are to be done.  What kind of calculations are to be done: The entries specified in positions 18 through 53 determine the kind of calculations to be done, specify the data (such as fields or files) upon which the operation is to be done, and specify the field that is to contain the results of the calculation.  What tests are to be made on the results of the operation: Indicators specified in positions 54 through 59 are used to test the results of the calculations and can condition subsequent calculations or output operations. The resulting indicator positions have various uses, depending on the operation code. The calculation specifications are entered on the RPG/400 Calculation Specifications. See Operation Codes for details on how these positions must be specified for individual calculation operations. The calculation specification can also be used to enter SQL statements into an RPG/400 program. See RPG/400* User's Guide and SQL/400* Reference for more information. ═══ 1.8.1. Calculation Specification Statement ═══  Position 6 (Form Type)  Positions 7-8 (Control Level) - Control Level Indicators - Last Record Indicator - Subroutine Identifier - AND/OR Lines Identifier  Positions 9-17 (Indicators)  Positions 18-27 (Factor 1)  Positions 28-32 (Operation)  Positions 33-42 (Factor 2)  Positions 43-48 (Result Field)  Positions 49-51 (Field Length)  Position 52 (Decimal Positions)  Position 53 (Operation Extender)  Positions 54-59 (Resulting Indicators)  Positions 60-74 (Comments)  Positions 75-80 (Comments) ═══ 1.8.1.1. Position 6 (Form Type) ═══ A C must appear in position 6 to identify this line as a calculation specifications statement. ═══ 1.8.1.2. Positions 7-8 (Control Level) ═══ Entry Explanation Blank The calculation operation is done at detail calculation time for each program cycle if the indicators in positions 9 through 17 allow it; or the calculation is part of a subroutine. L0 The calculation operation is done at total calculation time for each program cycle. L1-L9 The calculation operation is done when the appropriate control break occurs at total calculation time, or when the indicator is set on. LR The calculation operation is done after the last record has been processed or after the LR indicator has been set on. SR The calculation operation is part of an RPG/400 subroutine. A blank entry is also valid for calculations that are part of a subroutine. AN, OR Indicators on more than one line condition the calculation. ═══ 1.8.1.2.1. Control Level Indicators ═══ The L0 entry is used in positions 7 and 8 to indicate that the calculation is to be done during total time and is not dependent on the occurrence of a control break. If indicators L1 through L9 are specified in positions 7 and 8, the calculation is processed at total time only when the specified indicator is on. Remember that, if L1 through L9 are set on by a control break, all lower level indicators are also set on. If positions 7 and 8 are blank, the calculation is done at detail time, is a statement within a subroutine, or is a declarative statement. The following operations can be specified within total calculations with positions 7 and 8 blank: PLIST, PARM, KLIST, KFLD, TAG, DEFN, and ELSE. (Conditioning indicators in positions 9 through 17 are not allowed with these operations.) In addition, all the preceding operations except TAG and ELSE can be specified anywhere within the calculations, even between an ENDSR operation of one subroutine and the BEGSR operation of the next subroutine or after the ENDSR operation for the last subroutine. ═══ 1.8.1.2.2. Last Record Indicator ═══ The LR Indicator, if specified in positions 7 and 8, causes the calculation to be done during the last total time. If there is a primary file but no secondary files in the program, the LR indicator is set on after the last input record has been read, the calculations specified for the record have been done, and the detail output for the last record read has been completed. If there is more than one input file (primary and secondary), the RPG/400 programmer determines which files are to be checked for end-of-file by entering an E in position 17 of the file description specifications. LR is set on when all files with an end-of-file specification have been completely read, when detail output for the last record in these files has been completed, and after all matching secondary records have been processed. When the LR indicator is set on after the last input record has been read, the control level indicators L1 through L9 are also set on. If the indicators L1 through L9 have not been defined by an entry in positions 59 and 60 of the input specifications or by *INxx when used in a result field, the indicators are set on when LR is on, but they cannot be used in other specifications. ═══ 1.8.1.2.3. Subroutine Identifier ═══ An SR entry in positions 7 and 8 indicates that the specification is part of a subroutine. The SR entry is not required. Subroutine lines must appear after the total calculation specifications. The operation codes BEGSR and ENDSR serve as delimiters for a subroutine. ═══ 1.8.1.2.4. AND/OR Lines Identifier ═══ Positions 7 and 8 can contain AN or OR to define additional indicators (positions 9 through 17) for a calculation. Indicators in positions 9 through 17 contained in one line are always in an AND relationship. Indicators contained on more than one line can be a combination of AND and OR relationships. A maximum of seven AND/OR lines can be specified in one group. The entry in positions 7 and 8 of the line immediately preceding an AND/OR line or a group of AND/OR lines determines when the calculation is to be processed. The entry in positions 7 and 8 on the first line of a group applies to all AND/OR lines in the group. A control level indicator (L1 through L9, L0, or LR) is entered for total calculations, an SR or blanks for subroutines, and a blank for detail calculations. ═══ 1.8.1.3. Positions 9-17 (Indicators) ═══ Entry Explanation Blank The operation is processed on every record if the condition specified in positions 7 and 8 is satisfied. 01-99 General indicators. KA-KN, KP-KY Function key indicators. L1-L9 Control level indicators. LR Last record indicator. MR Matching record indicator. H1-H9 Halt indicators. RT Return indicator. U1-U8 External indicators. OA-OG, OV Overflow indicator. Positions 10 and 11, 13 and 14, and 16 and 17 contain indicators that are tested to determine if a particular calculation is to be processed. A blank in positions 9, 12, and 15 designates that the indicator must be on for a calculation to be done. An N in positions 9, 12, and 15 designates that the associated indicator must be off for a calculation to be done. One to three indicators can be entered in positions 9 through 17 on one line. Indicators on the same line are in an AND relationship. The AND relationship means that all three indicator conditions must be satisfied before the calculation can take place. If fewer than three indicators are specified, entries need not be made in sequence; that is, an indicator can be specified in positions 16 and 17, and positions 10 through 15 can be blank. When more than three indicators are needed to condition a calculation, AND/OR must be used. Seven is the maximum number of AND/OR lines that can be specified on calculation specifications. Positions 9 through 17 can contain a combination of the type of indicators discussed in the preceding text. ═══ 1.8.1.4. Positions 18-27 (Factor 1) ═══ Factor 1 names a field or gives actual data (literals) or RPG/400 special words (*NAMVAR DEFN) on which an operation is to be done. The entry must begin in position 18. The entries that are valid for factor 1 depend on the operation code specified in positions 28 through 32. For the specific entries for factor 1 for a particular operation code, see Operation Codes. With some operation codes, a colon can be used to separate parts of the factor, but must be preceded by and followed by a valid entry. ═══ 1.8.1.5. Positions 28-32 (Operation) ═══ Positions 28 through 32 specify the kind of operation to be done using factor 1, factor 2, and the result field entries. The operation code must begin in position 28. For further information on the operation codes, see Operation Codes. For a list of the operation codes, see Operation Codes List. The program processes the operations in the order specified on the calculation specifications form. ═══ 1.8.1.6. Positions 33-42 (Factor 2) ═══ Factor 2 names a field or gives the actual data (literals) on which a calculation is to be done. For the file operation codes, factor 2 names a file or record format to be used. The entry must begin in position 33. The entries that are valid for factor 2 depend on the operation code specified in positions 28 through 32. With some operation codes, a colon can be used to separate parts of the factor, but must be preceded by and followed by a valid entry. For the specific entries for factor 2 for a particular operation code, see Operation Codes. ═══ 1.8.1.7. Positions 43-48 (Result Field) ═══ The result field names the field that contains the result of the calculation operation specified in positions 28 through 32. Array elements are treated as fields. A look-ahead field, user date special word a literal, or a named constant cannot appear as the result field of a calculation. See Operation Codes for the result field rules for individual operation codes. ═══ 1.8.1.8. Positions 49-51 (Field Length) ═══ Entry Explanation 1-30 Numeric field length. 1-256 Character field length. Blank The result field is defined elsewhere. Positions 49 through 51 specify the length of the result field. This entry is optional, but can be used to define a field not defined elsewhere in the program. These definitions of the field entries are allowed if the result field contains a field name. The entry specifies the number of positions to be reserved for the result field. The entry must be right-adjusted. The unpacked length (number of digits) must be specified for numeric fields. If the length of an arithmetic result to the left of the decimal point exceeds the specified length, the excess leftmost digits and any excess decimal positions are dropped. No diagnostic message occurs if the result is truncated. If the result field is defined elsewhere in the program, no entry is required for the length. However, if the length is specified, and if the result field is defined elsewhere, the length must be the same as the previously defined length. If half-adjustment is specified in position 53 of the calculation specifications, the entries for field length (positions 49 through 51) and decimal positions (position 52) refer to the length of the result field after half-adjustment. ═══ 1.8.1.9. Position 52 (Decimal Positions) ═══ Entry Explanation Blank The result field is character data or has been defined elsewhere in the program. 0-9 Number of decimal positions in a numeric result field. Position 52 indicates the number of positions to the right of the decimal in a numeric result field. If the numeric result field contains no decimal positions, enter a '0' (zero). This position must be blank if the result field is character data. This position can be left blank if the result field is numeric but was described by input or calculation specifications or in an external description. In this case, field length (positions 49 through 51) must also be left blank. The number of decimal positions specified cannot exceed the length of the field. ═══ 1.8.1.10. Position 53 (Operation Extender) ═══ Entry Explanation Blank No operation extension supplied. H Half adjust. N Record is read but not locked. P Pad the result field with blanks. The operation extenders are single-character entries that provide additional attributes to the operations that they accompany. Operation extenders are specified in position 53 of calculation specifications. An H indicates whether the contents of the result field are to be half adjusted (rounded). Half-adjusting is done by adding 5 (-5 if the field is negative) one position to the right of the last specified decimal position in the result field. The half adjust entry is allowed only with arithmetic operations, but not with an MVR operation or with a DIV operation followed by the MVR operation. Half adjust can be specified only if the number of decimal positions in the generated result is greater than the number of decimal positions in the result field. Resulting indicators are set according to the value of the result field after half-adjusting has been done. An N in a READ, READE, READP, REDPE, or CHAIN operation on an update disk file indicates that a record is to be read, but not locked. If no value is specified, the default action of locking occurs. A P indicates that, for CAT, SUBST, MOVEA, MOVEL, or XLATE, the result field is padded on the right after executing the instruction if the result field is longer than the result of the operation. Padding is done from the left for MOVE. ═══ 1.8.1.11. Positions 54-59 (Resulting Indicators) ═══ These positions can be used, for example, to test the value of a result field after the completion of an operation, or to indicate an end-of-file, error, or record-not-found condition. The resulting indicator positions have different uses, depending on the operation code specified. See the individual operation codes in Operation Codes for a description of the associated resulting indicators. For arithmetic operations, the result field is tested only after the field is truncated and half-adjustment is done (if specified). The setting of indicators depends on the results of the tests specified. Entry Explanation Blank No resulting indicator specified 01-99 General indicators KA-KN, KP-KY Function key indicators H1-H9 Halt indicators L1-L9 Control level indicators LR Last record indicator OA-OG, OV Overflow indicators U1-U8 External indicators RT Return indicator. Resulting indicators cannot be used when the result field uses a non-indexed array. If the same indicator is used as a resulting indicator on more than one calculation specification, the last calculation specification processed determines the status of that indicator. Remember the following points when specifying resulting indicators:  When the calculation operation is done, the specified resulting indicators are set off, and, if a condition specified by a resulting indicator is satisfied, that indicator is set on.  When a control level indicator (L1 through L9) is set on, the lower level indicators are not set on.  When a halt indicator (H1 through H9) is set on, the program ends unless the halt indicator is set off before the indicator is tested. ═══ 1.8.1.12. Positions 60-74 (Comments) ═══ Positions 60 through 74 of each calculation specification line can be used for comments to document the purpose of that calculation. ═══ 1.8.1.13. Positions 75-80 (Comments) ═══ Positions 75 through 80 can be used for comments, or left blank. These positions are not printed contiguously with positions 6-74 on the compiled listing. ═══ 1.9. Output Specifications ═══ Output specifications describe the record and the format of fields in a program described output file and when the record is to be written. Output specifications are optional for an externally described file. Output specifications can be divided into two categories: record identification and control (positions 7 through 37), and field description and control (positions 23 through 70). These specifications are entered on the RPG/400 Output Specifications. Detailed information for the output specifications is given in:  Entries for program described files  Entries for externally described files ═══ 1.9.1. Program Described Files ═══  Position 6 (Form Type)  Record Identification and Control Entries  Field Description and Control Entries ═══ 1.9.1.1. Position 6 (Form Type) ═══ An O must appear in position 6 to identify this line as an output specifications statement. ═══ 1.9.2. Record Identification and Control Entries ═══  Positions 7-14 (File Name)  Positions 14-16 (Logical Relationship)  Position 15 (Type - Program Described File)  Positions 16-18 (Record Addition/Deletion)  Position 16 (Fetch Overflow/Release) - Fetch Overflow - Release  Positions 17-22 (Space and Skip)  Position 17 (Space Before)  Position 18 (Space After)  Positions 19-20 (Skip Before)  Positions 21-22 (Skip After)  Positions 23-31 (File Record ID Indicators)  Positions 32-37 (EXCPT Name) Entries in positions 7 through 37 identify the output records that make up the files, provide the correct spacing on printed reports, and determine under what conditions the records are to be written. ═══ 1.9.2.1. Positions 7-14 (File Name) ═══ Entry Explanation A valid file name Same file name that appears on the file description specifications for the output file. Specify the file name on the first line that defines an output record for the file. The file name specified must be the same file name assigned to the output, update, or combined file on the file description specifications. If records from files are interspersed on the output specifications, the file name must be specified each time the file changes. For files specified as output, update, combined or input with ADD, at least one output specification is required unless an explicit file operation code with a data structure name specified in the result field is used in the calculations. For example, a WRITE operation does not require output specifications. ═══ 1.9.2.2. Positions 14-16 (Logical Relationship) ═══ Entry Explanation AND or OR AND/OR indicates a relationship between lines of output indicators. AND/OR lines are valid for output records, but not for fields. Positions 14 through 16 specify AND/OR lines for output operations. To specify this relationship, enter AND/OR in positions 14 through 16 on each additional line following the line containing the file name. At least one indicator must be specified on each AND line. For an AND relationship and fetch overflow position 16 must be specified on the first line only (file name line). A fetch overflow entry is required on OR lines for record types requiring the fetch overflow routine. Positions 17 through 22 (spacing and skipping) must be blank on an AND line. In an OR relationship, positions 17 through 22 can be used; if they are blank, the definitions from the preceding line are used. Positions 7 through 13 must be blank when AND/OR is specified. An unlimited number of AND/OR lines can be specified on the output specifications. ═══ 1.9.2.3. Position 15 (Type - Program Described File) ═══ Entry Explanation H or D Detail records usually contain data that comes directly from the input record or that is the result of calculations processed at detail time. Heading records usually contain constant identifying information such as titles, column headings, page number, and date. No distinction is made between heading and detail records. The H/D specifications are available to help the programmer document the program. T Total records usually contain data that is the end result of specific calculations on several detail records. E Exception records are written during calculation time. Exception records can be specified only when the operation code EXCPT is used. See Operation Codes for further information on the EXCPT operation code. Position 15 indicates the type of record to be written. Position 15 must have an entry for every output record. Heading (H) and detail (D) lines are both processed as detail records. No special sequence is required for coding the output records; however, all lines of each record type (H, D, T, or E) are handled at separate times within the program cycle. ═══ 1.9.2.4. Positions 16-18 (Record Addition/Deletion) ═══ Entry Explanation ADD Add a record to the file or subfile. DEL Delete the last record read from the file. The deleted record cannot be retrieved; the record is deleted from the system. An entry of ADD is valid for input, output, or update files. DEL is valid for update DISK files only. Note: The file description specifications for a file using the ADD function for DISK files must have an A in position 66. This entry must appear on the same line that contains the record type (H, D, T, E) specification (position 15). If an OR line is used following an ADD or DEL entry, this entry applies to the OR line also. ═══ 1.9.2.5. Position 16 (Fetch Overflow/Release) ═══ Entry Explanation Blank Must be blank for all files except printer files (PRINTER specified in positions 40 through 46 of the file description specifications). If position 16 is blank for printer files, overflow is not fetched. F Fetch overflow. R Release a device (workstation) after output. ═══ 1.9.2.5.1. Fetch Overflow ═══ An F in position 16 specifies fetch overflow for the printer file defined on this line. This file must be a printer file that has overflow lines. Fetch overflow is processed only when an overflow occurs and when all conditions specified by the indicators in positions 23 through 31 are satisfied. An overflow indicator cannot be specified on the same line as fetch overflow. If an overflow indicator has not been specified in positions 33 and 34 of the file description specifications for a printer file, the compiler assigns one to the file. An overflow line is generated by the compiler for the file, except when no other output records exist for the file or when the printer uses externally described data. This compiler-generated overflow can be fetched. Overflow lines can be written during detail, total, or exception output time. When the fetch overflow is specified, only overflow output associated with the file containing the processed fetch is output. The fetch overflow entry (F) is required on each OR line for record types that require the overflow routine. The fetch overflow routine does not automatically advance forms. The form length and overflow line can be specified on the line counter specifications, in the printer device file, or through an OS/400 override command. ═══ 1.9.2.5.2. Release ═══ After an output operation is complete, the device used in the operation is released if you have specified an R in position 16 of the corresponding output specifications. See the REL (Release) operation for further information on releasing devices. ═══ 1.9.2.6. Positions 17-22 (Space and Skip) ═══ Use positions 17 through 22 to specify line spacing and skipping for a printer file. Spacing refers to advancing one line at a time, and skipping refers to jumping from one print line to another. If spacing and skipping are specified for the same line, the spacing and skipping operations are processed in the following sequence: Skip before Space before Print a line Skip after Space after. If PRTCTL (printer control option) is not specified on the file description specifications, an entry must be made in one of the following positions when the device is PRINTER: 17 (space before), 18 (space after), 19 and 20 (skip before), or 21 and 22 (skip after). If a space/skip entry is left blank, the particular function with the blank entry (such as space before or space after) does not occur. If entries are made in position 17 (space before) or in positions 19 through 22 (skip before and skip after) and no entry is made in position 18 (space after), no space occurs after printing. When PRTCTL is specified, it is used only on records with blanks specified in positions 17 through 22. If a skip before or a skip after a line on a new page is specified, but the printer is on that line, the skip does not occur. ═══ 1.9.2.7. Position 17 (Space Before) ═══ Entry Explanation 0 or Blank No spacing 1 Single spacing 2 Double spacing 3 Triple spacing. ═══ 1.9.2.8. Position 18 (Space After) ═══ Entry Explanation 0 or Blank No spacing 1 Single spacing 2 Double spacing 3 Triple spacing. ═══ 1.9.2.9. Positions 19-20 (Skip Before) ═══ Entry Explanation 0 or Blank No skipping occurs. 01-99 Skip to lines 1 to 99 before printing for printer files. A0-A9 Skip to lines 100 to 109 before printing for printer files. B0-B2 Skip to lines 110 to 112 before printing for printer files. ═══ 1.9.2.10. Positions 21-22 (Skip After) ═══ Entry Explanation 0 or Blank No skipping occurs. 01-99 Skip to lines 1 to 99 after printing for printer files. A0-A9 Skip to lines 100 to 109 after printing for printer files. B0-B2 Skip to lines 110 to 112 after printing for printer files. ═══ 1.9.2.11. Positions 23-31 (File Record ID Indicators) ═══ Entry Explanation Blank The line or field is output every time the record (heading, detail, total, or exception) is checked for output. 01-99 A general indicator that is used as a resulting indicator, field indicator, or record identifying indicator. KA-KN, KP-KY Function key indicators. L1-L9 Control level indicators. H1-H9 Halt indicators. U1-U8 External indicator set before running the program or set as a result of a calculation operation. OA-OG, OV Overflow indicator previously assigned to this file. MR Matching record indicator. LR Last record indicator. RT Return indicator. 1P First-page indicator. Valid only on heading or detail lines. Conditioning indicators are not required on output lines. If conditioning indicators are not specified, the line is output every time that record is checked for output. Up to three indicators can be entered on one specification line to control when a record or a particular field within a record is written. The indicators that condition the output are coded in positions 24 and 25, 27 and 28, and 30 and 31. When an N is entered in positions 23, 26, or 29, the indicator in the associated position must be off for the line or field to be written. Otherwise, the indicator must be on for the line or field to be written. If more than one indicator is specified on one line, all indicators are considered to be in an AND relationship. If the output record must be conditioned by more than three indicators in an AND relationship, enter the letters AND in positions 14 through 16 of the following line and specify the additional indicators in positions 23 through 31 on that line. For an AND relationship, fetch overflow (position 16) can only be specified on the first line. Positions 17 through 22 (spacing and skipping) must be blank for all AND lines. An overflow indicator must be defined on the file description specifications (positions 33 and 34) before it can be used as a conditioning indicator. If a line is to be conditioned as an overflow line, the overflow indicator must appear on the main specification line or on the OR line. If an overflow indicator is used on an AND line, the line is not treated as an overflow line, but the overflow indicator is checked before the line is written. In this case, the overflow indicator is treated like any other output indicator. If the output record is to be written when any one of two or more sets of conditions exist (an OR relationship), enter the letters OR in positions 14 and 15 of the following specification line, and specify the additional OR indicators on that line. When an OR line is specified for a printer file, the skip and space entries (positions 17 through 22) can all be blank, in which case the space and skip entries of the preceding line are used. If they differ from the preceding line, enter space and skip entries on the OR line. If fetch overflow (position 16) is used, it must be specified on each OR line. ═══ 1.9.2.12. Positions 32-37 (EXCPT Name) ═══ When the record type is an exception record (indicated by an E in position 15), a name can be placed in these positions of the record line. The EXCPT operation can specify the name assigned to a group of the records to be output. This name is called an EXCPT name. An EXCPT name must follow the rules for using symbolic names. A group of any number of output records can use the same EXCPT name, and the records do not have to be consecutive records. When the EXCPT operation is specified without an EXCPT name, only those exception records without an EXCPT name are checked and written if the conditioning indicators are satisfied. When the EXCPT operation specifies an EXCPT name, only the exception records with that name are checked and written if the conditioning indicators are satisfied. The EXCPT name is specified on the main record line and applies to all AND/OR lines. If an exception record with an EXCPT name is conditioned by an overflow indicator, the record is written only during the overflow portion of the RPG/400 cycle or during fetch overflow. The record is not written at the time the EXCPT operation is processed. An EXCPT operation with no fields can be used to release a record lock in a file. The UNLCK operation can also be used for this purpose. In the following figure, the record lock in file RCDA is released by the EXCPT operation. Record Lock in File Released by EXCPT Operation *...1....+....2....+....3....+....4....+....5....+....6....+....7... CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++ C* C KEY CHAINRCDA C EXCPTRELESE *...1....+....2....+....3....+....4....+....5....+....6....+....7... O O* ORCDA E RELESE O* (no fields) ═══ 1.9.3. Field Description and Control Entries ═══ Entries in positions 23 through 70 determine under what conditions and in what format fields of a record are to be written. Each field is described on a separate line. No entries are permitted in positions 7 through 22 of a field description line. Field description and control information for a field begins on the line following the record identification line.  Positions 23-31 (File Field Description Indicators)  Positions 32-37 (Field Name) - Field Names, Blanks, Tables and Arrays - PAGE, PAGE1-PAGE7 - *PLACE - User Date Reserved Words - *IN, *INxx, *IN,xx  Position 38 (Edit Codes)  Position 39 (Blank After)  Positions 40-43 (End Position)  Position 44 (Data Format)  Positions 45-70 (Constant or Edit Word) - Constants - Edit Words - Format Name  Positions 71-74 (Reserved)  Positions 75-80 (Comments) ═══ 1.9.3.1. Positions 23-31 (File Field Description Indicators) ═══ Indicators specified on the field description lines determine whether a field is to be included in the output record, except for PAGE reserved fields. See PAGE, PAGE1-PAGE7 for information on how output indicators affect the PAGE fields. The same types of indicators can be used to control fields as are used to control records, see Positions 23-31 (File Record ID Indicators). Indicators used to condition field descriptions lines cannot be specified in an AND/OR relationship. Conditioning indicators cannot be specified on format name specifications for program described WORKSTN files. ═══ 1.9.3.2. Positions 32-37 (Field Name) ═══ In positions 32 through 37, use one of the following entries to specify each field that is to be written out:  A field name  Blanks if a constant is specified in positions 45 through 70  A table name, array name, or array element  A named constant  The RPG/400 reserved words PAGE, PAGE1 through PAGE7, *PLACE, UDATE, *DATE, UDAY, *DAY, UMONTH, *MONTH, UYEAR, *YEAR, *IN, *INxx, or *IN,xx  A data structure name or data structure subfield name. ═══ 1.9.3.2.1. Field Names, Blanks, Tables and Arrays ═══ The field names used must be defined in the program. Do not enter a field name if a constant or edit word is used in positions 45 through 70. If a field name is entered in positions 32 through 37, positions 7 through 22 must be blank. Fields can be specified in any order because the sequence in which they appear on the output records is determined by the entry in positions 40 through 43. If fields overlap, the last field specified is the only field completely written. When a non-indexed array name is specified, the entire array is written. An array name with a constant index or variable index causes one element to be written. When a table name is specified, the element last found in a LOKUP (Look Up) operation is written. The first element of a table is written if no successful LOKUP operation was done. The conditions for a field and the conditions for the record it is contained in must be satisfied before the field is written out. ═══ 1.9.3.2.2. PAGE, PAGE1-PAGE7 ═══ To use automatic page numbering, code PAGE in positions 32 through 35 as the name of the output field. Indicators specified in positions 23 though 31 do not condition the field, but rather control the resetting of the PAGE field. When indicators are specified and their conditions are met, the PAGE field is set to zero and incremented by 1 before output; when the conditions are not met, the PAGE field is incremented by 1 and then output. If page numbers are needed for several output files (or for different numbering within one file), the entries PAGE1 through PAGE7 can be used. The PAGE fields are automatically zero-suppressed by the Z edit code. For more information on the PAGE reserved words, see RPG/400 Words with Special Functions. ═══ 1.9.3.2.3. *PLACE ═══ *PLACE is an RPG/400 reserved word that is used to repeat data in an output record. Fields or constants that have been specified on previous specification lines can be repeated in the output record without having the field and end positions named on a new specification line. When *PLACE is coded in positions 32 through 37, all data between the first position and the highest end position previously specified for a field in that output record is repeated until the end position specified in the output record on the *PLACE specification line is reached. The end position specified on the *PLACE specification line must be at least twice the highest end position of the group of fields to be duplicated. *PLACE can be used with any type of output. Blank after (position 39), editing (positions 38, 45 through 70), data format (position 44), and relative end positions cannot be used with *PLACE. ═══ 1.9.3.2.4. User Date Reserved Words ═══ The user date reserved words (UDATE, *DATE, UDAY, *DAY, UMONTH *MONTH, UYEAR, *YEAR) allow the programmer to supply a date for the program at run time. For more information on the user date reserved words, see Rules for User Date. ═══ 1.9.3.2.5. *IN, *INxx, *IN,xx ═══ The reserved words *IN, *INxx and *IN,xx allow the programmer to refer to and manipulate RPG/400 indicators as data. ═══ 1.9.3.3. Position 38 (Edit Codes) ═══ Entry Explanation Blank No edit code is used. 1-9, A-D, J-Q, X, Y, Z Numeric fields are zero-suppressed and punctuated according to a predefined pattern without the use of edit words. Position 38 is used to specify edit codes that suppress leading zeros in a numeric field or to punctuate a numeric field without using an edit word. Allowable entries are 1 through 9, A through D, J through Q, X, Y, Z, and blank. Edit codes 5 through 9 are user-defined edit codes and are defined externally by an OS/400 function. The edit code is determined at compilation time. Subsequent changes to a user-defined edit code will not affect the editing by the RPG/400 compiler unless the program is recompiled. For more information see Simple Edit Codes and Combination Edit Codes. ═══ 1.9.3.4. Position 39 (Blank After) ═══ Entry Explanation Blank The field is not reset. B The field specified in positions 32 through 37 is reset to blank or zero after the output operation is complete. Position 39 is used to reset a numeric field to zeros or a character field to blanks. If the field is conditioned by indicators in positions 23 through 31, the blank after is also conditioned. This position must be blank for look-ahead, user date special words, *PLACE, named constants, and constants. Resetting fields to zeros is useful when totals are accumulated and written for each control group in a program. After the total is accumulated and written for one control group, the total field can be reset to zeros before accumulation begins on the total for the next control group. If blank after (position 39) is specified for a field to be written more than once, the B should be entered on the last line specifying output for that field, or else the field named may be set to blanks or zeros after the field is written to the output record. ═══ 1.9.3.5. Positions 40-43 (End Position) ═══ Entry Explanation 1-n End position K1-K8 Length of format name for WORKSTN file. Positions 40 through 43 define the end position of a field or constant on the output record, or define the length of the data description specifications record format name for a program described WORKSTN file. The K identifies the entry as a length rather than an end position, and the number following the K indicates the length of the record format name. For example, if the format name is CUSPMT, the entry in positions 42 and 43 is K6. Leading zeros are permitted following the K, and the entry must be right-adjusted. Valid entries for end positions are blanks, +nnn, -nnn, and nnnn. All entries in these positions must end in position 43. Enter the position of the rightmost character of the field or constant. The end position must not exceed the record length for the file. If an entire array is to be written, enter the end position of the last element in the array in positions 40 through 43. If the array is to be edited, be careful when specifying the end position to allow enough positions to write all edited elements. Each element is edited according to the edit code or edit word. The +nnn or -nnn entry specifies the placement of the field or constant relative to the end position of the previous field. The sign must be in position 40. The number (nnn) must be right-adjusted, but leading zeros are not required. To calculate the end position, use these formulas: EP = PEP +nnn + FL EP = PEP -nnn + FL EP is the calculated end position. PEP is the previous end position. For the first field specification in the record, PEP is equal to zero. FL is the length of the field after editing, or the length of the constant specified in this specification. The use of +nnn is equivalent to placing nnn positions between the fields. A -nnn causes an overlap of the fields by nnn positions. For example, if the previous end position (PEP) is 6, the number of positions to be placed between the fields (nnn) is 5, and the field length (FL) is 10, the end position (EP) equals 21. When *PLACE is used, an actual end position must be specified; it cannot be blank or a displacement. An entry of blank is treated as an entry of +000. No positions separate the fields. ═══ 1.9.3.6. Position 44 (Data Format) ═══ Entry Explanation Blank The field is to be written in zoned decimal numeric or character format; numeric data is edited, or a constant is specified on this line. P The field is to be written in packed decimal format. B The field is to be written in binary format. L The numeric output field is to have a preceding (left) plus or minus sign. R The numeric output field is to have a following (right) plus or minus sign. This position must be blank if editing is specified. The entry in position 44 specifies the format of the data in the records in the file. This entry has no effect on the format used for internal processing of the output field in the program. ═══ 1.9.3.7. Positions 45-70 (Constant or Edit Word) ═══ Positions 45 through 70 are used to specify a constant, a format name, or an edit word for a program described file. ═══ 1.9.3.7.1. Constants ═══ Constants consist of character data (literals) that does not change from one processing of the program to the next. A constant is the actual data used in the output record rather than a name representing the location of the data. A constant of up to 24 characters can be placed in positions 45 through 70. The constant must begin in position 46 (apostrophe in position 45), and it must end with an apostrophe even if it contains only numeric characters. Any apostrophe used within the constant must be entered twice; however, only one apostrophe appears when the constant is written out. The field name (positions 32 through 37) must be blank. Instead of entering a constant, you can use a named constant containing a maximum of 256 characters. ═══ 1.9.3.7.2. Edit Words ═══ An edit word specifies the punctuation of numeric fields, including the printing of dollar signs, commas, periods, and sign status. See Parts of an Edit Word for details. ═══ 1.9.3.7.3. Format Name ═══ The name of the data description specifications record format that is used by a program described WORKSTN file must be specified in positions 45 through 54. One format name is required for each output record for the WORKSTN file; specifying more than one format name per record is not allowed. Conditioning indicators cannot be specified on format name specifications for program described WORKSTN files. The format name must be enclosed in apostrophes. You must also enter Kn in positions 40 through 43, where n is the length of the format name. For example, if the format name is 'CUSPMT', enter K6 in positions 42 and 43. A named constant can also be used. ═══ 1.9.3.8. Positions 71-74 (Reserved) ═══ Positions 71 through 74 must be blank. ═══ 1.9.3.9. Positions 75-80 (Comments) ═══ Positions 75 through 80 can be used for comments, or left blank. ═══ 1.9.4. Externally Described Files ═══  Position 6 (Form Type)  Record Identification and Control Entries  Field Description and Control Entries ═══ 1.9.4.1. Position 6 (Form Type) ═══ An O must appear in position 6 to identify this line as an output specifications statement. ═══ 1.9.5. Record Identification and Control Entries ═══ Output specifications for an externally described file are optional. Entries in positions 7 through 37 of the record identification line identify the record format and determine under what conditions the records are to be written.  Positions 7-14 (Record Name)  Positions 14-16 (External Logical Relationship)  Position 15 (Type - Externally Described File)  Position 16 (Release)  Positions 16-18 (Record Addition)  Positions 16-22 (Fetch Overflow/Space/Skip)  Positions 23-31 (External File Record ID Indicators)  Positions 32-37 (EXCPT Name) ═══ 1.9.5.1. Positions 7-14 (Record Name) ═══ Entry Explanation A valid record format name A record format name must be specified for an externally described file. ═══ 1.9.5.2. Positions 14-16 (External Logical Relationship) ═══ Entry Explanation AND or OR AND/OR indicates a relationship between lines of output indicators. AND/OR lines are valid for output records, but not for fields. See Positions 14-16 (Logical Relationship) for more information. ═══ 1.9.5.3. Position 15 (Type - Externally Described File) ═══ Entry Explanation H or D Detail records T Total records E Exception records. Position 15 indicates the type of record to be written. See Position 15 (Type - Program Described File) for more information. ═══ 1.9.5.4. Position 16 (Release) ═══ Entry Explanation R Release a device after output. See Release for more information. ═══ 1.9.5.5. Positions 16-18 (Record Addition) ═══ Entry Explanation ADD Add a record to a file. DEL Delete an existing record from the file. For more information on record addition, see Positions 16-18 (Record Addition/Deletion). ═══ 1.9.5.6. Positions 16-22 (Fetch Overflow/Space/Skip) ═══ The fetch overflow, space, and skip entries for an externally described file must be blank. Space and skip entries for an externally described printer file are specified in the data description specifications. ═══ 1.9.5.7. Positions 23-31 (External File Record ID Indicators) ═══ Output indicators for externally described files are specified in the same way as those for program described files. The overflow indicators OA-OG, OV are not valid for externally described files. For more information on output indicators, see Positions 23-31 (File Record ID Indicators). ═══ 1.9.5.8. Positions 32-37 (EXCPT Name) ═══ An EXCPT name can be specified in these positions for an exception record line. See Positions 32-37 (EXCPT Name) for more information. ═══ 1.9.6. Field Description and Control Entries ═══ For externally described files, the only valid field description and control entries are conditioning indicators (positions 23 through 31), field name (positions 32 through 37), and blank after (position 39).  Positions 23-31 (External Field Description Indicators)  Positions 32-37 (Field Name)  Position 38 (Edit Codes)  Position 39 (Blank After)  Positions 40-43 (End Position)  Position 44 (Data Format)  Positions 45-70 (Constant or Edit Word)  Positions 71-74 (Reserved)  Positions 75-80 (Comments) ═══ 1.9.6.1. Positions 23-31 (External Field Description Indicators) ═══ Indicators specified on the field description lines determine whether a field is to be included in the output record. The same types of indicators can be used to control fields as are used to control records. See Positions 23-31 (File Record ID Indicators) for more information. ═══ 1.9.6.2. Positions 32-37 (Field Name) ═══ Entry Explanation Valid field name A field name specified for an externally described file must be present in the external description unless the external name was renamed for the program. *ALL Specifies the inclusion of all the fields in the record. For externally described files, only the fields specified are placed in the output record. *ALL can be specified to include all the fields in the record. If *ALL is specified, no other field description lines can be specified for that record. In particular, you cannot specify a B (blank after) in position 39. For an update record, only those fields specified in the output field specifications and meeting the conditions specified by the output indicators are placed in the output record to be rewritten. The values that were read are used to rewrite all other fields. For the creation of a new record, the fields specified are placed in the output record. Those fields not specified or not meeting the conditions specified by the output indicators are written as zeros or blanks, depending on the data format specified in the external description. ═══ 1.9.6.3. Position 38 (Edit Codes) ═══ Position 38 must be blank because edit codes for externally described files are specified in the data description specifications. ═══ 1.9.6.4. Position 39 (Blank After) ═══ Entry Explanation Blank The field is not reset. B The field specified in positions 32 through 37 is reset to blanks or zeros after the output operation is complete. Do not specify *ALL in positions 32 through 37. For more information on blank after, see Position 39 (Blank After). ═══ 1.9.6.5. Positions 40-43 (End Position) ═══ These positions must be blank because the field is placed in the output record in the positions specified by the data description specifications. ═══ 1.9.6.6. Position 44 (Data Format) ═══ This position must be blank because the data format is defined in the data description specifications. ═══ 1.9.6.7. Positions 45-70 (Constant or Edit Word) ═══ These positions must be blank because editing is specified in the data description specifications. If a constant is to be placed in an externally described file, it must be done by a calculation operation. ═══ 1.9.6.8. Positions 71-74 (Reserved) ═══ Positions 71 through 74 must be blank. ═══ 1.9.6.9. Positions 75-80 (Comments) ═══ Positions 75 through 80 can be used for comments, or left blank. ═══ 1.10. Operation Codes ═══ The RPG/400 programming language allows you to do many different types of operations on your data. Operation codes, which are entered on the calculation specifications, indicate the operation to be done. Usually they are abbreviations of the name of the operation. For a list of the operation codes, see Operation Codes List. ═══ 1.10.1. Arithmetic Operations ═══ The arithmetic operations are:  ADD (Add)  DIV (Divide)  MULT (Multiply)  MVR (Move Remainder)  SQRT (Square Root)  SUB (Subtract)  XFOOT (Summing the Elements of an Array)  Z-ADD (Zero and Add)  Z-SUB (Zero and Subtract). For examples of arithmetic operations, see Figure "Summary of Arithmetic Operations". Remember the following when specifying arithmetic operations:  Arithmetic operations can be done only on numeric fields (including numeric subfields, numeric arrays, numeric array elements, numeric table elements, numeric named constants, numeric figurative constants, and numeric literals).  Arithmetic operations are done on data in packed decimal format. Data maintained in other formats is converted to or from packed decimal format.  Decimal alignment is done for all arithmetic operations. Even though truncation can occur, the position of the decimal point in the result field is not affected.  An arithmetic operation does not change factor 1 and factor 2 unless they are the same as the result field.  Any data placed in the result field replaces the data that was there.  The result field must be large enough to accommodate the results of the arithmetic operation because an RPG/400 program does not cause an error on an arithmetic overflow. If the result field is not large enough to accommodate the results, digits are dropped from either or both ends, depending on the location of the decimal point.  If you use conditioning indicators, it is your responsibility to ensure that the DIV operation occurs immediately before the MVR operation. If the MVR operation occurs before the DIV operation, undesirable results occur. An error message may be issued.  Half adjust (position 53) can be specified for all the arithmetic operations except for the MVR operation or for a DIV operation immediately followed by an MVR operation. For arithmetic operations in which all three fields are used:  Factor 1, factor 2, and the result field can be three different fields.  Factor 1, factor 2, and the result field can all be the same field.  Factor 1 and factor 2 can be the same field but different from the result field.  Either factor 1 or factor 2 can be the same as the result field. The length of any field specified in an arithmetic operation cannot exceed 30 digits. If the result exceeds 30 digits, digits are dropped from either or both ends, depending on the location of the decimal point. All arithmetic operations are done algebraically. The results of all operations are signed (a plus sign is a hexadecimal F and a minus sign is a hexadecimal D) according to the following rules. The sign is in the zone portion of the low-order byte. For information on using arrays with arithmetic operations, see Specifying an Array in Calculations. Addition: If factor 1 and factor 2 have like signs, the result field sign is the same. If factor 1 and factor 2 have unlike signs, the result field sign is the same as the sign of the factor with the larger absolute value. Subtraction: Change the sign of factor 2, and apply the rules for addition. Multiplication: If factor 1 and factor 2 have like signs, the result field sign is plus (+). If factor 1 and factor 2 have unlike signs, the result field sign is minus (-). Division: If factor 1 and factor 2 have like signs, the result field sign is plus (+). If factor 1 and factor 2 have unlike signs, the result field sign is minus (-). The sign of the remainder is the same as the factor 1 sign. For the ADD, SUB, MULT, and DIV operations, factor 1 is not required. If factor 1 is not specified, the operation is done as though factor 1 and the result field were the same field. ═══ 1.10.1.1. Arithmetic Operations Examples ═══ Summary of Arithmetic Operations *...1....+....2....+....3....+....4....+....5....+....6....+....7... CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++* C* Before the operations are processed, the field values are: C* A = 1.00 G = 2.77 C* B = 10.0 H = 70 C* C = 32 J = .6 C* D = -20 K = 25 C* E = 6. L = 1.0, 1.7, -1.1 RESULTS C* F = 10.0 ------- C ADD 1 A 30 002 C B ADD C V 52 042.00 C B ADD D V -10.00 C* C Z-ADDC V 032.00 C* C SUB 1 E 30 005 C C SUB B W 51 0022.0 C C SUB D W 0052.0 C* C Z-SUBC W -0032.0 C* C MULT E F 30 060 C B MULT G X 84 0027.7000 C B MULT D X -200.0000 C* C DIV B H 30 007 C C DIV J Y 62 0053.33 C* C MVR Z 53 00.020 C* C SQRT K Z 05.000 C* C XFOOTL Z 01.600 ═══ 1.10.2. Array Operations ═══ The array operations are:  LOKUP (Look Up)  MOVEA (Move Array)  SORTA (Sort an Array)  XFOOT (Summing the Elements of an Array). See each operation for an explanation of its function. ═══ 1.10.3. Bit Operations ═══ The bit operations are:  BITOF (Set Bits Off)  BITON (Set Bits On)  TESTB (Test Bit). The BITOF and BITON operations allow you to turn off and on specific bits in a field specified in the result field. The specified field must be a one-position character field. The TESTB operation compares the bits identified in factor 2 with the corresponding bits in the field named as the result field. In these operations, if factor 2 contains a 1-byte hexadecimal literal, the bits in the factor 2 entry will affect the result field entry in the same way a 1-byte character field would affect it. Note: You can also format one or more characters at a time using move operations with hexadecimal literals. See Move Operations for more detail. ═══ 1.10.4. Branching Operations ═══ The branching operations are:  CABxx (Compare and Branch)  ENDSR (End of Subroutine)  EXCPT (Calculation Time Output)  GOTO (Go To)  ITER (Iterate)  LEAVE (Leave a Do Group)  TAG (Tag). The GOTO operation (when used with a TAG operation) allows branching. For example:  Several operations can be skipped when certain conditions occur.  Certain operations can be done for several, but not all, record types.  Several operations can be repeated. The EXCPT operation allows records to be written during calculation time instead of at output time. The TAG operation names the label that identifies the destination of a GOTO or CABxx operation. The ITER operation transfers control from within a DO-group to the ENDDO statement of the DO-group. The LEAVE operation is similar to the ITER operation; however, LEAVE transfers control to the statement following the ENDDO operation. See each operation for an explanation of its function. ═══ 1.10.5. Call Operations ═══ The call operations are:  CALL (Call a Program)  FREE (Deactivate a Program)  PARM (Identify Parameters)  PLIST (Identify a Parameter List)  RETRN (Return to Caller). The CALL, FREE, and RETRN operations allow an RPG/400 program to transfer control to other programs. With the CALL, FREE, and RETRN function, the PLIST and PARM operations can be used to allow the calling and called programs to address the same data. See each operation for an explanation of its function. ═══ 1.10.6. Compare Operations ═══ The compare operations are:  ANDxx (And)  COMP (Compare)  CABxx (Compare and Branch)  CASxx (Conditionally Invoke Subroutine)  DOUxx (Do Until)  DOWxx (Do While)  IFxx (If)  ORxx (Or)  WHxx (When True Then Select). In the ANDxx, CABxx, CASxx, DOUxx, DOWxx, IFxx, ORxx, and WHxx operations, xx can be: xx Meaning GT Factor 1 is greater than factor 2. LT Factor 1 is less than factor 2. EQ Factor 1 is equal to factor 2. NE Factor 1 is not equal to factor 2. GE Factor 1 is greater than or equal to factor 2. LE Factor 1 is less than or equal to factor 2. Blanks Unconditional processing (CASxx or CABxx). The compare operations test fields for certain conditions. Resulting indicators assigned in positions 54 through 59 are set according to the results of the operation, or a branch occurs based on the results of the operation. No fields are changed by these operations. Remember the following when using the compare operations:  If numeric fields are compared, fields of unequal length are aligned at the implied decimal point. The fields are filled with zeros to the left and/or right of the decimal point making the field lengths and number of decimal positions equal for comparison.  If character fields are compared, fields of unequal length are aligned to their leftmost character. The shorter field is filled with blanks to equal the length of the longer field so that the field lengths are equal for comparison.  All numeric comparisons are algebraic. A plus (+) value is always greater than a minus (-) value.  Blanks within numeric fields are assumed to be zeros.  Numeric fields are converted to packed decimal format, if necessary, before they are compared.  If an alternate collating sequence (position 26 of the control specification) has been specified for the comparison of character fields, the fields are converted to the alternate sequence and then compared. If *HIVAL and *LOVAL are used to set up the comparison, the alternate collating sequence may alter the value before the compare operation. However, the actual field value will not change.  A character field cannot be compared with a numeric field.  An array name cannot be specified in a compare operation, but an array element may be specified.  The ANDxx and ORxx operations can be used with DOUxx, DOWxx, IFxx, and WHxx. ═══ 1.10.7. Data-Area Operations ═══ The data area operations are:  IN (Retrieve a Data Area)  OUT (Write a Data Area)  UNLCK (Unlock a Data Area or Release a Record). The IN and OUT operations allow you to retrieve and write one or all data areas in a program, depending on the factor 2 entry. The IN and OUT operations also allow you to control the locking or unlocking of a data area. When a data area is locked, it can be read but not updated by other programs. The following lock states are used:  For an IN operation with *LOCK specified, an exclusive allow read lock state is placed on the data area.  For an OUT or UNLCK operation, the exclusive allow read lock state is released. During the actual transfer of data into or out of a data area, there is a system-internal lock on the data area. If several users are contending for the same data area, a user may get an error message indicating that the data area is not available. Remember the following when using the IN, OUT, and UNLCK operations:  A data-area operation cannot be done on a data area that is not defined to the operating system.  Before the IN, OUT, and UNLCK operations can be done on a data area, you must specify that data area in the result field of an *NAMVAR DEFN statement. (For further information on the DEFN statement, see DEFN (Field Definition).)  The data-area operations can be done on a data-area data structure that is implicitly retrieved only if the data-area data structure name is specified in the result field of an *NAMVAR DEFN statement.  A locked data area cannot be updated or locked by another RPG/400 program; however, the data area can be retrieved in your own program by an IN operation with factor 1 blank.  A data-area name cannot be the name of a multiple-occurrence data structure, an input record field, an array, an array element, or a table.  A data area cannot be the subfield of a multiple occurrence data structure, a data-area data structure, a program-status data structure, a file-information data structure (INFDS), or a data structure that appears on an *NAMVAR DEFN statement. A data structure defined with a U in position 18 of the input specifications form indicates that the data structure is a data area. The data area is automatically read and locked at program initialization time, and the contents of the data structure are written to the data area when the program ends with LR on. Specify *LDA in factor 2 of a *NAMVAR DEFN statement to define the LDA data structure. Use the *NAMVAR DEFN operation with *PDA in factor 2 to define the name in the result field as the PDA data area. The result field follows the current conventions for *NAMVAR DEFN. ═══ 1.10.8. Declarative Operations ═══ The declarative operations do not cause action to occur; they can be specified anywhere within calculations. The control level entry (positions 7 and 8) can be blank or can contain an entry to group the statements within the appropriate section of the program. The control level entry is for documentation purposes only. The declarative operations are:  DEFN (Field Definition)  KFLD (Define Parts of a Key)  KLIST (Define a Composite Key)  PARM (Identify Parameters)  PLIST (Identify a Parameter List)  TAG (Tag). The DEFN operation either defines a field based on the attributes (length and decimal positions) of another field or defines a field as a data area. The KLIST and KFLD operations are used to indicate the name by which a composite key field may be referred and the fields that compose the composite key. A composite key is a key that contains a list of key fields. It is built from left to right, with the first KFLD specified being the leftmost (high-order) field of the composite key. The PLIST and PARM operations are used with the CALL operation to allow a called program access to parameters from a calling program. The TAG operation names the destination of a branching operation such as GOTO or CABxx. ═══ 1.10.9. File Operations ═══ The file operation codes are:  ACQ (Acquire)  CHAIN (Random Retrieval from a File)  CLOSE (Close Files)  COMIT (Commit)  DELET (Delete Record)  EXCPT (Calculation Time Output)  EXFMT (Write/Then Read Format)  FEOD (Force End of Data)  FORCE (Force a Certain File to Be Read Next Cycle)  NEXT (Next)  OPEN (Open File for Processing)  POST (Post)  READ (Read a Record)  READC (Read Next Changed Record)  READE (Read Equal Key)  READP (Read Prior Record)  REDPE (Read Prior Equal)  REL (Release)  ROLBK (Roll Back)  SETGT (Set Greater Than)  SETLL (Set Lower Limit)  UNLCK (Unlock a Data Area or Release a Record)  UPDAT (Modify Existing Record)  WRITE (Create New Records). File operations can be used with both program described and externally described files (F or E respectively in position 19 of the file description specifications). When an externally described file is used with certain file operations, a record format name, rather than a file name, can be specified in factor 2. Thus, the processing operation code retrieves and/or positions the file at a record format of the specified type according to the rules of the calculation operation code used. When the OVRDBF command is used with the MBR (*ALL) parameter specified, the SETLL, SETGT and CHAIN operations only process the current file member. For more information, refer to the Programming: Data Base Guide. The WRITE and UPDAT operations that specify a program described file name in factor 2 must have a data structure name specified in the result field. The CHAIN, READ, READE, READP, and REDPE operations that specify a program described file name in factor 2 may have a data structure name specified in the result field. With the CHAIN, READ, READE, READP, and REDPE operations, data is transferred directly between the file and the data structure, bypassing the normal field extract function. Thus, no record identifying or field indicators are set on as a result of an input operation to a data structure. If all input and output operations to the file have a data structure specified in the result field, input and output specifications are not required. However, the data structure must be defined on the input specifications. If an input operation (CHAIN, EXFMT, READ, READC, READE, READP, REDPE) does not retrieve a record because no record was found, because an error occurred in the operation, or because the last record was already retrieved (end of file), then no data is extracted and all fields in the program remain unchanged. If you specify an N in position 53 of a CHAIN, READ, READE, READP, or REDPE operation for an update disk file, a record is read without locking. If no value is specified in position 53, the record is locked if the file is an update disk file. Exception/errors that occur during file operations can be handled by the programmer (by coding an error indicator or specifying a file-error subroutine), or by the RPG/400 error handler. ═══ 1.10.10. Indicator-Setting Operations ═══ The SETON (Set On) and SETOF (Set Off) operations set (on or off) indicators specified in positions 54 through 59. At least one resulting indicator must be specified in these positions. Remember the following when setting indicators:  The 1P, MR, KA through KN, and KP through KY indicators cannot be set on by the SETON operation.  The 1P and MR indicators cannot be set off by the SETOF operation.  Setting L1 through L9 on or off with a SETON or SETOF operation does not automatically set any lower control level indicators. ═══ 1.10.11. Information Operations ═══ The information operations are:  DEBUG (Debug Function)  DUMP (Program Dump)  SHTDN (Shut Down)  TIME (Time of Day). The DEBUG operation writes the following information that you can use to debug an RPG/400 program:  The source statement sequence number of the DEBUG operation  The contents of factor 1 (if factor 1 is specified) that identifies the DEBUG written information  All indicators that are on at the time the operation is encountered  The contents of the result field (if the result field contains an entry). The information is sent to the file named in factor 2, or, if factor 2 is blank, the information is sent to a system defined file. The DUMP operation provides a dump of all indicators, fields, data structures, arrays, and tables used in a program. The SHTDN operation allows the program to determine whether the system operator has requested shutdown. If so, the resulting indicator that must be specified in positions 54 and 55 is set on. The TIME operation allows the program to access the system time of day and system date at any time during program running. ═══ 1.10.12. Initialization Operations ═══ The initialization operations provide run-time clearing and resetting of all elements in a structure (record format, data structure, array, or table) or a variable (field, subfield, or indicator). The initialization operations are:  CLEAR (Clear)  RESET (Reset). The CLEAR operation sets all elements in a structure or variable to zero, blank, or '0', depending on the field type (numeric, character, or indicator). This allows you to clear structures globally, instead of element by element. The RESET operation sets all elements in a structure or variable to their initial values (the values they had at the end of the initialization step in the program cycle). The RESET operation is used with data structure initialization and the initialization subroutine (*INZSR). You can use both data structure initialization and the *INZSR to set the initial value of a variable. The initial value will be used to set the variable if it appears in factor 2 of a RESET operation. When these operation codes are applied to record formats, only fields which are output are affected. See CLEAR (Clear) and RESET (Reset) for more detail. For more information see "Initialization" in Chapter 9 of the RPG/400* User's Guide. ═══ 1.10.13. Message Operation ═══ The message operation DSPLY (Display Function) allows communication between the program and the system console or between the program and the display workstation that requested the program. ═══ 1.10.14. Move Operations ═══ The move operations are:  MOVE (Move)  MOVEA (Move Array)  MOVEL (Move Left). Move operations transfer all or part of factor 2 to the result field. Factor 2 remains unchanged. Factor 1 must be blank. Resulting indicators can be specified in positions 54 through 59., except for the MOVE and MOVEL operations if the result field is an array, or for the MOVEA operation if the result field is an array or array element. In the move operations, factor 2 and the result field are generally of the same type (both numeric or both character). However, you can use the move operations to change numeric fields to character fields and character fields to numeric fields. To change a numeric field to a character field, enter the name of the numeric field in factor 2 and specify a character result field. To change a character field to a numeric field, enter the name of the character field in factor 2 and specify a numeric result field. When a character field is moved into a numeric result field, the digit portion of each character is converted to its corresponding numeric character and then moved to the result field. Blanks are transferred as zeros. For the MOVE operation, the zone portion of the rightmost character is converted to its corresponding sign and moved to the rightmost position of the numeric result field. It becomes the sign of the field. (See Figure "MOVE Operation" for an example.) For the MOVEL operation, the zone portion of the rightmost character of factor 2 is converted and used as the sign of the result field (unless factor 2 is shorter than the result field) whether or not the rightmost character is included in the move operation. (See Figure "MOVEL Operation" for an example.) If move operations are specified to move data into numeric fields, the decimal positions specified for the factor 2 field are ignored. For example, if 1.00 is moved into a three-position numeric field with one decimal position, the result is 10.0. If you specify P in position 53 for a move operation, the result field is padded from the right for MOVEL and MOVEA and from the left for MOVE. The pad characters are blank for character, 0 for numeric and '0' for indicator. The padding takes place after the operation. If you use MOVE or MOVEL to move a field to an array, each element of the array will be padded. If you use these operations to move an array to an array and the result contains more elements than the factor 2 array, the same padding takes place but the extra elements are not affected. A MOVEA operation with an array name in the result field will pad the last element affected by the operation plus all subsequent elements. When resulting indicators are specified for move operations, the result field determines which indicator is set on. If the result field is a character field, only the resulting indicator in positions 58 and 59 can be specified. This indicator is set on if the result field is all blanks. When the result field is numeric, all three resulting indicator positions may be used. These indicators are set on as follows: High (54-55) Set on if the result field is greater than 0. Low (56-57) Set on if the result field is less than 0. Equal (58-59) Set on if the result field is equal to 0. ═══ 1.10.15. Move Zone Operations ═══ The move zone operations are:  MHHZO (Move High to High Zone)  MHLZO (Move High to Low Zone)  MLHZO (Move Low to High Zone)  MLLZO (Move Low to Low Zone). The move zone operations move only the zone portion of a character. A minus (-) sign in a move zone operation does not result in a negative character in the result field, because a minus sign is represented by a hexadecimal 60 internally and a D zone is required for a negative character. Characters J through R have D zones and can be used to obtain a negative value (J = hexadecimal D1, ..., R = hexadecimal D9). Note: Whenever the word high is used in a move zone operation, the field involved must be a character field; whenever low is used, the field involved can be either a character or a numeric field. Function of MOVE Zone Operations Character │ │ │ │ │ │ Factor │ │ │ │ │ │ │ │ │ │ │ │ Two │ └──┴──┴──┴──┴──┴──┴──┴──┴──┴──┘ │ ││ MLHZO ││ │ MHHZO││┌─────────────────────┘│MLLZO │ │└┼─────────────────────┐│ │ │┌┘ MHLZO ││ │   │ │ │ │ │ │ │  │ │ │ │ │ │ │ │ │ │ │ Result Character └──┴──┴──┴──┴──┴──┴──┴──┴──┴──┘ Field Character │ │ │ │ │ │ Factor │ │ │ │ │ │ │ │ │ │ │ │ Two │ └──┴──┴──┴──┴──┴──┴──┴──┴──┴──┘ │ │ │ │ │ │MLLZO │ └───────────────────────┐│ │ MHLZO ││ │  │ │ │ │ │ │ │  │ │ │ │ │ │ │ │ │ │ │ Result Numeric └──┴──┴──┴──┴──┴──┴──┴──┴──┴──┘ Field Numeric │ │ │ │ │ │ Factor │ │ │ │ │ │ │ │ │ │ │ │ Two │ └──┴──┴──┴──┴──┴──┴──┴──┴──┴──┘ │ MLHZO ││ │ ┌───────────────────────┘│MLLZO │ │ │ │ │ │ │   │ │ │ │ │ │ │  │ │ │ │ │ │ │ │ │ │ │ Result Character └──┴──┴──┴──┴──┴──┴──┴──┴──┴──┘ Field Numeric │ │ │ │ │ │ Factor │ │ │ │ │ │ │ │ │ │ │ │ Two │ └──┴──┴──┴──┴──┴──┴──┴──┴──┴──┘ │ │ │ │MLLZO │ │ │ │ │  │ │ │ │ │ │ │  │ │ │ │ │ │ │ │ │ │ │ Result Numeric └──┴──┴──┴──┴──┴──┴──┴──┴──┴──┘ Field ═══ 1.10.16. String Operations ═══ The string operations include concatenation, scanning, substringing, translation, and verification. String operations can only be used on character fields. The string operations are:  CAT (Concatenate Two Character Strings)  CHECK (Check Characters)  CHEKR (Check Reverse)  SCAN (Scan Character String)  SUBST (Substring)  XLATE (Translate). The CAT operation concatenates two character strings to form one. The CHECK and CHEKR operations verify that each character in factor 2 is among the valid characters in factor 1. CHECK verifies from left to right and CHEKR from right to left. The SCAN operation scans a base character string for occurrences of a second specified character string. The SUBST operation extracts a specified character string from a base character string. The XLATE operation translates characters in factor 2 according to the from and to strings in factor 1. Note: Figurative constants cannot be used in the factor 1, factor 2, or result fields. No overlapping in a data structure is allowed for factor 1 and the result field, or factor 2 and the result field. In the string operations, factor 1 and factor 2 may have two parts. If both parts are specified, they must be separated by a colon. This option applies to all but the CAT, CHECK, CHEKR, and SUBST operations (where it applies only to factor 2). If you specify P in position 53 for the CAT, SUBST, or XLATE operations, the result field is padded from the right with blanks after the operation. See each operation for a more detailed explanation. ═══ 1.10.17. Structured Programming Operations ═══ The structured programming operations are:  ANDxx (And)  CASxx (Conditionally Invoke Subroutine)  DO (Do)  DOUxx (Do Until)  DOWxx (Do While)  ELSE (Else)  ENDyy (End a Group)  IFxx (If)  ITER (Iterate)  LEAVE (Leave a Do Group)  ORxx (Or)  OTHER (Otherwise Select)  SELEC (Begin a Select Group)  WHxx (When True Then Select). The DO operation allows the processing of a group of calculations zero or more times starting with the value in factor 1, incrementing each time by a value on the associated ENDDO operation until the limit specified in factor 2 is reached. The DOUxx operation allows the processing of a group of calculations one or more times based on the results of comparing factor 1 and factor 2. The end of a DOUxx operation is indicated by an ENDDO operation. The DOWxx operation allows the processing of a group of calculations zero or more times based on the results of comparing factor 1 and factor 2. The end of a DOWxx operation is indicated by an ENDDO operation. The LEAVE operation interrupts control flow prematurely and transfers control to the statement following the ENDDO operation of an iterative structured group. The ITER operation causes the next loop iteration to occur immediately. An IFxx operation allows the processing of a group of calculations based on the results of comparing factor 1 and factor 2. The ELSE operation allows you to specify a group of calculations to be processed if the IFxx condition is not satisfied. The end of an IFxx group is indicated by ENDIF. The SELEC, WHxx, and OTHER group of operations are used to conditionally process one of several alternative sequences of operations. The beginning of the select group is indicated by the SELEC operation. The WHxx operations are used to choose the operation sequence to process. The OTHER operation is used to indicate an operation sequence that is processed when none of the WHxx conditions are fulfilled. The end of the select group is indicated by the ENDSL operation. The ANDxx and ORxx operations are used with the DOUxx, DOWxx, WHxx, and IFxx operations to specify a more complex condition than the comparison of a single factor 1 and factor 2 pair. The ANDxx operation has higher precedence than the ORxx operation. Example of AND/OR Precedence *...1....+....2....+....3....+....4....+....5....+....6....+....7... CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++ C* C* In the following example, indicator 25 will be set on only if the C* first two conditions are true or the third condition is true. C* Algebraically, this would be represented as: C* ( ( (FIELDA > FIELDB) & (FIELDA >= FIELDC) ) | (FIELDA < FIELDD) ) C* C FIELDA IFGT FIELDB C FIELDA ANDGEFIELDC C FIELDA ORLT FIELDD C SETON 25 C ENDIF The CASxx operation allows a subroutine to be conditionally selected for processing. An ENDCS operation ends a CASxx group. For more information about the CASxx operation, see Compare Operations. A DO, DOUxx, DOWxx, IFxx, or SELEC operation (with or without ANDxx or ORxx operations), and an ENDyy operation, delimit a structured group. The ENDDO operation ends each DO, DOUxx, and DOWxx group or causes the structured group to be reprocessed until the specified ending conditions are met. The SELEC must end with an ENDSL. An IFxx operation and an IFxx operation with an ELSE operation must end with an ENDIF operation. Using END gives you the same results as using ENDIF, ENDSL, or ENDDO. The rules for making the comparison on the ANDxx, DOUxx, DOWxx, IFxx, ORxx and WHxx operation codes are the same as those given under Compare Operations. In the ANDxx, CASxx, DOUxx, DOWxx, IFxx, ORxx, and WHxx operations, xx can be: xx Meaning GT Factor 1 is greater than factor 2. LT Factor 1 is less than factor 2. EQ Factor 1 is equal to factor 2. NE Factor 1 is not equal to factor 2. GE Factor 1 is greater than or equal to factor 2. LE Factor 1 is less than or equal to factor 2. Blanks Unconditional processing (CASxx only). In the ENDyy operation, yy can be: yy Meaning CS End for CASxx operation. DO End for DO, DOUxx, and DOWxx operation. IF End for IFxx operation. SL End for SELEC operation. Blanks End for any structured operation. Note: The yy in the ENDyy operation is optional. If a structured group, in this case a do group, contains another complete structured group, together they form a nested structured group. Structured groups can be nested to a maximum depth of 100 levels. The following is an example of nested structured groups, three levels deep: ┌─────────DO │ ┌───DO │ └───ENDDO │ ┌──────IFxx │ │ ┌───SELEC │ │ │ WHxx │ │ └───ENDSL │ ├──────ELSE │ └──────ENDIF └─────────ENDDO Remember the following when specifying structured groups:  Each nested structured group must be completely contained within the outer level structured group.  Each structured group must contain one of a DO, DOUxx, DOWxx, IFxx, or SELEC operation and its associated ENDyy operation.  A structured group can be contained in detail, total, or subroutine calculations, but it cannot be split among them.  Branching into a structured group from outside the structured group may cause undesirable results. ═══ 1.10.18. Subroutine Operations ═══ An RPG/400 subroutine is a group of calculation specification statements in a program that can be processed several times in that program. The RPG/400 subroutine operations are:  BEGSR (Beginning of Subroutine)  ENDSR (End of Subroutine)  EXSR (Invoke Subroutine)  CASxx (Conditionally Invoke Subroutine). RPG/400 subroutine specifications must follow all other calculation operations that can be processed for a program; however, the PLIST, PARM, KLIST, KFLD, and DEFN operations may be specified between an ENDSR operation (the end of one subroutine) and a BEGSR operation (the beginning of another subroutine) or after all subroutines. A subroutine can be called from any point in the calculation operations. Subroutine lines can be identified by SR in positions 7 and 8. The only valid entries in positions 7 and 8 of a subroutine line are SR, AN, OR, or blanks. For information on how to code a subroutine, see Coding Subroutines. ═══ 1.10.19. Test Operations ═══ The test operations are:  TESTB (Test Bit)  TESTN (Test Numeric)  TESTZ (Test Zone). The TESTx operations allow you to test character fields specified in the result field. ═══ Operation Codes List ═══ The contents of the operation field on the referenced line are not valid. The valid operation codes are:  ACQ (Acquire)  ADD (Add)  ANDxx (And)  BEGSR (Beginning of Subroutine)  BITOF (Set Bits Off)  BITON (Set Bits On)  CABxx (Compare and Branch)  CALL (Call a Program)  CASxx (Conditionally Invoke Subroutine)  CAT (Concatenate Two Character Strings)  CHAIN (Random Retrieval from a File)  CHECK (Check Characters)  CHEKR (Check Reverse)  CLEAR (Clear)  CLOSE (Close Files)  COMIT (Commit)  COMP (Compare)  DEBUG (Debug Function)  DEFN (Field Definition)  DELET (Delete Record)  DIV (Divide)  DO (Do)  DOUxx (Do Until)  DOWxx (Do While)  DSPLY (Display Function)  DUMP (Program Dump)  ELSE (Else)  ENDyy (End a Group)  ENDSR (End of Subroutine)  EXCPT (Calculation Time Output)  EXFMT (Write/Then Read Format)  EXSR (Invoke Subroutine)  FEOD (Force End of Data)  FORCE (Force a Certain File to Be Read Next Cycle)  FREE (Deactivate a Program)  GOTO (Go To)  IFxx (If)  IN (Retrieve a Data Area)  ITER (Iterate)  KFLD (Define Parts of a Key)  KLIST (Define a Composite Key)  LEAVE (Leave a Do Group)  LOKUP (Look Up)  MHHZO (Move High to High Zone)  MHLZO (Move High to Low Zone)  MLHZO (Move Low to High Zone)  MLLZO (Move Low to Low Zone)  MOVE (Move)  MOVEA (Move Array)  MOVEL (Move Left)  MULT (Multiply)  MVR (Move Remainder)  NEXT (Next)  OCUR (Set/Get Occurrence of a Data Structure)  OPEN (Open File for Processing)  ORxx (Or)  OTHER (Otherwise Select)  OUT (Write a Data Area)  PARM (Identify Parameters)  PLIST (Identify a Parameter List)  POST (Post)  READ (Read a Record)  READC (Read Next Changed Record)  READE (Read Equal Key)  READP (Read Prior Record)  REDPE (Read Prior Equal)  REL (Release)  RESET (Reset)  RETRN (Return to Caller)  ROLBK (Roll Back)  SCAN (Scan Character String)  SELEC (Begin a Select Group)  SETGT (Set Greater Than)  SETLL (Set Lower Limit)  SETOF (Set Off)  SETON (Set On)  SHTDN (Shut Down)  SORTA (Sort an Array)  SQRT (Square Root)  SUB (Subtract)  SUBST (Substring)  TAG (Tag)  TESTB (Test Bit)  TESTN (Test Numeric)  TESTZ (Test Zone)  TIME (Time of Day)  UNLCK (Unlock a Data Area or Release a Record)  UPDAT (Modify Existing Record)  WHxx (When True Then Select)  WRITE (Create New Records)  XFOOT ( Summing the Elements of an Array)  XLATE (Translate)  Z-ADD (Zero and Add)  Z-SUB (Zero and Subtract) ═══ 1.10.20. Operation Codes List ═══ The operation codes are:  ACQ (Acquire)  ADD (Add)  ANDxx (And)  BEGSR (Beginning of Subroutine)  BITOF (Set Bits Off)  BITON (Set Bits On)  CABxx (Compare and Branch)  CALL (Call a Program)  CASxx (Conditionally Invoke Subroutine)  CAT (Concatenate Two Character Strings)  CHAIN (Random Retrieval from a File)  CHECK (Check Characters)  CHEKR (Check Reverse)  CLEAR (Clear)  CLOSE (Close Files)  COMIT (Commit)  COMP (Compare)  DEBUG (Debug Function)  DEFN (Field Definition)  DELET (Delete Record)  DIV (Divide)  DO (Do)  DOUxx (Do Until)  DOWxx (Do While)  DSPLY (Display Function)  DUMP (Program Dump)  ELSE (Else)  ENDyy (End a Group)  ENDSR (End of Subroutine)  EXCPT (Calculation Time Output)  EXFMT (Write/Then Read Format)  EXSR (Invoke Subroutine)  FEOD (Force End of Data)  FORCE (Force a Certain File to Be Read Next Cycle)  FREE (Deactivate a Program)  GOTO (Go To)  IFxx (If)  IN (Retrieve a Data Area)  ITER (Iterate)  KFLD (Define Parts of a Key)  KLIST (Define a Composite Key)  LEAVE (Leave a Do Group)  LOKUP (Look Up)  MHHZO (Move High to High Zone)  MHLZO (Move High to Low Zone)  MLHZO (Move Low to High Zone)  MLLZO (Move Low to Low Zone)  MOVE (Move)  MOVEA (Move Array)  MOVEL (Move Left)  MULT (Multiply)  MVR (Move Remainder)  NEXT (Next)  OCUR (Set/Get Occurrence of a Data Structure)  OPEN (Open File for Processing)  ORxx (Or)  OTHER (Otherwise Select)  OUT (Write a Data Area)  PARM (Identify Parameters)  PLIST (Identify a Parameter List)  POST (Post)  READ (Read a Record)  READC (Read Next Changed Record)  READE (Read Equal Key)  READP (Read Prior Record)  REDPE (Read Prior Equal)  REL (Release)  RESET (Reset)  RETRN (Return to Caller)  ROLBK (Roll Back)  SCAN (Scan Character String)  SELEC (Begin a Select Group)  SETGT (Set Greater Than)  SETLL (Set Lower Limit)  SETOF (Set Off)  SETON (Set On)  SHTDN (Shut Down)  SORTA (Sort an Array)  SQRT (Square Root)  SUB (Subtract)  SUBST (Substring)  TAG (Tag)  TESTB (Test Bit)  TESTN (Test Numeric)  TESTZ (Test Zone)  TIME (Time of Day)  UNLCK (Unlock a Data Area or Release a Record)  UPDAT (Modify Existing Record)  WHxx (When True Then Select)  WRITE (Create New Records)  XFOOT (Summing the Elements of an Array)  XLATE (Translate)  Z-ADD (Zero and Add)  Z-SUB (Zero and Subtract) ═══ 1.10.20.1. ACQ (Acquire) ═══ ┌─────────┬───────────────┬─────────────────┬──────────┬─────────┐ │ CODE │ FACTOR 1 │ FACTOR 2 │ RESULT │ INDICA- │ │ │ │ │ FIELD │ TORS │ ├─────────┼───────────────┼─────────────────┼──────────┼─────────┤ │ ACQ │ Device name │ WORKSTN file │ │ _ ER _ │ └─────────┴───────────────┴─────────────────┴──────────┴─────────┘ The ACQ operation acquires the program device specified in factor 1 for the WORKSTN file specified in factor 2. If the device is available, ACQ attaches it to the file. If it is not available or is already attached to the file, an error occurs. If an indicator is specified in positions 56 and 57, the indicator is set on. If no indicator is specified, but the INFSR subroutine is specified, the INFSR receives control when an error/exception occurs. If no indicator or INFSR subroutine is specified, the default error/exception handler receives control when an error/exception occurs. No input or output operation occurs when the ACQ operation is processed. ACQ must only be used with a multiple device file. See the section on "Multiple-Device Files" in the chapter about using WORKSTN files in the RPG/400* User's Guide. ═══ 1.10.20.2. ADD (Add) ═══ ┌─────────┬───────────────┬─────────────────┬──────────┬─────────┐ │ CODE │ FACTOR 1 │ FACTOR 2 │ RESULT │ INDICA- │ │ │ │ │ FIELD │ TORS │ ├─────────┼───────────────┼─────────────────┼──────────┼─────────┤ │ ADD(1/2)│ Addend │ Addend │ Sum │ + - Z │ └─────────┴───────────────┴─────────────────┴──────────┴─────────┘ If factor 1 is specified, the ADD operation adds it to factor 2 and places the sum in the result field. If factor 1 is not specified, the contents of factor 2 are added to the result field and the sum is placed in the result field. Factor 1 and factor 2 must be numeric and can contain one of: an array, array element, constant, field name, literal, subfield, or table name. For the rules for specifying an ADD operation, see Arithmetic Operations. ADD Operations *...1....+....2....+....3....+....4....+....5....+....6....+....7... CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++ C* C* The value 1 is added to RECNO. C ADD 1 RECNO C* The contents of EHWRK are added to CURHRS. C ADD EHWRK CURHRS C* The contents of OVRTM and REGHRS are added together and C* placed in TOTPAY. C OVRTM ADD REGHRS TOTPAY ═══ 1.10.20.3. ANDxx (And) ═══ ┌─────────┬───────────────┬─────────────────┬──────────┬─────────┐ │ CODE │ FACTOR 1 │ FACTOR 2 │ RESULT │ INDICA- │ │ │ │ │ FIELD │ TORS │ ├─────────┼───────────────┼─────────────────┼──────────┼─────────┤ │ ANDXX │ Comparand │ Comparand │ │ │ └─────────┴───────────────┴─────────────────┴──────────┴─────────┘ If you specify this optional operation, it must immediately follow a ANDxx, DOUxx, DOWxx, IFxx, ORxx, or WHxx operation. With ANDxx, you can specify a complex condition for the DOUxx, DOWxx, IFxx, and WHxx operations. The ANDxx operation has higher precedence than the ORxx operation. The control level entry (positions 7 and 8) can be blank or can contain an L1 through L9 indicator, an LR indicator, or an L0 entry to group the statement within the appropriate section of the program. The control level entry must be the same as the control level entry for the associated DOUxx, DOWxx, IFxx, or WHxx operation. Conditioning indicator entries (positions 9 through 17) are not permitted. Factor 1 and factor 2 must contain a literal, a named constant, a figurative constant, a table name, an array element, a data structure name, or a field name. Factor 1 and factor 2 must be either both character data or both numeric data. The comparison of factor 1 and factor 2 follows the same rules as those given for the compare operations. See Compare Operations. ANDxx Operations *...1....+....2....+....3....+....4....+....5....+....6....+....7... CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++ C* C* If ACODE is equal to A and indicator 50 is on, the MOVE C* and WRITE operations are processed. C ACODE IFEQ 'A' C *IN50 ANDEQ*ON C MOVE 'A' ACREC C WRITERCRSN C* If the previous conditions were not met but ACODE is equal C* to A, indicator 50 is off, and ACREC is equal to D, the C* following MOVE operation is processed. C ELSE C ACODE IFEQ 'A' C *IN50 ANDEQ*OFF C ACREC ANDEQ'D' C MOVE 'A' ACREC C ENDIF C ENDIF ═══ 1.10.20.4. BEGSR (Beginning of Subroutine) ═══ ┌─────────┬───────────────┬─────────────────┬──────────┬─────────┐ │ CODE │ FACTOR 1 │ FACTOR 2 │ RESULT │ INDICA- │ │ │ │ │ FIELD │ TORS │ ├─────────┼───────────────┼─────────────────┼──────────┼─────────┤ │ BEGSR │ Subroutine │ │ │ │ │ │ name │ │ │ │ └─────────┴───────────────┴─────────────────┴──────────┴─────────┘ The BEGSR operation identifies the beginning of an RPG/400 subroutine. Factor 1 contains the subroutine name. You must specify the same name in factor 2 of the EXSR operation referring to the subroutine, in the result field of the CASxx operation referring to the subroutine, or in the entry of an INFSR file continuation option if the subroutine is a file-error subroutine. The control level entry (positions 7 and 8) can be SR or blank. Conditioning indicator entries are not permitted. Every subroutine must have a unique symbolic name. The keyword *PSSR used in factor 1 specifies that this is a program exception/error subroutine to handle program-detected exception/errors. Only one subroutine can be defined by this keyword. *INZSR in factor 1 specifies a subroutine to be run during the initialization step. Only one subroutine can be defined *INZSR. See Figure "Example of Coding Subroutines" for an example of coding subroutines; see Subroutine Operations for general information on subroutine operations. ═══ 1.10.20.5. BITOF (Set Bits Off) ═══ ┌─────────┬───────────────┬─────────────────┬──────────┬─────────┐ │ CODE │ FACTOR 1 │ FACTOR 2 │ RESULT │ INDICA- │ │ │ │ │ FIELD │ TORS │ ├─────────┼───────────────┼─────────────────┼──────────┼─────────┤ │ BITOF │ │ Bit numbers │ Char- │ │ │ │ │ │ acter │ │ │ │ │ │ field │ │ └─────────┴───────────────┴─────────────────┴──────────┴─────────┘ The BITOF operation causes bits identified in factor 2 to be set off (set to 0) in the result field. Bits not identified in factor 2 remain unchanged. Therefore, when using BITOF to format a character, you should use both BITON and BITOF: BITON to specify the bits to be set on (=1), and BITOF to specify the bits to be set off (=0). Unless you explicitly set on or off all the bits in the character, you might not get the character you want. Factor 2 can contain:  Bit numbers 0-7: From 1 to 8 bits can be set off per operation. They are identified by the numbers 0 through 7. (0 is the leftmost bit.) Enclose the bit numbers in apostrophes, and begin the entry in position 33. For example, to set off bits 0, 2, and 5, enter '025' in factor 2.  Field name: You can specify the name of a one-position character field, table element, or array element in factor 2. The bits that are on in the field, table element, or array element are set off in the result field; bits that are off are not affected.  Hexadecimal literal or named constant: You can specify a 1-byte hexadecimal literal or hexadecimal named constant. Bits that are on in factor 2 are set off in the result field; bits that are off are not affected.  Named constant: A character named constant up to eight positions long containing the bit numbers to be set off. In the result field, specify a one-position character field. It can be an array element if each element in the array is a one-position character field. See Figure "BITON and BITOF Operations" for an example of the BITOF operation. ═══ 1.10.20.6. BITON (Set Bits On) ═══ ┌─────────┬───────────────┬─────────────────┬──────────┬─────────┐ │ CODE │ FACTOR 1 │ FACTOR 2 │ RESULT │ INDICA- │ │ │ │ │ FIELD │ TORS │ ├─────────┼───────────────┼─────────────────┼──────────┼─────────┤ │ BITON │ │ Bit numbers │ Char- │ │ │ │ │ │ acter │ │ │ │ │ │ field │ │ └─────────┴───────────────┴─────────────────┴──────────┴─────────┘ The BITON operation causes bits identified in factor 2 to be set on (set to 1) in the result field. Bits not identified in factor 2 remain unchanged. Therefore, when using BITON to format a character, you should use both BITON and BITOF: BITON to specify the bits to be set on (=1), and BITOF to specify the bits to be set off (=0). Unless you explicitly set on or off all the bits in the character, you might not get the character you want. Factor 2 can contain:  Bit numbers 0-7: From 1 to 8 bits can be set on per operation. They are identified by the numbers 0 through 7. (0 is the leftmost bit.) Enclose the bit numbers in apostrophes, and begin the entry in position 33. For example, to set bits 0, 2, and 5 on, enter '025' in factor 2.  Field name: You can specify the name of a one-position character field, table element, or array element in factor 2. The bits that are on in the field, table element, or array element are set on in the result field; bits that are off are not affected.  Hexadecimal literal or named constant: You can specify a 1-byte hexadecimal literal. Bits that are on in factor 2 are set on in the result field; bits that are off are not affected.  Named constant: A character named constant up to eight positions long containing the bit numbers to be set on. In the result field, specify a one-position character field. It can be an array element if each element in the array is a one-position character field. Figure "BITON and BITOF Operations" illustrates uses of the BITON operation. ═══ 1.10.20.6.1. BITON and BITOF Examples ═══ *...1....+....2....+....3....+....4....+....5....+....6....+....7... I..............Namedconstant+++++++++C.........Fldnme......... .... I '01234567' C BITNC I X'0F' C HEXNC CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++ C* C* Before the operations are processed, the bit settings are: C* FLDA = 00000000 C* FLDB = 00000000 C* FLDC = 11111111 C* FLDD = 11000000 C* FLDE = 11000000 C* FLDF = 10000001 C* FLDG = 11111111 AFTER C* FLDH = 00000000 OPERATIONS C* FLDI = 11001010 ---------- C* C BITON'04567' FLDA = 10001111 C BITON'3' FLDB = 00010000 C BITON'3' FLDC = 11111111 C BITON'3' FLDD = 11010000 C BITONFLDE FLDF = 11000001 C BITONX'01' FLDH = 00000001 C* C BITOF'0' FLDG = 01111111 C* C BITOFBITNC FLDI = 00001110 C BITONHEXNC FLDI = 00001111 BITON and BITOF Operations ═══ 1.10.20.7. CABxx (Compare and Branch) ═══ ┌─────────┬───────────────┬─────────────────┬──────────┬─────────┐ │ CODE │ FACTOR 1 │ FACTOR 2 │ RESULT │ INDICA- │ │ │ │ │ FIELD │ TORS │ ├─────────┼───────────────┼─────────────────┼──────────┼─────────┤ │ CABXX │ Comparand │ Comparand │ Label │ HI LO │ │ │ │ │ │ EQ │ └─────────┴───────────────┴─────────────────┴──────────┴─────────┘ The CABxx operation compares factor 1 with factor 2. If the condition specified by xx is true, the program branches to the TAG operation associated with the label specified in the result field. Otherwise, the program continues with the next operation in the sequence. If the result field is not specified, the resulting indicators (positions 54-59) are set accordingly, and the program continues with the next operation in the sequence. You can specify conditioning indicators. Factor 1 and factor 2 must contain a character literal, a numeric literal, a named constant, a figurative constant, a field name, a table name, an array element, or a data structure name. Both the factor 1 and the factor 2 entries must be character data, or both must be numeric. The CABxx operation can specify a branch:  To a previous or a succeeding specification line  From a detail calculation line to another detail calculation line  From a total calculation line to another total calculation line  From a detail calculation line to a total calculation line  From a subroutine to a detail calculation line or a total calculation line. The CABxx operation cannot specify a branch from outside a subroutine to a TAG or ENDSR operation within that subroutine. Branching from one part of the RPG/400 logic cycle to another may result in an endless loop. You must ensure that the logic of your program does not produce undesirable results. The label specified in the result field must be associated with a unique TAG operation and must be a unique symbolic name. Resulting indicators are optional. When specified, they are set to reflect the results of the compare operation. For example, the HI indicator is set when F1>F2, LO is set when F1 Full Line ═══ You can use this line to enter any of the following: Control File description Extension Line counter Input Calculation Output Compiler Directive SQL Statement Array Data Comment (* in position 7). ═══ Creating RPGHSPEC.RPG ═══ You can use any editor to create RPGHSPEC.RPG provided the file is 80 characters long, a properly coded control specification, and in the CODE base directory. If you wish to use the CODE/400 editor, you can follow this procedure: 1. Start CODE. 2. Click on File Pull-down and create a new file. 3. Select LOCAL from the Servers list. e 4. Select the RPG_400 Language profile. 5. Enter the desired H specification fields. You can use the H specification prompt. 6. Save the file as RPGHSPEC.RPG if the CODE base directory. 7. Exit the edit session. Rename the file or move it to another directory if you wish to use the default blank H specification. ═══ 1.16. RPG/400 Reserved Fields ═══  Control Specification Reserved Fields  File Description Specification Reserved Fields  File Description Specification Externally Described Files Reserved Fields  File Description Specification Continuation Line Reserved Fields  File Description Specification Continuation (SFILE/RENAME)  Extension Specification Reserved Fields  Line Counter Specification Reserved Fields  Input Specification Record Reserved Fields  Input Specification Record AND/OR Reserved Fields  Input Specification Externally Described Record Reserved Fields  Input Specification Data Structure Reserved Fields  Input Specification Data Structure Subfield Reserved Fields  Input Specification Data Structure Subfield *KEYWORD Reserved Fields  Input Specification Initialization Reserved Fields  Input Specification Named Constant Reserved Fields  Output Specification Record Reserved Fields  Output Specification Record AND/OR Reserved Fields  Output Specification File Reserved Fields  Output Specification Externally Described Record Reserved Fields  Output Specification Externally Described File Reserved Fields ═══ 1.16.1. Control Specification Reserved Fields ═══ Positions 7-14, 16-17, 22-25, 27-40, 42, 44-56, and 58-74 must be blank. ═══ 1.16.2. File Description Specification Reserved Fields ═══ Positions 20-23, 47-52, 67-70 and 73-74 must be blank. ═══ 1.16.3. File Description Specification Externally Described Files Reserved Fields ═══ Positions 20-27, 29-30, 32-39, 47-52, 67-70, and 73-74 must be blank. ═══ 1.16.4. File Description Specification Continuation Line Reserved Fields ═══ Positions 7-18, 29-46, and 68-74 must be blank. ═══ 1.16.5. File Description Specification Continuation (SFILE/RENAME) ═══ Positions 7-18, 29-46, and 66-74 must be blank. ═══ 1.16.6. Extension Specification Reserved Fields ═══ Positions 7-10 must be blank. ═══ 1.16.7. Line Counter Specification Reserved Fields ═══ Positions 25-74 must be blank. ═══ 1.16.8. Input Specification Record Reserved Fields ═══ Positions 42-74 must be blank. ═══ 1.16.9. Input Specification Record AND/OR Reserved Fields ═══ Positions 7-13, 17-18, and 42-74 must be blank. ═══ 1.16.10. Input Specification Externally Described Record Reserved Fields ═══ Positions 15-18, 21-41, and 42-74 must be blank. ═══ 1.16.11. Input Specification File Reserved Fields ═══ Positions 7-42, and 71-74 must be blank. ═══ 1.16.12. Input Specification Externally Described File Reserved Fields ═══ Positions 7-20, 31-52, 63-64, and 71-74 must be blank. ═══ 1.16.13. Input Specification Data Structure Reserved Fields ═══ Positions 13-16, 31-43, and 52-74 must be blank. ═══ 1.16.14. Input Specification Data Structure Subfield Reserved Fields ═══ Positions 7, 9-20, 31-42, and 59-74 must be blank. ═══ 1.16.15. Input Specification Data Structure Subfield *KEYWORD Reserved Fields ═══ Positions 7-43, 52, and 59-74 must be blank. ═══ 1.16.16. Input Specification Initialization Reserved Fields ═══ Positions 7, 9-20, and 59-74 must be blank. ═══ 1.16.17. Input Specification Named Constant Reserved Fields ═══ Positions 7-20, 44-52, and 59-74 must be blank. ═══ 1.16.18. Output Specification Record Reserved Fields ═══ Positions 38-74 must be blank. ═══ 1.16.19. Output Specification Record AND/OR Reserved Fields ═══ Positions 7-13 and 32-74 must be blank. ═══ 1.16.20. Output Specification File Reserved Fields ═══ Positions 7-22, and 71-74 must be blank. ═══ 1.16.21. Output Specification Externally Described Record Reserved Fields ═══ Positions 19-22, and 38-74 must be blank. ═══ 1.16.22. Output Specification Externally Described File Reserved Fields ═══ Positions 7-22, 38, and 40-74 must be blank.