RPG IV 新特性概览. 钟嘉田 DB2 for i Performance, IBM 中国系统与科技研发中心

Similar documents
ICP Enablon User Manual Factory ICP Enablon 用户手册 工厂 Version th Jul 2012 版本 年 7 月 16 日. Content 内容

Previous on Computer Networks Class 18. ICMP: Internet Control Message Protocol IP Protocol Actually a IP packet

Command Dictionary CUSTOM

如何查看 Cache Engine 缓存中有哪些网站 /URL

AvalonMiner Raspberry Pi Configuration Guide. AvalonMiner 树莓派配置教程 AvalonMiner Raspberry Pi Configuration Guide

计算机组成原理第二讲 第二章 : 运算方法和运算器 数据与文字的表示方法 (1) 整数的表示方法. 授课老师 : 王浩宇

Logitech G302 Daedalus Prime Setup Guide 设置指南

实验三十三 DEIGRP 的配置 一 实验目的 二 应用环境 三 实验设备 四 实验拓扑 五 实验要求 六 实验步骤 1. 掌握 DEIGRP 的配置方法 2. 理解 DEIGRP 协议的工作过程

Understanding IO patterns of SSDs

PCU50 的整盘备份. 本文只针对操作系统为 Windows XP 版本的 PCU50 PCU50 启动硬件自检完后, 出现下面文字时, 按向下光标键 光标条停在 SINUMERIK 下方的空白处, 如下图, 按回车键 PCU50 会进入到服务画面, 如下图

三 依赖注入 (dependency injection) 的学习

OTAD Application Note

Chapter 11 SHANDONG UNIVERSITY 1

<properties> <jdk.version>1.8</jdk.version> <project.build.sourceencoding>utf-8</project.build.sourceencoding> </properties>

Triangle - Delaunay Triangulator

Chapter 1 (Part 2) Introduction to Operating System

Microsoft RemoteFX: USB 和设备重定向 姓名 : 张天民 职务 : 高级讲师 公司 : 东方瑞通 ( 北京 ) 咨询服务有限公司

组播路由 - MSDP 和 PIM 通过走

Build a Key Value Flash Disk Based Storage System. Flash Memory Summit 2017 Santa Clara, CA 1

nbns-list netbios-type network next-server option reset dhcp server conflict 1-34

#MDCC Swift 链式语法应 用 陈乘

Chapter 7: Deadlocks. Operating System Concepts 9 th Edition

第二小题 : 逻辑隔离 (10 分 ) OpenFlow Switch1 (PC-A/Netfpga) OpenFlow Switch2 (PC-B/Netfpga) ServerB PC-2. Switching Hub

NyearBluetoothPrint SDK. Development Document--Android

XML allows your content to be created in one workflow, at one cost, to reach all your readers XML 的优势 : 只需一次加工和投入, 到达所有读者的手中

Multiprotocol Label Switching The future of IP Backbone Technology

The Design of Everyday Things

Machine Vision Market Analysis of 2015 Isabel Yang

Open Source on IBM I Announce Materials

Ganglia 是 UC Berkeley 发起的一个开源集群监视项目, 主要是用来监控系统性能, 如 :cpu mem 硬盘利用率, I/O 负载 网络流量情况等, 通过曲线很容易见到每个节点的工作状态, 对合理调整 分配系统资源, 提高系统整体性能起到重要作用

上汽通用汽车供应商门户网站项目 (SGMSP) User Guide 用户手册 上汽通用汽车有限公司 2014 上汽通用汽车有限公司未经授权, 不得以任何形式使用本文档所包括的任何部分

Wireless Presentation Pod

Apache Kafka 源码编译 Spark 大数据博客 -

Safe Memory-Leak Fixing for C Programs

Skill-building Courses Business Analysis Lesson 3 Problem Solving

Computer Networks. Wenzhong Li. Nanjing University

display portal server display portal user display portal user count display portal web-server

2. Introduction to Digital Media Format

Technology: Anti-social Networking 科技 : 反社交网络

DEV Office 客户端开发增强

测试 SFTP 的 问题在归档配置页的 MediaSense

<?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="configuration.xsl"?> <configuration> <!--- global properties --> <property>

朱晔和你聊 Spring 系列 S1E2: SpringBoot 并不神秘

我们应该做什么? 告知性分析 未来会发生什么? 预测性分析 为什么会发生 诊断性分析 过去发生了什么? 描述性分析 高级分析 传统 BI. Source: Gartner

H3C CAS 虚拟机支持的操作系统列表. Copyright 2016 杭州华三通信技术有限公司版权所有, 保留一切权利 非经本公司书面许可, 任何单位和个人不得擅自摘抄 复制本文档内容的部分或全部, 并不得以任何形式传播 本文档中的信息可能变动, 恕不另行通知

CloudStack 4.3 API 开发指南!

Air Speaker. Getting started with Logitech UE Air Speaker. 快速入门罗技 UE Air Speaker. Wireless speaker with AirPlay. 无线音箱 (AirPlay 技术 )

CHINA VISA APPLICATION CONCIERGE SERVICE*

TBarCode OCX Microsoft ActiveX compliant Barcode Control

Windows Batch VS Linux Shell. Jason Zhu

Software Engineering. Zheng Li( 李征 ) Jing Wan( 万静 )

NetScreen 概念与范例. ScreenOS 参考指南 第 7 卷 : 虚拟系统. ScreenOS 编号 SC 修订本 E

Spark Standalone 模式应用程序开发 Spark 大数据博客 -

U-CONTROL UMX610/UMX490/UMX250. The Ultimate Studio in a Box: 61/49/25-Key USB/MIDI Controller Keyboard with Separate USB/Audio Interface

1. DWR 1.1 DWR 基础 概念 使用使用 DWR 的步骤. 1 什么是 DWR? Direct Web Remote, 直接 Web 远程 是一个 Ajax 的框架

