AS400-RPG入门_第1页
AS400-RPG入门_第2页
AS400-RPG入门_第3页
AS400-RPG入门_第4页
AS400-RPG入门_第5页
已阅读5页,还剩7页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

一 RPG 介绍 RPG 程序的特点 1 程序的编写对于每一个位置都有明确的定义 所以程序的编写必 须在指定的位置开始 通过使用 ILE 工具可以进行一些方便的输入 2 RPG 程序的设计针对每一部分都有严格的要求 有相应的规格 说明 他们包括 a 配置规格说明 Control Specifications 主要规定了程序 的命名 日期格式等信息 b 文件描述说明 File Description Specifications 对程 序使用到的文件的说明 c 定义说明 Definition Specifications 主要对程序使用的 数据进行说明 d 输入说明 Input Specifications 主要对文件输入数据进 行说明 e 计算说明 Calculation Specifications 主要对数据计算 和计算顺序的说明 f 输出说明 Output Specifications 主要针对数据的输出记 录和字段的说明 g 子程序说明 包括有三种 对子程序的各种进行进行了定义说明 3 指示器 Indicators 通常是一个字节 被设置为 0 或者 1 他主要作为程序操作 的结果或者进行操作的条件 好像程序的逻辑开关 决定着程序的 流程 指示器必须在定义规范中进行定义 RPG VI 也有一些系统 的指示器 他们一般是两个字符的变量 如 LR 等 指示器可以在程 序的任何地方使用 也可以在程序中修改他的值 4 操作代码 相当与汇编语言的命令一样 有 RPG 程序提供一套完整的操作代码 比如读一条数据使用 READ RPG 程序对操作代码进行了分类 比 如字符串操作符 数组操作符等 5 定义描述文件 a 文件服务是程序和 IO 设备的连接 系统里的每一个文件都有相 应的描述文件 对文件的特性和数据的组织形式进行描述 如果在 程序中要使用 IO 操作 必须要指定一个描述文件 对 IO 的设备进 行描述 对于文件的类型 系统支持以下几种 1 数据库文件 database files 对数据进行持久存储 2 设备文件 Device files 容许访问的扩展设备 包括显示 文件 打印文件 磁盘文件等 3 一般文件 save files 保存在硬盘上的文件 4 远程文件 DDM files 保存在远程系统上的文件 b 每一个 IO 设备都对应有一个描述文件 在程序中如果要使用到 IO 设备 就要指定相应的文件 这主要根据操作代码来决定 有的 操作代码是设备依赖的 必须指定特定的设备才可以使用 而有些 操作代码是和设备独立的 如 WRITE 等 产用的设备类型有 RPG Device Type iSeries File Type DISK database save DDM files PRINTER printer files WORKSTN display ICF files SEQ tape diskette save printer database SPECIAL N A c 描述文件的类型 1 一般程序描述文件 program described file 在输入输出 描述的文件中会做相应的处理 2 扩展描述文件 externally described file 主要是多个 应用程序可以共享数据 a 通过针对描述文件的不同配置 RPG 程序实现了程序和数据的分 离 这样可以针对不同的保存数据的设备和形式 来对描述文件进 行配置 这样就很容易的实现的程序的灵活性 在设备进行升级以 后 程序依然可以使用 二 通过 ILE 建立 RPG 程序 a ILE Intergrated Language Environment 的介绍 ILE 是 AS400 中提供的一套增强编程的工具包 他针对不同的编程 语言 都有相应的环境支持 ILE RPG ILE C ILE COBOL ILE CL 等 b ILE 的优势 i ILE 本身提供了许多程序模块 供程序员调用 ii 提供编译的环境 可以对代码进行调试 iii 提供优化的调用性能 iv 可以集成多种语言 v 对代码进行优化 vi 而且提供老版本的代码转换到新版本的代码 主要是针对 RPG 程序和 CL 程序 c 使用 ILE 建立一个应用程序的例子 vii 建立一个库 取名 PRTLIB CRTLIB LIB PRTLIB TEXT SAMPLE ILE APPLICATION viii 将 PRTLIB 设置为当前库 CHGCURLIB CURLIB PRTLIB ix 建立一个源码文件在 PRTLIB 中 CRTSRCPF FILE SOURCE RCDLEN 112 TEXT SAMPLE ILE Appliaction x 编辑文件 输入文件内容 分配源文件类型是 CLP 描述信息是 OPM WRKMBRPDM FILE PRTLIB SOURCE xi 按 F3 键 退出后 建立命令 系统将会产生 CRTCLPGM 命令 三 SEU 工具的使用 SEU Source entry utility 源码输入工具 如图 这个界面的输入分为两部分 上面的 SEU 在之后 可以输入 SEU 编辑的命令 包括查找等命令 都是辅助编辑使用 可以在输入代码的时候 随时输入命令 代码输入在 Beginning of data 和 End of data 之间输入代 码 如果要插入一行 必须在行首位置输入 I 系统会自动增加一 行 同时提示出代码行号 在此界面按 F1 有具体的帮助信息 四 源码示例 00 10 PRTPGMR Print program OPM 00 20 00 30 QADSPOBJ is the outfile from DSPOBJD Override occurs in CL 00 40 FQADSPOBJIF E DISK 00 50 FQPRINT O F 132 OF PRINTER 00 60 00 70 Parameter list 00 80 C ENTRY PLIST Parm list 00 90 C PARM LIB 10 Library 01 00 C EXCPTHDG Prt heading 01 10 01 20 Read a record 01 30 QLIDOBJD is the format name of the QADSPOBJ file 01 40 C READ QLIDOBJD 20 Read 01 50 Continue reading until EOF 01 60 C IN20 DOWEQ 0 Not EOF 01 70 01 80 Use a subroutine to convert the date from MMDDYY to YYMMDD 01 90 C MOVE ODUDAT MMDDYY 6 MMDDYY fmt 02 00 C EXSR CVTDAT Convert date 02 10 C MOVE YYMMDD LSTUSD 60 Last used dt 02 20 C EXCPTDETAIL Print detail 02 30 C OF EXCPTHDG Prt heading 02 40 C READ QLIDOBJD 20 Read 02 50 C ENDDO Loop Back 02 60 End the program 02 70 C SETON LR Set LR 02 80 02 90 C CVTDAT BEGSR 03 00 Convert date from MMDDYY to YYMMDD format 03 10 C MOVE MMDDYY WORK2 2 Move YY 03 20 C MOVELWORK2 YYMMDD 6 Move YY 03 30 C MOVELMMDDYY WORK4 4 Move MMDD 03 40 C MOVE WORK4 YYMMDD Move MMDD 03 50 C ENDSR 03 60 03 70 OQPRINT E 206 HDG 03 80 O 25 Objects 03 90 O in Library 04 00 O LIB 04 10 O E 2 HDG 04 20 O 6 Object 04 30 O 18 Obj type 04 40 O 30 Attribute 04 50 O 42 Last used 04 60 O E 1 DETAIL 04 70 O ODOBNM 10 04 80 O ODOBTP 19 04 90 O ODOBAT 33 05 00 O LSTUSDY 41 对于源码的解释如下 由于还没有很清楚 所以暂不翻译 00 40The externally described database file is named QADSPOBJ This is the name of the file provided by the system that is used when an outfile is created by the DSPOBJD command The system essentially copies the format of the model file to the outfile named on DSPOBJD The RPG program describes the file in QSYS because it wants to use the format that exists in the file An OVRDBF command in the CL program causes the DSPOBJDP file in QTEMP to be read instead of the file that is compiled into the program Because both files use the same format the compiled RPG program knows what the layout of the format is 00 50 The QPRINT file is described as a fixed format file Since no OVRPRTF command was specified prior to the open operation of QPRINT the system provides access to the first QPRINT file found on the library list This is probably the QPRINT file supplied by IBM in the QGPL library This file causes spooled printed output to occur 00 80 The PLIST and PARM operation codes provide the means to pass in the variable library name from the CL program This library name is printed on the heading line 01 00 The EXCPT statement prints the heading line as output 01 40 The program reads a record using the QLIDOBJD format This is the name of the format used in the QADSPOBJD outfile 01 60 If end of file is detected the program sets the LR indicator on and returns 01 80 A subroutine is used to convert the date last used field which exists in the outfile in a MMDDYY format to a YYMMDD format There are many solutions to the problem of reformatting a date field In this example the subroutine method is used because in a later chapter we change from an RPG subroutine to a subprogram 01 90 The program moves the ODUDAT field date last used to a common field MMDDYY and then calls the subroutine This type of coding creates a general purpose subroutine that can convert any MMDDYY date format When the subroutine returns the YYMMDD field is moved t

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

最新文档

评论

0/150

提交评论