AS400 培训教材 RPG_V6R1_Enhancements
AS400培训-RPG

AS/400培训资料于勇IPACS北京在RPGLE中的文件定义_________________________________________________ 3 在RPGLE中有关文件操作的操作码_______________________________________ 5 只输出子文件定义_______________________________________________________ 8 实现输出类型子文件_____________________________________________________ 9 输出类型子文件有定位处理______________________________________________ 12 实现有定位处理输出类型子文件__________________________________________ 13 处理类型子文件有定位处理______________________________________________ 17 实现处理类型子文件有定位处理__________________________________________ 20 处理类型子文件有定位处理和光标处理____________________________________ 26 实现有定位处理、光标处理子文件________________________________________ 29 处理类型子文件有定位、光标、信息子文件处理____________________________ 35 实现有定位、光标、信息子文件的处理类型子文件__________________________ 38 处理类型单页子文件定义________________________________________________ 45 实现处理类型单页子文件________________________________________________ 49 打印文件定义__________________________________________________________ 59 实现打印文件__________________________________________________________ 61在RPGLE中的文件定义**************************************************************** * Copyright 北京宇博电子科技有限公司 1998 * **************************************************************** * * * Program Id - FileDfn * * Program Type - RPGLE * * Purpose - 用于讲解在RPGLE中的文件定义 * * 不可编译 * * Date Generated - 1998-07-22 * * Author - 于勇 * * * *****************************************************************ilename++IPEASFRlen+LKlen+AIDevice+.Keywords+++++++++++++++++++ *..1....+....2....+....3....+....4....+....5....+....6....+. (7)* -------------------------------------------------------------- * 顺序和直接存取只用于输入操作 ( Read , Chain )* -------------------------------------------------------------- FCustomer IF E K DISK* -------------------------------------------------------------- * 仅使用Write来增加记录* -------------------------------------------------------------- FCustomer O E K DISK* -------------------------------------------------------------- * 顺序和直接存取用于输入( Read , Chain ) , Update , Delete* 不包含Write操作* -------------------------------------------------------------- FCustomer UF E K DISK* -------------------------------------------------------------- * 顺序和直接存取用于输入( Read , Chain ) , Update , Delete* 包含Write操作* -------------------------------------------------------------- FCustomer UF A E K DISK* -------------------------------------------------------------- * 显示文件定义说明* -------------------------------------------------------------- FCustomerD CF E Workstn* -------------------------------------------------------------- * 打印文件定义说明* -------------------------------------------------------------- FCustomerP O E Printer在RPGLE中有关文件操作的操作码***************************************************************** Copyright 北京宇博电子科技有限公司 1998 ****************************************************************** ** Program Id - FileOpr ** Program Type - RPGLE ** Purpose - 用于讲解在RPGLE中的文件操作码 ** 不可编译 ** Date Generated - 1998-07-22 ** Author - 于勇 ** ******************************************************************物理文件定义FCustomer UF A E K Disk*显示文件定义FCustomerd CF E Workstn*参照外部文件的数据结构定义D Customer_DsE Ds Extname( Customer )D Dspf_DsE Ds Extname( Customer )D Prefix(XS:2)*关键字列表定义C Csklist KlistC Kfld Csid*读下一条记录*IN90 = *OFF表示读到记录C Read Customerr 99*读上一条记录*IN90 = *OFF表示读到记录C ReadP Customerr 99*最小值定位C *Loval SetLl Customerr*最大值定位C *Hival SetGT Customerr*定位指示符含义C Csklist Setll Customerr 979899* *In97 No Record Found* *In98 Error Occurred* *in99 Exact Match for Search Argument Found*读下一条等于关键字的记录C Csklist Reade Customerr 99*读上一条等于关键字的记录C Readpe Customerr 99*用指定关键字读一条记录并且不锁定读到记录*IN88 = *OFF读到C Csklist Chain(N) Customerr 97*修改记录C Update Customerr*删除记录C Delete Customerr*增加记录C Write CUSTOMERR*记录解锁C UNLOCK CUSTOMERR*条件语句C If Not *In97*赋值语句C EVAL FLD2=FLD1C MOVE FLD1 FLD2C ELSEC MOVE FLD2 FLD1C EndIf*条件选择语句C SELECTC WHEN FLD1=FLD2C OTHERC ENDSL*循环语句C Dow Not *In97C EndDoC Dow Not *In03*显示屏幕并从屏幕中读取内容C ExFmt Dsp01C EndDo*程序结束C Move *ON *InLr只输出子文件定义A*%%TS SD 19980811 141319 YUYONG REL-V3R7M0 5716-PW1 A*%%EC A DSPSIZ(24 80 *DS3) A R SFL01 SFL A*%%TS SD 19980807 103111 YUYONG REL-V3R7M0 5716-PW1 A CSID R O 9 10REFFLD(CUSTOMERR/CSID *LIBL/CUSTOM- A ER) A CSNAME R O 9 23REFFLD(CUSTOMERR/CSNAME *LIBL/CUST- A OMER) A R CTL01 SFLCTL(SFL01) A*%%TS SD 19980811 141319 YUYONG REL-V3R7M0 5716-PW1 A SFLSIZ(0100) A SFLPAG(0010) A CA03(03) A OVERLAY A 30 SFLDSP A 31 SFLDSPCTL A 33 SFLCLR A 34 SFLEND(*MORE) A 1 3'CS0101D' A 1 31'查询用子文件' A DSPATR(HI) A 1 72DATE A EDTCDE(Y) A 2 72TIME A 8 9'客户号' A DSPATR(HI) A 8 31'客户名称' A DSPATR(HI) A R FUN01 A*%%TS SD 19980811 141319 YUYONG REL-V3R7M0 5716-PW1 A 22 3'F3 =退出' A COLOR(BLU)实现输出类型子文件**************************************************************** * Copyright 北京宇博电子科技有限公司 1998 * **************************************************************** * * * Program ID - CS0101R * * Program Type - RPGLE * * Purpose - 建立一个输出类型的子文件 * * Date Generated - 1998-08-06 * * Author - 于勇 * * * **************************************************************** *数据文件定义FCustomer IF E K Disk *显示文件定义FCs0101D CF E WorkStn Sfile( Sfl01 : RecNbr )*子文件用相对记录号定义D RecNbr S 4 0 Inz( *Zero ) *子文件最大记录数D RecLmt S 4 0 Inz( 9999 )*============================* * 主程序 * *============================* *子文件清除C ExSr SflClrSr *子文件记录装入C ExSr SflLodSrC Dow Not *In03 F3*子文件显示C Exsr SflDspSr C EndDo C Move *On *InLr*----------------------------* * 子文件初始化 * *----------------------------*C SflClrSr BegSrC Eval *In30 = *Off SflDspC Eval *In31 = *Off SflCtlDspC Eval *In33 = *On SflClr*写字文件控制记录C Write Ctl01 C Eval *In33 = *Off C Eval *In34 = *Off SflEnd*恢复子文件初值C Reset RecNbr C EndSr*----------------------------* * 子文件数据装入 * *----------------------------* C SflLodSr BegSrC *Loval SetLL CustomerR C Read CustomerR 99 C Dow Not *In99 And C RecNbr <= RecLmt *生成子文件相对记录号C Eval RecNbr = RecNbr + 1 *写子文件记录C Write Sfl01 C Read CustomerR 99 C EndDo *子文件不为空C If RecNbr > *Zero C Move *On *In30 SflDspC Endif *读文件结束C If *In99 C Move *On *In34 SflEndC Endif C EndSr*----------------------------* * 子文件显示 * *----------------------------* C SfldspSr BegSrC Eval *In31 = *On SflCtlDspC Write Fun01 C Exfmt Ctl01 C Eval *In31 = *Off SflCtlDspC EndSr输出类型子文件有定位处理A*%%TS SD 19980811 135301 YUYONG REL-V3R7M0 5716-PW1 A*%%EC A DSPSIZ(24 80 *DS3) A R SFL01 SFL A*%%TS SD 19980807 103529 YUYONG REL-V3R7M0 5716-PW1 A CSID R O 9 10REFFLD(CUSTOMERR/CSID *LIBL/CUSTOM- A ER) A CSNAME R O 9 23REFFLD(CUSTOMERR/CSNAME *LIBL/CUST- A OMER) A R CTL01 SFLCTL(SFL01) A*%%TS SD 19980811 135301 YUYONG REL-V3R7M0 5716-PW1 A SFLSIZ(0100) A SFLPAG(0010) A CA03(03) A OVERLAY A 30 SFLDSP A 31 SFLDSPCTL A 33 SFLCLR A 34 SFLEND(*MORE) A RECRRN 4S 0H SFLRCDNBR A 1 3'CS0102D' A 1 31'有定位子文件' A 1 72DATE A EDTCDE(Y) A 2 72TIME A 4 60'客户号定位:' A POSCSID 5A I 4 75 A 8 9'客户号' A 8 32'客户名称' A R FUN01 A*%%TS SD 19980805 161157 YUYONG REL-V3R7M0 5716-PW1 A 22 3'F3 =退出'实现有定位处理输出类型子文件**************************************************************** * Copyright 北京宇博电子科技有限公司 1998 * **************************************************************** * * * Program ID - CS0102R * * Program Type - RPGLE * * Purpose - 建立一个输出类型的子文件 * * 有定位 * * Date Generated - 1998-08-06 * * Author - 于勇 * * * **************************************************************** *数据文件定义FCustomer UF E K Disk *显示文件定义FCs0102D CF E WorkStn Sfile( Sfl01 : RecNbr )D CsKeyAry S 5 Dim( 9999 ) D Ascend *数组下标定义D X S 4 0 Inz( 1 )D CsKeyDs DS D Csid 5D PosDs DS D PosCsid 5 Inz( *Blank )*子文件用相对记录号定义D RecNbr S 4 0 Inz( *Zero ) D LstRecNbr S 4 0 Inz( *Zero )*子文件最大记录数D RecLmt S 4 0 Inz( 9999 )*============================* * 主程序 * *============================**子文件清除*子文件记录装入C ExSr SflLodSrC Dow Not *In03 *子文件定位C Exsr SflPosSr*子文件显示C Exsr SflDspSr C EndDoC Move *On *InLr *----------------------------* * 子文件初始化 * *----------------------------* C SflClrSr BegSrC Eval *In30 = *Off SflDspC Eval *In31 = *Off SflCtlDspC Eval *In33 = *On SflClr*写字文件控制记录C Write Ctl01 C Eval *In33 = *Off SflClr*恢复子文件初值C Reset RecNbrC EndSr *----------------------------- * 子文件数据装入 * *----------------------------- C SflLodSr BegSrC *Loval SetLL CustomerR C Read CustomerR 99 C Dow Not *In99 And C RecNbr <= RecLmt *生成子文件相对记录号C Eval RecNbr = RecNbr + 1 *将关键字赋值给数组C Eval CsKeyAry( RecNbr ) = CsKeyDs *写子文件记录C Write Sfl01C EndDo*子文件不为空C If RecNbr > *Zero C Eval LstRecNbr = RecNbr C Move *On *In30 C Endif*读文件结束C If *In99 C Move *On *In34 C EndifC EndSr *----------------------------* * 子文件定位 * *----------------------------* C SflPosSr BegSrC If PosDs <> *BlankC ReSet X C PosDS LookUP CsKeyAry( X ) 97 99 C If *In97 Or *in99 C Eval RecRrn = X C Else C Eval RecRrn = LstRecNbr C EndIfC Else C Eval RecRrn = 1 C EndIfC EndSr *----------------------------* * 子文件显示 * *----------------------------* C SfldspSr BegSrC Eval *In31 = *On C Write Fun01 C Exfmt Ctl01 C Eval *In31 = *OffC EndSr处理类型子文件有定位处理A*%%TS SD 19980811 141059 YUYONG REL-V3R7M0 5716-PW1 A*%%EC A DSPSIZ(24 80 *DS3) A R SFL01 SFL A*%%TS SD 19980811 135222 YUYONG REL-V3R7M0 5716-PW1 A SCADDRESS 30A H A OPT 1Y 0B 9 5EDTCDE(2) A SCCSID R O 9 10REFFLD(CUSTOMERR/CSID *LIBL/CUSTOM- A ER) A SCCSNAME R O 9 23REFFLD(CUSTOMERR/CSNAME *LIBL/CUST- A OMER) A R CTL01 SFLCTL(SFL01) A*%%TS SD 19980811 141059 YUYONG REL-V3R7M0 5716-PW1 A SFLSIZ(0100) A SFLPAG(0010) A CA03(03) A CA06(06) A OVERLAY A 30 SFLDSP A 31 SFLDSPCTL A 33 SFLCLR A 34 SFLEND(*MORE) A RECRRN 4S 0H SFLRCDNBR(CURSOR) A 1 3'CS0103D' A 1 29'有选项处理定位子文件' A DSPATR(HI) A 1 72DATE A EDTCDE(Y) A 2 72TIME A 4 2'请键入选项,按执行键继续。
IBM_AS400_RPG学习手册