Supplementary Materials on Semaphores

密级 : 博士学位论文. 论文题目基于 ScratchPad Memory 的嵌入式系统优化研究

PubMed 简介. PubMed 是美国国立医学图书馆 (NLM) 所属的国家生物技术信息中心 (NCBI) 开发的因特网生物医学信息检索系统

学习沉淀成长分享 EIGRP. 红茶三杯 ( 朱 SIR) 微博 : Latest update:

TDS - 3. Battery Compartment. LCD Screen. Power Button. Hold Button. Body. Sensor. HM Digital, Inc.

PTZ PRO 2. Setup Guide 设置指南

Packaging 10Apr2012 Rev V Specification MBXL HSG 1. PURPOSE 目的 2. APPLICABLE PRODUCT 适用范围

XPS 8920 Setup and Specifications

Logitech ConferenceCam CC3000e Camera 罗技 ConferenceCam CC3000e Camera Setup Guide 设置指南

TW5.0 如何使用 SSL 认证. 先使用 openssl 工具 1 生成 CA 私钥和自签名根证书 (1) 生成 CA 私钥 openssl genrsa -out ca-key.pem 1024

Command Dictionary -- DAMSTAB

Oracle 一体化创新云技术 助力智慧政府信息化战略. Copyright* *2014*Oracle*and/or*its*affiliates.*All*rights*reserved.** *

Declaration of Conformity STANDARD 100 by OEKO TEX

Chapter 2: Java OO II. Yang Wang wyang AT njnet.edu.cn

CA Application Performance Management

Color LaserJet Pro MFP M477 入门指南

Safety Life Cycle Model IEC61508 安全生命周期模型 -IEC61508

VAS 5054A FAQ ( 所有 5054A 整合, 中英对照 )

IPC 的 Proxy-Stub 设计模式 ( c)

ZWO 相机固件升级参考手册. ZWO Camera Firmware Upgrade reference manual. 版权所有 c 苏州市振旺光电有限公司 保留一切权利 非经本公司许可, 任何组织和个人不得擅自摘抄 复制本文档内容的部分或者全部, 并

SHANDONG UNIVERSITY 1

新一代 ODA X5-2 低调 奢华 有内涵

Apache OpenWhisk + Kubernetes:

Murrelektronik Connectivity Interface Part I Product range MSDD, cable entry panels MSDD 系列, 电缆穿线板

China Next Generation Internet (CNGI) project and its impact. MA Yan Beijing University of Posts and Telecommunications 2009/08/06.

MateCam X1 User Manual

测试基础架构 演进之路. 茹炳晟 (Robin Ru) ebay 中国研发中心

OpenCascade 的曲面.

Operating Systems. Chapter 4 Threads. Lei Duan

计算机科学与技术专业本科培养计划. Undergraduate Program for Specialty in Computer Science & Technology

Autodesk Backburner 2011 安装手册

New Media Data Analytics and Application. Lecture 7: Information Acquisition An Integration Ting Wang

漂亮的测试. By Alberto Savoia 代码之美 第七章 史际帆

SNMP Web Manager. User s Manual

libde265 HEVC 性能测试报告

Compile times - assert macros

Jbuilder 2007 开发 EJB3.0 Entity 罗代均 ldj_work#126.com 2007 年 8 月

Presentation Title. By Author The MathWorks, Inc. 1

梁永健. W K Leung. 华为企业业务 BG 解决方案销售部 CTO Chief Technology Officer, Solution Sales, Huawei

3dvia Composer Solidworks

畅联科技锁掌柜开放接口 - Android 版本 用户手册

FLIGHT INSTRUMENT PANEL

Cisco IP Phone 8800 系列和 Cisco IP Conference Phone 8832 多平台 电话设置指南

Microsemi - Leading Innovation for China s Hyperscale Data Centers

S 1.6V 3.3V. S Windows 2000 Windows XP Windows Vista S USB S RGB LED (PORT1 PORT2 PORT3) S I 2 C. + 表示无铅 (Pb) 并符合 RoHS 标准 JU10 JU14, JU24, JU25

Transcription:

RPG IV 新特性概览 钟嘉田 zhongjt@cn.ibm.com DB2 for i Performance, IBM 中国系统与科技研发中心

议程 RPG 更新旅程 V3R1 ~ V6R1,RPG IV 在各个领域的更新 7.1 ~ 7.3 RPG IV 的新功能 2017 International Business Machines Corporation 2

RPG 更新旅程 RPG 是 IBM i 上最主要的编程语言之一 从诞生到现在,IBM 为 RPG 持续注入了大量更新和改变 之前 OS 版本 V3R1 V3R2 ~ V3R7 V4R2 ~ V4R4 V5R1 ~ V5R4 V6R1 7.1 7.2 7.3 RPG I~III (OPM 模式 ) I II III RPG IV ILE RPG 自由格式 D-Spec. 命名扩展 内置函数 移除和减少很多限制 模块中可以包含多个 Procedures 支持数据库 Null 字段 新数据类型及提高的精度 变长字段 针对 indicator 的大量改进 线程安全 与 Java 的交互 IV 增强的 Java 交互 自由格式语法检查 Web-Service 转换 并行的多线程 Procedure 中处理文件的能力 Procedure 的其他优化 RPG Open Access 增强的 XML 支持 Teraspace 存储模式 自由格式增强 CCSID 相关 全自由格式 %SCANR 空指示器 参考 :http://publib.boulder.ibm.com/infocenter/iseries/v7r1m0/topic/rzasd/sc09250802.htm 2017 International Business Machines Corporation 3

议程 RPG 更新旅程 V3R1 ~ V6R1,RPG IV 在各个领域的更新 7.1 ~ 7.3 的新功能 2017 International Business Machines Corporation 4

