Copyright © Cloud Software Group, Inc. All Rights Reserved
Copyright © Cloud Software Group, Inc. All Rights Reserved


Chapter 10 Accessing External Routines : Making a COBOL Program Compatible with TIBCO Object Service Broker

Making a COBOL Program Compatible with TIBCO Object Service Broker
Requirements
Use IBM Enterprise COBOL for z/OS or later compiler if the external routine is to be run on multiple threads of a multi-threaded application, such as a Native Execution Environment. Older programs written in OS/VS Cobol or COBOL II should be recompiled with this new compiler.
COBOL Run-Units
A COBOL run-unit is created when you invoke a COBOL external routine and terminated when the COBOL program issues a GOBACK to return control to TIBCO Object Service Broker. A subsequent call to the routine within the same transaction causes the routine to be executed as though it were being called for the first time. If the routine opens files or sets flags, expecting to use this environment on subsequent calls, processing errors occur, with possible abends or incorrect logic paths.
How to Prevent Premature Termination of the COBOL Run-Unit
To ensure that a COBOL run-unit is not terminated prematurely and is active for the life of the current rule stream/transaction level, you can take the following steps. Additional information can be found in the IBM “Enterprise COBOL for z/OS Programming Guide”.
1.
Define the COBOL routine to TIBCO Object Service Broker in the ROUTINES table as LANGUAGE=LEPERSIST. This creates a CEEPIPI environment for the COBOL run unit/Language Environment enclave.
2.
Specify the COBOL compiler THREAD option for the compilation. (The module will also execute successfully in a non-THREAD environment with this option.)
3.
4.
Linkedit the COBOL module with RENT option. Do not include any IGZEOPT definition because this facility is not supported with the THREAD option.
A sample COBOL external routine is included in the COBOL sample library and is called COBENTXR.
Link-Edit and Runtime Options
Your COBOL external routine can override TIBCO Object Service Broker error-handling with a runtime option. If the program has its own error handling, it must restore TIBCO Object Service Broker error-handling, including the program mask, before returning. Failure to do so produces unpredictable results.
Syntax Mapping
The following table shows how TIBCO Object Service Broker syntax is mapped to COBOL syntax.

COBOL Syntax Declaration #
PIC 9(4) USAGE COMP‑4 and PIC X(n) 1
PIC S9(2n-1-d)V9(d) USAGE COMP-3
n = 2
n = 4
n = 4
n = 8
n = 16

1
The first part of the COBOL syntax for V describes the length of the argument and the second part contains the data. Refer to Example COBOL Program for an example of this usage.

2
TIBCO Object Service Broker supports floating point, 16 bytes long, which is not supported in COBOL and therefore cannot be used in COBOL subroutines.

3
An RD field consists of a four-byte non-exclusive binary length followed by the data.

Example COBOL Program
The following routine shows how to define the arguments in COBOL. The sample external routine requires five arguments. The routine and its arguments must be identified to TIBCO Object Service Broker as described in Identifying Your External Routine to TIBCO Object Service Broker.

 
CBL MAP,RENT,NOSEQUENCE,TEST(SYM),THREAD,VBREF
IDENTIFICATION DIVISION.
PROGRAM-ID. USEARG RECURSIVE.
AUTHOR. JANET JONES.
INSTALLATION. SITE.
DATE-WRITTEN. 21/3/2007.
******************************************************************
* *
* USEARG - SAMPLE PROGRAM: *
* *
* N.B.: CALLED FROM OSB WITH PARAMETERS; *
* CALL IS BY REFERENCE *
* *
* OSB ARGUMENTS(USEARG) TABLE CONTAINS THE FOLLOWING *
* DEFINITION FOR PARAMETERS *
* *
* B2: C B 2 0 *
* B4: C B 4 0 *
* C16: S C 16 0 *
* P5D2: Q P 5 2 *
* V128: S V 128 0 *
* *
******************************************************************
ENVIRONMENT DIVISION.
*
DATA DIVISION.
*
WORKING-STORAGE SECTION.
*
LINKAGE SECTION.
01 B2 PIC S9(4) USAGE COMP-4.
01 B4 PIC S9(9) USAGE COMP-4.
01 C16 PIC X(16).
01 P5D2 PIC 9(7)V9(2) USAGE COMP-3.
01 V128.
* FOR "V" SYNTAX PREFIX DATA WITH ACTUAL LENGTH OF DATA. (DOES
* NOT INCLUDE LENGTH OF ITSELF.)
05 V128-LENGTH PIC 9(4) USAGE COMP-4.
05 V128-TEXT PIC X(128).
*
PROCEDURE DIVISION USING B2, B4, C16, P5D2, V128.
*
* YOUR CODE
*
MOVE 12 TO B2.
MOVE 605 TO B4.
MOVE 'SUCCESS' TO C16.
MOVE 311.73 TO P5D2.
MOVE 12 TO V128-LENGTH.
MOVE 'SOME MESSAGE' TO V128-TEXT.
GOBACK.

 
See Also
TIBCO Object Service Broker Programming in Rules about TIBCO Object Service Broker syntax.

Copyright © Cloud Software Group, Inc. All Rights Reserved
Copyright © Cloud Software Group, Inc. All Rights Reserved