使用 Native API 开发 IBM TXSeries 和 CTG

21
® IBM Software Group – TXSeries for Multiplatforms © 2006 IBM Corporation Version 1 12-May-2006 使使 Native API 使使 IBM TXSeries 使 CTG

description

使用 Native API 开发 IBM TXSeries 和 CTG. 概要. TXSeries 编程框架 TXSeries/CICS 客户机程序 TXSeries 服务器程序. TXSeries 编程框架. 基于 TXSeries 的三层应用开发环境. TXSeries 的应用开发支持框架. 交易 (Transaction) ,任务 (Task) 和逻辑处理单元 (LUW) 的概念. - PowerPoint PPT Presentation

Transcript of 使用 Native API 开发 IBM TXSeries 和 CTG

Page 1: 使用 Native API 开发 IBM TXSeries 和 CTG

®

IBM Software Group – TXSeries for Multiplatforms

© 2006 IBM Corporation

Version 112-May-2006

使用 Native API 开发 IBM TXSeries 和 CTG

Page 2: 使用 Native API 开发 IBM TXSeries 和 CTG

IBM Software Group – TXSeries for Multiplatforms

概要

TXSeries 编程框架 TXSeries/CICS 客户机程序 TXSeries 服务器程序

Page 3: 使用 Native API 开发 IBM TXSeries 和 CTG

®

IBM Software Group – TXSeries for Multiplatforms

© 2006 IBM Corporation

Version 112-May-2006

TXSeries 编程框架

Page 4: 使用 Native API 开发 IBM TXSeries 和 CTG

IBM Software Group – TXSeries for Multiplatforms

基于 TXSeries 的三层应用开发环境

Page 5: 使用 Native API 开发 IBM TXSeries 和 CTG

IBM Software Group – TXSeries for Multiplatforms

TXSeries 的应用开发支持框架

IBM C++ Family

Compilers³ ÌÐ ò

VisualAge C++Visual C++

Borland C++C++ Builder

³ ÌÐ ò

Visual BasicDelphi

PowerBuilderSQL Window

³ ÌÐ ò

ExcelMS Word

IENetscape

³ ÌÐ ò

CICS Clients CICS Server

OLE 2 Automation Interface

CC++

COBOLPL/I³ ÌÐ ò

CC++

COBOLPL/I³ ÌÐ ò

ECI & EPI Classes** CICS ServerClasses*

CICS APIECI & EPI API

» ùÓ Ú¶ ÔÏ óµ ÄÓ ¦Ó ó ÌÐ ò» ùÓ Ú¶ ÔÏ óµ ÄÓ ¦Ó ó ÌÐ ò

ECI/EPI

Page 6: 使用 Native API 开发 IBM TXSeries 和 CTG

IBM Software Group – TXSeries for Multiplatforms

交易 (Transaction) ,任务 (Task) 和逻辑处理单元(LUW) 的概念

交易 (Transaction) :一个交易可以对应于一支或多支 CICS 服务器端程序的执行。交易的执行多是由终端发出的请求:在终端键入一个四位的交易 ID 号。在一个交易的执行过程中,可能会触发一个或多个任务的执行。 CICS 允许一个交易程序被很多用户同时请求执行,而交易之间互不妨碍。这个交易(Transaction) 的概念对应一个 TD 。

任务 (Task) :它是交易执行的一个单一实例。 CICS 与操作系统相结合,通过分配系统进程给每个任务,这样当一个任务处于等待状态时,操作系统可以将控制权交给另外一个任务。这个任务 (Task) 的概念对应一个 PD 。

逻辑处理单元 (LUW, logical unit of work, also termed a unit of work)每个逻辑处理单元是一组对数据的修改。比如说在一个帐户系统中一个逻辑处理单元由更新可支付帐户,更新帐簿,创建一张支票组成。每一个逻辑处理单元所作的工作是完全独立于由其它逻辑处理单元的工作。在一个逻辑处理单元中修改的资源或是全部成功或全部失败。这个逻辑处理单元(LUW) 的概念对应 SYNCPOINT 之间的代码。