数据类型 (Data Types) V3R1 ~ V3R7 命名扩展 超过 10 位的命名 支持下划线 支持大小写 支持时间和日期 I: 有符号整数 (3,5,10,20) U: 无符号整数 F: 浮点数 空字段支持 Test, %STR V4R2 ~ V4R4 V5R1 ~ V5R4 V6R1 Java 兼容性的定制支持 1-byte 和 8-byte integer 有符号数 (3I, 20I) 无符号数 (3U, 20U) Unicode: UCS-2 (Unicode) 字符集 DECPREC (30 31 63) 31 位数字支持 (DECPREC 键字 ) 63 位数字支持 (Packed and Zoned) 极大地提高了变量空间及数组元素个数的上限 D TESTCHR1 S A LEN(16773104) Data structures/array size: 16,773,104 Character length: 16,773,104 UCS-2 length:8,386,552 Graphic lenght: 8,386,552 变长字段 新数据类型 内建函数支持 : %LEN D fld 10A VARYING * It does not matter what length 'fld' has before the * EVAL; after the EVAL, the length will be 2. * fld = x 0002E7E800 C EVAL fld = 'XY * After the first MOVEL, it will have a value of 'XY' C MOVEL 'XYZ' fld * After the second MOVEL, it will have the value '1Y' C MOVEL '1' fld 指定变长字段长度位的位数 (2 or 4) VARYING{(2 4)}, 65535 for varying(2) 针对 character, UCS-2 和 graphic 的自动数据类型转换 ( 通过 PTF 对 V5R3/4 同样适用 ) 2017 International Business Machines Corporation 5

数据类型 (Data Types) %STR Used to Get Null-Terminated String Fld1 = '<' + %str(string1 : 2) + '>'; // Fld1= <12> if String1= 123\0. Fld1 = '<' + %str(string1 : 5) + '>'; // Fld1= <123> if String1= 123\0, I use \0 instead of Null here. 2017 International Business Machines Corporation 6

数据结构 (Data Structure) V3R1 ~ V3R7 V4R2 ~ V4R4 V5R1 ~ V5R4 V6R1 PREFIX 支持外部描述数据结构 用 PREFIX 键字替换现存字段名中的部分字符 Indicator 相关 Indicator 数据结构 (INDDS) Indicator 数据类型 ( N ): 将数据定义为 Indicator 类型. 数据结构支持 Qualified 名称 结果数据结构 (result data structure) 的宽松规则 I/O 结果可以输出到外部描述 DS 外部描述文件的 I/O 结果可以输出到 DS 按元素名拷贝数据结构 : EVAL-CORR 数据结构长度可达到 16,773,104. 记录格式支持 Qualified LIKEREC 键字 LEN(length) 键字 指定数据结构的长度 Ffile1 if e disk D ds1 e ds extname(file1) prefix(@) D qualified DDS1 DS LEN(55) D FULLNAME 50A D SUBNAME1 10A OVERLAY(FULLNAME:1) D SUBNAME2 10A OVERLAY(FULLNAME:*NEXT) D AGE 5S 0 C EVAL FULLNAME='0123456789ABCDEFGHIJ' //SUBNAME2 is ABCDEFGHI now OVERLAY(name : *NEXT) 使用 OVERLAY 键字定义的子字段可以通过 *NEXT 自动保持接续 D ds1 ds qualified D num 10i 0 D extra d D char 20a D otherfld 1a D diff 5p 0 D ds2 ds qualified D char 20a D diff 5a D another 5a D num 15p 5 /free // assign corresponding fields from DS1 to DS2 EVAL-CORR ds2 = ds1; // this EVAL-CORR is equivalent to these EVAL operations // EVAL ds2.num = ds1.num; // EVAL ds2.char = ds1.char; /end-free 2017 International Business Machines Corporation 7

数据结构 (Data Structure) 编译器不会为 Qualified 的文件生成 I 表和 O 表,I/O 只能通过数据结构完成 FRPG201LF1 IF E K DISK template F qualified * Ffile1 likefile(rpg201lf1) F infds(inf_ds) F extfile('zjttstlib/rpg201lf2') F extmbr('rpg201lf1') F usropn * Dinf_ds Ds D FILE *FILE D STATUS *STATUS D OPCODE *OPCODE * DResult_Ds Ds likerec(rpg201lf1.rec1 : *input) * /Free Open file1 ; SetLL *Loval file1.rec1 ; Read file1.rec1 Result_Ds ; Close file1 ; Return ; /End-Free FNew O E Disk Qualified ExtDesc('CUST') FOld IF E Disk Qualified ExtDesc('CUST') * Vars Define D InData Ds LikeRec(Old.Cust:*INPUT) D OutData Ds LikeRec(New.Cust:*OUTPUT) * C /Free... read Old.Cust OutData ;... write New.Cust InData ;... 2017 International Business Machines Corporation 8

数据结构 (Data Structure) EXTDESC 键字可以定义一个在编译时使用的外部描述文件 EXTFILE 键字可以允许新的值 *EXTDESC, 来表明 EXTDESC 指定的文件也可用于运行时 EXTNAME 在 D 表中的增强, 还可用于指定库名 2017 International Business Machines Corporation 9