1 简单说明 (3)2 程序代码行的编写 (3)2.1 最简单的RPGLE程序 (3)2.2 举例准备 (3)2.3 简单的程序流程 (4)2.4 常见的程序流程 (5)2.5 F行说明 (5)2.5.1 内容说明 (5)2.5.2 常用例子 (9)2.5.3 补充说明 (10)2.6 D行说明 (10)2.6.1 内容说明 (10)2.6.2 常用例子 (13)2.6.3 补充说明 (14)2.7 入口参数 (14)2.8 C行说明 (16)2.8.1 写在前面 (16)2.8.2 内容说明 (17)2.8.3 ILE操作码分类: (18)2.8.4 ILE操作码 (19)2.8.4.1 A--C (19)2.8.4.2 D--E (27)2.8.4.3 F--N (32)2.8.4.4 O--R (39)2.8.4.5 S--Z (43)3 和程序相关的数据库知识 (49)3.1 LF(逻辑文件) (49)3.1.1 逻辑文件概念 (49)3.1.2 有关编译的问题............................................................... 错误!未定义书签。
3.1.3 逻辑文件对效率的影响 (51)3.2 MEMBER (51)3.3 游标 (52)3.3.1 游标的概念 (52)3.3.2 不同操作码对应的游标的处理 (52)3.3.3 “有且仅有”的游标 (53)3.3.4 LOV AL、HIV AL对应的游标操作 (53)3.4 事务处理-- COMMIT (54)3.4.1 概念描述 (54)3.4.2 使用方法 (54)3.4.3 注意事项 (55)3.5 关于锁表的问题LCKW (56)4 DEBUG调试以及常见出错信息 (56)4.1 写在前面 (56)4.2 常规用法 (57)4.2.1 程序编译 (57)4.2.2 执行DEBUG命令 (57)4.2.3 运行程序 (57)4.2.4 在DEBUG模式中进行调试 (58)4.2.5 跟踪被当前程序调用的程序 (58)4.2.6 一定要退出DEBUG模式 (59)4.2.7 补充 (59)4.3 跟踪批处理程序( From qingzhou) (60)4.4 常见的出错信息 (60)4.4.1 编译程序时的出错信息 (60)4.4.2 运行时的出错信息 (62)5 CL、CMD (62)5.1 CL程序 (62)5.1.1 基本认识 (62)5.1.2 CL程序的常用语法及命令: (63)5.1.3 不常用的语法 (65)5.2 CMD (66)6 屏幕文件及使用 (67)7 其它 (67)7.1 报表打印 (72)7.2 SA VF,备份与恢复 (77)7.3 菜单--MENU (78)7.4 开发时常用的命令 (78)7.5 一点想法 (81)1简单说明内部交流、或可作培训使用。
AS400_初级培训

