Chapter 7 Calling Application Engine Programs from COBOL 从COBOL调用应用程序引擎程序

本文介绍了如何从COBOL程序调用应用程序引擎,包括在程序中添加副本(如PTCCBLAE.CBL),数据传输过程,指定复制簿值,以及处理COBOL程序中的错误。重点讲解了状态记录、参数传递方法和错误管理策略。
摘要由CSDN通过智能技术生成

Chapter 7 Calling Application Engine Programs from COBOL

COBOL调用应用程序引擎程序

Adding Copybooks to COBOL Programs

COBOL程序中添加副本

To enable you to call Application Engine programs from COBOL programs, include the copybook called PTCCBLAE.CBL with your COBOL programs. This copybook is located in PS_HOME\src\cbl\base.

为了使您能够从COBOL程序调用应用程序引擎程序,请在您的COBOL程序中包含名为PTC CBLAE.CBL的副本。本抄写本位于PS_HOME\src\cbl\base中。

The following is the PTCCBLAE.CBL copybook:

以下是PTCCBLAE.CBL字帖:

*01  CBLAE.

NOCLN      02  CBLAE-PRCSNAME          PIC X(12)   VALUE SPACE.

NOCLN      02  CBLAE-COMMIT-FLAG       PIC X(1)    VALUE SPACE.

               88 AE-COMMITS-SUCCESS               VALUE 'B'.

               88 AE-COMMITS-ALL                   VALUE 'C'.

    1. CBLAE-PARMS.
    2. CBLAE-PARM-CNT      PIC 9(4)                COMP.

               03  CBLAE-PARM-ENT      OCCURS 500 TIMES.

                   05 CBLAE-STATEREC   PIC X(15).

                   05 CBLAE-FIELDNM    PIC X(18).

                   05 CBLAE-DATA-PTR               POINTER.

                   05 CBLAE-LENGTH     PIC 9999                COMP.

                   05 CBLAE-SCALE      PIC 99                  COMP.

NOCLN              05 CBLAE-TYPE       PIC X.

                       88  CBLAE-TYPE-CHAR         VALUE 'C'.

                       88  CBLAE-TYPE-SMALLINT     VALUE 'S'.

                       88  CBLAE-TYPE-INT          VALUE 'I'.

                       88  CBLAE-TYPE-DEC          VALUE 'P'.

                       88  CBLAE-TYPE-DATE         VALUE 'D'.

                       88  CBLAE-TYPE-TIME         VALUE 'T'.

                       88  CBLAE-TYPE-TIMEONLY     VALUE 'V'.

                       88  CBLAE-TYPE-NUMERIC      VALUE 'S' 'I' 'P'.

Data Transfer Process Between COBOL Programs and Application Engine Programs

COBOL程序与应用引擎程序之间的数据传输过程

To interface between COBOL programs and Application Engine programs, the process uses a file to pass parameters from COBOL to the Application Engine program. This file is owned by the process and has the prm extension. The location of the file is determined by the following:

为了在COBOL程序和Application Engine程序之间建立接口,该流程使用一个文件将参数从COBOL传递到Application Engine程序。该文件由进程拥有,并具有-prm扩展名。文件的位置由以下内容决定:

  • If an application server root directory is defined, then the file resides in the output directory of that particular process instance.
  • 如果定义了应用服务器根目录,则文件驻留在特定进程实例的输出目录中。
  • If the output directory on the application server is not defined, then the file resides in the default output directory of the Process Scheduler domain.
  • 如果应用程序服务器上的输出目录没有定义,那么文件驻留在“进程计划程序”域的默认输出目录中。
  • If neither of the above is defined, then the file is written to the default temp directory.
  • 如果上述两个都没有定义,那么文件将被写入默认的临时目录。

Assigning Copybook Values

指定复制簿值

To assign values to the copybook of the calling COBOL program to be passed as parameters into the state records of the called Application Engine program:

要将值分配给调用cobol程序的copybook,以作为参数传递到被调用的应用程序引擎程序的状态记录中,请执行以下操作:

  • Identify the fields in your COBOL program that contain the values you want to pass to the Application Engine program.
  • 确定COBOL程序中包含要传递给应用程序引擎程序的值的字段。
  • Load the PTCCBLAE.CBL copybook with the state record name, field name, field length (this should be the size of the field not the size of the contents), the scale (decimal places if any), and set the field type.
  • 加载包含状态记录名、字段名、字段长度的PTCCBLAE.CBL抄写本(这应该是字段的大小而不是内容的大小)、小数位数(如果有的话),并设置字段类型。
  • Call the PTPSETAD program to set the pointer in PTCCBLAE.CBL to the host programs variable.
  • 调用PTPSETAD程序来设置PTCCBLAE.CBL中指向主机程序变量的指针。
  • Set the variable AE-COMMIT-FLAG to either AE-COMMITS-ALL or AE-COMMITS-SUCCESS.
  • 将变量AE-提交-标志设置为AE-提交-全部或AE-提交-成功。

AE-COMMITS-ALL means that the Application Engine program commits as specified in the program. AE-COMMITS-SUCCESS means that the Application Engine program ignores all commits and performs one commit at the end of successful execution.

AE-COMMITS-ALL表示应用程序引擎程序按照程序中指定的方式提交。AE-COMMITS-SUCCESS表示应用程序引擎程序忽略所有提交,并在成功执行结束时执行一次提交。

Example of Loading Values from PTPTSTAE.CBL Sample Program

PTPTSTAE.CBL示例程序加载值的示例

Make sure the calling COBOL program has connected successfully to the database before calling the PTPCBLAE copybook. Also ensure that the calling program is not running through a RemoteCall function.

在调用PT PCBLAE copybook之前,确保调用COBOL程序已成功连接到数据库。还要确保调用程序没有通过RemoteCall函数运行。