Procedures V3R1 ~ V3R7 V4R2 ~ V4R4 V5R1 ~ V5R4 V6R1 用户自定义 Procedures 支持本地变量 创建自定义函数 同一 Module 中多个 Procedures NOMAIN: 定义没有程序入口 Procedure 的模块 IMPORT 和 EXPORT 中可以使用大小写混排名称 Procedure 原型可使用参数 OPTIONS(*TRIM) 传入参数去空格 OPTIONS(*STRING : *TRIM), 指针去空格 OPTIONS(*NULLIND) null-indicators bitmap is passed Subprocedures 中定义和使用文件 Subprocedures 中使用 LIKEFILE 键字定义文件 将文件作为参数传递 MAIN: 指定当前模块中 Procedure 所使用的程序入口 Procedure THREAD(*CONCURRENT) Example of a Subprocedure * Prototype for procedure FUNCTION D FUNCTION PR 10I 0 D TERM1 5I 0 VALUE D TERM2 5I 0 VALUE D TERM3 5I 0 VALUE P Function B * This procedure performs a function on the 3 numeric values * passed to it as value parameters. * This illustrates how a procedure interface is specified for a * procedure and how values are returned from a procedure. D Function PI 10I 0 D Term1 5I 0 VALUE D Term2 5I 0 VALUE D Term3 5I 0 VALUE D Result S 10I 0 /free Result = Term1 ** 2 * 17 + Term2 * 7 + Term3; return Result * 45 + 23; /end-free P E Call in other procedure: /Free myresult = FUNCTION(Parm1:Parm2:parm3); //The returned value will not be available to the caller C /Ene-Free CALLP FUNCTION(Parm1:Parm2:parm3); 2017 International Business Machines Corporation 10

Procedures H 表中可以定义 MAIN 关键字 Main procedure 是普通的 subprocedure, 非 RPG cycle 2017 International Business Machines Corporation 11

Procedures 可以在 SubProcedure 里定义本地文件, 在 P 表开始和 D 表之间 对于本地文件 (Local File), 不能再定义 I 和 O 表 缺省情况下, 该文件仅和该 SubProcedure 相关, 当 Procedure 结束时, 文件被关闭 STATIC 关键字可用来在 Procedure 结束后, 保持打开状态 2017 International Business Machines Corporation 12

Procedures 文件可以作为参数传递给 SubProcedure 必须使用数据结构来进行 I/O 操作 易于封装 I/O 处理 2017 International Business Machines Corporation 13

内置函数 (Build-in functions) V3R1 ~ V3R7 V4R2 ~ V4R4 格式编辑 :%EDITW, %EDITC, %EDITFLT 在字符串中查找 (%SCAN) 数据类型转换 : %CHAR, %INT, %FLOAT, %DEC, %UNS ( 四舍五入版本 :%INTH, %DECH, %UNSH) 数据文件操作 : 替代 Result indicators %EOF, %EQUAL, %FOUND, %OPEN, as well as %ERROR, %STATUS %XFOOT: 数组求和 %DIV(n:m): 整除 D date S D INZ(D'1997/02/03') D time S T INZ(T'12:23:34') D result S 100A VARYING D points S 10i 0 INZ(234) /FREE result = 'It is ' + %CHAR(time) + ' on ' + %CHAR(date); // result = 'It is 12:23 PM on 02/03/1997' result = 'You have ' + %char(points) + ' points.'; // result = 'You have 234 points.' // Check if the customer is in the file chain Cust CustRec; if %found; exsr HandleCustomer; endif; /END-FREE V5R1 ~ V5R4 V6R1 %XLATE, %OCCUR, %CHECK, %CHECKR, %ALLOC, %REALLOC, %LOOKUP, etc 位逻辑运算 : %BITAND, %BITOR, %BITXOR, %BITNOT 为以下函数增加字符串支持 : %DEC, %DECH, %INTH, %UNS, %UNSH, %FLOAT 取得变长字段中数据部分的地址 %ADDR(varying-field : *DATA) E.g: uppercasedata (%ADDR(fld : *DATA) : %LEN(fld)); %DEC 支持转换 date/time/timestamp %TRIMx 增加第二个参数 动态数组元素个数 %SUBARR sorta %subarr(myarray:4:10) sorts 10 elements of myarray starting at 4th: // Assume procedure "uppercasedata" requires a pointer and a length. // %ADDR(fld:*DATA) returns the pointer to the data portion of // the varying field, and %LEN(fld) returns the length. uppercasedata (%ADDR(fld : *DATA) : %LEN(fld)); // The number of bytes used for the prefix is the // offset between the address of the field and the // address of the data. prefix_size = %addr(fld : *data) - %addr(fld); 2017 International Business Machines Corporation 14

表达式 (Expression) V3R1 ~ V3R7 V4R2 ~ V4R4 V5R1 ~ V5R4 V6R1 MOVE, MOVEL and TEST 支持 *CYMD 日期格式 COPYRIGHT 键字 定义常量 :CONST{(constant)} RETURN 在运行时设置 DECEDIT 的值 EVALR 操作符 : 右对齐赋值 LEAVESR 操作符 : 从任意位置退出 subroutine 在表达式中操作 Date/time/timestamp ELSEIF 操作码 ( 之前使用嵌套 IFs) 在 Update 操作里指定被更新的字段 UPDATE record %fields(field1 : field3) EXFMT 的结果字段中可以使用数据结构 EXFMT format { result-ds } QUALIFIED:Qualified Record Format (alternative of RENAME) CALLP: 调用 prototyped 程序或者 procedure 新的 D-Specification 赋值操作符 EVAL * Assume FIELD1 = 10 * FIELD2 = 9 * FIELD3 = 8 * FIELD4 = 7 /FREE // The content of RESULT after the operation is 20 eval RESULT=FIELD1 + FIELD2+(FIELD3-FIELD4); /END-FREE * RPG program using MYDSPF (QUESTION O, Name I, CITY B) Fmydspf cf e workstn * Define a data structure for use with EXFMT REC D recds ds likerec(rec : *all) /free // Set the output-apable fields recds.question = 'What is your name?'; recds.city = 'Toronto'; // Show the screen to the user exfmt rec recds; dsply ('Hello ' + recds.name + ' in ' + recds.city); /end-free 2017 International Business Machines Corporation 15

