RPG Ⅳ基础
to the value of the job date when the program starts running in the system. The value of the user date special words are not updated during program processing, even if the program runs past midnight or if the job date is changed. Use the TIME operation code to obtain the time and date while the program is running.
UMONTH, *MONTH, UDAY, *DAY, and UYEAR when specified in positions 30 through 43 of the output specifications, print a 2-position numeric date field. *YEAR can be used to print a 4-position numeric date field. Use UMONTH or *MONTH to print the month only, UDAY or *DAY to print the day only, and UYEAR or *YEAR to print the year only.
UDATE and *DATE can be edited when they are written if the Y edit code is specified in position 44 of the output specifications. The DATEDIT(fmt{separator}) keyword on the control specification determines the format and the separator character to be inserted; for example, 12/31/88, 31.12.88., 12/31/1988.
UMONTH, *MONTH, UDAY, *DAY, UYEAR and *YEAR cannot be edited by the Y edit code in position 44 of the output specifications.
The user date fields cannot be modified. This means they cannot be used:
o In the result field of calculations o As factor 1 of PARM operations
o As the factor 2 index of LOOKUP operations o With blank after in output specifications o As input fields
The user date special words can be used in factor 1 or factor 2 of the calculation specifications for operation codes that use numeric fields. User date fields are not date data type fields but are numeric fields.
?
?
? ?
? ?
PAGE, PAGE1-PAGE7
PAGE is used to number the pages of a report, to serially number the output records in a file, or to sequentially number output fields. It does not cause a page eject. The eight possible PAGE fields (PAGE, PAGE1, PAGE2, PAGE3, PAGE4, PAGE5, PAGE6, and PAGE7) may be needed for numbering different types of output pages or for numbering pages for different printer files.
PAGE fields can be specified in positions 30 through 43 of the output specifications or in the input or calculation specifications.
Rules for PAGE, PAGE1-PAGE7
Remember the following rules when using the PAGE fields:
? When a PAGE field is specified in the output specifications, without being
defined elsewhere, it is assumed to be a four-digit, numeric field with zero decimal positions.
? Page numbering, unless otherwise specified, starts with 0001; and 1 is
automatically added for each new page.
? To start at a page number other than 1, set the value of the PAGE field to
RPG Ⅳ基础
one less than the starting page number. For example, if numbering starts with 24, enter a 23 in the PAGE field. The PAGE field can be of any length but must have zero decimal positions (see Figure 1).
? Page numbering can be restarted at any point in a job. The following methods
can be used to reset the PAGE field:
o Specify blank-after (position 45 of the output specifications). o Specify the PAGE field as the result field of an operation in the
calculation specifications.
o Specify an output indicator in the output field specifications (see
Figure 2). When the output indicator is on, the PAGE field will be reset to 1. Output indicators cannot be used to control the printing of a PAGE field, because a PAGE field is always written.
o Specify the PAGE field as an input field as shown in Figure 1. ? Leading zeros are automatically suppressed (Z edit code is assumed) when a
PAGE field is printed unless an edit code, edit word, or data format (P/B/L/R in position 52) has been specified. Editing and the data format override the suppression of leading zeros. When the PAGE field is defined in input and calculation specifications, it is treated as a field name in the output specifications and zero suppression is not automatic.
Figure 1. Page Record Description
*...1....+....2....+....3....+....4....+....5....+....6....+....7... IFilename++SqNORiPos1+NCCPos2+NCCPos3+NCC................................ I........................Fmt+SPFrom+To+++DcField+++++++++L1M1FrPlMnZr.... IINPUT PG 50 1 CP I 2 5 0PAGE Figure 2. Resetting the PAGE Fields to Zero
*...1....+....2....+....3....+....4....+....5....+....6....+....7... OFilename++DF..N01N02N03Excnam++++B++A++Sb+Sa+........................... O..............N01N02N03Field+++++++++YB.End++PConstant/editword/DTformat O* When indicator 15 is on, the PAGE field is set to zero and 1 is O* added before the field is printed. When indicator 15 is off, 1 O* is added to the contents of the PAGE field before it is printed. OPRINT H L1 01 O 15 PAGE 1 75 F表说明
F(File):定义所有程序使用到的文件。
*.. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+... FFilename++IPEASFRlen+LKlen+AIDevice+.Keywords+++++++++++++++++++++++++++++
RPG Ⅳ基础
FCMU120FM CF E WORKSTN INFDS(FEEDBK)
文件类型 Position 17 (File Type)
I:输入 I 以指示输入文件。 O:输入 O 以指示输出文件。 U:输入 U 以指示更新文件。 C:输入 C 以指示组合(输入 / 输出)文件。
文件指定 Position 18 (File Designation)
空白: 留空此字段以指示输出文件。 P :输入 P 以指示主文件。 S :输入 S 以指示次文件。 R :输入 R 以指示“记录”地址文件。 T :输入 T 以指示数组或表文件。 F :输入 F 以指示全过程文件。
文件添加 Position 20 (File Addition)
空白: 保留字段为空白,以阻止添加记录到输入或更新文件中。对于输出文件,一个 空格相当于一个 A 。 A : 如想在 DISK 文件添加记录,则输入 A 。 如果程序中只有WRITE操作,文件类型用O; 如果程序中有UPDATE、WRITE操作,文件类型用U+A; 如果程序中只有WRITE操作,文件类型用U+A,则编译有20的错误,如果 修改错误级别为21,可通过; 序列 Position 21 (Sequence)
A 或空白: 若匹配字段是依升序排列,输入 A 或使字段保 留为空白。 D: 若匹配字段是依降序排列,输入 D 。
文件格式 Position 22 (File Format) E:输入 E 以表示外部描述文件
F:输入 F 以表示程序描述文件(在I表/O表中描述的)
记录地址类型 Position 34 (Record Address Type)
对于指定为带索引文件或记录地址极限文件的程序描述文件,从下列各项中选择: RAT:空白:用RRN处理文件(按记录顺序),K:按键值处理
空白: 若使用相对记录号以处理文件,或连续读取记录,或记录地址极限文件中的关 键字与要处理的文件中关键字的格式相同,则将该字段留空。 A: 对于字符关键字输入 A 。 D: 对于“日期”关键字输入 D 。 F: 对于浮点数字关键字输入 F 。 G: 对于“图形”关键字字段输入 G 。 K: 对于用于处理文件的关键字值输入 K 。它仅对外部描述文件有效。
RPG Ⅳ基础
P: 对于压缩关键字输入 P 。 T: 对于“时间”关键字输入 T 。 Z: 对于“时间戳记”关键字输入 Z 。
设备 Positions 36-42 (Device)
PRINTER:该文件是一个打印文件。
DISK:这文件是磁盘文件。该文件提供顺序读/写和随机读/写功能。 WORKSTN:该文件是工作站文件。 SPECIAL:这是特别文件。 SEQ:这是顺序组织的文件。
1.顺序和直接存取只用于输入操作 ( Read , Chain ) FCustomer IF E K DISK 2.仅使用Write来增加记录 FCustomer O E K DISK 3.顺序和直接存取用于输入( Read , Chain ) , Update , Delete不包含Write操作 FCustomer UF E K DISK 4.顺序和直接存取用于输入( Read , Chain ) , Update , Delete包含Write操作 FCustomer UF A E K DISK 5.显示文件定义说明 FCustomerD CF E Workstn 6.打印文件定义说明 FCustomerP O E Printer
F表关键字:
BLOCK(*NO | *YES) 输入此关键字,以控制文件记录的分区 (BLOCKing) 。 COMMIT{(rpg 名称 )} 若此文件在委托控制下,则输入 COMMIT 。若要确定在运行时间文件是否在委托控
制下,则指定 rpg 名称。
在程序中用COMMIT和ROLBK命令把对文件的改变放到组中,以使所有的改变一起发
生或均不发生。
DEVID (字段名) 输入 DEVID 以指定包含设备名的字段名。 EXTIND(*INU1-*INU8)
指定此关键字以指示仅当在作业中设置外部指示符时,该文件是用于 OPEN的侯选。 IGNORE (记录格式名 : 记录格式名 :... )
输入要从外部描述文件中忽略的记录格式名。可指定多个记录格式。若要指定
INCLUDE ,则不能指定 IGNORE 。 INCLUDE (记录格式名 : 记录格式名 :... ) 输入要包括的记录格式名。不指定对有 SFILE 关键字的 WORKSTN 文件指定的 记录格式。可指定多个记录格式。若要指定 IGNORE ,则不指定 INCLUDE 。 INDDS (数据结构名) 输入与工作站或打印机文件相关的指示符数据结构的名称。
RPG Ⅳ基础
INFDS (数据结构名) 输入要包含异常/错误信息的数据结构名。
FCMU120FM CF E WORKSTN INFDS(FEEDBK) F INFSR(*PSSR) D*
D FEEDBK DS
D FUNKEY 369 369 C*Input field check
C FUNKEY IFEQ X'F1' C EXSR CHK1 C GOTO DSP C ENDIF
INFSR (子程序名) 输入当发生异常/错误情况时将获得控制的子程序名。 FSARDL11 IF E K DISK INFSR(*PSSR) FSARDL02 UF E K DISK INFSR(*PSSR)
当由该文件引发异常/错误情况出现时,控制交给*PSSR子例程。
MAXDEV(*ONLY|*FILE) 指定 WORKSTN 设备文件的类型。缺省值 *ONLY 指示单个设备文件。输入 *FILE 以检索文件打开时的最大设备数。 OFLIND (指示符) 输入从 *IN01 到 *IN99 之间的数以设置指示符,指示何时在溢出行上打印一 行,或在空格或跳过操作时,何时到达或通过溢出行。 FFONTPR O E PRINTER OFLIND(*IN73) *IN73 = * ON 时,重写表头,换页。
C WRITEDETAIL OF C *INOF IFEQ *ON C WRITEHEADING C ENDIF
PGMNAME (程序名) 输入用户提供的程序名以获得 SPECIAL 文件的控制。 PLIST (参数列表名) 输入对 SPECIAL 文件要传递的参数列表名。 PREFIX (前缀名 {: 被置换的字段符数 } ) 输入要应用于外部描述文件的所有记录中定义的所有字段名的前缀。应用前缀之后
名称的总长度不能超过 14 个字符。在“输入说明”上显式重新命名的字段不受影响。
RECNO (字段名) 为根据相对记录号处理的 DISK 文件或由随机 WRITE 计算参考的输出文件或 与输出说明上的 ADD 一起使用的输出文件,输入相对记录号。 RENAME (外部格式 : 内部格式) 输入要重新命名的记录格式的外部名以及要使用的内部名。该外部名由程序中 此名称置换。