一.AS/400简介 (3)二.开发环境和开发工具介绍 (4)1.AS/400环境简介 (4)1.1三级存储结构 (4)1.2 如何建立库、文件和成员 (7)2、ILE简介 (8)3、AS/400开发工具介绍 (9)三.DDS介绍和实例说明 (10)1、AS/400的DDS常用类型介绍 (11)2、AS/400物理文件和逻辑文件介绍 (11)3、AS/400如何使用DDS来创建物理文件和逻辑文件 (11)4、AS/400如何使用DDS来创建显示文件 (16)四.RPG介绍和实例说明 (20)1、RPG的基本结构介绍 (20)2、F段介绍 (21)3、D段介绍 (23)3.1 单独变量的定义 (23)3.2 结构变量的定义 (24)3.3 常量的定义 (24)3.3 数组的定义 (24)4、C段介绍 (25)4.1 概念 (25)4.2 程序入口的定义 (27)4.3 程序的结束 (27)4.4 变量的赋值 (27)4.5 子过程的定义 (28)a)概述 (28)b)子过程的建立 (28)c)子过程的调用 (29)4.6 程序过程控制(判断、循环) (30)a) 判断 (30)b) 多重判断 (30)c) 循环 (30)4.7 数据文件的操作 (31)a) 文件相关操作 (31)b) 记录定位相关操作(游标) (31)c) 记录更新相关操作 (33)5、一个程序的实例及分析 (34)6、在RPG中嵌入SQL (48)五.CL程序的开发介绍 (48)1、CL 命令的介绍 (48)2、CL 程序 (49)3、CL 程序实例 (50)六.程序间的互相调用 (53)1、RPGIV之间的调用 (53)2、CLP与RPG之间的调用 (55)AS/400 初级培训讲义目的:希望通过短期培训,让有编程基础的技术人员,了解AS/400的一些基本概念和操作方式。
了解AS/400的代码编辑方式和基本概念一. AS/400简介AS/400是IBM于1988年推出的一种商用小型机,它是在 IBM System/32,System/34,System/36,System/38这个系列的基础上发展而来的。
AS400程序员培训手册(中级)

1 简单说明 (3)2 程序代码行的编写 (3)2.1 最简单的RPGLE程序 (3)2.2 举例准备 (3)2.3 简单的程序流程 (4)2.4 常见的程序流程 (5)2.5 F行说明 (5)2.5.1 内容说明 (5)2.5.2 常用例子 (9)2.5.3 补充说明 (10)2.6 D行说明 (10)2.6.1 内容说明 (10)2.6.2 常用例子 (13)2.6.3 补充说明 (14)2.7 入口参数 (14)2.8 C行说明 (16)2.8.1 写在前面 (16)2.8.2 内容说明 (17)2.8.3 ILE操作码分类: (18)2.8.4 ILE操作码 (19)2.8.4.1 A--C (19)2.8.4.2 D--E (27)2.8.4.3 F--N (32)2.8.4.4 O--R (39)2.8.4.5 S--Z (43)3 和程序相关的数据库知识 (49)3.1 LF(逻辑文件) (49)3.1.1 逻辑文件概念 (49)3.1.2 逻辑文件对效率的影响 (51)3.2 MEMBER (51)3.3 游标 (52)3.3.1 游标的概念 (52)3.3.2 不同操作码对应的游标的处理 (52)3.3.3 “有且仅有”的游标 (53)3.3.4 LOV AL、HIV AL对应的游标操作 (53)3.4 事务处理 -- COMMIT (54)3.4.1 概念描述 (54)3.4.2 使用方法 (54)3.4.3 注意事项 (55)3.5 关于锁表的问题 LCKW (56)4 DEBUG调试以及常见出错信息 (56)4.1 写在前面 (56)4.2 常规用法 (57)4.2.1 程序编译 (57)4.2.2 执行DEBUG命令 (57)4.2.3 运行程序 (57)4.2.4 在DEBUG模式中进行调试 (58)4.2.5 跟踪被当前程序调用的程序 (58)4.2.6 一定要退出DEBUG模式 (59)4.2.7 补充 (59)4.3 跟踪批处理程序( From qingzhou) (60)4.4 常见的出错信息 (60)4.4.1 编译程序时的出错信息 (60)4.4.2 运行时的出错信息 (62)5 CL、CMD (62)5.1 CL程序 (62)5.1.1 基本认识 (62)5.1.2 CL程序的常用语法及命令: (63)5.1.3 不常用的语法 (65)5.2 CMD (66)6 屏幕文件及使用(整理中) (67)7 其它 (72)7.1 报表打印 (72)7.2 SA VF,备份与恢复 (77)7.3 菜单--MENU (78)7.4 几个命令 (78)7.5 关于代码风格的几点想法 (81)1简单说明内部交流、或可作培训使用。
AS400系统管理员培训