编译及运行时 V3R1 ~ V3R7 V4R2 ~ V4R4 V5R1 ~ V5R4 V6R1 支持 ILE( 集成语言环境 ) 条件编译 定义编译参数 (/DEFINE, /UNDEFINE), /IF, /ELSEIF, /ELSE, /ENDIF 停止编译当前源码 (/EOF) 新的编译选项 (DEFINE) 可以定义最多 32 个条件 支持在 H Specification 里指定编译参数 CRTRPGMOD 支持 BNDDIR (binding directory) 选项 预指定编译指令 : /DEFINE names *VnRnMn, *ILERPG, *CRTBNDRPG *CRTRPGMOD 新 Debug 键字值 : *INPUT, *XMLSAX, *DUMP H-Specification 中指定 VALIDATE(*NODATETIME) 在程序目标中存储 PCML 信息并通过 API QBNRPII 获取 MAIN 集成文件系统 (IFS) 源文件支持 为 SQL 预处理器所做优化 处理条件编译及嵌套 /COPY 从 Object 中清除未使用的变量 CRTBNDRPG 和 CRTRPGMOD 的 OPTION 选项增加值 *UNREF 和 *NOUNREF 2017 International Business Machines Corporation 16

编译及运行时 VALIDATE(*NODATETIME) 让编译器视之为数字 目的 : 显著提高日期, 时间及时间戳字段密集处理的程序的性能 注意 : 会导致非法日期, 时间及时间戳数据 建议 : 仅在该程序从未发现日期, 时间及时间戳错误的程序中使用在必要的操作前, 使用 TEST 操作码强制进行日期, 时间及时间戳的检查 H 表中的 MAIN 2017 International Business Machines Corporation 17

自由格式 V3R2 ~ V3R7 V4R2 ~ V4R4 自由格式的 CALL 可以通过原型声明校验参数 自由格式的 FOR 循环 : iterative loop; allows free-form expressions for initial, increment, and limit /free chain trn_number emp_rec; if %found(emp_rec); pay = CalcPay (emp_rate:trn_hours:trn_bonus); endif; /end-free 在自由格式操作中使用 Integer 和 unsigned integer 字段的 16 进制形式 V5R1 ~ V5R4 V6R1 SEU 增加自由格式语法检查 简短操作 : Variable1 += Variable2 %FIELDS(name{:name...}) 在 UPDATE 操作中指定要更新的字段 没有重要更新 支持嵌入式 SQL Factor 1 can be a list of key values CHAIN, DELETEREADE, READPE, SETGT, SETLL /FREE X = Y + Z; EXEC SQL INSERT INTO MYLIB/MYFILE (FLD1) VALUES(12); EXEC SQL INSERT INTO MYLIB/MYFILE (FLD1) VALUE(12); /END-FREE 2017 International Business Machines Corporation 18

与 Java 的交互 V4R4 支持从线程应用中调用 ILE RPG Procedures, 例如 Domino 或者 Java 生成 PCML 文件 V5R1 ~ Now 增强 Java 相关支持 (JNI) New data type: Object EXTPROC(*JAVA:class-name:procname) :Specifies that a Java method is called. CLASS(*JAVA:class-name): Specifies the class for an object. 用于支持 Java 方法调用的新环境变量 QIBM_RPG_JAVA_PROPERTIES 生成 PCML 信息到 Module 中 通过 API QBNRPII 获取 如果你有在 Java 包中的类, 你可以指定该 Jar 包为你的 classpath: ADDENVVAR CLASSPATH '/home/myclasses:/home/mypackages:/home/myjarfiles/ j1.jar' 你可以在 RPG 的 prototype 里声明 Java 方法 D simplemethod PR EXTPROC(*JAVA D : 'Simple' D : 'method') D STATIC D pkgmethod PR EXTPROC(*JAVA D : 'Pkg.PkgClass' D : 'method') D STATIC // 当你使用 CRTRPGMOD 创建一个模块并将其加入服务程序 (SRVPGM) 中, 你可以在你的 Java 代码里使用由 ProgramCallDocument class 提供的 setpath(string) 方法. 例如 : AS400 as400; ProgramCallDocument pcd; String path = "/QSYS.LIB/MYLIB.LIB/MYSRVPGM.SRVPGM"; as400 = new AS400 (); pcd = new ProgramCallDocument (as400, "mymodule"); pcd.setpath ("MYFUNCTION", path); pcd.setvalue ("MYFUNCTION.PARM1", "abc"); rc = pcd.callprogram("myfunction"); 参考 :http://publib.boulder.ibm.com/infocenter/iseries/v7r1m0/topic/rzasc/sc092507229.htm#javameth 2017 International Business Machines Corporation 19

议程 RPG 更新旅程 V3R1 ~ V6R1,RPG IV 在各个领域的更新 7.1 ~ 7.3 RPG IV 的新功能 2017 International Business Machines Corporation 20

ILE RPG 在 i 7.1 上的更新 开放与现代化 XML-INTO 的新选项及操作码 RPG Open Access ( 开放访问 ) 可维护性 外部描述数据结构支持别名 (ALIAS) %PARMNUM: 参数在参数列表中的位置 加密调试时源代码 V7R1 生产力 对数据结构数组进行排序和搜索 :SORTA 对数组进行正反排序 :SORTA(A) SORTA(D) 系统集成 增强与 DB2, 显示及打印文件的集成性 与系统其他功能的集成性 性能 编译器与针对 Power 7 的集成与优化 Teraspace 存储模式支持 其他项 隐式 Unicode 转换 改进一些数据类型的易用性 *SEU 语法检查保留在 V6R1 级别 %SCANRPL: 查找并替换 %LEN(varying : *MAX) : 最大字符数 可选的 prototype 返回大数据集时性能的提高 : RTNPARM D center pr 100000a varying D rtnparm DD len 10i 0 value *Calling the procedure D title s 100a varying /free title = center ('Chapter 1' : 20); // title = ' Chapter 1 ' text 50000a const varying 2017 International Business Machines Corporation 21