Page 7: 使用 Native API 开发 IBM TXSeries 和 CTG

IBM Software Group – TXSeries for Multiplatforms

Logical Unit of Work

LUW-- 交易中两个相邻的提交 / 回滚之间的处理 Server Program 可以控制 LUW

EXEC CICS SYNCPOINT ; EXEC CICS SYNCPOINT ROLLBACK ;

ECI Client 可以控制 LUW eci_extend_mode 参数

ECI_NO_EXTEND 结束一个 LUW

ECI_EXTENDED 将 LUW 延续至下一次 ECI 调用 eci_luw_token 参数

说明 LUW 的编号 ECI_LUW_NEW 本次 CALL 作为一个 LUW

Page 8: 使用 Native API 开发 IBM TXSeries 和 CTG

IBM Software Group – TXSeries for Multiplatforms

CICS Communication Area

CICS 通讯区域,由 CICS 自动传递。 长度不大于 32 K (32500) 。 EXEC CICS ADDRESS COMMAREA 。 被异步启动的交易程序通讯区域长度为 0 。

Page 9: 使用 Native API 开发 IBM TXSeries 和 CTG

®

IBM Software Group – TXSeries for Multiplatforms

© 2006 IBM Corporation

Version 112-May-2006

TXSeries/CICS 客户机程序

Page 10: 使用 Native API 开发 IBM TXSeries 和 CTG

IBM Software Group – TXSeries for Multiplatforms

CICS Client 编程概述

功能 从非 CICS 程序的客户程序调用 CICS Server 交易

编程方式 External Call Interface ,简称 ECI

基于对 Server 程序 (Program) 的请求 通过通讯缓冲数据区 (COMMAREA) 与 Server 交换数据 ECI 应用程序被 Server 视为发出 DPL 请求的对等 Server

External Presentation Interface ,简称 EPI

基于对 Server 交易 (Transaction) 的请求 通过 3270 数据流与 Server 交换数据 EPI 应用程序被 Server 视为 3270 终端 多用于内部管理应用 , 不宜用于业务应用

Page 11: 使用 Native API 开发 IBM TXSeries 和 CTG

IBM Software Group – TXSeries for Multiplatforms

External Call Interface (ECI)

¿ Í» §» ú · þÎ ñÆ÷

CICS ClientÓ ¦Ó ó ÌÐ ò

CICSClient

CICS

CICS

CICS Server

CICS ServerÓ ¦Ó ó ÌÐ ò

LANECI

APPLICATION

APPLICATION

Ô ¶¶ Ë· þÎ ñÆ÷

Ê ý¾ ÝÇ ø

Page 12: 使用 Native API 开发 IBM TXSeries 和 CTG

IBM Software Group – TXSeries for Multiplatforms

ECI Client 程序示例 #include <cics_eci.h>

ECI_PARMS EciParms;

char commArea[1024];

memset (&EciParms, 0, sizeof (ECI_PARMS));

memset(commArea,0,sizeof(commArea));

EciParms.eci_version = ECI_VERSION_1A;

EciParms.eci_call_type = ECI_SYNC;

memcpy(&EciParms.eci_program_name, "SERV0001",8);

memcpy(&EciParms.eci_userid, "CICSUSER", 8);

memcpy(&EciParms.eci_password, "CICSUSER", 8);

memcpy(&EciParms.eci_system_name, "CICSRG01",8);

EciParms.eci_commarea = commArea;

EciParms.eci_commarea_length = sizeof(commArea);

EciParms.eci_extend_mode = ECI_NO_EXTEND;

EciParms.eci_luw_token = ECI_LUW_NEW;

EciParms.eci_timeout = 0;

memcpy(EciParms.tpn_name, "BPMI", 4);

Rc = CICS_ExternalCall (&EciParms);

Page 13: 使用 Native API 开发 IBM TXSeries 和 CTG

IBM Software Group – TXSeries for Multiplatforms

ECI 函数调用

CICS_ExternalCall cics_sshort_t CICSCALL CICS_ExternalCall(ECI_PARMS CICSPTR

*EciParms);