条件:在PC上配置一块第三方适配器,与双芯同轴电缆端口相连, 与常规的主控制台使用相同的连接方式。
认识IPL ( initial program load )
面板设置: 01 B N V=F
第一部分表示目前状态,01表示显示状态、02表 示改动状态
第二部分B表示打过补丁、D表示安装操作系统 第三部分N表示自动启动、M表示手动启动 第四部分V=F表示快速启动,S代表慢速启动(为
ShareDdistLrib2uted Switch
Distributed Switch
Enhanced Scaling Simultaneous Multi-Threading (SMT) Enhanced Distributed Switch Enhanced Core Parallelism Improved FP Performance Increased memory bandwidth Reduced memory latencies Virtualization
其它状态:11-显示SRC代码,21-进入DST模式 …
一、系统概述
AS/400概述
– 集成性 – 开放性 – 可移植性 – 兼容性
– 可连接性 – 可支付性 – 可扩充性
体系结构
– TIMI 结构 (Technology Independent Machine Interface) – 集成性 – 单级存储结构
AS/400前身诞生于七十年代末,当时的名字叫做S/38。集成的关系数 据库、单级存储、虚拟存贮和面向对象的设计等。
•第二代AS/400
1988年推出了AS/400的第二代,融合了S/38的基本技术与S/36的用户 界面。IBM公司先后经历了B、C、D、E、F先进系列和e系列。
AS400培训资料(下)

AS400培训资料(下)AS400应用开发培训高级应用与交易实现前言本阶段的培训,在上一级培训的基础上,讲解业务系统的处理以及交易的实现。
目的是使大家掌握如何在AS400上实现具体的交易,完成本次开发任务。
在讲解业务系统的例子程序和会计记帐核心的过程中我们将穿插讲解AS400中一些编程方式和一些简单工具的使用。
由于篇幅和时间的关系在本教材中对一些简单工具不作具体的介绍,请大家作好记录。
同时为了配合本次培训,我们将下发两本教材,一本是操作码手册,另外一本是本公司原来出的IBM AS400 培训教材第二分册,对这两本教材的内容我们可能不作具体的讲解,主要是给大家在学有余力的情况下进行自学,以及今后进行实际编码时的参考手册。
对于一些非常少见的应用,我们不作讲解,请大家参考下发的教材或使用联机的帮助。
使用F6或其他方式建立的成员在Opt选14编译物理文件参与编译其他类型的目标(Object) SLRRPG(可执行程序 *PGM) 物理文件,逻辑文件,打印文件等参与编译,若RPG程序的F表进行了相应的定义其他需要参与编译的目标第一章 RPG程序使用RLU的方法在上一期的培训中我们简要的介绍了RLU的一些用法,现在我们来学习RLU的一些应用,以及如何在RPG程序中使用RLU生成的打印文件在今后的设计过程中,应业务人员的要求,在报表中对于一些域的属性可能要进行修改。
以下是将光标移到域后出现的域属性内容Work with Field KeywordsField . . . . . . . . : ' 客户 ... Record format . . . . : HEADType options, press Enter.2=Specify 4=RemoveOpt Keyword Opt Keyword Opt KeywordALIAS EDTCDE MSGCONBARCODE EDTWRD PAGNBRBLKFOLD FLTFIXDEC PRTQLTYCDEFNT FLTPCN REFFLDCHRID FNTCHRSET SKIPACHRSIZ FONT SKIPBCOLOR HIGHLIGHT SPACEACPI IGCALTTYP > SPACEBCVTDTA IGCANKCNV TEXTDATE IGCCDEFNT TIME> DFT IGCCHRRTT TRNSPYDLTEDT INDTXT UNDERLINEBottomF3=Exit F5=Refresh F9=Input keyword parameters F10=Specify informationF12=Cancel F16=Remove all keywords选择(opt)2 进行该项的内容说明 4 是取消该项说明在这些选项中经常用到的是:DFT 若前面有”>”则说明该项是常量域,否则是变量域。
AS400中文教程
AS400中文教程AS400是一种使用广泛的主机操作系统,也是一种经典的企业级计算机系统。
它具有稳定性、可靠性、安全性和易用性等特点,广泛应用于企业、金融、物流、制造等领域。
本篇教程将介绍AS400的概念、原理、操作和应用等内容,帮助初学者了解和掌握AS400系统。
一、AS400是什么AS400(即IBMi)是IBM公司推出的一种企业级计算机系统。
它以稳定性、可靠性和安全性著称,广泛应用于企业的核心业务系统和数据处理中心。
AS400采用了先进的虚拟化技术,可以同时运行多个操作系统和应用程序,提供强大的计算和存储能力。
二、AS400的原理AS400的核心原理是通过操作系统管理和控制计算机硬件资源,提供一种可靠、高效的计算环境。
AS400操作系统采用了独特的对象概念,将计算机资源(例如打印机、磁盘、网络连接等)抽象为对象,通过开放的API接口提供给应用程序使用。
这种面向对象的设计可以方便地进行系统管理、应用开发和资源分配。
三、AS400的基本操作1.登录系统:AS400通常通过终端或PC客户端进行远程登录。
输入正确的用户名和密码后,即可登录到系统。
2.发布任务:AS400支持多任务处理,可以同时运行多个任务。
通过发布任务可以在系统中创建新的任务,并指定其优先级和执行时间。
3.管理文件:AS400系统使用基于对象的文件系统,管理文件非常方便。
可以通过命令行或图形界面操作,创建、删除、复制和移动文件等。
4.资源监控:AS400提供了强大的系统监控工具,可以实时查看系统的运行状态、资源使用情况和性能指标等。
通过监控可以及时发现和解决系统问题,保证系统的稳定运行。
四、AS400的应用1.金融系统:AS400可以作为金融机构的核心业务系统,处理各种金融交易、资金结算和风险管理等业务。
2.物流系统:AS400可以用于物流企业的仓库管理、货物跟踪和配送管理等业务。
3.制造系统:AS400可以用于制造企业的生产计划、工艺控制和品质管理等业务。
RPG AS400程序员培训手册-19页精选文档
2.8.4.4 O--RON-ERROR (On-Error)没用过OPEN {(E)} (Open File for Processing) 打开文件Factory 1 Operation Factory 2 Result HI LO EQOPEN 文件名OPEN 后面的目标,必须是在当前程序中已声明的文件名(不是文件的记录格式名),而且在OPEN 操作之后,在程序结束之前之前,必须有对应的CLOSE 操作。
使用OPEN 操作,文件在声明时,必须使用USROPN 关键字(详见D 行说明)。
ORxx (Or) 逻辑判断—或Factory 1 Operation Factory 2 Result HI LO EQFLD01 IFGT FLD03FLD01 OREQ FLD02等价于IF FLD01>FLD03 OR FLD01=FLD02与IF、IFxx,AND、ANDxx 类似,RPGLE 的写法OR,比RPG 的写法ORxx 要灵活,而且可以用来表达一些复杂的逻辑关系。
有鉴于此,所以通常IF 语句中,我会以OR 为主,基本不用ORxx。
如果在编程序方面,公司/项目组无硬性要求,那我觉得还是少用ORxx 吧,总觉得这种写法的逻辑关系看起来不直接,尤其是有很复杂的AND,OR 时。
OTHER (Otherwise Select) 分支语句的判断与分支语句SELECT 一起使用,表示不符合上述所有条件时的操作,如下:Factory 1 Operation Factory 2 Result HI LO EQSELECTWHEN 条件判断1处理语句1WHEN 条件判断2处理语句2OTHER处理语句3ENDSL在这个例子中,当满足条件判断1 时,运行处理语句1,运行结束后跳至ENDSL 处;如果不满足条件判断1,则程序继续向下执行,判断是否满足条件判断2。
当满足条件判断2 时,运行处理语句2,跳至ENDSL;当不满足当不满足条件判断2 时,程序继续向下执下,当读到OTHER 操作码时,无条件运行处理语句3(即当程序当前不满足以上所以条件判断时,则执行OTHER 之后的语句。
IBM AS400培训教程和手册
12
磁带组使用者的名字,这一项一般不用进行修改 Check tape for active files . . . . . . . Y Y=Yes, N=No 这一项与格式化一盘磁带的意义相同,一般使用N,也就是NO的意 思,表示不进行检查
13
第五章 磁带什么时候该丢弃
每盘磁带都有一定的使用寿命,AS/400系统提供了一个磁带文卷寿 命统计的监督程序,通过该程序可以确定某盘磁带是否已到使用寿 命需要更换新磁带。 操作步骤: 1、在命令行输入STRSST命令,进入System Service Tools菜单 2、选择1(Start a Service Tool) 3、在Start a Service Tool 3 Start Tool菜单上选择1(Product activity log ) 1 Product 4、在Product activity log 菜单上选择4(Work with tape/diskette lifetime Statistes) 5、在Select Media Option屏幕上在Removable media参数选择相 应的介质类型
20
第八章 提交作业
(1)在主菜单(Main)中选择3(General system tasks) (2)在General system tasks菜单中选择1(Jobs) (3)在Jobs菜单上键入选项7(Submit a job) (4)按执行键(Enter)出现Submit a job命令提示屏幕,或者键 入命令SBMJOB,并按F4键。 (5)在Command to run 5 Command run输入字段内键入在批作业中你要运行的命 令。如果该作业是一个CL程序,则要键入程序名,如CALL PAYROLL。 (6)如果需要可修改其它字段的缺省值,也可以不修改。
AS400学习笔记
AS/400】AS/400學習筆記八月 16, 2005 bangdoll留言Go to comments第一章 AS/400概論AS/400自77年6月以來已歷經九代變革IBM每隔一年均會推出新的機型及作業系統AS/400 High-Level Machine單一層次記憶體(Single Level Storage)虛擬記憶體(Virtual Storage)軟體簡介AS/400軟體可分為三大部份1.系統支援2.程式設計3.應用軟體系統支援:OS/4001.OS/400是AS/400機器的作業系統2.OS/400有選擇畫面(MENU)及控制語言(Control Language)指令,可提供使用者操作AS/400系統3.OS/400可同時執行多個交談式工作(Interactive job),批次工作(Batch job)及同時發展其他應用程式4.OS/400有關連式資料庫系統,保全系統,通訊網路系統及各種備份/回復能力5.OS/400自動建立硬體系統環境6.OS/400提供IBM S/36與S/38之操作環境程式設計支援1.RPG/400(目前常用)2.COBOL/400(目前常用)3.C/4004.SQL/400(目前常用)5.Fortran/4006.AS/400 Basic7.AS/400 PL/I8.AS/400 Pascal9.RM/COBOL-85應用軟體支援軟體名稱:Application Development Tool Set/400(ADTS)主要功能:1.針對結構化語言開發環境提供程式編輯,線上即時偵錯功能2.提供螢幕畫面設計及報表格式設計輔助能力3.提供基本檔案維護及資料庫結構維護功能第二章終端機操作使用者界面畫面型態1.選擇畫面(Menu)2.鍵入畫面(Entry)3.列示畫面(List)4.說明畫面(Information)使用System Request畫面第三章 Object管理Object是在儲存體佔有空間的一個最小單位,系統根據其型態,有不同之操作方式,來執行其運作例如:FileLibraryProgramComandsQueuesUser ProfileJob DescriptionsDevice Descriptions……The AS/400 Object Description-Name-Library-Object type-Type attribute(PF,LF)-Owner(creator)-Public authorization-Change date/time-Date/Time last saved-Restore volume ID-Storage freed-Text description-SizeLibrary1.是一個目錄Directory,其中包含Object之相關資訊(型態及位置),指向其相關之Object2.其儲存之Object並不需要在同一硬碟中3.所有Library都在QSYS Library內如何組織Library為了1.保全功用2.備份功用區分由1.應用程式2.使用者3.Object型態非限定名稱(Unqualified name)/限定名稱(Qualified Name)1.在指定Object時,均需給予名稱,此名稱包含兩個部份,即Library部份及Object部份2.非限定名稱僅用Object名稱來使用-PGMA3.限定名稱用法使用Library名稱及Object名稱-LIBA/PGMA第四章控制語言指令(CL Commands)控制語言所有系統功能均被單一之語言來控制1.由操作者來使用2.可組合為程式3.可交談式或批次使用列示主要指令群1.游標移至Command line 按F42.輸入go major尋找某種型態指令游標移至Command line 輸入go cmdfile指令提示游標移至Command line 輸入1.?DSPOBJD2.DSPOBJD 按F4? OR F4 : List若使用者想知道某個參數可輸入哪些值時,可將游標移至欲輸入欄位鍵入’?'再按執行鍵或是F4第五章訊息指令應用訊息:一種通訊之方式基本訊息佇列(Message Queue)通訊1.系統操作者(System Operator)訊息佇列2.使用者訊息佇列3.工作站訊息佇列4.一個訊息佇列(Message Queue)會自動建立當1.建立一個工作站2.建立一個使用者Profile5.系統操作者的訊息佇列是系統提供的6.使用者可隨時建立其他訊息佇列訊息佇列(Message Queue)模態有中斷(Break),通知(Notify),留置(Hold)1.訊息佇列(Message Queue)有個傳輸(Delivery)參數來說明訊息如何接收及使用者如何被通知:1.中斷(Break)-使用者作業被中斷,訊息顯示在畫面上2.通知(Notify)-使用者被通知,而訊息訊號燈亮且有聲響3.留置(Hold)-使用者不會被通知訊息2.所有訊息會儲存在訊息佇列(Message Queue),除非是被刪除使用者及工作站訊息佇列(Queue)訊息永遠可以送至任何一個訊息佇列(Queue),即使使用者或工作站在登出系統後基本訊息處理指令1.發送訊息 SNDMSGSNDBRKMSG2.察看訊息 DSPMSG訊息1.訊息本文最多可送512個字元給使用者訊息佇列,工作站訊息佇列,系統操作者佇列(System Operator Queue)或系統記錄日誌QHST2.TOUSR只能輸入一個值3.TOMSGQ最多可輸入50個值系統操作者訊息系統操作者訊息佇列內容包括:1.硬體裝置使用相關訊息2.使用者及系統活動相關訊息DSPMSG MSGQ(QSYSOPR)(*SYSOPR)第六章線上輔助說明1.輔助說明(Help):F12.欄位說明(Field Help):F13.訊息說明(Message Help):F14.整體說明(Extended Help):F2第七章系統開關系統開機(Starting the System)1.不參與式開機(Unattended IPL):一般的開機 IPL:Inital Program Load2.參與式開機(Attended IPL)3.遠端開機(Remote IPL)4.自動開機(Automatic IPL’s):大部分都是使用這一種方式開機-System Value-Operational Assistant4.AS/400一般來說一次的開機時間大約20mins~30mins系統關機1.使用PWRDWNSYS指令2.使用電源開關(Power Switch)3.使用緊急開關(Emergency Switch)4.使用Operation Assistant第八章工作管理之觀念工作型態(Types of jobs)1.交談式作業(Interqctive):系統回應給每一個工作站上使用者需求的處理2.批次作業(Batch):系統執行一組程式指令的處理3.周邊裝置線上同時作業(Spool)(Simultaneous Perpheral Operation On-Line)將慢速周邊裝置的輸出入資料先存放於快速周邊裝置(如硬碟),然後才由CPU讀取、印表機將其列表,由於CPU不必和這些慢速裝置直接界面,所以提升了CPU操作速度第九章工作作業控制(Job Control)工作作業控制(Job Control)包括了交談式作業及批次作業;工作作業控制(Job Control)控制了在工作佇列(Job Queue)中的工作,及在輸出佇列(Output Queue)中的工作SBMJOB指令批次作業中的第一個步驟是將批次工作放置在工作佇列中排列,此作業使用的指令是SBMJOB工作佇列(Job Queue)WRKSBMJOB:允許使用者看到所有批次工作,不論此工作目前在工作佇列內,輸出佇列內或在執行中WRKUSRJOBWRKACTJOB:可查詢在各子系統下活動的工作狀態及一些系統工作(System job) 如何結束工作ENDJOBENDJOBABN第十章 Spool及印表控制啟動Spool作業Writer為一系統程式,可將報表由輸出佇列中取出而由印表機印出,欲啟動此程式可用指令STRPRTWTRWork with All Spooled Files指令WRKSPLF允許查詢目前使用者,或所有使用者產生的Spool Files查看Spool Files狀況指令WRKWTR管理AS/400上連接的印表機工作管理(Work Management)總論JOBQ—>BATCH(INTERACTIVE)—>OUTQ—>WRITER —>PRINTER WRKJOBQ —>WRKACTJOB—>WRKOUTQ(WRKSPLF)—>WRKWTR—>WRKCFGSTS*DEVAS400 Spool Converter ProSpool to PDF, HTML, TXT, CSV, XML Easy to use. Shareware version。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
i want stress-free IT.i want control.i want an i.IBM System i ™©2008 IBM Corporation What’s new in RPG for V6R1(And a brief review of V5R4)Don YantziIBM Toronto Lab2i want an i.IBM System i ™©2008 IBM CorporationRPG V5R43i want an i.IBM System i ™©2008 IBM CorporationXML supportRPG’s XML support currently only supports reading the XML documents.There is nosupport for creating or modifying XML documents. RPG has two ways to get data from XML documents.XML-INTO allows the programmer to read all or part of the XML document directlyinto an RPG variable.XML-SAX allows the programmer to get the data from XML document, one piece ata time. The XML data is passed to a user-provided procedure which may be called many times during the course of a single XML-SAX operation.RPG supports XML documents in memory (character or UCS-2 data) or inIntegrated File System files.4i want an i.IBM System i ™©2008 IBM CorporationXML supportIn case you are unfamiliar with XML, here is a small XML document: <pet species=“dog”><name>Ruff</name><age>3</age><agetype>dog years</agetype></pet>Elements : pet, name, age, agetypeAttribute : species5i want an i.IBM System i ™©2008 IBM CorporationBrief introduction to XMLAn XML document represents data in a tree structure. The data is all in text form.Here is an introduction to the syntax: /wiki/XML#Quick_syntax_tour There are two basic types of XML parsers: SAX and DOM.“SAX”stands for “Simple API for XML”. A SAX parser operates by reading the XML document and calling a user-provided procedure for every “event”that the parser finds. “DOM”stands for “Document Object Model”. The parser creates a tree representing the XML document, and provides several functions for randomly accessing the tree.Both facets of the RPG support use a SAX parser, but only XML-SAX exposes the actual XML events to the RPG programmer. XML-INTO hides the complexity of the SAX event handling.6i want an i.IBM System i ™©2008 IBM Corporation%XML builtin function%XML(document { : options })The %XML builtin function is used to identify an XML document and specify options to control how the XML document is parsed. The first operand can be the actual contents of the XML document, or it can indicate the location of the XML document. It can be a character or UCS-2 expression, either a constant or a variable.The second operand is optional; it allows the RPG programmer to customize the XML operation. It can be a character expression, either a constant or a variable.The valid options depend on the operation code, XML-SAX or XML-INTO. One option is common to both operations: the “doc”option, which specifies whether the first operand is the actual document, or the location of the document.The options are specified as a character expression in the form ‘opt1=value1 opt2=value2’, for example ‘doc=file ccsid=job’.The option=value pairs are separated by blanks.Examples :%XML(‘<name>Bob</name>’);// 1st operand is an XML document%XML(‘custinfo.xml’: ‘doc=file’);// 1st operand is the name of an IFS file7i want an i.IBM System i ™©2008 IBM CorporationDefault values for %XML optionsThe valid options and valid values for each option depend on the context (opcode)of %XML.If you would like different default options, you can define a constant value with thedefaults you want, and then append updates or additions on each operation. (If the RPG runtime finds an option specified more than once, it takes the last value specified, so be sure to specify your defaults first.)For example, if you would prefer the default for the “allowmissing”option for XML-INTO to be “yes”, and the “doc”option to be “file”, you could code like this:D intoDfts c ‘allowmissing=yes doc=file ’xml-into ds %xml(xmldata: intoDfts + ‘doc=string’);// overrides “doc=file”with “doc=string”8i want an i.IBM System i ™©2008 IBM CorporationXML-INTO operation codeUsing the XML-INTO operation requires knowledge of the XML document’s structure. For example, an RPG programmer may know that an XML document will be laid out as follows,with the “document element”named “cust”and two “child elements”named “name”and “id”:<cust><name>ABC Electronics</name><id>1233273</id></cust>The structure of the document can be represented by an RPG data structure named “cust”withtwo subfields “name”and “id”. For example D cust dsD name 100A varyingD id 15P 0The XML document can be “assigned”directly into the data structure:XML-INTO cust %XML(custXml : ‘doc=file’);XML-INTO can be used to read data into a scalar variable, scalar array, or array of data structures.RPG subfields can be filled with data from either an XML element or XML attribute.9i want an i.IBM System i ™©2008 IBM CorporationXML-INTO assumptionsBy default, the RPG runtime makes several assumptions about the XML document:It assumes that XML element and attribute names in the document are the same as the names of the RPG variable and subfields, and that the XML names will be in lower case. For data structures:–It assumes that there is an XML element or attribute for every RPG subfield, and that every XML element or attribute has a matching RPG subfield to receive the data.–It assumes that if one of the RPG subfields is an array, that there will be exactly as many repeated XML elements as there are elements in the RPG array.If the target variable is not an array, it assumes that the outermost XML document has the same name as the RPG variable. If the target variable is an array, it assumes that the outermost element contains several child elements with the same name as the RPG variable.However, XML-INTO has several options that allow the RPG programmer to override some of these assumptions.10i want an i.IBM System i ™©2008 IBM CorporationXML-INTO optionscase : If the element and attribute names are all in upper case, specify‘case=upper’; if they are in unknown or mixed case, specify ‘case=any’. allowmissing :Use ‘allowmissing=yes’if the document may not contain XML data to fill every RPG subfield. allowextra :Use ‘allowextra=yes’if the document may have XML data that has no matching RPG subfield to receive it. trim :Used to control whether “whitespace”(blanks, tabs, new-line characters)should be trimmed from the XML data before being assigned to the RPG subfields. The default is “all”, meaning that leading and trailing whitespace is trimmed, and interior whitespace is reduced to a single blank; To have the whitespace included in the RPG subfields, use ‘trim=none’. (Whitespace is always trimmed before assigning to numeric, date etc.)…more on next page11i want an i.IBM System i ™©2008 IBM CorporationXML-INTO options, continuedccsid :Used to control the CCSID that the document is parsed in. By default, theRPG runtime will choose the CCSID that will best preserve the data in the document (‘ccsid=best’); if the document is in UCS-2, or if it is a CCSID other than the job CCSID, the RPG runtime will convert the document to UCS-2 before parsing. Otherwise, the RPG runtime will parse the document in the job CCSID. If the RPG programmer wants the document to be parsed in the job CCSID (which may involve fewer CCSID conversions during parsing), use ‘ccsid=job’. If the RPG programmer wants the document to be parsed in UCS-2, use ‘ccsid=ucs2’.–Restriction:The parser does not support all job CCSIDs. When thedocument may be in an unsupported CCSID, ‘ccsid=ucs2’should be used. …more on next page12i want an i.IBM System i ™©2008 IBM CorporationXML-INTO options, continuedpath :Used to locate the XML data within the XML document. For example:–Option ‘path=info/num’indicates that the outer XML element will be called “info”and itwill have a child element called “num”which should be used to obtain the data for the RPG variable. –Option ‘path=employees/manager/address’indicates that the outer XML element called “employees”will have a child called “manager”which itself will have a childcalled “address”. The “address”XML element should be used to obtain the XML data for the RPG variable.The path option can also be used to “rename”the outer XML element. Ifthe data structure’s name is ‘custinfo’, but the outer XML element is called “customer”, then ‘path=customer’should be used to inform the RPG runtime of the actual name of the outer element. Note: there is no way to indicate a different name for the XML element or attribute to match a particular subfield.13i want an i.IBM System i ™©2008 IBM CorporationXML-INTO with repeating elementsAn XML document may contain repeating XML elements, such as in the following example:<customers><cust name=“J Smith”id=“031”/><cust name=“M Jones”id=“402”/></customers>For this type of document, an RPG array can be used as the receiver variable.D cust DS DIM(10)D name 50a VARYING D id 10a XML-INTO customers %xml(xmldoc : ‘doc=file’);Note the following about this example:The “path”option was not specified,even though the XML elements matching the RPG array are inner elements. Thedefault for an array is to assume that the XML elements are child elements of the outer element. (This is because an XML document can only have one outer element.)The dimension of the RPG array is 10, but there are only 2 repeated elements inthe XML document. This situation doesnot require “allowmissing=yes”, since the target array is not a subfield.The actual number of array elements set by the operation can be obtained from a new “number of XML elements”subfield in the PSDS.14i want an i.IBM System i ™©2008 IBM CorporationXML-INTO with an unknown numberof repeating elementsIf the number of repeating elements may be larger than the maximum number of elements in an RPG array (32767), then a more complex form of XML-INTO must be used.Rather than read the repeating XML data into an RPG array variable, instead the parser will read the XML data into a temporary array,and call an RPG “XML-INTOhandling procedure”whenever ithas read enough XML data to fillthe temporary array.<band><member name=“John”/><member name=“Paul”/><member name=“George”/><member name=“Ringo”/></band>If the RPG handler is capable of receiving 3elements at once, it would be called twice, with the following data:1. John, Paul, George (3 elems)2. Ringo (1 elem)15i want an i.IBM System i ™©2008 IBM Corporation%HANDLER%HANDLER(prototype : firstParameter)The %HANDLER builtin function is used to describe a user-definedprocedure that is to be called during the operation.The first operand is the name of the prototype for the handler. Therequired parameters and return type of the handler depend on the context in which %HANDLER is specified.The second operand is the parameter which is received by the firstparameter of the handler procedure.16i want an i.IBM System i ™©2008 IBM CorporationXML-INTO with %HANDLERAn XML-INTO handler has the following rules:The return type is a 4-byte integer (10i 0). Returning a value of zero indicates that parsing should continue to find XML data and call the handler again if necessary. Returning any other value indicates that parsing should stop immediately. This will cause an RPG exception to be issued for the XML-INTO operation.The first parameter can be any type, passed by reference. The parameter is passed as the second operand of the %HANDLER builtin function.The second parameter specifies the type of the array elements to be filled by the XML data. It can have any type, but the DIM and CONST keywords must be coded. The third parameter is for the actual number of elements passed in for that particular call to the handler. (Recall the previous example where the first call had 3 elements (John, Paul, George) and the second call had only 1 element (Ringo).)17i want an i.IBM System i ™©2008 IBM CorporationXML-INTO %HANDLER exampleSample definitions required to use %HANDLER with XML-INTO:* The definition for the data structure to receive the XML dataD cust DS DIM(10)D name 50a VARYINGD id 10a* The prototype for the handlerD custHandler PR 10i 0D foundBlankId nD custs LIKEDS(cust)D DIM(32767)D numCusts 10i 0 VALUE18i want an i.IBM System i ™©2008 IBM CorporationXML-INTO %HANDLER exampleThe XML-INTO operation looks like this. Note that the “path”option is required forXML-INTO with %HANDLER.* Parameter to pass to the handlerD hadBlank S n/freehadBlank = *OFF; // initialize the “communication”parameterxml-into %HANDLER(custHandler : hadBlank)%XML(xmldoc : ‘doc=file path=customers/custs’);19i want an i.IBM System i ™©2008 IBM CorporationXML-INTO %HANDLER exampleP custHandler B EXPORT D custHandler PI 10i 0D foundBlankId…D n D custs LIKEDS(cust)D DIM(32767)D numCusts 10i 0 VALUE /free for i = 1 to numCusts;---do something with the data ---if custs(i).id = ‘‘;foundBlankId = *on;endif;return 0;/end-free P custHandler E The handling procedure, custHandleris called repeatedly whenever theparser has read enough XMLdata to fill 32767 RPG elements.The variable “blankId”specified asthe second parameter of %HANDLER is passed directly byreference to the handling procedure by the parser. If the handling procedure changes the parameter, the changes will bevisible to the “XML-INTO”procedure.The procedure itself would normally do something useful with the data. In this case, it illustrates how the first parameter is used for communication between the RPG procedure doing the XML-INTO operation and the custHandler procedure.20i want an i.IBM System i ™©2008 IBM CorporationSAX parsingConsider this XML document <cust type=“business”><name>ABC Tools</name></cust>The parsing “events”are–Start document–Start element (“cust”)–Attribute name (“type”)–Attribute value (“business”)–Start element (“name”)–Characters (“ABC Tools”)–End element (“name”)–End element (“cust”)–End document21i want an i.IBM System i ™©2008 IBM CorporationXML-SAX operationThe XML-SAX operation identifies a handling procedure to handlethe various SAX events generated by the parser. Theprocedure will be called several times during the XML-SAX operation, once for each event.If the procedure needs to retain information about the events, itcould either use static variables in the procedure, or it could use the “communication area”parameter passed by theprocedure doing the XML-SAX operation.22i want an i.IBM System i ™©2008 IBM Corporation%XML options for XML-SAXdoc –same as for XML-INTO, identifies whether the first operand is an XMLdocument, or the location of an XML documentccsid –indicates the CCSID for the data to be passed to the XML-SAXhandling procedure. The default is the job CCSID; to have the data passed as UCS-2, use ‘ccsid=ucs2’; to have another CCSID for example 1208, use ‘ccsid=1208’. Warning : if a CCSID other than the job CCSID is used, and a character variable is used to access the data, the RPG compiler will assume that the character data is in the job CCSID. This may cause incorrect results. For example, if comparisons are done with other character data in the program, the comparison operands would not be in the same CCSID, and the results of the comparison would be incorrect.23i want an i.IBM System i ™©2008 IBM CorporationXML-SAX eventsFor most events, the parameters passed to the procedure will include a stringparameter containing the data associated with the event, and a string-length parameter. This parameter is defined as a pointer passed by value; the pointer points at either character or UCS-2 data, depending on the “ccsid”option. The pointer can be used as a basing pointer for a character or UCS-2 variable.The data may be longer than can be handled by an RPG variable. In that case,the RPG programmer must use some means other than a simple basedvariable to access the data; for example, it could call a procedure in some other language.For a few events, such as the start-document, end-document or exception events,there is no data associated with the event, and accessing the string parameter will result in an exception.24i want an i.IBM System i ™©2008 IBM CorporationXML-SAX handlerAn XML-SAX handler has the following rules:The return type is a 4-byte integer (10i 0). Returning a value of zero indicates that parsing should continue to find XML data and call the handler again if necessary. Returning any other value indicates that parsing should stop immediately. This will cause an RPG exception to be issued for the XML-SAX operation.The first parameter can be any type, passed by reference. The parameter is passed as the second operand of the %HANDLER builtin function.The second parameter identifies the SAX event. There are several new RPG special names in the form *XML_START_ELEM, *XML_ATTR_NAME etc, that can be used to determine which event is being handled.The third parameter is the pointer to the data for the event, passed by value. The fourth parameter is the length of the data, an 8-byte integer (20i 0) passed by value. In cases where no data is passed, the value is -1.The fifth parameter is only meaningful for exception events. It gives the returncode associated with the exception. The meanings of the return codes are listed in the ILE RPG Programmer’s Guide.25i want an i.IBM System i ™©2008 IBM CorporationXML-SAX handling procedureThis handler looks for an “start-element”event with the event data “name”; on the next “characters”event, itupdates the first parameter with the character data. If the XML document is<info><name>Bob</name></info>, then the “nameVal”parameter, passed by the XML-SAX operation, would be set to the value “Bob”.P getName BD getName PI 10I 0D nameVal 20AD event 10I 0 VALUED string * VALUED stringlen 20I 0 VALUED excpId 10I 0 VALUED stringVal S 65535A BASED(string)D hadNameElem S N STATIC INZ(*OFF)/freeif event = *XML_START_ELEM and %subst(stringVal:1:stringlen) = ‘name’;hadNameElem = *ON;elseif hadNameElem and event = *XML_CHARS;nameVal = %SUBST(stringVal : 1 : stringlen); // update caller’s parmendif;return 0;/end-freeP E26i want an i.IBM System i ™©2008 IBM CorporationDebugging aid for XML-SAX handlersIf DEBUG(*XMLSAX) is specified on the H spec, an array called_QRNU_XMLSAX will be generated into the module. This array contains the names of the events.In the debugger:==> eval eventEVENT = 2==> eval _QRNU_XMLSAX(event)_QRNU_XMLSAX(event) = ‘ATTR_NAME’27i want an i.IBM System i ™©2008 IBM CorporationRPG V6R128i want an i.IBM System i ™©2008 IBM CorporationILE RPG enhancements -overviewMajor enhancements for ILE RPG include Data structure type definitionsNo more compile-time overridesDefining files locally in subprocedures, and passing files as parameters Significantly higher limits for the size of variables and array elements A new kind of RPG main procedureRelaxation of some UCS-2 rules (available for V5R3/4 through PTFs) Run concurrently in multiple threads; RPG doesn’t have to be a bottleneck29i want an i.IBM System i ™©2008 IBM CorporationILE RPG –TEMPLATE definitionsRPG programmers often code variable definitions that are intended as “type definitions”, to be used by later LIKE or LIKEDS definitions. To prevent the compiler from defining storage for these definitions, they code the BASED keyword, hoping that no maintenance programmer will try to use the definitions as program variables.The RPG compiler supports INZ(*LIKEDS) to initialize a LIKEDS data with the same initialization value as the parent data structure,but initialization values are not supported with the BASED keyword. TEMPLATE solves both these problems:–The compiler doesn’t allow the definition to be used as program variable.–The INZ keyword is supported with TEMPLATE, so defaultinitializations can be coded for a template data structure30i want an i.IBM System i ™©2008 IBM CorporationTEMPLATE example –defining the templateD custId_t S 10A TEMPLATED CUST_ID_NOT_SET...D C -1D custInfo_t DS TEMPLATED QUALIFIEDD name 35A VARYINGD city 25A VARYINGD INZ('Toronto')D province 25A VARYINGD INZ('Ontario')D postal 6A INZ(*BLANKS)D id LIKE(custId_t)D INZ(CUST_ID_NOT_SET)31i want an i.IBM System i ™©2008 IBM CorporationTEMPLATE example –using the templateD cust1 DS LIKEDS(custInfo_t)INZD cust2 DS LIKEDS(custInfo_t)D INZ(*LIKEDS)Both CUST1 and CUST2 are defined like the template data structure, so they have subfields NAME, CITY etc.CUST1 has default initializations, so CUST1.CITY is initialized with an empty name.CUST2 is initialized with *LIKEDS, so CUST2.CITY is initialized with ‘Toronto’.32i want an i.IBM System i ™©2008 IBM CorporationILE RPG –avoid compile-time overridesA common complaint by RPG programmers is that they have to do file overrides at compile time, for externally-described files and data structures.When RPG added the EXTFILE keyword in V5R1, which removed most of the necessity to do overrides at runtime, but theEXTFILE keyword was not used at compile time.A new F spec keyword EXTDESC handles this problem for files, and an enhancement to the EXTNAME keyword handles this problem for data structures.33i want an i.IBM System i ™©2008 IBM CorporationILE RPG –avoid compile-time overridesFor F specs, new keyword EXTDESC and enhanced keyword EXTFILE(*EXTDESC)EXTDESC(‘LIBNAME/FILENAME’) or EXTDESC(‘FILENAME’) locates the file at compile timeEXTFILE(*EXTDESC) indicates that the file specified by EXTDESC is also to be used at runtime.For D specs, the EXTNAME keyword is enhancedEXTNAME(‘LIBNAME/FILENAME’) or EXTNAME(‘FILENAME’) locates the file for the data structure at compile time.34i want an i.IBM System i ™©2008 IBM CorporationILE RPG –local filesV6R1 introduces the ability for RPG programmers to define fileslocally in subprocedures. This has two main advantages:1.Maintainability : Prior to V6R1, all files had to be definedglobally. There was no way for an RPG programmer to limit the file’s access to only one subprocedure, which could cause some maintenance difficulties. By coding the file definition in asubprocedure, the RPG programmer can explicitly limit the file’s access to only that subprocedure.2.Reduction of static storage : Defining the file locally reduces ofthe static storage required by the module, if the file is defined to use automatic storage for the internal storage required to manage the file.35i want an i.IBM System i ™©2008 IBM CorporationILE RPG –local files –some rulesLocal F specifications follow the Procedure-begin specificationand precede the Definition specifications.I/O to local files can only be done with data structures. Thereare no I and O specifications for local files.By default, the storage associated with local files is automatic;the file is closed when the subprocedure returns normally or abnormally.The STATIC keyword can be used to indicate that the storageassociated with the file is static, so that all invocations of the procedure will use the same file. If a static file is open when the procedure returns, it will remain open for the next call to the procedure.36i want an i.IBM System i ™©2008 IBM CorporationILE RPG –local files –example 1P fixPostalCode BFcust UF E DISKD custDsE DS EXTNAME(cust:*INPUT)/freeread custrec custDs;dow not %eof;if postCode = ‘‘;postCode = getPostalCode(addr:city:prv);endif;read custrec custDs;enddo;The file is not defined with STATIC, so it will be closed when the procedure ends.37i want an i.IBM System i ™©2008 IBM CorporationILE RPG –local files –example 2P getCust BFcust IF E K DISK STATICD getCust PI ND id LIKE(custrec.id)D CONSTD custDs LIKEREC(custrec)/freechain id custrec custDs;return %FOUND;The file is defined with STATIC, so it will stay open when theprocedure ends.38i want an i.IBM System i ™©2008 IBM CorporationILE RPG –qualified record formatsAnother file-related enhancement is Qualified record formats. Using qualified record formats makes it easier to read and maintain RPG code.Consider this code which does not use any qualified names:read custRec custDs;if not %eof(inFile);if amtOwing > 1000;Compare to this version which uses qualified names for the file and the data structure:read inFile .custRec custDs ;if not %eof(inFile );if custDs .amtOwing > 1000;39i want an i.IBM System i ™©2008 IBM CorporationILE RPG –qualified record formatsSome of the rules for using qualified formats:When a file is defined with the QUALIFIED keyword, the record formats must be qualified by the file name, MYFILE.MYFMT. Qualified files do not have I and O specifications generated by the compiler; I/O can only be done through data structures.When files are qualified, the names of the record formats can be the same as the formats of other files. For example, you can have FILE1.FMT1 and FILE2.FMT1.40i want an i.IBM System i ™©2008 IBM CorporationA review of how RPG I and O specs workWhen the compiler does generate I specs, you get program fields defined from the fields in the file.1 Fcustfile if e disk2=ICUSTREC3=I P 1 6 0ID 4=I A 7 56 NAME 5=I A 57 106 CITY 6 C if name = *blanksGlobal Field References:Field Attributes ReferencesNAME A(50) 4D 641i want an i.IBM System i ™©2008 IBM CorporationWhat if there are no I and O specs?When the compiler does not generate I specs, you don’t get any program fields defined from the fields in the file.5 P myProc b6 Fcustfile if e disk7 C if name = *blanksField References for subprocedure MYPROC:Field Attributes ReferencesRNF7030 NAME **UNDEF** 742i want an i.IBM System i ™©2008 IBM CorporationInstead of I and O specsInstead, you define a data structure to hold the fields from the file.1 Fcustfile if e disk qualified2 D custDs ds likerec(custfile.custrec )3 /free4 read custfile.custrec custDs;5 if = *blanks;Global Field References:Field Attributes ReferencesCUSTDS DS(100) 2D 4M 5ID P(11,0) 2DNAME A(50) 2D 5CITY A(50) 2D43i want an i.IBM System i ™©2008 IBM CorporationILE RPG –LIKEFILEFiles defined like other files:Using the LIKEFILE keyword, a file can be defined to use the same settings as another File specification.If the file is externally-described, the QUALIFIED keyword is implied. I/O to the file can only be done through data structures. The LIKEFILE keyword is mainly used with file parameters.44i want an i.IBM System i ™©2008 IBM CorporationILE RPG –file parametersAnother major file-related enhancement for RPG is the ability to pass files as parameters between procedures and programs: A prototyped parameter can be defined as a File parameter using the LIKEFILE keyword.Any file related by LIKEFILE keywords to the same original File specification may be passed as a parameter to the procedure.Within the called procedure or program, all supported operations can be done on the file parameter. However, I/O to the file parameter can only be done through data structures.RPG file parameters are not compatible with file parameters in other languages such as C or COBOL.。