This code is an example of how to load values from the copybook:

这段代码是一个如何从copybook加载值的示例:

MOVE 0 TO CBLAE-PARM-CNT OF CBLAE

           ADD  1 TO CBLAE-PARM-CNT OF CBLAE

           MOVE 'QE_CBLAETST_AET' TO CBLAE-STATEREC                   OF CBLAE (CBLAE-PARM-CNT OF CBLAE)

           MOVE 'DESCR' TO CBLAE-FIELDNM

                  OF CBLAE (CBLAE-PARM-CNT OF CBLAE)

Chapter 7                                                                                     Calling Application Engine Programs from COBOL

           MOVE 30 TO CBLAE-LENGTH                   OF CBLAE (CBLAE-PARM-CNT OF CBLAE)

           MOVE 0 TO CBLAE-SCALE

                  OF CBLAE (CBLAE-PARM-CNT OF CBLAE)            SET CBLAE-TYPE-CHAR OF CBLAE (CBLAE-PARM-CNT OF CBLAE)

                  TO TRUE

           CALL 'PTPSETAD' USING  CBLAE-DATA-PTR                   OF CBLAE (CBLAE-PARM-CNT OF CBLAE)

                  W-DESCR OF W-WORK

           ADD  1 TO CBLAE-PARM-CNT OF CBLAE

           MOVE 'QE_CBLAETST_AET' TO CBLAE-STATEREC

                  OF CBLAE (CBLAE-PARM-CNT OF CBLAE)

           MOVE 'QE_AE_INT_7' TO CBLAE-FIELDNM                   OF CBLAE (CBLAE-PARM-CNT OF CBLAE)

           MOVE 2 TO CBLAE-LENGTH                   OF CBLAE (CBLAE-PARM-CNT OF CBLAE)

           MOVE 0 TO CBLAE-SCALE                   OF CBLAE (CBLAE-PARM-CNT OF CBLAE)

           SET CBLAE-TYPE-SMALLINT    OF CBLAE (CBLAE-PARM-CNT OF CBLAE)

                  TO TRUE

           CALL 'PTPSETAD' USING  CBLAE-DATA-PTR                   OF CBLAE (CBLAE-PARM-CNT OF CBLAE)                   W-SMINT OF W-WORK

  •        DA000-CALL-AE SECTION.

       DA000.

  •     MOVE 'QE_AETESTPRG' TO CBLAE-PRCSNAME OF CBLAE

           SET AE-COMMITS-ALL TO TRUE

       CALL 'PTPCBLAE' USING SQLRT CBLAE.

       CALL-AE-EXIT.

       EXIT.

Sample of the Communication Area of PTPBLAE.CBL

PTBLAE.CBL的通信区示例

If the called Application Engine program updated the state records or fields that were passed by PTPCBLAE, then the fields or records are stored in the local variables of the calling program, as identified by PTPSETAD:

如果被调用的应用引擎程序更新了由PT PC BLAE传递的状态记录或字段,那么这些字段或记录被存储在调用程序的本地变量中,由PT PS TAD标识:

  • PTCCBLAE - Communication area for PTPCBLAE                     **01  CBLAE.

NOCLN   02   CBLAE-PRCSNAME   PIC X(12)   VALUE SPACE.

  • Name of AE program to be called.

NOCLN   02   CBLAE-COMMIT-FLAG   PIC X(1)   VALUE SPACE.

  • Flag to determine which of the following commits to make.

           88 AE-COMMITS-SUCCESS         VALUE 'B'.

  • No in-process commit; if successful, then commit occurs.

           88 AE-COMMITS-ALL         VALUE 'C'.

  • Commits occur when defined in the AE program.
      1. CBLAE-PARMS.
      2. CBLAE-PARM-CNT   PIC 9(4)COMP.
  • Counter of the number of state records passed.

           03  CBLAE-PARM-ENT   OCCURS 500 TIMES.

  • Maximum value of state record entries.

             05 CBLAE-STATEREC   PIC X(15).

  • State record name.

             05 CBLAE-FIELDNM   PIC X(18).

  • Field name.

             05 CBLAE-DATA-PTR   POINTER.

  • Pointer to your own working storage area.

             05 CBLAE-LENGTH   PIC 9999   COMP.

  • Field length of defined state record.

             05 CBLAE-SCALE   PIC 99   COMP.

  • Number of decimal places.

NOCLN        05 CBLAE-TYPE      PIC X.

  • Field data type.

                88  CBLAE-TYPE-CHAR         VALUE 'C'.

                88  CBLAE-TYPE-SMALLINT     VALUE 'S'.

                88  CBLAE-TYPE-INT          VALUE 'I'.

                88  CBLAE-TYPE-DEC          VALUE 'P'.

                88  CBLAE-TYPE-DATE         VALUE 'D'.

Chapter 7                                                                                     Calling Application Engine Programs from COBOL

                88  CBLAE-TYPE-TIME         VALUE 'T'.

                88  CBLAE-TYPE-TIMEONLY     VALUE 'V'.

                88  CBLAE-TYPE-NUMERIC      VALUE 'S' 'I' 'P'.

Handling COBOL Errors

处理COBOL错误

If your COBOL program needs error handling, try the following procedure:

如果您的COBOL程序需要错误处理,请尝试以下过程:

    1. Add a field (return code) to your state record.

向状态记录添加字段(返回代码)。

    1. Initialize the field to a negative value.

将字段初始化为负值。

    1. Pass the value into the Application Engine program.

将值传递到应用程序引擎程序中。

    1. At the successful completion of the Application Engine program, change the field value to a positive value.

在成功完成应用程序引擎程序时,将字段值更改为正值。

    1. Check for that value in your COBOL program.

在COBOL程序中检查该值。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值