对结构数组排序和查找 按某个子字段对结构数组进行排序 ( 可按升序或降序排序 ) * The names array does not have a sequence keyword * (ASCEND or DESCEND) specified. D OutData Ds LikeRec(New.Cust:*OUTPUT) D info DS QUALIFIED D names 10A DIM(2) /free // Initialize the array info.names(1) = 'Bart'; info.names(2) = 'Lisa'; // Sort the info.names in descending order SORTA(D) info.names; // info.names(1) = 'Lisa' // info.names(2) = 'Bart' // Sort the info.names in ascending order SORTA(A) info.names; // info.names(1) = 'Bart' // info.names(2) = 'Lisa' 将某个子字段作为键字进行查找 /FREE arr(1) = 'Cornwall'; arr(2) = 'Kingston'; arr(3) = 'London'; arr(4) = 'Paris'; n = %LOOKUP('Paris':arr); // n = 4 n = %LOOKUP('Thunder Bay':arr); // n = 0 (not found) n = %LOOKUP('Kingston':arr:3); // n = 0 (not found after start index) n = %LOOKUPLE('Paris':arr); // n = 4 2017 International Business Machines Corporation 22

对结构数组排序和查找 排序示例 D child_t Ds Qualified Template D name 25a Varying D age 5i 0 D family Ds Qualified Dim(5) D name 25a Varying D numchild 5i 0 D child LikeDs(child_t) dim(10) 对 孩子 子数组按年龄逆序排序 For i = 1 to numfamily ; SORTA(D) %SUBARR (family(i).child(*).age : 1 : family(i).numchild ; EndFor ; 对 家庭 数组按家中长子 / 女年龄排序 SORTA family(*).child(1).age ; 2017 International Business Machines Corporation 23

返回大数据集时性能的提高 RTNPARM 键字可以在 procedure 返回大数据集时, 显著提高性能 新的 build-in 函数 %SCANRPL %SCANRPL 函数用一个字符串替换所有的另一个字符串 手工编写查找 + 替换的逻辑会导致代码复杂化, 易于出错, 难于维护 2017 International Business Machines Corporation 24

build-in 函数增强 %LEN(varying:*MAX) 解决的问题 : 从 V6R1 开始, 计算变长类型数据的前缀的长度变得易于出错, 因为可能是 2 或 4 V6R1 中, 增强的 %ADDR(*DATA) 用于获取变长数据的数据部分, 在此之前, 程序员多数是在程序中给 %ADDR 加上 2 %LEN(*MAX) 可以简捷获取数据部分的最大长度, 而在此之前, 程序员只能从 2 开始, 截取子串到 %SIZE, 对于 UCS2 或 DBCS, 还要再除以 2 2017 International Business Machines Corporation 25

%PARMNUM 返回参数在参数列表中的位置 %PARMNUM 解决的问题 : 传递参数个数到某些参数信息的 API 检查某一指定参数是否被传递进来 %PARMNUM 和 RTNPARM 返回值会被处理为一个额外的参数 该额外参数是实际上的第一个参数 %PARMS 和参数 API 使用的是实际的个数 2017 International Business Machines Corporation 26

数据结构中的别名 Alias 的支持 突破外部描述文件 10 个字符的限制 (RPG III 只允许 6 个字符 ), 很多客户希望能使用多达 128 个字符的别名 支持 F 表中的本地文件或 Qualified 文件, 可用于 LIKEREC 定义的数据结构 支持 D 表中定义的外部描述数据结构 如果子字段是 LIKEREC 定义的, 或外部描述的数据结构, 可以使用别名来代替标准名 2017 International Business Machines Corporation 27

Teraspace 7.1 之前版本的问题 : 单级存储 (Single-Level Storage) 模式, 对于一个 procedure 以及调用堆栈 (call stack) 中所有的 procedure 的自动管理存储区的大小有 16MB 的限制 RPG 的 %ALLOC 和 %REALLOC 有 16MB 的限制 解决方法 :Teraspace 模式 大幅提升自动管理区的大小限制 对于编译时使用 *CALLER 的程序, 使用参数 STGMDL(*INHERIT), 将按照起调程序来决定存储模式 RPG 的 %ALLOC 和 %REALLOC 将可以分配更大的存储空间 使用 Teraspace 模式, 将缺省按 Teraspace 来分配空间 可以在 H 表中指定 ALLOC(*TERASPACE), 不管使用哪种存储模式, 都强制按照 Teraspace 来分配空间 2017 International Business Machines Corporation 28

SEU 语法检查将停留在 V6R1 版本 文件所在位置 SEU 语法检查将停留在 V6R1 版本! V6R1 之后新增的语法, 编译器支持, 但 SEU 的语法检查会报错 在 Rational Developer for i 中支持新语法 字段定义 支持开源语言, 支持全自由格式 RPG 零安装, 基于浏览器, 运行于任何平台 交叉导航 RDi 支持 Git 源代码版本管理 Orion 编译界面可自定义各种风格 2017 International Business Machines Corporation 29

2017 International Business Machines Corporation 30 IBM Confidenti al 加密调试源码 如何保护 debug-able program 中的源代码? 从 7.1 开始, 你可以选择加密 ILE 程序调试视图中的数据 创建 ILE 模块的时候, 使用 DBGENCKEY 参数设置代码加密 CRTBNDRPG MYPGM DBGENCKEY(12345) 调试程序时 STRDBG MYPGM DBGENCKEY(12345) Or STRDBG MYPGM 然后输入密码

RPG Open Access 的实现 5250 Screens RPG Applications 传统 RPG 界面 如何支持其他界面? JSPs F Define the Handler D*********************** C* C Write Section1 C* : C* : C Write Section2 C : Data Handlers Handlers Handlers Target Program Target Program Target Program Other Servers Mobile Devices 2017 International Business Machines Corporation 31

在 RPG 代码中定义 Open Access 文件 所有的 RPG 设备类型都可以被定义为 Open Access 文件 DISK PRINTER WORKSTN 提供者可以选择最适合 Handler 功能的设备类型, 例如 用户界面 : WORKSTN file 创建 Excel 文档 : PRINTER file 访问 Web service: keyed DISK file Handlers 2017 International Business Machines Corporation 32

Free-form RPG 支持源码从第一列到行末, 对源码行的长度没有实际的限制 所有在 **FREE 的源文件中的代码必须是自由格式的, 如果需要任何固定格式的代码, 需要放入 /COPY 的源文件中, 这类源码总是被视为是长度有限制的源码除非其在首行是 **FREE 所有源码都不能以 ** 开头, 除非是特殊的 compile-time data 所用指令, 或更改排序依据 /FREE 和 /END-FREE 不允许在 **FREE 源文件中出现 2017 International Business Machines Corporation 33

CCSID 转换中的 warnings 和 exceptions 有时候 CCSID 的转换会导致结果中的字符被截断, 比如从 unicode 到 ccsid 37 当转换发生阶段时,RPG status 码会被设置成 50 每次都对 CCSID 转换进行检查并不方便, 并且有时候是隐式转换 H 表中新添 CCSIDCVT(*EXCP) 来捕获 CCSID 转换中发生的阶段, 新的状态码为 00452 也可以通过 CCSIDCVT(*LIST) 来获得转换信息, 预估数据丢失或避免转换以提升性能 2017 International Business Machines Corporation 34

7.2 中对其他 CCSID 的支持 从 7.2 开始, 可以通过 CCSID 对字符字段定义字符集, 包括 : 所有的 EBCDIC CCSIDs ASCII CCSIDs Unicode CCSID UTF-8 (1208, or *UTF8) 假设 getdata procedure 返回 UTF-8 数据 (CCSID 1208) 7.2 之前, 我们需要调用 API 把数据转换成 UCS-2: 注意 : 避免对该数据使用普通的 RPG 语句, 因为 RPG 认为该数据是使用 job CCSID 7.2 开始, 我们可以定义该数据为 UTF-8 RPG 会了解到该数据为 UTF-8, 可以对其使用普通的 RPG 语句 2017 International Business Machines Corporation 35

避免对数据库文件的 CCSID 转换 缺省状态下, 对数据库文件 读一行记录时, 数据库将文字数据从字段 CCSID 转换成 job CCSID 写或更新一行时, 数据库讲文字数据从 job CCSID 转换成字段定义 CCSID 在打开文件时, 使用 DATA(*NOCVT) 来避免在数据库层面的转换, 尽可能在 RPG 程序中进行 CCSID 转换 或者在 H 表使用 OPENOPT(*NOCVTDATA), 对程序中所有对数据库操作行为, 缺省避免 CCSID 转换 2017 International Business Machines Corporation 36

Fully free-form RPG 支持源码从第一列到行末, 对源码行的长度没有实际的限制 所有在 **FREE 的源文件中的代码必须是自由格式的, 如果需要任何固定格式的代码, 需要放入 /COPY 的源文件中, 这类源码总是被视为是长度有限制的源码除非其在首行是 **FRE 所有源码都不能以 ** 开头, 除非是特殊的 compile-time data 所用指令, 或更改排序依据 /FREE 和 /END-FREE 不允许在 **FREE 源文件中出现 2017 International Business Machines Corporation 37

%SCANR(Scan reverse) %SCANR(search argument : source string { : start position }) 类似 %SCAN, 仅搜索方向不同 start position 代表搜索开始位置 %SCANR 从 string 的尾部开始向前搜索知道找到匹配子串的位置或到达 start position 示例一 : 找到 path 中的文件名 示例二 : 找到 path 中的文件名后缀 2017 International Business Machines Corporation 38

NULLIND( 对于空指示器更多的控制 ) 使用 NULLIND 来关联一个指示器与一个字段来代表该字段是否为空 下面两种写法等价 : 2017 International Business Machines Corporation 39

LIKEREC(rec:*NULL) and EXTNAME(file:*NULL) *NULL 定义一个 null 位图数据结构来代表对应的字段或子字段是否为空, 其中子字段名和文件中的字段同名但子字段的类型都是指示器 *NULL 与 trigger 程序更容易协作 在 trigger 程序中,before 和 after image 都有一个 null byte map 之前 现在 2017 International Business Machines Corporation 40

更容易使用数据结构来进行 I/O 操作 问题 :RPG 对于进行 I/O 操作的数据结构要求很严苛, 必须声明用途如 :*INPUT, *OUTPUT, 对于 update 操作, 需要 *INPUT 和 *OUTPUT 之前 现在, 如果没有特意声明使用用途, 可以对该结构进行任何 I/O 操作 2017 International Business Machines Corporation 41

Useful links for RPG IV ILE RPG 语言参考 http://publib.boulder.ibm.com/infocenter/iseries/v7r1m0/topic/rzasd/sc09250802.htm ILE RPG 程序员指南 http://publib.boulder.ibm.com/infocenter/iseries/v7r1m0/index.jsp?topic=%2frzasd%2fsc09250802.ht m Who Knew You Could Do That with RPG IV http://www.redbooks.ibm.com/abstracts/sg245402.html?open RPG and Java http://publib.boulder.ibm.com/infocenter/iseries/v7r1m0/index.jsp?topic=%2frzasc%2fsc092507229. htm Rational Open Access: RPG Edition http://publib.boulder.ibm.com/infocenter/iseries/v7r1m0/topic/books/rzasm.pdf 2017 International Business Machines Corporation 42

感谢您的参与 衷心感谢 2017 International Business Machines Corporation 43

2017 International Business Machines Corporation 44

Special notices This document was developed for IBM offerings in the United States as of the date of publication. IBM may not make these offerings available in other countries, and the information is subject to change without notice. Consult your local IBM business contact for information on the IBM offerings available in your area. Information in this document concerning non-ibm products was obtained from the suppliers of these products or other public sources. Questions on the capabilities of non-ibm products should be addressed to the suppliers of those products. IBM may have patents or pending patent applications covering subject matter in this document. The furnishing of this document does not give you any license to these patents. Send license inquires, in writing, to IBM Director of Licensing, IBM Corporation, New Castle Drive, Armonk, NY 10504-1785 USA. All statements regarding IBM future direction and intent are subject to change or withdrawal without notice, and represent goals and objectives only. The information contained in this document has not been submitted to any formal IBM test and is provided "AS IS" with no warranties or guarantees either expressed or implied. All examples cited or described in this document are presented as illustrations of the manner in which some IBM products can be used and the results that may be achieved. Actual environmental costs and performance characteristics will vary depending on individual client configurations and conditions. IBM Global Financing offerings are provided through IBM Credit Corporation in the United States and other IBM subsidiaries and divisions worldwide to qualified commercial and government clients. Rates are based on a client's credit rating, financing terms, offering type, equipment type and options, and may vary by country. Other restrictions may apply. Rates and offerings are subject to change, extension or withdrawal without notice. IBM is not responsible for printing errors in this document that result in pricing or information inaccuracies. All prices shown are IBM's United States suggested list prices and are subject to change without notice; reseller prices may vary. IBM hardware products are manufactured from new parts, or new and serviceable used parts. Regardless, our warranty terms apply. Any performance data contained in this document was determined in a controlled environment. Actual results may vary significantly and are dependent on many factors including system hardware configuration and software design and configuration. Some measurements quoted in this document may have been made on development-level systems. There is no guarantee these measurements will be the same on generallyavailable systems. Some measurements quoted in this document may have been estimated through extrapolation. Users of this document should verify the applicable data for their specific environment. Revised September 26, 2006 2017 International Business Machines Corporation 45

Special notices (cont.) IBM, the IBM logo, ibm.com AIX, AIX (logo), AIX 6 (logo), AS/400, Active Memory, BladeCenter, Blue Gene, CacheFlow, ClusterProven, DB2, ESCON, i5/os, i5/os (logo), IBM Business Partner (logo), IntelliStation, LoadLeveler, Lotus, Lotus Notes, Notes, Operating System/400, OS/400, PartnerLink, PartnerWorld, PowerPC, pseries, Rational, RISC System/6000, RS/6000, THINK, Tivoli, Tivoli (logo), Tivoli Management Environment, WebSphere, xseries, z/os, zseries, AIX 5L, Chiphopper, Chipkill, Cloudscape, DB2 Universal Database, DS4000, DS6000, DS8000, EnergyScale, Enterprise Workload Manager, General Purpose File System,, GPFS, HACMP, HACMP/6000, HASM, IBM Systems Director Active Energy Manager, iseries, Micro-Partitioning, POWER, PowerExecutive, PowerVM, PowerVM (logo), PowerHA, Power Architecture, Power Everywhere, Power Family, POWER Hypervisor, Power Systems, Power Systems (logo), Power Systems Software, Power Systems Software (logo), POWER2, POWER3, POWER4, POWER4+, POWER5, POWER5+, POWER6, POWER7, purescale, System i, System p, System p5, System Storage, System z, Tivoli Enterprise, TME 10, TurboCore, Workload Partitions Manager and X-Architecture are trademarks or registered trademarks of International Business Machines Corporation in the United States, other countries, or both. If these and other IBM trademarked terms are marked on their first occurrence in this information with a trademark symbol ( or ), these symbols indicate U.S. registered or common law trademarks owned by IBM at the time this information was published. Such trademarks may also be registered or common law trademarks in other countries. A current list of IBM trademarks is available on the Web at "Copyright and trademark information" at www.ibm.com/legal/copytrade.shtml The Power Architecture and Power.org wordmarks and the Power and Power.org logos and related marks are trademarks and service marks licensed by Power.org. UNIX is a registered trademark of The Open Group in the United States, other countries or both. Linux is a registered trademark of Linus Torvalds in the United States, other countries or both. Microsoft, Windows and the Windows logo are registered trademarks of Microsoft Corporation in the United States, other countries or both. Intel, Itanium, Pentium are registered trademarks and Xeon is a trademark of Intel Corporation or its subsidiaries in the United States, other countries or both. AMD Opteron is a trademark of Advanced Micro Devices, Inc. Java and all Java-based trademarks and logos are trademarks of Sun Microsystems, Inc. in the United States, other countries or both. TPC-C and TPC-H are trademarks of the Transaction Performance Processing Council (TPPC). SPECint, SPECfp, SPECjbb, SPECweb, SPECjAppServer, SPEC OMP, SPECviewperf, SPECapc, SPEChpc, SPECjvm, SPECmail, SPECimap and SPECsfs are trademarks of the Standard Performance Evaluation Corp (SPEC). NetBench is a registered trademark of Ziff Davis Media in the United States, other countries or both. AltiVec is a trademark of Freescale Semiconductor, Inc. Cell Broadband Engine is a trademark of Sony Computer Entertainment Inc. InfiniBand, InfiniBand Trade Association and the InfiniBand design marks are trademarks and/or service marks of the InfiniBand Trade Association. Other company, product and service names may be trademarks or service marks of others. Revised February 9, 2010 2017 International Business Machines Corporation 46