实现了 ECI 的大部分功能 只有一个参数 , 称为 ECI 参数模块 (ECI parameter block)

该模块描述了 ECI 调用实现的功能及输入输出的数据 CICS_EciListSystems

获得 Client 定义的可连接的 Server 名称及描述

Page 14: 使用 Native API 开发 IBM TXSeries 和 CTG

IBM Software Group – TXSeries for Multiplatforms

ECI CICS_ExternalCall 调用分类

CICS_ExternalCall 通过设置 ECI 参数模块中的 eci_call_type 栏位来控制调用类型。

程序执行调用 (Program link calls)请求执行 Server 程序

同步调用 异步调用 ( 异步调用后必须使用回复信息查询调用获得结果 )

状态查询调用 (Status information calls)查询 Server 属性及状态信息

同步调用 异步调用

回复查询调用 (Reply solicitation calls)获得异步调用的结果

获得任何类型的异步调用结果 获得指定异步调用的返回结果 (eci_message_qualifier)

Page 15: 使用 Native API 开发 IBM TXSeries 和 CTG

IBM Software Group – TXSeries for Multiplatforms

External Presentation Interface (EPI)¿ Í» §» ú · þÎ ñÆ÷

CICS ClientÓ ¦Ó ó ÌÐ ò

CICSClient

CICS

CICS

CICS Server

CICS ServerÓ ¦Ó ó ÌÐ ò

LANECI

APPLICATION

APPLICATION

Ô ¶¶ Ë· þÎ ñÆ÷

3270Ê ý¾ ÝÁ ÷

Page 16: 使用 Native API 开发 IBM TXSeries 和 CTG

®

IBM Software Group – TXSeries for Multiplatforms

© 2006 IBM Corporation

Version 112-May-2006

TXSeries 服务器程序

Page 17: 使用 Native API 开发 IBM TXSeries 和 CTG

IBM Software Group – TXSeries for Multiplatforms

Server 程序框架 - C

main(){

unsigned long respCode;

char *commArea;

EXEC CICS ADDRESS EIB(dfheiptr) RESP(respCode);

if (respCode != DFHRESP(NORMAL)) {

fprintf(stderr, "Error occurred addressing commarea, rc = %d\n", respCode);

EXEC CICS RETURN;

}

EXEC CICS ADDRESS COMMAREA(commArea) RESP(respCode);

if (respCode != DFHRESP(NORMAL)) {

fprintf(stderr, "Error occurred addressing commarea, rc = %d\n", respCode);

EXEC CICS RETURN;

}

...

EXEC SQL ...

...

EXEC CICS SYNCPOINT;

strcpy(commArea, "Return from Server.\n");

EXEC CICS RETURN;

}

Page 18: 使用 Native API 开发 IBM TXSeries 和 CTG

IBM Software Group – TXSeries for Multiplatforms

编译 CICS 程序

数 据 库 预 编 译 db2 prep -- db2

proc -- Oracle

cpre -- Sybase

CICS 预编译cicstran -lC server.ccs

C 编译 / 连接 xlc_r4, cc_r

cl

预编译 + C 编译 / 连接cicstcl -lC server.ccs

Page 19: 使用 Native API 开发 IBM TXSeries 和 CTG

IBM Software Group – TXSeries for Multiplatforms

部署 CICS 程序

安装 Program cicsadd

cicsupdate

cicsdelete

cicsget

安装事务

Page 20: 使用 Native API 开发 IBM TXSeries 和 CTG

IBM Software Group – TXSeries for Multiplatforms

程序与交易

程序 完成一定功能的代码段

交易 CICS 程序运行的特定环境 本身无实际的代码 第一个程序 (First Program) ,链接其他程序

Page 21: 使用 Native API 开发 IBM TXSeries 和 CTG

IBM Software Group – TXSeries for Multiplatforms

CICS API

提供 CICS 服务,由服务器端程序调用 分类

逻辑控制 数据及存储服务 时间服务 程序跟踪 APPC 通讯 ...

通过 CICS API 调用 - EXEC CICS ...