5. Welcome to Teradata Vantage
Teradata Vantage™ is our flagship analytic platform offering, which evolved from our industry-leading
Teradata® Database. Until references in content are updated to reflect this change, the term Teradata
Database is synonymous with Teradata Vantage.
Advanced SQL Engine (was NewSQL Engine) is a core capability of Teradata Vantage, based on our
best-in-class Teradata Database. Advanced SQL refers to the ability to run advanced analytic functions
beyond that of standard SQL.
Overview
The following sections provide an overview of the IMS (Information Management System) interface to
the database.
Prerequisites
The following prerequisite knowledge is required for this product:
• Teradata Vantage™ or UNIX
• Call-Level Interface Version 2
• Preprocessor 2 (PP2)
Supported Releases
This book supports the following releases:
• Vantage 2.0
• Teradata Tools and Utilities 17.00
• IMS 17.00
The most current information about supported operating systems, supported Vantage versions, and
product version numbers for all Teradata Tool and Utilities is available (at https://docs.teradata.com/) in
a single spreadsheet titled Teradata® Tools and Utilities ##.# Supported Platforms and Product Versions
(B035-3119) .
Supported Regions
The IMS interface allows IMS programs executing in the following regions to access data from the database:
Interface Overview
1
Teradata® Tools and Utilities IBM IMS Interface for Teradata®
Reference, Release 17.00 5
6. • IMS BATCH
• BMP (Batch Message Program)
• MPP (Message Processing Program)
Note:
The interface does not support the execution of IMS programs from a fast path region.
Writing IMS Programs
IMS programs can be written in any language that supports direct calls to Call-Level Interface version 2
(CLIv2), such as the following:
• Assembler
• Fortran
• Pascal
• C, or
• PL/I
The Teradata Preprocessor2 supports IMS programs written in COBOL or PL/I.
Refer to the following documents for more information.
• Teradata® Call-Level Interface Version 2 Reference for Mainframe-Attached Systems, B035-2417
• Teradata® Preprocessor2 for Embedded SQL Programmer Guide, B035-2446
Synchronizing Resources: Overview
The following sections discuss issues relating to synchronizing resources for non-2PC and
2PC applications.
• For non-2PC applications that update multiple databases, there is a period of time between
transactions when databases are not synchronized or protected. The user must make sure that
databases do not get out of sync and, if they do, explicit correct this condition.
• For 2PC applications that update multiple databases, the 2PC protocol synchronizes IMS and the
database resources in a protected fashion.
The 2PC protocol is part of an overall scheme that allows IMS applications to access the database as
a checkpoint or synchronization (syncpoint) participant.
Synchronizing Resources for Non-2PC Applications
For non-2PC applications, the IMS interface does not participate in any IMS checkpointing or
synchronization. IMS and database commits are independently executed.
Although an application program can perform an explicit IMS commit (for example, Checkpoint) and an
explicit database commit (for example, END TRANSACTION) in consecutive statements, there is a period
1: Interface Overview
Teradata® Tools and Utilities IBM IMS Interface for Teradata®
Reference, Release 17.00 6
7. of time when the commits are not synchronized. A failure at this point could leave the databases in an
inconsistent or indeterminate state.
How the Interface Operates
The IMS interface sets a flag when the call to CLIv2 is identified as one coming from an IMS application.
When such a call is identified in non-2PC applications, the interface takes control at the termination (normal
and abnormal) of a program and ensures that all sessions originated by the program are logged off.
Uncommitted transactions, aborts, spooled sessions, and spool files are processed by the Teradata
Director Program (TDP) in the same manner that it processes the termination of any MVS task.
Synchronizing Resources for 2PC Applications
The 2PC protocol allows the development of IMS applications that can access the database as an IMS
syncpoint participant. As a result, the updates requested in a defined unit of work within a transaction either
all commit or all roll back.
IMS and 2PC
IMS provides the following:
• Programming interfaces for communicating with, and synchronizing the access to, the database with
access to other IMS-managed resources
• System services to terminate a database update
• Syncpoint manager to coordinate the rollback or commitment of all resources accessed in the logical
unit of work. The syncpoint manager uses the 2PC protocol to guarantee data consistency.
Note:
Teradata transaction management operates differently on 2PC sessions than on
non-2PC sessions.
IMS as Coordinator
For IMS applications using the 2PC protocol, IMS acts as a coordinator and manages the 2PC processing.
A database becomes a resource that can be controlled by IMS system events, such as syncpoint
and rollback.
For more information on the coordinator and 2PC in general, see the section on 2PC in Teradata
Vantage™ - Database Administration, B035-1093 or Teradata® Call-Level Interface Version 2 Reference
for Mainframe-Attached Systems, B035-2417.
For more information on 2PC and IMS, see DB2 Administration and IBM IMS Communication
and Concepts.
1: Interface Overview
Teradata® Tools and Utilities IBM IMS Interface for Teradata®
Reference, Release 17.00 7
8. An IMS Transaction with the 2PC Protocol: Example
With the 2PC protocol, a task is one invocation of an IMS transaction, and each task can update multiple
database management systems (DBMSs).
The processing example in the figure below depicts such a task. The IMS task establishes sessions on the
appropriate DBMSs and issues the updates.
A set of updates, such as Updates 1A, 1B, and 1C in the figure, will take the multiple databases from one
state to another (in this case, from the initial state to State 1).
The set of updates is referred to as a logical unit of work. After each logical unit of work is completed, there
is a “commit” or “rollback” action.
If a failure occurs so that a logical unit of work cannot be completed, the logical unit of work becomes a unit
of recovery. The data can be recovered only back to the last completed logical unit of work.
Note:
An update within a Teradata session is occasionally referred to as a “transaction.”
2PC IMS Processing Example
In-Doubt Resolution
It is possible for a failure to occur during the 2PC session during one of the following circumstances:
• The communication link between the coordinator, such as IMS, and the participant, such as the
database, is lost.
• There is an IMS system crash.
• A participant, such as DB2, experiences a system failure.
When the electrical power, system, or communication line is restored after a failure, the coordinator
reconciles existing activity logs from the coordinator and the participants.
1: Interface Overview
Teradata® Tools and Utilities IBM IMS Interface for Teradata®
Reference, Release 17.00 8
9. If the logs cannot be reconciled, then in-doubt resolution is necessary.
There are two forms of in-doubt resolution: automatic and manual.
Automatic In-Doubt Resolution
If the coordinator or any participants experiences a failure, automatic in-doubt resolution will occur once
the communication between the coordinator and the participants is reestablished.
The coordinator automatically resolves the participant’s in-doubt units of recovery listed in the IMS
transient journal, without any manual intervention.
However, if a participant has additional in-doubt units of recovery in its log, the participant will not resolve
them until it receives instructions to do so from the coordinator or another authorized source (see Manual
In-Doubt Resolution).
Manual In-Doubt Resolution
Manual in-doubt resolution is necessary when automatic in-doubt resolution is unavailable
or unsuccessful.
When the control region is restarted and there are still in-doubt units of recovery left, the master console
will display the following IMS message: DSNM004I.
You can find out about in-doubt sessions and manually resolve them using any of the following means:
• The TPCCONS utility on the system console (see Teradata Vantage™ - Database
Utilities, B035-1102).
• A CLIv2 application that logs on to the Resolver Base Module and resolves in-doubt sessions using
TPCCONS commands (see Teradata Vantage™ - Database Utilities, B035-1102).
• The TDP commands DISPLAY INDOUBT, COMMIT, and ROLLBACK (see Teradata® Director
Program Reference, B035-2416).
• IMS log records for a unit of recovery.
In addition, you can use many of the monitoring, accounting, and tuning facilities within IMS/VS.
TDP Session Pools
Using TDP Session Pools with 2PC
To have the Teradata Director Program (TDP) establish sessions in 2PC mode within a session pool, use
the TDP command, START POOL, with the TWOPC option.
For more information on START POOL and other TDP commands, see Teradata® Director Program
Reference, B035-2416.
1: Interface Overview
Teradata® Tools and Utilities IBM IMS Interface for Teradata®
Reference, Release 17.00 9
10. Session Pool Logoff Processing
If there is a logoff or if an in-doubt session exists, the TDP uses “pseudo-logoff” processing.
The logoff can be initiated thorough an application request or the abnormal end of an IMS TCB.
If the session is in-doubt, the TDP processes the pseudo-logoff without database communication (cleanup
is suppressed).
When the pseudo-logoff is completed, the TDP issues the TDP0868 message and remove the session
from the session pool.
This in-doubt transaction can be terminated using only automatic or manual in-doubt resolution.
The IMS Attachment Package
The IMS External Subsystem Attachment Package provides optional, transparent participant support for the
database as a syncpoint participant.
As a result, you can use the IMS attachment package to synchronize database transaction boundaries
with the IMS coordinator’s logical unit of work boundaries, using the IMS syncpoint facilities to terminate
Teradata transactions.
Teradata DBS Attachment Facility
This section discusses only the differences specific to the Teradata DBS Attachment Facility. For full
documentation of the IMS subsystem-related commands, see the IBM publications, DB2 Command
Reference and DB2 Utilities Guide and Reference or IMS Operator’s Reference Manual.
All IMS/VS commands related to the external system are supported in the IMS interface, with a few
exceptions (see below).
If you are accustomed to using the IMS attachment package with DB2, you will notice the following
differences in IMS command facilities with the database.
IMS Command Differences
Command Differences
/START
SUBSYS
The /START SUBSYS command can initialize communication with one or more of the
TDPs named in the SSM.
This command makes the connection between IMS/VS and the specified external
subsystems available. IMS/VS processing of this command involves refreshing the
in-core copy of the SSM, and invoking the external subsystem initialization modules.
While the connection to subsystems named in the SSM occurs automatically during
IMS/VS initialization, you can use the /START command to enable the modification of
the SSM subsequent to IMS start-up, thus avoiding IMS restart.
/STOP SUBSYS This command prevents applications from communicating with the named
external subsystem.
Applications that are currently accessing external subsystems are allowed to complete.
1: Interface Overview
Teradata® Tools and Utilities IBM IMS Interface for Teradata®
Reference, Release 17.00 10
11. Command Differences
When all applications are completed, the connection is terminated.
/DISPLAY
SUBSYS ALL
The /DISPLAY SUBSYS command displays the status of the subsystem connections,
including the TDP subsystems defined in the SSM.
/DISPLAY OASN
SUBSYS
This command displays the outstanding recovery units (Origin Application Sequence
Numbers) associated with the specified external subsystem
/CHANGE
SUBSYS
This command resets an in-doubt unit of recovery.
The command deletes the item (from the standpoint of IMS). No communication takes
place with the external subsystem.
/SSR The /SSR command routes commands to connected external subsystems.
The Teradata DBS Attachment Facility does not support this command facility for
TDP commands.
1: Interface Overview
Teradata® Tools and Utilities IBM IMS Interface for Teradata®
Reference, Release 17.00 11
12. What’s in SAMPLIB?
Sample IMS programs are provided in SAMPLIB of the Teradata software release media to assist you in
writing your IMS application to access databases.
A list of the sample programs and sample DBCAREAs contained in SAMPLIB is shown below:
• CLI2CTB
• CLI2MCI
• CLI2MCB
• CLI2MPI
• CLI2MPB
• CLI2SCI
• CLI2SCB
• DBCAREAC
• DBCAREAP
• PPC2PC02
The sample programs listed above, CLI2CTB, CLI2MCI, CLI2MPI, and CLI2SCI, are described in Sample
IMS Programs.
Using the Sample Programs
To use the sample programs, compile and define them to your IMS system according to the procedures at
your site for other IMS application programs.
Executing CLI2CTB: Example
The source statements for CLI2CTB, a called subroutine, are included on the Teradata release tape.
The CLI2CTB subroutine is called by the following sample programs:
• CLI2MCB
• CLI2MCI
• CLI2MPB
• CLI2MPI
After the tape is loaded and before the sample programs listed above are executed, CLI2TB must be
compiled and linked into <dbcpfx>.APPLOAD (see JCL to Compile/Link CLI2CTB).
Executing Sample IMS Programs
2
Teradata® Tools and Utilities IBM IMS Interface for Teradata®
Reference, Release 17.00 12
13. APPLCTN and TRANSACT Macros
There are no special IMS macros required for the IMS interface.
The APPLCTN and TRANSACT macros defined for the sample IMS conversational and non-conversational
programs included in Sample IMS Programs are shown in the sections that follow.
Sample APPLCTN/TRANSACT Macros (Conversational)
Substitute the PSB name for “CLI2MCI” in the sample below.
APPLCTN PSB=CLI2MCI,PGMTYPE=(TP,,1),
SCHEDTYP=PARALLEL
TRANSACT CODE=CLI2MCI,SPA=(2000,DASD,FIXED),
MSGTYPE=(SNGLSEG,NONRESPONSE,1),
INQUIRY=(YES,RECOVER),PRTY=(5,11,03),
MODE=SNGL,PROCLIM=(3,3),PARLIM=1,SCHD=3
Although the SPA size of 2000 is specified in this macro, the sample program requires only an 80-byte SPA
and can accept a maximum SPA size of 2048 bytes.
Sample APPLCTN/TRANSACT Macros (Non-
Conversational)
Substitute the PSB name for “CLI2SCI” in the sample below.
APPLCTN PSB=CLI2SCI
TRANSACT CODE=CLI2SCI,PRTY=(7,10,2),
INQUIRY=YES,MODE=SNGL
PSBGEN and DBDGEN Macros
There are no special requirements for PSBGEN or DBDGENs. Prepare the APPLCTN and TRANSACT
macros and perform PSBGEN and DBDGEN to meet the requirements of your application.
If you wish to bypass the specification of APPLCTN and TRANSACT and an IMSGEN for the sample
programs, simply replace any existing conversational program and non-conversational program in PGMLIB
with the sample conversational (CLI2MPI or CLI2MCI) and non-conversational (CLI2SCI) programs.
The preparation of the sample programs is described in Sample IMS Programs.
2: Executing Sample IMS Programs
Teradata® Tools and Utilities IBM IMS Interface for Teradata®
Reference, Release 17.00 13
14. Overview
This topic describes following sample programs:
Sample IMS Programs
Program Name Description
CLI2CTB COBOL subroutine called by the following programs:
• CLI2MCI
• CLI2MCB
• CLI2MPI
• CLI2MPB
CLI2MCI COBOL IMS MPP conversational program (multiple sessions)
CLI2MPI PL/I IMS MPP conversational program (multiple sessions)
CLI2SCI COBOL IMS MPP non-conversational program (single session)
Sample Subroutine (CLI2CTB)
This program is a COBOL subroutine that may be called by both COBOL and PL/I programs to perform the
following functions:
• Connect a Teradata session using the logon string contained in the DBCAREA.
The DBCAREA is actually contained in the working storage (COBOL) or static storage (PL/I) of the
calling program.
The address of the DBCAREA is passed to the called program.
• DROP and CREATE a table into which data rows will be inserted and updated.
• Move error messages and codes to the calling program’s storage.
The messages (IMS) are sent by the calling program to a terminal.
• Disconnect a session before returning to the calling program.
CLI2CTB must be compiled and linked before executing the sample programs CLI2MCI or CLI2MPI. The
JCL for compiling CLI2CTB is described in the next section.
JCL to Compile/Link CLI2CTB
The CLI2CTB module is contained in <dbcpfx>.SAMPLIB.
Sample IMS Programs
3
Teradata® Tools and Utilities IBM IMS Interface for Teradata®
Reference, Release 17.00 14
15. Submit the following JCL to compile the program. Review and modify the JCL to comply with conventions
and standards at your installation.
//jobname JOB (acct-info),MSGCLASS=A,MSGLEVEL=(1,1)
// CLASS=A
//COBOL EXEC COBUCL,REGION=1012K,
// PARM.COB=(LOA,SUP,VS,DMAP,CLIST,LIB,
// APOST,’SIZE=512K,BUF=128K’)
//COB.SYSLIB DD DSN=<dbcpfx>.SAMPLIB,DISP=SHR
//COB.SYSIN DD DSN=<dbcpfx>.SAMPLIB(CLI2CTB),DISP=SHR
//LKED.SYSLMOD DD DSN=<user.linklib>,DISP=SHR
//LKED.SYSLIB DD DSN=<user.linklib>,DISP=SHR
//LKED.SYSIN DD *
// INCLUDE SYSLIB(DBCHSTBB)
// NAME CLI2CTB(R)
/*
//*
This job stream is based on the cataloged procedures listed in Cataloged Procedures Used in Sample
Jobs. If necessary, modify the job stream to make it compatible with the underlying procedure used at your
installation. The source listing for CLI2CTB is in Sample Subroutine (CLI2CTB) Listing.
Multi-Session COBOL/IMS (CLI2MCI)
This program is a COBOL IMS Conversational MPP that demonstrates the use of the DBCHWAT routine to
perform waits on pending requests.
The waits are scheduled by the application program to allow overlap of database and client processing.
The program performs the following functions:
• Calls another program (CLI2CTB) to drop/create a table
• Passes an initialized DBCAREA containing the logon string to the called program
• Connects multiple sessions
• Calls DBCHWAT to wait for available request
• Terminates a request and initiates another request after response parcels have been fetched
• Disconnects sessions when all transactions are processed.
JCL to Compile and Link CLI2MCI
The CLI2MCI source module is contained in <dfcpfx>.SAMPLIB.
Submit the following JCL to compile the program. Review and modify the JCL to comply with conventions
and standards at your installation.
3: Sample IMS Programs
Teradata® Tools and Utilities IBM IMS Interface for Teradata®
Reference, Release 17.00 15
16. //jobname JOB (acct-info),MSGCLASS=A,MSGLEVEL=(1,1)
// CLASS=A
//COBOL EXEC COBUCL,REGION=2048K,
// PARM.COB=(LOA,SUP,VS,DMAP,CLIST,LIB,
// APOST,’SIZE=1048K,BUF=128K’)
//COB.SYSLIB DD DSN=<dbcpfx>.SAMPLIB,DISP=SHR
//COB.SYSIN DD DSN=<dbcpfx>.SAMPLIB(CLI2MCI),DISP=SHR
//LKED.SYSLMOD DD DSN=<user.linklib>,DISP=SHR
//LKED.SYSLIB DD DSN=<user.linklib>,DISP=SHR
// DD DSN=<ims.reslib>,DISP=SHR
//LKED.SYSIN DD *
// INCLUDE SYSLIB(CLI2CTB)
// ENTRY DLITCBL
// NAME CLI2MCI(R)
/*
//*
This job stream is based on the cataloged procedures listed in Cataloged Procedures Used in Sample
Jobs. If necessary, modify the job stream to make it compatible with the underlying procedure used at your
installation. The source program, CLI2MCI, is listed in Multi-Session Cobol/IMS (CLI2MCI) Listing.
Operation of CLI2MCI
This program initiates the following multi-statement request “MAXTRANS” times:
Note:
MAXTRANS is a program constant that specifies the number of transactions to be initiated for each
iteration of the conversation.
USING V1 (INT),V2 (INT),V3 (INT),V4 (INT),V5 (INT)
INSERT INTO MYTABLE2 (F1) VALUES(:V1);
INSERT INTO MYTABLE2 (F1) VALUES(:V2);
INSERT INTO MYTABLE2 (F1) VALUES(:V3);
INSERT INTO MYTABLE2 (F1) VALUES(:V4);
INSERT INTO MYTABLE2 (F1) VALUES(:V5);
UPDATE MYTABLE2 SET F2 = F1+1 WHERE F1=:V1;
UPDATE MYTABLE2 SET F2 = F1+1 WHERE F1=:V2;
UPDATE MYTABLE2 SET F2 = F1+1 WHERE F1=:V3;
UPDATE MYTABLE2 SET F2 = F1+1 WHERE F1=:V4;
UPDATE MYTABLE2 SET F2 = F1+1 WHERE F1=:V5;
Data values are generated by the program. The generated data are the integers 1,2,...N.
3: Sample IMS Programs
Teradata® Tools and Utilities IBM IMS Interface for Teradata®
Reference, Release 17.00 16
17. Each request (transaction) inserts and then updates five rows into MYTABLE2.
The following variables are contained within the program and can be adjusted to reset the total number of
rows or concurrent sessions:
• NUMLOG: Number of parallel sessions which are connected.
• MAXTRANS: Number of times that the transaction is initiated.
This particular compilation set NUMLOG=3 and MAXTRANS=10.
Initiate Transaction
To start the conversational transaction, enter:
<trancode logon-string>
For example:
cli2mci 0/my_userid,my_password
Expected Results
After the first entry, the following is displayed at the terminal:
1 PASS COMPLETED ENTER YES TO CONTINUE OR NO TO END CONVERSATION
If you type “YES” the following message is displayed:
2 PASSES COMPLETED ENTER YES TO CONTINUE OR NO TO END CONVERSATION
This process continues until you type “NO”. Then the following message is displayed and the conversation
is terminated.
TRANSACTION COMPLETED. USE BTEQ/ITEQ TO CHECK RESULTS
The table my_userid.MYTABLE2 contains 50 rows for each “YES” response.
Thus, if “YES” is entered 7 times, then the table my_userid.MYTABLE2 contains 350 rows with the values
1,2,...350 for the field F1 and 2,3,...351 for the field F2.
Use BTEQ (see Basic Teradata® Query Reference, B035-2414), or some other appropriate utility, to
validate the results and drop the table.
Logon String
This program accepts the logon string from the terminal.
3: Sample IMS Programs
Teradata® Tools and Utilities IBM IMS Interface for Teradata®
Reference, Release 17.00 17
18. Multi-Session/PLI/IMS (CLI2MPI)
This program is a PL/I IMS MPP Conversational program that demonstrates the use of the DBCHWAT
routine to perform waits on pending requests.
The waits are scheduled by the application program to allow overlap of database and host processing.
The program performs the following functions:
• Calls another program (CLI2CTB) to drop/create the table userid.MYTABLE
• Passes an initialized DBCAREA containing the logon string to the called program
• Connects multiple sessions
• Calls DBCHWAT to wait for available request
• Terminates a request and initiates another request after response parcels have been fetched
• Disconnects sessions when all transactions are processed.
JCL to Compile/Link CLI2MPI
The CLI2MPI source module is contained in <dbcpfx>.SAMPLIB.
Submit the following JCL to compile the program. Review and modify the JCL to comply with conventions
and standards at your installation.
//jobname JOB (acct-info),MSGCLASS=A,MSGLEVEL=(1,1)
// CLASS=A
//PLI EXEC PLIXCL,
// PARM.PLI=(INCLUDE),
// REGION.LKED-1012K
//PLI.SYSLIB DD DSN=<dbcpfx>.SAMPLIB,DISP=SHR
//PLI.SYSIN DD DSN=<dbcpfx>.SAMPLIB(CLI2MPI),DISP=SHR
//LKED.SYSLMOD DD DSN=<user.linklib>,DISP=SHR
//LKED.SYSLIB DD DSN=<user.linklib>,DISP=SHR
// DD DSN=<ims.reslib>,DISP=SHR
//LKED.SYSIN DD *
// INCLUDE SYSLIB(CLI2CTB)
// ENTRY PLICALLA
// NAME CLI2MPI(R)
/*
//*
This job stream is based on the cataloged procedures listed in Cataloged Procedures Used in Sample
Jobs. If necessary, modify the job stream to make it compatible with the underlying procedure used at your
installation. The Source program CLI2MPI is listed in Multi-Session/PLI/IMS (CLI2MPI) Listing.
3: Sample IMS Programs
Teradata® Tools and Utilities IBM IMS Interface for Teradata®
Reference, Release 17.00 18
19. Operation of CLI2MPI
This program initiates the following multi-statement request “MAXTRANS” times:
USING V1 (INT),V2 (INT),V3 (INT),
V4 (INT),V5 (INT)
INSERT INTO MYTABLE2 (F1) VALUES(:V1);
INSERT INTO MYTABLE2 (F1) VALUES(:V2);
INSERT INTO MYTABLE2 (F1) VALUES(:V3);
INSERT INTO MYTABLE2 (F1) VALUES(:V4);
INSERT INTO MYTABLE2 (F1) VALUES(:V5);
UPDATE MYTABLE2 SET F2 = F1+1 WHERE F1=:V1;
UPDATE MYTABLE2 SET F2 = F1+1 WHERE F1=:V2;
UPDATE MYTABLE2 SET F2 = F1+1 WHERE F1=:V3;
UPDATE MYTABLE2 SET F2 = F1+1 WHERE F1=:V4;
UPDATE MYTABLE2 SET F2 = F1+1 WHERE F1=:V5;
Data values are generated by the program. The generated data values are the integers 1,2,...N.
Each request (transaction) inserts and then updates five rows into MYTABLE2.
The following variables are contained within the program and can be adjusted to reset the total number of
rows or concurrent sessions:
• NUMLOG: Number of parallel sessions which are connected.
• MAXTRANS: Number of times that the transaction is initiated.
This particular compilation sets NUMLOG=3 and MAXTRANS=10.
Initiate Transaction
To start the conversational transaction, enter:
<trancode logon-string>
For example:
cli2mpi 0/my_userid,my_password
Expected Results
After first entry the following is displayed at the terminal:
1 PASS COMPLETED ENTER YES TO CONTINUE OR NO TO END CONVERSATION
If you type YES, then the following message displays:
3: Sample IMS Programs
Teradata® Tools and Utilities IBM IMS Interface for Teradata®
Reference, Release 17.00 19
20. 2 PASSES COMPLETED ENTER YES TO CONTINUE OR NO TO END CONVERSATION
This process continues until you type NO. Then the following message displays and the
conversation terminates.
TRANSACTION COMPLETED. USE BTEQ/ITEQ TO CHECK RESULTS
The table my_userid.MYTABLE2 contains 50 rows for each “YES” response. Thus, if “you enter YES” 7
times, then the table my_userid.MYTABLE2 contains 350 rows with the values 1,2,...350 for the field F1
and 2,3,...351 for the field F2.
Use BTEQ (see Basic Teradata® Query Reference, B035-2414) or some other appropriate utility, to
validate the results and drop the table.
Logon String
This program accepts the logon string from the terminal.
Single-Session/COBOL/IMS (CLI2SCI)
This program is a COBOL IMS MPP non-conversational program that depends on the CLIv2 to implicitly
perform all wait functions.
This program does not call DBCHWAT. Only one database session is used.
The program performs the following functions:
• Drops then creates a table
• Inserts rows into the table
• Updates all rows (single transaction)
• Selects rows from the table
• Displays fetched parcels
• Terminates a request after response parcels are fetched
• Disconnects the session after requests are processed
JCL To Compile/Link CLI2SCI
The CLI2SCI source module is contained in <dfcpfx>.SAMPLIB.
Submit the following JCL to compile the program. Review and modify the JCL to comply with conventions
and standards at your installation.
//jobname JOB (acct-info),MSGCLASS=A,MSGLEVEL=(1,1)
// CLASS=A
//COBOL EXEC COBUCL,REGION=2048K,
// PARM.COB=(LOA,SUP,VS,DMAP,CLIST,LIB,
// APOST,’SIZE=1048K,BUF=128K’)
//COB.SYSLIB DD DSN=<dbcpfx>.SAMPLIB,DISP=SHR
3: Sample IMS Programs
Teradata® Tools and Utilities IBM IMS Interface for Teradata®
Reference, Release 17.00 20
21. //COB.SYSIN DD DSN=<dbcpfx>.SAMPLIB(CLI2SCI),DISP=SHR
//LKED.SYSLMOD DD DSN=<user.linklib>,DISP=SHR
//LKED.SYSLIB DD DSN=<user.linklib>,DISP=SHR
// DD DSN=<ims.reslib>,DISP=SHR
//LKED.SYSIN DD *
// ENTRY DLITCBL
// NAME CLI2SCI(R)
/*
//*
This job stream is based on the cataloged procedures listed in Cataloged Procedures Used in Sample
Jobs. If necessary, modify the job stream to make it compatible with the underlying procedure used at your
installation. The source program CLI2SCI is listed in Single-Session/COBOL/IMS (CLI2SCI) Listing.
Operation of CLI2SCI
This program initiates the following set of requests in sequence.
Each request is a separate transaction.
1. DROP TABLE T;
2. CREATE TABLE T (I INT,I2 SMALLINT);
3. USING V (INTEGER),V2(SMALLINT)INS INTO T VALUES(:V,:V2);
4. UPDATE T SET I2 = I + 1;
5. SEL SUM(I) FROM T;
Data values are generated by the program. The data generated for the INSERT statement are the integers
1,2,...MAXROWS for the fields I and I2 (equal values are inserted for the fields I and I2). MAXROWS can
be adjusted to set the total number of rows inserted.
Terminal Interface
To start the IMS non-conversational transaction, enter:
<trancode logon string>
For example:
cli2sci my_userid,my_password
Expected Results
The INSERT statement inserts MAXROWS (100 in this example) rows using the USING modifier, INSERT
statement and data generated by the program.
3: Sample IMS Programs
Teradata® Tools and Utilities IBM IMS Interface for Teradata®
Reference, Release 17.00 21
22. The UPDATE statement changes I2 to be one greater than the field I.
The SELECT statement selects the sum of I (that is, 5050).
When a record-type parcel is received, the program displays:
SUM OF FIELD I = 5050
at the IMS terminal.
The table MY_USERID.T will contain 100 rows. Field I will contain the values 1,2,...100 and the field I2 will
contain the values 2,3,...101.
Use BTEQ (see Basic Teradata® Query Reference, B035-2414) or some other appropriate utility, to
validate the results and drop the table.
Logon String
This program accepts the logon string from the terminal.
3: Sample IMS Programs
Teradata® Tools and Utilities IBM IMS Interface for Teradata®
Reference, Release 17.00 22
23. Overview
The annotations in the following sections apply directly to the sample program CLI2MCI (COBOL IMS/MPP
Conversational program).
The source listing for the sample program is contained in Multi-Session Cobol/IMS (CLI2MCI) Listing.
Notes to CLI2Mxx Program Listings
Although CLI2MCI is the only annotated listing, the notes can also be used to review CLI2MPI, a direct PL/I
counterpart of CLI2MCI.
CLI2Mxx Annotated Listing
Note Annotation
1 NUMLOG is a program constant which specifies the number of sessions to be connected.
2 MAXTRANS is a program constant that specifies the number of transactions to be initiated for each
iteration of the conversation.
3 COBOL programs must specify Move Mode Fetch.
The response buffer size must be specified when in move mode.
Paragraph DBCAREA-SETUP indicates move mode by setting DBCAREA-LOC-MODE to N and
DBCAREA-FET-I-MAX-DATA-LEN to the response buffer size.
4 The IMS SPA area is used to retain the logon string and data values across iterations of
the conversation.
The iteration count is also maintained in the SPA.
5 The Teradata SQL request in this example consists of multiple statements per request.
Thus, each transaction consists of five insert and five update statements which must complete as a
group (that is, all or none).
MAXTRANS such transactions are initiated for each iteration of the program.
6 Since a USING modifier precedes the request, data must by supplied by the program.
In this case the data is described as five integer values which are initially set to 1,2,3,4,5.
7 Use the standard DBCAREA COPY member DBCAREAC in COBOL application programs, and
the standard COBOL COPY member CLIPARMC in COBOL programs to define various CLI and
parcel constants.
8 A variable length data item VARMSG is used to handle the variable length messages returned by
failure and error parcels.
9 TOKEN-ARRAY is the structure used to hold values related to each session.
Annotated Listings
4
Teradata® Tools and Utilities IBM IMS Interface for Teradata®
Reference, Release 17.00 23
24. Note Annotation
This program is designed to use only one copy of a DBCAREA.
Values related to a particular session are indexed by a TOKEN which is specified by the program
when a session is connected.
This TOKEN is retained by CLI2 at CONNECT time and returned to the program after a call
to DBCHWAT.
The program can then use the returned TOKEN as an index to obtain values from the TOKEN-
ARRAY and store into the DBCAREA, or to obtain values from the DBCAREA and store into
the TOKEN-ARRAY.
10 The IMS sample programs reference only the IO/PCB. Your application program can define any
number of PCBs.
11 This conversational program is designed to process messages until the PROCLIM value is exceeded
or until no message is available (that is, status = QC).
The transaction can be scheduled to execute in any number of MPP regions with
SCHDTYP=PARALLEL or SERIAL.
12 The CLI2 related functions are performed in the paragraphs (procedure for PL/I programs) starting
with INSERT-ROWS.
The remaining paragraphs handle the IMS related functions which deal with ISRTing the response
message, ISRTing the SPA, and then asking for more work (messages).
13 ISRT “Transaction Completed” message.
14 ISRT “Enter YES or NO” message.
If YES is entered, the program retrieves the data values of the previous iteration from the SPA and
continues to generate (insert/update) more rows into the table.
If NO is entered, the program terminates the conversation by storing blanks in the TRANCODE field
of the SPA, ISRTing the message and ISRTing the SPA.
15 Whenever the application program is entered, it must perform the initialization function (that is, call
DBCHINI).
This is true for programs designed to process either non-conversational or
conversational transactions.
DBCHINI must be called on every iteration of a conversation. Use session pooling (see Teradata®
Director Program Reference, B035-2416 for more information) to avoid actual database logons for
each transaction.
Note that DBCHINI will verify the length value stored in DBCAREA and then CLEAR the DBCAREA
to binary zeros.
The EYE-CATCHER field will then be set by DBCHINI. Thus, the VALUE (COBOL) and INIT
(PL/I) clauses which are specified in the program (or in the COPY/INCLUDE members) have
no significance.
16 Set the address of the LOGON string into the DBCAREA field DBCAREA-LOGON-PTR.
Note that this program identifies DBCAREA fields with the prefix DBC.
The recommended method is to use the standard DBCAREA definitions (that is, COPY DBCAREAC
for COBOL programs or %INCLUDE DBCAREAP for PL/I programs). DBCAREAC identifies
DBCAREA fields with names that begin with “DBCAREA-”.
DBCAREAP declares PL/I variables without using “DBCAREA” as part of the name.
The qualifier “DBCAREA.” can be used to identify DBCAREA variables in a PL/I program.
Note that DBCHSAD is called by COBOL programs to store address type values in DBCAREA.
4: Annotated Listings
Teradata® Tools and Utilities IBM IMS Interface for Teradata®
Reference, Release 17.00 24
25. Note Annotation
PL/I uses the ADDR function to store addresses.
17 On the first entry of the conversation, this particular program calls an external subroutine (CLI2CTB)
to DROP and then CREATE a table (MYTABLE2).
Note that the logon string is stored in the DBCAREA prior to the call.
The subroutine is passed the address of the DBCAREA (contained in the calling program’s storage
area), and the address of another area, MSG-INFO, used to pass error/failure indicators and
messages between the programs.
The calling program performs all IMS message handling.
The called program CLI2CTB is a COBOL program which is called by the COBOL sample programs
(CLI2MCB and CLI2MCI) and the PL/I sample programs (CLI2MPB and CLI2MPI).
18 On return from the sub program, the MSG-INFO area is checked for indications of error/failure during
the CREATE TABLE process.
19 Also, only on first entry, the generated data values are initialized.
An application program would, for example, position to the database segment containing the first
segment to be processed.
20 Connect the number of concurrent sessions required by the program.
This program connects ALL of the sessions (call DBCHCL after setting the CONNECT-FUNC
function code in the DBCAREA) prior to executing a call to DBCHCL to FETCH the response parcels
(a successful CONNECT results in no parcels being returned); a CLI EOF code will be returned for
the FETCH call.
21 The WAIT-FETCH-IRQ paragraph/procedure is performed/called to perform the following sequence.
WAIT for a request to complete.
FETCH and process each response parcel.
If FETCH-EOF, then end (close) the request and initiate a new request.
If BUSY, go back to WAIT. Note that the first attempt to fetch a response after CONNECT will always
produce a BUSY CLI code (or failure), even after waiting (call to DBCHWAT).
This is explained as follows: The CONNECT process is a two-step process, LOGON and RUN.
The first return from wait indicates that the logon has completed.
The attempt to fetch, however, will return an indication that the session is busy (processing the RUN
request).
This sequence may change in a future release.
An application program which is written to return to WAIT after a BUSY return code should be
compatible with a future change which combines the LOGON/RUN into a single request.
When there is no more work (rows to be inserted in this example), the session whose TOKEN was
returned by DBCHWAT will be disconnected by the application program.
The program will then WAIT again for the next available session (which will also be disconnected
because of lack of work).
When all sessions have been disconnected, the processing is terminated.
22 Wait for session not pending.
23 Use TOKEN returned by DBCHWAT as an index into TOKEN-ARRAY.
24 Move the related logical session id and request id to the DBCAREA in preparation for FETCH calls.
25 FETCH and process parcels until EOF or BUSY or CRASH codes.
4: Annotated Listings
Teradata® Tools and Utilities IBM IMS Interface for Teradata®
Reference, Release 17.00 25
26. Note Annotation
26 If EOF and last function was LOGON (really CONNECT), then save the actual (not logical) TDP
session id (TDPSESS) in the related element of TOKEN-ARRAY.
Note that the only time that a valid TDPSESS value will be available is after the FETCH-EOF which
occurs after the CONNECT function.
27 End the request (call DBCHCL with END-REQUEST-FUNC) after FETCH-EOF.
If the end request call is not made after FETCH-EOF.
The control blocks maintained by CLI2 will accumulate and unnecessarily consume storage.
A large number of unended requests may result in the abnormal termination of the program.
28 If more transactions need to be processed, perform the INITIATE-REQ-FUNC function.
29 ELSE disconnect the session and reduce the session counter.
30 The following values are initialized in the DBCAREA:
• Set address of the DBC/SQL request (a multi- statement request in this example).
• Set length of the request.
• Set address of Using data.
• This is the data that will be used to INSERT/UPDATE rows in the table.
• Set length of data.
• Since the data consists of 5 full word integers, the total data length is 20 bytes.
• Set address of the area into which FETCHed parcels will be stored when in Move Mode.
This address is required to be set by all COBOL programs. PL/I programs can operate in Locate
Mode, and consequently, instead of providing an address to CLI2, an address will be provided
by CLI2.
31 The size of the parcel area is also required to be set by COBOL program.
32 Setting the “maximum number of sessions” is not mandatory but will assist CLI2 in its space
management functions.
33 Setting Locate Mode to N (NO) is required for COBOL program.
34 Set N value for Wait For Response if your program is designed to manage multiple sessions with
overlap of DBC and host processing.
Programs which do not call DBCHWAT should use the default value Y (yes, wait for response).
35 This program set N for crash-wait. CLI2 will not wait for completion of the DBC crash recovery
process and the DBC session will terminate.
36 This program set Y for crash-tell.
CLI2 will indicate that a crash has occurred.
However, since the Crash Wait option was set to N the program cannot prompt the user to determine
if he/she wants to wait on database recovery.
A better combination for an interactive program is the default set of Y Y.
If the user does not wish to wait, then the session can be aborted by the program.
37 The Change option must be set to Y to trigger the changing of the options.
4: Annotated Listings
Teradata® Tools and Utilities IBM IMS Interface for Teradata®
Reference, Release 17.00 26
27. CLI2MCI Program Listing
IDENTIFICATION DIVISION.
PROGRAM-ID. CLI2MCI.
AUTHOR. J LAHOOD.
INSTALLATION. TDAT.
REMARKS. THIS PROGRAM PROVIDES AN EXAMPLE OF HOW THE CLI2
* INTERFACE CAN BE USED TO PERFORM THE FOLLOWING FUNCTIONS:
*
* -- CALL ANOTHER PROGRAM TO DROP/CREATE A TABLE. AN
* INITIALIZED DBCAREA CONTAINING THE LOGON STRING
* IS PASSED TO THE CALLED PROGRAM. THE CALLED
* PROGRAMWILL CONNECT AND DISCONNECT A SINGLE
* SESSION.
*
* -- CONNECT MULTIPLE SESSIONS.
*
* -- CALL “DBCHWAT” TO WAIT ON AVAILABLE REQUEST (NO
* IMPLICIT WAITS BY CLI2).
*
* -- TERMINATE A REQUEST AND INITIATE ANOTHER REQUEST
* AFTER RESPONSE PARCELS HAVE BEEN FETCHED.
*
* -- THE INITIATED REQUEST IS A MULTI-STATEMENT
* REQUEST CONTAINING FIVE INSERT AND FIVE UPDATES
* STATEMENTS (ONE TRANSACTION).
*
* -- DISCONNECT SESSIONS WHEN ALL TRANSACTIONS HAVE
* BEEN PROCESSED.
*
* NOTE: THIS VERSION OF THE SAMPLE PROGRAM IS DESIGNED
* TO EXECUTE AS AN IMS MPP CONVERSATIONAL PROGRAM.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SOURCE-COMPUTER. IBM-370.
OBJECT-COMPUTER. IBM-370.
INPUT-OUTPUT SECTION.
DATA DIVISION.
Multi-Session Cobol/IMS (CLI2MCI) Listing
A
Teradata® Tools and Utilities IBM IMS Interface for Teradata®
Reference, Release 17.00 27
28. WORKING-STORAGE SECTION.
******************************************************
* DATA DEFINITIONS *
* *
******************************************************
* DL/I CALL FUNCTIONS
*
77 GU-FUNC PIC X(4) VALUE ’GU ’.
77 GN-FUNC PIC X(4) VALUE ’GN ’.
77 ISRT-FUNC PIC X(4) VALUE ’ISRT’.
* CONSTANTS.
* FUNCTION TYPE TO BE INCLUDED IN ERROR MESSAGES.
77 TYPE-FUNC PIC X(8) VALUE SPACES.
* NUMBER OF SESSIONS TO BE CONNECTED
(1) 77 NUMLOG PIC 9999 COMP VALUE IS 3.
* CURRENT NUMBER OF SESSIONS.
77 NUMBER-OF-SESSIONS PIC 9999 VALUE IS 0 COMP.
* NUMBER OF INSERT/UPDATE TRANSACTIONS PER ITERATION
(2) 77 MAXTRANS PIC S9(9) COMP VALUE IS +10.
* TRANSACTION COUNTER
77 TRANS-COUNT PIC S9(9) COMP VALUE IS +0.
* MAXIMUM RESPONSE BUFFER SIZE FOR FETCHING
* (MUST BE SPECIFIED WHEN IN MOVE MODE).
(3) 77 RESPBUF-SIZE PIC S9(9) COMP VALUE IS +4096.
* WORD USED IN MESSAGE (SINGULAR/PLURAL FORM).
77 PASS-TYPE PIC X(7) VALUE SPACES.
77 PASS-FIL PIC X(1) VALUE SPACES.
* LOGON STRING -- FROM IMS INPUT MESSAGE (FIRST PASS).
77 LOGON-STRING PIC X(40) VALUE SPACES.
*77 LOGON-STRING PIC X(40) VALUE ’0/LAHOOD,J’.
* LENGTH OF LOGON STRING
77 LOGON-LEN PIC 9(9) VALUE IS 30 COMP.
* LENGTH OF VARIABLE LENGTH MESSAGES (OCCURS BY)
77 TEXT-LEN PIC 9999 COMP VALUE IS 0.
* RUNNING COUNT OF LOGGED ON SESSIONS
77 LOGID PIC 9999 COMP VALUE IS 1.
* SESSION ID RETURNED BY DBCHWAT
77 WAIT-SESSID PIC S9(9) VALUE +0 COMP.
* TOKEN RETURNED BY DBCHWAT
77 WAIT-TOKEN PIC S9(9) VALUE +0 COMP.
77 BUSY-CODE PIC S9(9) VALUE +150 COMP.
77 EOF-CODE PIC S9(9) VALUE +33 COMP.
77 CRASH-CODE PIC S9(9) VALUE +286 COMP.
01 PASS-COUNT-DISP PIC ZZ9 .
A: Multi-Session Cobol/IMS (CLI2MCI) Listing
Teradata® Tools and Utilities IBM IMS Interface for Teradata®
Reference, Release 17.00 28
29. ******************************************************
*
*
* SCRATCH PAD AREA LAYOUT
*
(4) 01 SPA.
02 FILLER PIC X(6).
02 SPA-TRANCODE PIC X(8).
02 PASS-COUNT PIC S9(3) COMP.
88 FIRST-TIME VALUE +0.
02 NEXT-DATA-VALUES.
03 DATA1 PIC S9(9) COMP.
03 DATA2 PIC S9(9) COMP.
03 DATA3 PIC S9(9) COMP.
03 DATA4 PIC S9(9) COMP.
03 DATA5 PIC S9(9) COMP.
02 LOGON-STRING-SPA PIC X(40).
02 FILLER PIC X(2048).
01 INSERT-MORE-SW PIC X(1) VALUE ’Y’.
88 INSERT-MORE VALUE ’Y’.
01 INSERT-OK-SW PIC X(4) VALUE ’YES ’.
88 INSERT-OK VALUE ’YES ’.
* INPUT MESSAGE AREA
01 INPUT-MESSAGE.
02 IN-LL1 PIC S9(3) COMP.
02 IN-ZZ1 PIC S9(3) COMP.
02 IN-TEXT PIC X(30) VALUE SPACES.
02 FILLER PIC X(132).
*
*
* OUTPUT MESSAGE AREA
*
01 OUTPUT-MESSAGE.
02 OUT-LL PIC S9(3) COMP VALUE +79.
02 OUT-ZZ PIC S9(3) COMP VALUE +0.
02 OUT-TEXT PIC X(132) VALUE SPACES.
*
************************************************************
* REQUEST TO BE EXECUTED.
(5) 01 MULTI-STMT-REQS.
05 FILL1 PIC X(50) VALUE IS
’USING V1 (INTEGER),V2 (INTEGER),V3 (INTEGER), ’.
05 FILL1 PIC X(50) VALUE IS
’ V4 (INTEGER),V5 (INTEGER) ’.
A: Multi-Session Cobol/IMS (CLI2MCI) Listing
Teradata® Tools and Utilities IBM IMS Interface for Teradata®
Reference, Release 17.00 29
30. 05 FILL2 PIC X(50) VALUE IS
’INSERT INTO MYTABLE2 (F1) VALUES(:V1); ’.
05 FILL3 PIC X(50) VALUE IS
’INSERT INTO MYTABLE2 (F1) VALUES(:V2); ’.
05 FILL4 PIC X(50) VALUE IS
’INSERT INTO MYTABLE2 (F1) VALUES(:V3); ’.
05 FILL5 PIC X(50) VALUE IS
’INSERT INTO MYTABLE2 (F1) VALUES(:V4); ’.
05 FILL6 PIC X(50) VALUE IS
’INSERT INTO MYTABLE2 (F1) VALUES(:V5); ’.
05 FILL7 PIC X(50) VALUE IS
’UPDATE MYTABLE2 SET F2 = F1+1 WHERE F1=:V1; ’.
05 FILL8 PIC X(50) VALUE IS
’UPDATE MYTABLE2 SET F2 = F1+1 WHERE F1=:V2; ’.
05 FILL9 PIC X(50) VALUE IS
’UPDATE MYTABLE2 SET F2 = F1+1 WHERE F1=:V3; ’.
05 FILL10 PIC X(50) VALUE IS
’UPDATE MYTABLE2 SET F2 = F1+1 WHERE F1=:V4; ’.
05 FILL11 PIC X(50) VALUE IS
’UPDATE MYTABLE2 SET F2 = F1+1 WHERE F1=:V5; ’.
01 MULTI-STMT-REQ REDEFINES MULTI-STMT-REQS.
05 ENTIRE-REQUEST PIC X(600).
* LENGTH OF REQUEST.
01 MULT-STMT-LEN PIC 9(9) VALUE IS 600 COMP.
(6) 01 DATA-FOR-INSERT-UPDATE.
05 DATA1 PIC S9(9) COMP VALUE IS +1.
05 DATA2 PIC S9(9) COMP VALUE IS +2.
05 DATA3 PIC S9(9) COMP VALUE IS +3.
05 DATA4 PIC S9(9) COMP VALUE IS +4.
05 DATA5 PIC S9(9) COMP VALUE IS +5.
01 DATA-LEN PIC 9(9) VALUE IS 20 COMP.
01 DBCAREA.
(7) COPY DBCAREAC.
* CLI REQUIRED PARAMETERS
01 CLI-RETURN-CODE PIC S9(9) VALUE +0 COMP.
01 CLI-RC-DISPLAY PIC S9(9) SIGN IS LEADING SEPARATE.
01 DBCAREA-FUNC-ID-DISPLAY PIC S9(9) SIGN IS LEADING SEPARATE.
01 CONTEXT-PTR PIC S9(9) VALUE +0 COMP.
* DBC FUNCTION CODES
01 FUNCTIONS.
05 CONNECT-FUNC PIC S9(9) VALUE +1 COMP.
05 DISCONNECT-FUNC PIC S9(9) VALUE +2 COMP.
05 RUN-STARTUP-FUNC PIC S9(9) VALUE +3 COMP.
05 INITIATE-REQ-FUNC PIC S9(9) VALUE +4 COMP.
A: Multi-Session Cobol/IMS (CLI2MCI) Listing
Teradata® Tools and Utilities IBM IMS Interface for Teradata®
Reference, Release 17.00 30
31. 05 FETCH-FUNC PIC S9(9) VALUE +5 COMP.
05 REWIND-FUNC PIC S9(9) VALUE +6 COMP.
05 ABORT-FUNC PIC S9(9) VALUE +7 COMP.
05 END-REQUEST-FUNC PIC S9(9) VALUE +8 COMP.
* COMMON PARCEL FLAVORS
01 FLAVOR.
05 SUCCESS-TYPE PIC S9(9) VALUE +8 COMP.
05 FAILURE-TYPE PIC S9(9) VALUE +9 COMP.
05 RECORD-TYPE PIC S9(9) VALUE +10 COMP.
05 END-STATEMENT-TYPE PIC S9(9) VALUE +11 COMP.
05 END-REQUEST-TYPE PIC S9(9) VALUE +12 COMP.
05 ERROR-TYPE PIC S9(9) VALUE +49 COMP.
05 DATA-INFO-TYPE PIC S9(9) VALUE +71 COMP.
* PARCEL WORK AREA FOR MOVE MODE PARCEL FETCHES
01 PARCEL PIC X(4096) VALUE LOW-VALUES.
* SUCCESS PARCEL (RELEASE 3.0 AND LATER)
01 SUCCESS-PCL REDEFINES PARCEL.
05 STATEMENT-NO PIC S9(4) COMP.
05 ACTIVITY-COUNT PIC S9(9) COMP.
05 WARNING-CODE PIC S9(4) COMP.
05 FIELD-COUNT PIC S9(4) COMP.
05 ACTIVITY-TYPE PIC S9(4) COMP.
05 WARNING-LEN PIC S9(4) COMP.
05 WARNING-MSG PIC X(256).
* FAILURE PARCEL
01 FAILURE-PCL REDEFINES PARCEL.
05 STATEMENT-NO PIC S9(4) COMP.
05 INFO PIC S9(4) COMP.
05 FAILURE-CODE PIC S9(4) COMP.
05 FAILURE-LEN PIC S9(4) COMP.
05 FAILURE-MSG PIC X(256).
* ERROR PARCEL
01 ERROR-PCL REDEFINES PARCEL.
05 STATEMENT-NO PIC S9(4) COMP.
05 INFO PIC S9(4) COMP.
05 ERROR-CODE PIC S9(4) COMP.
05 ERROR-LEN PIC S9(4) COMP.
05 ERROR-MSG PIC X(256).
(8) 01 VARMSG.
10 VTEXT OCCURS 1 TO 256 TIMES DEPENDING ON TEXT-LEN.
15 TEXT-DUM PIC X.
(9) 01 TOKEN-ARRAY.
05 SESSION-DESCRIPT OCCURS 100 TIMES
INDEXED BY TOKEN-INDEX.
A: Multi-Session Cobol/IMS (CLI2MCI) Listing
Teradata® Tools and Utilities IBM IMS Interface for Teradata®
Reference, Release 17.00 31
33. ELSE
STRING SPA-TRANCODE,
(13) ’ TRANSACTION COMPLETED. USE BTEQ/ITEQ TO CHECK RESULTS.’
DELIMITED BY SIZE INTO OUT-TEXT
MOVE ’NO ’ TO INSERT-OK-SW
MOVE SPACES TO SPA-TRANCODE
PERFORM ISRT-MSG.
IF INSERT-OK THEN
ADD +1 TO PASS-COUNT
MOVE PASS-COUNT TO PASS-COUNT-DISP
PERFORM SET-PASS-TYPE
STRING
PASS-COUNT-DISP, PASS-TYPE, ’ COMPLETED. ’,
(14) ’ENTER YES TO CONTINUE OR NO TO END CONVERSATION.’
DELIMITED BY SIZE INTO OUT-TEXT
PERFORM ISRT-MSG.
PERFORM ISRT-SPA.
PERFORM READ-SPA.
READ-SPA.
CALL ’CBLTDLI’ USING GU-FUNC, IOPCB, SPA.
IF IOPCB-STATUS = SPACES OR ’QC’
THEN NEXT SENTENCE
ELSE
MOVE ’GU-SPA’ TO TYPE-FUNC
PERFORM STATUS-ERROR.
*
*
*
READ1.
MOVE SPACES TO IN-TEXT.
CALL ’CBLTDLI’ USING GN-FUNC, IOPCB, INPUT-MESSAGE.
IF IOPCB-STATUS NOT = SPACES
MOVE ’GN 1’ TO TYPE-FUNC
PERFORM STATUS-ERROR.
MOVE IN-TEXT TO LOGON-STRING.
MOVE SPACES TO LOGON-STRING-SPA.
MOVE IN-TEXT TO LOGON-STRING-SPA.
MOVE ’Y’ TO INSERT-MORE-SW.
MOVE ’YES ’ TO INSERT-OK-SW.
*
*
READ2.
CALL ’CBLTDLI’ USING GN-FUNC, IOPCB, INPUT-MESSAGE.
IF IOPCB-STATUS NOT = SPACES
A: Multi-Session Cobol/IMS (CLI2MCI) Listing
Teradata® Tools and Utilities IBM IMS Interface for Teradata®
Reference, Release 17.00 33
34. MOVE ’GN 2’ TO TYPE-FUNC
PERFORM STATUS-ERROR.
MOVE LOGON-STRING-SPA TO LOGON-STRING.
MOVE IN-TEXT TO INSERT-MORE-SW.
MOVE ’YES ’ TO INSERT-OK-SW.
*
*
ISRT-SPA.
CALL ’CBLTDLI’ USING ISRT-FUNC, IOPCB, SPA.
IF IOPCB-STATUS NOT = SPACES
MOVE ’ISRT-SPA’ TO TYPE-FUNC
PERFORM STATUS-ERROR.
*
*
ISRT-MSG.
CALL ’CBLTDLI’ USING ISRT-FUNC, IOPCB, OUTPUT-MESSAGE.
IF IOPCB-STATUS NOT = SPACES
MOVE ’ISRT-MSG’ TO TYPE-FUNC
PERFORM STATUS-ERROR.
MOVE SPACES TO OUT-TEXT.
STATUS-ERROR.
STRING ’BAD IOPCB-STATUS -- FUNCTION = ’, TYPE-FUNC
DELIMITED BY SIZE INTO OUT-TEXT.
DISPLAY OUT-TEXT UPON CONSOLE.
GOBACK.
EJECT
SET-PASS-TYPE.
IF PASS-COUNT = 1
MOVE ’ PASS’ TO PASS-TYPE
ELSE
MOVE ’ PASSES’ TO PASS-TYPE.
******************************************************
INSERT-ROWS.
(15) PERFORM DBC-INIT.
* SET UP POINTER TO LOGON STRING
(16) CALL ’DBCHSAD’ USING CLI-RETURN-CODE,
DBCAREA-LOGON-PTR, LOGON-STRING.
* SET UP LENGTH OF LOGON STRING
MOVE LOGON-LEN TO DBCAREA-LOGON-LEN.
* ON FIRST PASS ONLY:
* CALL A PROGRAM TO DROP THEN CREATE THE TABLE “MYTABLE2".
IF FIRST-TIME
(17) CALL ’CLI2CTB’ USING DBCAREA, MSG-INFO
(18) PERFORM CHECK-CALL
A: Multi-Session Cobol/IMS (CLI2MCI) Listing
Teradata® Tools and Utilities IBM IMS Interface for Teradata®
Reference, Release 17.00 34
35. (19) MOVE +1 TO DATA1 OF DATA-FOR-INSERT-UPDATE
MOVE +2 TO DATA2 OF DATA-FOR-INSERT-UPDATE
MOVE +3 TO DATA3 OF DATA-FOR-INSERT-UPDATE
MOVE +4 TO DATA4 OF DATA-FOR-INSERT-UPDATE
MOVE +5 TO DATA5 OF DATA-FOR-INSERT-UPDATE
ELSE
MOVE CORRESPONDING NEXT-DATA-VALUES OF SPA
TO DATA-FOR-INSERT-UPDATE.
PERFORM DBCAREA-SETUP.
MOVE ZERO TO NUMBER-OF-SESSIONS.
MOVE ZERO TO TRANS-COUNT.
(20) PERFORM CLI-CONNECT VARYING LOGID FROM 1 BY 1
UNTIL LOGID GREATER NUMLOG.
(21) PERFORM WAIT-FETCH-IRQ UNTIL NUMBER-OF-SESSIONS = ZERO.
MOVE CORRESPONDING DATA-FOR-INSERT-UPDATE
TO NEXT-DATA-VALUES OF SPA.
INSERT-ROWS-EXIT.
EXIT.
* CHECK CODES AND MESSAGES FROM CALLED PROGRAM.
CHECK-CALL.
IF MSG-INFO-RC NOT = ZERO
MOVE MSG-INFO-FUNC TO DBCAREA-FUNC-ID
MOVE MSG-INFO-RC TO CLI-RETURN-CODE
MOVE MSG-INFO-CLI-MSG TO DBCAREA-MSG-TEXT
PERFORM DISP-ERROR
ELSE
IF MSG-INFO-LEN NOT = ZERO
MOVE MSG-INFO-LEN TO TEXT-LEN
MOVE MSG-INFO-TEXT TO VARMSG
STRING VARMSG
DELIMITED BY SIZE INTO OUT-TEXT
PERFORM END-TRANS.
END-TRANS.
PERFORM ISRT-MSG.
MOVE SPACES TO SPA-TRANCODE.
MOVE ’NO ’ TO INSERT-OK-SW.
GO TO INSERT-ROWS-EXIT.
*********** WAIT FOR AVAILABLE REQUEST. **********
*********** USE TOKEN FROM WAIT AS INDEX TO **********
*********** OBTAIN SESSID AND REQID. **********
*********** FETCH PARCELS -- **********
*********** WHEN EOF,INITIATE INSERT REQUEST. **********
WAIT-FETCH-IRQ.
MOVE BUSY-CODE TO CLI-RETURN-CODE.
A: Multi-Session Cobol/IMS (CLI2MCI) Listing
Teradata® Tools and Utilities IBM IMS Interface for Teradata®
Reference, Release 17.00 35
36. (22) PERFORM CLI-WAIT UNTIL
CLI-RETURN-CODE NOT = BUSY-CODE AND
CLI-RETURN-CODE NOT = CRASH-CODE.
(23) SET TOKEN-INDEX TO WAIT-TOKEN.
(24) MOVE SESSID(TOKEN-INDEX) TO DBCAREA-I-SESS-ID.
MOVE REQID(TOKEN-INDEX) TO DBCAREA-I-REQ-ID.
(25) PERFORM CLI-FETCH-PARCELS UNTIL CLI-RETURN-CODE = EOF-CODE
OR CLI-RETURN-CODE = BUSY-CODE
OR CLI-RETURN-CODE = CRASH-CODE.
IF CLI-RETURN-CODE = EOF-CODE AND
(26) LAST-FUNCTION(TOKEN-INDEX) = ’LOGON’
MOVE DBCAREA-O-SESS-ID TO TDPSESS(TOKEN-INDEX).
IF CLI-RETURN-CODE = EOF-CODE THEN
(27) PERFORM CLI-END-REQUEST
IF TRANS-COUNT < MAXTRANS
(28) PERFORM IRQ-CALL
ELSE
PERFORM CLI-DISCONNECT
(29) SUBTRACT 1 FROM NUMBER-OF-SESSIONS.
***************************************************
******** WAIT FOR AVAILABLE REQUEST ************
CLI-WAIT.
* WAIT THEN SET UP DBCAREA IDS
CALL ’DBCHWAT’ USING CLI-RETURN-CODE, CONTEXT-PTR,
WAIT-SESSID, WAIT-TOKEN.
IF CLI-RETURN-CODE NOT = 0
MOVE CLI-RETURN-CODE TO CLI-RC-DISPLAY
STRING ’WAIT ERROR, RETURN CODE = ’, CLI-RC-DISPLAY
DELIMITED BY SIZE INTO OUT-TEXT
PERFORM ISRT-MSG
STRING DBCAREA-MSG-TEXT
DELIMITED BY SIZE INTO OUT-TEXT
PERFORM END-TRANS.
MOVE SESSID(TOKEN-INDEX) TO DBCAREA-I-SESS-ID.
MOVE REQID(TOKEN-INDEX) TO DBCAREA-I-REQ-ID.
***************************************************
********* FETCH PARCELS **********
CLI-FETCH-PARCELS.
MOVE FETCH-FUNC TO DBCAREA-FUNC-ID.
CALL ’DBCHCL’ USING CLI-RETURN-CODE, CONTEXT-PTR, DBCAREA.
IF CLI-RETURN-CODE NOT = EOF-CODE AND
CLI-RETURN-CODE NOT = BUSY-CODE AND
CLI-RETURN-CODE NOT = CRASH-CODE
PERFORM DISPLAY-PARCEL.
A: Multi-Session Cobol/IMS (CLI2MCI) Listing
Teradata® Tools and Utilities IBM IMS Interface for Teradata®
Reference, Release 17.00 36
37. ***************************************************
*********** INITIATE INSERT REQUEST ********
IRQ-CALL.
MOVE SESSID(TOKEN-INDEX) TO DBCAREA-I-SESS-ID.
MOVE TOKEN(TOKEN-INDEX) TO DBCAREA-TOKEN.
MOVE INITIATE-REQ-FUNC TO DBCAREA-FUNC-ID.
CALL ’DBCHCL’ USING CLI-RETURN-CODE, CONTEXT-PTR, DBCAREA.
IF CLI-RETURN-CODE = ZERO
MOVE ’INSERT’ TO LAST-FUNCTION(TOKEN-INDEX)
MOVE DBCAREA-O-REQ-ID TO REQID(TOKEN-INDEX)
MOVE DBC-TDP-REQNO TO TDPREQID(TOKEN-INDEX)
ADD +1 TO TRANS-COUNT.
ADD +5 TO DATA1 OF DATA-FOR-INSERT-UPDATE,
DATA2 OF DATA-FOR-INSERT-UPDATE,
DATA3 OF DATA-FOR-INSERT-UPDATE,
DATA4 OF DATA-FOR-INSERT-UPDATE,
DATA5 OF DATA-FOR-INSERT-UPDATE.
***************************************************
******** TERMINATE REQUEST **********
CLI-END-REQUEST.
MOVE END-REQUEST-FUNC TO DBCAREA-FUNC-ID.
CALL ’DBCHCL’ USING CLI-RETURN-CODE, CONTEXT-PTR, DBCAREA.
IF CLI-RETURN-CODE NOT = 0
PERFORM DISP-ERROR.
***************************************************
*********** DISCONNECT SESSION **********
CLI-DISCONNECT.
MOVE DISCONNECT-FUNC TO DBCAREA-FUNC-ID.
CALL ’DBCHCL’ USING CLI-RETURN-CODE, CONTEXT-PTR, DBCAREA.
IF CLI-RETURN-CODE NOT = 0
PERFORM DISP-ERROR.
***************************************************
*********** DISPLAY PARCEL **********
DISPLAY-PARCEL.
IF DBCAREA-FET-PARCEL-FLAVOR = ERROR-TYPE
STRING ’ERROR PARCEL RECEIVED ’
DELIMITED BY SIZE INTO OUT-TEXT
PERFORM ISRT-MSG
MOVE ERROR-LEN TO TEXT-LEN
MOVE ERROR-MSG TO VARMSG
STRING VARMSG
DELIMITED BY SIZE INTO OUT-TEXT
PERFORM END-TRANS
ELSE
A: Multi-Session Cobol/IMS (CLI2MCI) Listing
Teradata® Tools and Utilities IBM IMS Interface for Teradata®
Reference, Release 17.00 37
38. IF DBCAREA-FET-PARCEL-FLAVOR = FAILURE-TYPE
STRING ’FAILURE PARCEL RECEIVED ’
DELIMITED BY SIZE INTO OUT-TEXT
PERFORM ISRT-MSG
MOVE FAILURE-LEN TO TEXT-LEN
MOVE FAILURE-MSG TO VARMSG
STRING VARMSG
DELIMITED BY SIZE INTO OUT-TEXT
PERFORM END-TRANS.
***************************************************
********** DISPLAY ERROR MESSAGE **********
DISP-ERROR.
MOVE CLI-RETURN-CODE TO CLI-RC-DISPLAY.
MOVE DBCAREA-FUNC-ID TO DBCAREA-FUNC-ID-DISPLAY.
STRING ’FUNCTION = ’,DBCAREA-FUNC-ID-DISPLAY,’RETURN CODE’
CLI-RC-DISPLAY
DELIMITED BY SIZE INTO OUT-TEXT.
PERFORM ISRT-MSG.
STRING DBCAREA-MSG-TEXT
DELIMITED BY SIZE INTO OUT-TEXT.
PERFORM END-TRANS.
***************************************************
********** INITIALIZE DBCAREA **********
DBC-INIT.
CALL ’DBCHINI’ USING CLI-RETURN-CODE, CONTEXT-PTR, DBCAREA.
IF CLI-RETURN-CODE NOT = 0
MOVE CLI-RETURN-CODE TO CLI-RC-DISPLAY
STRING ’CLI RETURN CODE AFTER INIT = ’, CLI-RC-DISPLAY
DELIMITED BY SIZE INTO OUT-TEXT,
PERFORM ISRT-MSG,
STRING DBCAREA-MSG-TEXT
DELIMITED BY SIZE INTO OUT-TEXT,
PERFORM END-TRANS.
***************** CONNECT SESSION **********
CLI-CONNECT.
SET TOKEN-INDEX TO LOGID.
MOVE LOGID TO DBCAREA-TOKEN.
MOVE CONNECT-FUNC TO DBCAREA-FUNC-ID.
CALL ’DBCHCL’ USING CLI-RETURN-CODE, CONTEXT-PTR, DBCAREA.
IF CLI-RETURN-CODE NOT = 0
PERFORM DISP-ERROR.
MOVE DBC-TDP-REQNO TO TDPREQID(TOKEN-INDEX).
ADD 1 TO NUMBER-OF-SESSIONS.
* SAVE TOKEN, SESSION ID , REQUEST ID , AND LAST-FUNCTION.
A: Multi-Session Cobol/IMS (CLI2MCI) Listing
Teradata® Tools and Utilities IBM IMS Interface for Teradata®
Reference, Release 17.00 38
39. MOVE LOGID TO TOKEN(TOKEN-INDEX).
MOVE DBCAREA-O-SESS-ID TO SESSID(TOKEN-INDEX).
MOVE DBCAREA-O-REQ-ID TO REQID(TOKEN-INDEX).
MOVE ’LOGON’ TO LAST-FUNCTION(TOKEN-INDEX).
*****************************************************
(30) DBCAREA-SETUP.
*****************************************************
* SET UP DBCHSAD CALLS (STORE ADDRESSES IN DBCAREA) *
* AND OTHER DBCAREA CONSTANTS. *
*****************************************************
*** SET UP POINTER TO DBC/SQL STATEMENT.
(31) CALL ’DBCHSAD’ USING CLI-RETURN-CODE,
DBCAREA-REQ-PTR, MULTI-STMT-REQ.
*** SET UP LENGTH OF DBC/SQL STATEMENT.
(32) MOVE MULT-STMT-LEN TO DBCAREA-REQ-LEN.
*** SET UP POINTER TO USING DATA
(33) CALL ’DBCHSAD’ USING CLI-RETURN-CODE,
DBCAREA-USING-DATA-PTR, DATA-FOR-INSERT-
*** SET UP LENGTH OF DATA FOR DBC/SQL STATEMENT.
MOVE DATA-LEN TO DBCAREA-USING-DATA-LEN.
(34)
*** SET UP POINTER TO PARCEL AREA (MOVE MODE)
(35) CALL ’DBCHSAD’ USING CLI-RETURN-CODE,
DBCAREA-FET-DATA-PTR, PARCEL.
*** SET UP MAX SIZE FOR PARCEL (REQUIRED FOR MOVE MODE)
(36) MOVE RESPBUF-SIZE TO DBCAREA-FET-MAX-DATA-LEN.
*** SET UP MAXIMUM NUMBER OF SESSIONS.
(37) MOVE NUMLOG TO DBCAREA-MAX-NUM-SESS.
******************************************************
* *
* SET OPTION FLAGS *
******************************************************
* SET MOVE-MODE OPTION FOR COBOL PROGRAMS. *
* *
******************************************************
(38) MOVE ’N’ TO DBCAREA-LOC-MODE.
******************************************************
* SET NO WAIT-FOR-RESPONSE OPTION. *
* (TECHNIQUE USED BY THIS SAMPLE PROGRAM) *
******************************************************
(39) MOVE ’N’ TO DBCAREA-WAIT-FOR-RESP.
******************************************************
* SET ’N’ FOR CRASH-WAIT OPTION. *
* (TECHNIQUE USED BY THIS SAMPLE PROGRAM) *
A: Multi-Session Cobol/IMS (CLI2MCI) Listing
Teradata® Tools and Utilities IBM IMS Interface for Teradata®
Reference, Release 17.00 39
40. ******************************************************
(40) MOVE ’N’ TO DBCAREA-WAIT-ACROSS-CRASH.
******************************************************
* SET ’Y’ FOR CRASH-TELL OPTION. *
* (TECHNIQUE USED BY THIS SAMPLE PROGRAM) *
******************************************************
MOVE ’Y’ TO DBCAREA-TELL-ABOUT-CRASH.
******************************************************
* SET ’Y’ TO TRIGGER CHANGED OPTIONS. *
* *
******************************************************
MOVE ’Y’ TO DBCAREA-CHANGE-OPTS.
* END OF SOURCE CODE.
A: Multi-Session Cobol/IMS (CLI2MCI) Listing
Teradata® Tools and Utilities IBM IMS Interface for Teradata®
Reference, Release 17.00 40
41. CLI2/MPI Program Listing
*PROCESS MAR(2,72,1); /* THIS PROGRAM PROVIDES AN EXAMPLE OF HOW THE CLI2 INTER- */
/* FACE CAN BE USED TO PERFORM THE FOLLOWING FUNCTIONS: */
/* */
/* -- CALL ANOTHER PROGRAM TO DROP/CREATE A TABLE. AN */
/* INITIALIZED DBCAREA CONTAINING THE LOGON STRING */
/* IS PASSED TO THE CALLED PROGRAM. */
/* */
/* -- CONNECT MULTIPLE SESSIONS. */
/* */
/* -- CALL “DBCHWAT” TO WAIT ON AVAILABLE REQUEST (NO */
/* IMPLICIT WAITS BY CLI2). */
/* */
/* -- TERMINATE A REQUEST AND INITIATE ANOTHER REQUEST */
/* AFTER RESPONSE PARCELS HAVE BEEN FETCHED. */
/* */
/* -- THE INITIATED REQUEST IS A MULTI-STATEMENT */
/* REQUEST CONTAINING FIVE INSERT AND FIVE UPDATES */
/* (ONE TRANSACTION). */
/* */
/* -- DISCONNECT SESSIONS WHEN ALL TRANSACTIONS HAVE */
/* BEEN PROCESSED. */
/* */
/* NOTE: THIS VERSION OF THE SAMPLE PROGRAM IS DESIGNED */
/* TO EXECUTE AS AN IMS MPP CONVERSATIONAL PROGRAM. */
/* */
/* AUTHOR: J. LAHOOD */
/* */
1CLI2MPI: PROC(PCBPTR) OPTIONS(MAIN);
DCL PLITDLI ENTRY EXTERNAL;
DCL PLIXOPT CHAR(24) VAR
INIT(’ISA(4K),NOSTAE,NOSPIE’) STATIC EXTERNAL;
DCL PCBPTR POINTER,
1 IOPCB BASED(PCBPTR),
2 LTERM CHAR(8),
2 FILLER CHAR(2),
2 IOPCB_STATUS CHAR(2),
Multi-Session/PLI/IMS (CLI2MPI) Listing
B
Teradata® Tools and Utilities IBM IMS Interface for Teradata®
Reference, Release 17.00 41
42. 2 PREFIX CHAR(12);
DCL (STG,SUBSTR,ADDR) BUILTIN;
/* */
/*----------------------------------------------------------*/
/* * DATA DEFINITIONS */
/* * */
/* ---------------------------------------------------------*/
/* DL/I CALL FUNCTIONS */
DCL GU_FUNC CHAR(4) STATIC INIT(’GU ’),
GN_FUNC CHAR(4) STATIC INIT(’GN ’),
ISRT_FUNC CHAR(4) STATIC INIT(’ISRT’);
/* */
/* PL/I PARAMETER COUNTER */
/* */
DCL THREE FIXED BIN(31) INIT(3);
/* */
/* CLI2 SUBROUTINES AND CLICTAB (CREATES TABLE) */
/* */
DCL (DBCHINI,
DBCHCL,
DBCHWAT,
CLI2CTB,
DBCHCLN) ENTRY EXTERNAL OPTIONS(ASSEMBLER, INTER);
/* CONSTANTS */
/* TYPE OF FUNCTION -- USED IN MESSAGES */
DCL TYPE_FUNC CHAR(8) STATIC,
/* NUMBER OF SESSIONS TO BE CONNECTED */
/* */
/* */
NUMLOG FIXED BIN(15) STATIC INIT(3),
/* */
/* CURRENT NUMBER OF SESSIONS. */
/* */
NUMBER_OF_SESSIONS FIXED BIN(15) STATIC INIT(0),
/* */
/* NUMBER OF INSERT/UPDATE TRANSACTIONS PER ITERATION */
/* */
MAXTRANS FIXED BIN(31) STATIC INIT(10),
/* */
/* TRANSACTION COUNTER */
/* */
TRANS_COUNT FIXED BIN(31) STATIC INIT(0),
/* */
/* MAXIMUM RESPONSE BUFFER SIZE FOR FETCHING */
B: Multi-Session/PLI/IMS (CLI2MPI) Listing
Teradata® Tools and Utilities IBM IMS Interface for Teradata®
Reference, Release 17.00 42
43. /* */
RESPBUF_SIZE FIXED BIN(31) STATIC INIT(4096),
/* */
/* WORD USED IN MESSAGE (SINGULAR/PLURAL FORM). *
/* */
PASS_TYPE CHAR(7) STATIC,
/* */
/* LOGON STRING -- FROM IMS INPUT MESSAGE (FIRST PASS). */
/* LOGON_STRING CHAR(4) STATIC INIT(’0/LAHOOD,J’) */
/* */
LOGON_STRING CHAR(40) STATIC,
/* */
/* LENGTH OF LOGON STRING -- OBTAINED VIA PL/I ’STG’ */
/* FUNCTION. */
/* MY_LOGON_LEN FIXED BIN(31) STATIC INIT(30),
/* */
/* */
/* RUNNING COUNT OF LOGGED ON SESSIONS */
/* */
LOGID FIXED BIN(15) STATIC INIT(1),
/* */
/* SESSION ID RETURNED BY DBCHWAT */
/* */
WAIT_SESSID FIXED BIN(31) STATIC INIT(0),
/* */
/* INDEX USED TO ACCESS TOKEN_ARRAY */
/* */
TOKEN_INDEX FIXED BIN(31) STATIC INIT(0),
/* */
/* TOKEN RETURNED BY DBCHWAT */
/* */
WAIT_TOKEN FIXED BIN(31) STATIC INIT(0),
/* */
/* CLI CODES */
/* */
BUSY_CODE FIXED BIN(31) STATIC INIT(150),
EOF_CODE FIXED BIN(31) STATIC INIT(33),
CRASH_CODE FIXED BIN(31) STATIC INIT(286);
/* */
/* SCRATCH PAD AREA LAYOUT */
/* */
DCL 1 SPA STATIC,
2 LL FIXED BIN(31),
2 ZZ FIXED BIN(31),
B: Multi-Session/PLI/IMS (CLI2MPI) Listing
Teradata® Tools and Utilities IBM IMS Interface for Teradata®
Reference, Release 17.00 43
52. END CLI_END_REQUEST;
/* *************************************************************/
/* ***************** DISCONNECT SESSION *****/
CLI_DISCONNECT: PROC;
DBCAREA.FUNC = DISCONNECT_FUNC;
CALL DBCHCL(CLI_RETURN_CD, CONTEXT_PTR, DBCAREA);
IF CLI_RETURN_CD = 0 THEN CALL DISP_ERROR;
END CLI_DISCONNECT;
/* **************************************************************/
/* ***************** DISPLAY PARCEL *****/
DISPLAY_PARCEL: PROC;
IF DBCAREA.FET_PARCEL_FLAVOR = ERROR_TYPE THEN
DO;
OUT_TEXT = ’ERROR PARCEL RECEIVED ’;
CALL ISRT_MSG;
OUT_TEXT = SUBSTR(ERROR_MSG,1,ERROR_LEN);
CALL END_TRANS;
END;
ELSE
IF DBCAREA.FET_PARCEL_FLAVOR = FAILURE_TYPE THEN
DO;
OUT_TEXT = ’FAILURE PARCEL RECEIVED ’;
CALL ISRT_MSG;
OUT_TEXT = SUBSTR(FAILURE_MSG,1,FAILURE_LEN);
CALL END_TRANS;
END;
END DISPLAY_PARCEL;
/* ***********************************************************/
/* ***************** DISPLAY ERROR MESSAGE *****/
DISP_ERROR: PROC;
OUT_TEXT =
’FUNCTION = ’ || DBCAREA.FUNC || ’RETURN CODE = ’ ||
CLI_RETURN_CD;
CALL ISRT_MSG;
OUT_TEXT = DBCAREA.MSG_TEXT;
CALL END_TRANS;
END DISP_ERROR;
/* ************************************************************/
/* ***************** INITIALIZE DBCAREA *****/
DBC_INIT: PROC;
CALL DBCHINI(CLI_RETURN_CD, CONTEXT_PTR, DBCAREA);
IF CLI_RETURN_CD = 0 THEN
DO;
OUT_TEXT = ’CLI RETURN CODE AFTER INIT = ’
B: Multi-Session/PLI/IMS (CLI2MPI) Listing
Teradata® Tools and Utilities IBM IMS Interface for Teradata®
Reference, Release 17.00 52
53. || CLI_RETURN_CD;
CALL ISRT_MSG;
OUT_TEXT = DBCAREA.MSG_TEXT;
CALL END_TRANS;
END;
END DBC_INIT;
/* ***************** CONNECT SESSION *****/
CLI_CONNECT: PROC;
TOKEN_INDEX = LOGID;
DBCAREA.TOKEN = LOGID;
DBCAREA.FUNC = CONNECT_FUNC;
CALL DBCHCL(CLI_RETURN_CD, CONTEXT_PTR, DBCAREA);
IF CLI_RETURN_CD = 0 THEN CALL DISP_ERROR;
TDPREQID(TOKEN_INDEX) = DBCAREA.TDP_REQ_NO;
NUMBER_OF_SESSIONS = NUMBER_OF_SESSIONS + 1;
/* SAVE TOKEN, SESSION ID, REQUEST ID, AND LAST_FUNCTION */
TOKEN_ARRAY.TOKEN(TOKEN_INDEX) = LOGID;
SESSID(TOKEN_INDEX) = DBCAREA.O_SESS_ID;
REQID(TOKEN_INDEX) = DBCAREA.O_REQ_ID;
LAST_FUNCTION(TOKEN_INDEX) = ’LOGON’;
END CLI_CONNECT;
/* ***********************************************************/
DBCAREA_SETUP: PROC;
/* ***********************************************************/
/* * SET UP DBCAREA CONSTANTS */
/* * */
/* ***********************************************************/
/* *** SET UP POINTER TO DBC/SQL STATEMENT. */
DBCAREA.REQ_PTR= ADDR(MULTI_STMT_REQ);
/* *** SET UP LENGTH OF DBC/SQL STATEMENT. */
DBCAREA.REQ_LEN = STG(MULTI_STMT_REQ);
/* *** SET UP POINTER TO USING DATA */
DBCAREA.USING_DATA_PTR =ADDR(DATA_FOR_INS_UPD);
/* *** SET UP LENGTH OF DATA FOR DBC/SQL STATEMENT. */
DBCAREA.USING_DATA_LEN = DATA_LEN;
/* *** SET UP POINTER TO PARCEL AREA (MOVE MODE) */
/* CALL ’DBCHSAD’ USING CLI_RETURN_CD, */
/* DBC_FET_DATA_PTR, PARCEL. */
/* *** SET UP MAX SIZE FOR PARCEL (REQUIRED FOR MOVE MODE */
/* MOVE RESPBUF_SIZE TO DBC_FET_I_MAX_DATA_LEN. */
/* *** SET UP MAXIMUM NUMBER OF SESSIONS. */
DBCAREA.MAX_NUM_SESS = NUMLOG;
/* ***********************************************************/
/* * */
B: Multi-Session/PLI/IMS (CLI2MPI) Listing
Teradata® Tools and Utilities IBM IMS Interface for Teradata®
Reference, Release 17.00 53
54. /* * SET OPTION FLAGS */
/* ***********************************************************/
/* * SET MOVE MODE OPTION FOR COBOL PROGRAMS. */
/* * */
/* ***********************************************************/
/* MOVE ’N’ TO DBC_LOC_MODE. */
/* ***********************************************************/
/* * SET NO WAIT-FOR-RESPONSE OPTION. */
/* * (TECHNIQUE USED BY THIS SAMPLE PROGRAM) */
/* ***********************************************************/
DBCAREA.WAIT_FOR_RESP = ’N’;
/* ***********************************************************/
/* * SET ’N’ FOR CRASH-WAIT OPTION. */
/* * (TECHNIQUE USED BY THIS SAMPLE PROGRAM) */
/* ***********************************************************/
DBCAREA.WAIT_ACROSS_CRASH = ’N’;
/* ***********************************************************/
/* * SET ’Y’ FOR CRASH-TELL OPTION. */
/* * (TECHNIQUE USED BY THIS SAMPLE PROGRAM) */
/* ***********************************************************/
DBCAREA.TELL_ABOUT_CRASH = ’Y’;
/* ***********************************************************/
/* * SET ’Y’ TO TRIGGER CHANGED OPTIONS. */
/* * */
/* ***********************************************************/
DBCAREA.CHANGE_OPTS = ’Y’;
END DBCAREA_SETUP;
IMMEDIATE_IMS_RETURN: END CLI2MPI;
B: Multi-Session/PLI/IMS (CLI2MPI) Listing
Teradata® Tools and Utilities IBM IMS Interface for Teradata®
Reference, Release 17.00 54
55. CLI2SCI Program Listing
IDENTIFICATION DIVISION. PROGRAM-ID. CLI2SCI.
AUTHOR. J LAHOOD.
INSTALLATION. TDAT.
REMARKS. THIS PROGRAM PROVIDES AN EXAMPLE OF HOW THE CLI2
* INTERFACE CAN BE USED TO PERFORM THE FOLLOWING FUNCTIONS:
* -- DROP THEN CREATE A TABLE.
* -- INSERT ROWS INTO THE TABLE (values from “using data”).
* -- UPDATE ALL ROWS (Single Transaction).
* -- SELECT ROWS FROM THE TABLE (WHERE FIELD = “using data”)
* -- DISPLAY FETCHED PARCELS.
* -- TERMINATE A REQUEST AFTER RESPONSE PARCELS HAVE BEEN
* FETCHED.
* -- DISCONNECT A SESSION AFTER ALL REQUESTS HAVE BEEN
* PROCESSSED.
***** OPTIONS:
* MOVE MODE FETCH (REQUIRED FOR COBOL PROGRAMS)
* WAIT FOR RESPONSE
* WAIT FOR CRASH RECOVERY = YES
* TELL ABOUT CRASH = NO
*
***** SINGLE SESSION.
*
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SOURCE-COMPUTER. IBM-370.
OBJECT-COMPUTER. IBM-370.
INPUT-OUTPUT SECTION.
DATA DIVISION.
WORKING-STORAGE SECTION.
*********************************************************
* DATA DEFINITIONS
*
**********************************************************
* CONSTANTS.
77 GET-UNIQUE PIC XXXX VALUE ’GU ’.
77 IN-SERT PIC XXXX VALUE ’ISRT’.
Single-Session/COBOL/IMS (CLI2SCI) Listing
C
Teradata® Tools and Utilities IBM IMS Interface for Teradata®
Reference, Release 17.00 55
56. 77 NO-MSG PIC XX VALUE ’QX’.
* CURRENT NUMBER OF SESSIONS.
77 NUMBER-OF-SESSIONS PIC 9999 VALUE IS 0 COMP.
* NUMBER OF ROWS TO BE INSERTED.
77 MAXROWS PIC S9(9) COMP VALUE IS +100.
* MAXIMUM RESPONSE BUFFER SIZE FOR FETCHING1fa
* (MUST BE SPECIFIED WHEN IN MOVE MODE).
77 RESPBUF-SIZE PIC S9(9) COMP VALUE IS +4096.
* LOGON STRING
*77 LOGON-STRING PIC X(50)
* VALUE ’0/J,LAHOOD ’.
* LENGTH OF LOGON STRING
77 LOGON-LEN PIC 9(9) VALUE IS 50 COMP.
* DBC/SQL REQUEST TO BE EXECUTED.
77 REQUEST-BUF PIC X(60) VALUE IS SPACES.
* LENGTH OF DBC/SQL REQUEST.
77 INSERT-LEN PIC 9(9) VALUE IS 60 COMP.
* LENGTH OF VARIABLE LENGTH MESSAGES (OCCURS BY)
77 TEXT-LEN PIC 9999 COMP VALUE IS 0.
77 EOF-CODE PIC S9(9) VALUE +33 COMP.
77 CRASH-CODE PIC S9(9) VALUE +286 COMP.
* LAST REQUEST IRQ’D
77 LAST-REQUEST PIC X(6) VALUE IS SPACES.
01 TERM-OUTPUT.
02 CHAR-COUNT PICTURE S99 COMPUTATIONAL VALUE +79.
02 FILLER PICTURE S99 COMPUTATIONAL VALUE ZERO.
* THE FOLLOWING VALUE IS ACTUALLY X’15’ -- NOT BLANK.
02 CAR-RET PICTURE X VALUE ’ ’.
02 OUTPUT-TEXT PICTURE X(132) VALUE SPACES.
01 TERM-INPUT.
02 INPUT-COUNT PICTURE S99 COMPUTATIONAL.
02 FILLER PICTURE S99 COMPUTATIONAL.
02 INPUT-TEXT.
05 LOGON-STRING PIC X(50) VALUE SPACES.
05 FILLER PIC X(120).
01 STATUS-CODE-MSG.
02 FILLER PICTURE X(23) VALUE ’UNEXPECTED STATUS CODE ’.
02 FILL-STATUS PICTURE XX.
02 FILLER PICTURE X(4) VALUE ’ ON ’.
02 FILL-FUNCTION PICTURE X(4).
02 CR-SC PICTURE X.
01 DONE-MSG1.
02 FILLER PICTURE X(40) VALUE
’* TEST SIMP2 COMPLETED WITHOUT ERROR. ’.
C: Single-Session/COBOL/IMS (CLI2SCI) Listing
Teradata® Tools and Utilities IBM IMS Interface for Teradata®
Reference, Release 17.00 56
57. 02 CR-1 PICTURE X.
01 DONE-MSG2.
02 FILLER PICTURE X(40) VALUE
’ VALIDATE RESULTS USING BTEQ/ITEQ. ’.
02 CR-2 PICTURE X.
*************************************************************************
01 DBC-SQL-REQUESTS.
05 FILLER PIC X(6) VALUE ’DROP’.
05 FILLER PIC X(60) VALUE
’DROP TABLE T;’.
05 FILLER PIC X(6) VALUE ’CT’.
05 FILLER PIC X(60) VALUE
’CREATE TABLE T (I INTEGER,I2 SMALLINT);’.
05 FILLER PIC X(6) VALUE ’INSERT’.
05 FILLER PIC X(60) VALUE
’USING V (INTEGER),V2 (SMALLINT) INS INTO T (:V,:V2);’.
05 FILLER PIC X(6) VALUE ’UPDATE’.
05 FILLER PIC X(60) VALUE
’UPDATE T SET I2 = I + 1 ALL ;’.
05 FILLER PIC X(6) VALUE ’SELECT’.
05 FILLER PIC X(60) VALUE
’ SEL SUM(I) FROM T;’.
05 FILLER PIC X(6) VALUE ’ENDREQ’.
05 FILLER PIC X(60) VALUE ’DUMMY’.
01 DBC-SQL-TEST-DRIVER REDEFINES DBC-SQL-REQUESTS.
05 DBC-SQL-REQUEST OCCURS 6 TIMES INDEXED BY
REQUEST-INDEX.
10 REQUEST-TYPE PIC X(6).
10 REQUEST PIC X(60).
*****************************************************************
01 DBCAREA.
COPY DBCAREAC.
* CLI REQUIRED PARAMETERS
01 CLI-RETURN-CODE PIC S9(9) VALUE +0 COMP.
01 CLI-RETURN-DISPLAY PIC ZZZZZZZZ9 .
01 FUNC-DISPLAY PIC ZZZZZZZZ9 .
01 CONTEXT-PTR PIC S9(9) VALUE +0 COMP.
* DBC FUNCTION CODES
01 FUNCTIONS.
05 CONNECT-FUNC PIC S9(9) VALUE +1 COMP.
05 DISCONNECT-FUNC PIC S9(9) VALUE +2 COMP.
05 RUN-STARTUP-FUNC PIC S9(9) VALUE +3 COMP.
05 INITIATE-REQ-FUNC PIC S9(9) VALUE +4 COMP.
05 FETCH-FUNC PIC S9(9) VALUE +5 COMP.
C: Single-Session/COBOL/IMS (CLI2SCI) Listing
Teradata® Tools and Utilities IBM IMS Interface for Teradata®
Reference, Release 17.00 57
58. 05 REWIND-FUNC PIC S9(9) VALUE +6 COMP.
05 ABORT-FUNC PIC S9(9) VALUE +7 COMP.
05 END-REQUEST-FUNC PIC S9(9) VALUE +8 COMP.
* COMMON PARCEL FLAVORS
01 FLAVOR.
05 SUCCESS-TYPE PIC S9(9) VALUE +8 COMP.
05 FAILURE-TYPE PIC S9(9) VALUE +9 COMP.
05 RECORD-TYPE PIC S9(9) VALUE +10 COMP.
05 END-STATEMENT-TYPE PIC S9(9) VALUE +11 COMP.
05 END-REQUEST-TYPE PIC S9(9) VALUE +12 COMP.
05 ERROR-TYPE PIC S9(9) VALUE +49 COMP.
05 DATA-INFO-TYPE PIC S9(9) VALUE +71 COMP.
* PARCEL WORK AREA FOR MOVE MODE PARCEL FETCHES
01 PARCEL PIC X(4096) VALUE LOW-VALUES.
* SUCCESS PARCEL (RELEASE 3.0 AND LATER)
01 SUCCESS-PCL REDEFINES PARCEL.
05 STATEMENT-NO PIC S9(4) COMP.
05 ACTIVITY-COUNT PIC S9(9) COMP.
05 WARNING-CODE PIC S9(4) COMP.
05 FIELD-COUNT PIC S9(4) COMP.
05 ACTIVITY-TYPE PIC S9(4) COMP.
05 WARNING-LEN PIC S9(4) COMP.
05 WARNING-MSG PIC X(256).
* FAILURE PARCEL
01 FAILURE-PCL REDEFINES PARCEL.
05 STATEMENT-NO PIC S9(4) COMP.
05 INFO PIC S9(4) COMP.
05 FAILURE-CODE PIC S9(4) COMP.
05 FAILURE-LEN PIC S9(4) COMP.
05 FAILURE-MSG PIC X(256).
* ERROR PARCEL
01 ERROR-PCL REDEFINES PARCEL.
05 STATEMENT-NO PIC S9(4) COMP.
05 INFO PIC S9(4) COMP.
05 ERROR-CODE PIC S9(4) COMP.
05 ERROR-LEN PIC S9(4) COMP.
05 ERROR-MSG PIC X(256).
01 DATA-RECORD REDEFINES PARCEL.
05 DATA-VALUE PIC S9(9) COMP.
05 DATA-VALUE2 PIC S9(4) COMP.
01 DATA-FIELD-DISPLAY PIC S9(9) SIGN IS LEADING SEPARATE.
01 VARMSG.
10 VTEXT OCCURS 0 TO 256 TIMES DEPENDING ON TEXT-LEN.
15 TEXT-DUM PIC X.
C: Single-Session/COBOL/IMS (CLI2SCI) Listing
Teradata® Tools and Utilities IBM IMS Interface for Teradata®
Reference, Release 17.00 58
59. 01 DATA-TO-BE-INS-OR-SEL.
05 FIELD1 PIC S9(9) VALUE IS +0 COMP.
05 FIELD2 PIC S9(4) VALUE IS +0 COMP.
01 DATA-LEN-INSERT PIC 9(9) VALUE IS 6 COMP.
01 DATA-LEN-SELECT PIC 9(9) VALUE IS 4 COMP.
LINKAGE SECTION.
01 IOPCB.
02 LTERM-NAME PICTURE X(8).
02 FILLER PICTURE XX.
02 IOPCB-STATUS PICTURE XX.
02 IOPCB-PREFIX.
03 FILLER PICTURE X.
03 JULIAN-DATE PICTURE S9(5) COMPUTATIONAL-3.
03 TIME-O-DAY PICTURE S9(7) COMPUTATIONAL-3.
03 FILLER PICTURE XXXX.
01 DBDUMMY PIC X(69).
PROCEDURE DIVISION.
ENTRY ’DLITCBL’ USING IOPCB, DBDUMMY.
BEGIN.
PERFORM IMS-GU.
STRING ’INPUT AREA = ’, LOGON-STRING
DELIMITED BY SIZE INTO OUTPUT-TEXT.
PERFORM TERM-OUT.
*** BLANK OUT TRANSACTION CODE IN INPUT MESSAGE.
EXAMINE INPUT-TEXT REPLACING UNTIL FIRST ’ ’ BY ’ ’.
PERFORM DBC-INIT.
PERFORM DBCAREA-SETUP.
PERFORM CLI-CONNECT.
*** SET UP INITIAL DATA FOR INSERT STATEMENT.
MOVE 1 TO FIELD1 OF DATA-TO-BE-INS-OR-SEL.
MOVE 1 TO FIELD2 OF DATA-TO-BE-INS-OR-SEL.
SET REQUEST-INDEX TO 1.
MOVE REQUEST(REQUEST-INDEX) TO REQUEST-BUF.
MOVE ZERO TO DBCAREA-USING-DATA-LEN.
PERFORM FETCH-THEN-IRQ UNTIL NUMBER-OF-SESSIONS = ZERO.
PERFORM SEND-DONE-MSG.
GOBACK.
***********************************************************
* PERFORMED PARAGRAPHS. *
***********************************************************
********* FETCH PARCELS FOR PREVIOUS IRQ OR CONNECT ******
********* IF EOF, INITIATE INSERT REQUEST **********
FETCH-THEN-IRQ.
PERFORM CLI-FETCH-PARCELS UNTIL CLI-RETURN-CODE = EOF-CODE
C: Single-Session/COBOL/IMS (CLI2SCI) Listing
Teradata® Tools and Utilities IBM IMS Interface for Teradata®
Reference, Release 17.00 59
60. OR CLI-RETURN-CODE = CRASH-CODE.
IF CLI-RETURN-CODE = EOF-CODE THEN
PERFORM CLI-END-REQUEST
IF REQUEST-TYPE(REQUEST-INDEX) = ’ENDREQ’
PERFORM CLI-DISCONNECT
ELSE
PERFORM CLI-IRQ
PERFORM ADVANCE-TO-NEXT-REQUEST
ELSE PERFORM DISP-ERROR.
***********************************************************
****************** ADVANCE TO NEXT REQUEST **********
ADVANCE-TO-NEXT-REQUEST.
IF REQUEST-TYPE(REQUEST-INDEX) = ’INSERT’
IF FIELD1 OF DATA-TO-BE-INS-OR-SEL < MAXROWS
ADD +1 TO FIELD1 OF DATA-TO-BE-INS-OR-SEL
ADD +1 TO FIELD2 OF DATA-TO-BE-INS-OR-SEL
ELSE
*** SET UP VALUES FOR NEXT STATEMENT (RESET KEY VALUE)
MOVE 1 TO FIELD1 OF DATA-TO-BE-INS-OR-SEL
MOVE ZERO TO DBCAREA-USING-DATA-LEN
SET REQUEST-INDEX UP BY 1
MOVE REQUEST(REQUEST-INDEX) TO REQUEST-BUF
ELSE
SET REQUEST-INDEX UP BY 1
MOVE REQUEST(REQUEST-INDEX) TO REQUEST-BUF
IF REQUEST-TYPE(REQUEST-INDEX) = ’INSERT’
MOVE DATA-LEN-INSERT TO DBCAREA-USING-DATA-LEN.
***********************************************************
***************** FETCH PARCELS **********
CLI-FETCH-PARCELS.
MOVE FETCH-FUNC TO DBCAREA-FUNC.
CALL ’DBCHCL’ USING CLI-RETURN-CODE, CONTEXT-PTR, DBCAREA.
IF CLI-RETURN-CODE NOT = EOF-CODE
PERFORM DISPLAY-PARCEL.
**********************************************************
***************** INITIATE INSERT REQUEST **********
CLI-IRQ.
MOVE REQUEST-TYPE(REQUEST-INDEX) TO LAST-REQUEST.
MOVE INITIATE-REQ-FUNC TO DBCAREA-FUNC.
CALL ’DBCHCL’ USING CLI-RETURN-CODE, CONTEXT-PTR, DBCAREA.
IF CLI-RETURN-CODE = ZERO
MOVE DBCAREA-O-REQ-ID TO DBCAREA-I-REQ-ID
ELSE PERFORM DISP-ERROR.
************************************************************
C: Single-Session/COBOL/IMS (CLI2SCI) Listing
Teradata® Tools and Utilities IBM IMS Interface for Teradata®
Reference, Release 17.00 60
61. ***************** TERMINATE REQUEST **********
CLI-END-REQUEST.
MOVE END-REQUEST-FUNC TO DBCAREA-FUNC.
CALL ’DBCHCL’ USING CLI-RETURN-CODE, CONTEXT-PTR, DBCAREA.
IF CLI-RETURN-CODE NOT = 0
PERFORM DISP-ERROR.
************************************************************
***************** DISCONNECT SESSION **********
CLI-DISCONNECT.
MOVE DISCONNECT-FUNC TO DBCAREA-FUNC.
CALL ’DBCHCL’ USING CLI-RETURN-CODE, CONTEXT-PTR, DBCAREA.
IF CLI-RETURN-CODE NOT = 0
PERFORM DISP-ERROR.
SUBTRACT 1 FROM NUMBER-OF-SESSIONS.
************************************************************
***************** DISPLAY PARCEL **********
DISPLAY-PARCEL.
IF DBCAREA-FET-PARCEL-FLAVOR = ERROR-TYPE
MOVE ERROR-LEN TO TEXT-LEN
MOVE ERROR-MSG TO VARMSG
STRING VARMSG
DELIMITED BY SIZE INTO OUTPUT-TEXT
PERFORM TERM-OUT
IF LAST-REQUEST NOT = ’DROP’
GOBACK
ELSE NEXT SENTENCE
ELSE
IF DBCAREA-FET-PARCEL-FLAVOR = FAILURE-TYPE
MOVE FAILURE-LEN TO TEXT-LEN
MOVE FAILURE-MSG TO VARMSG
STRING VARMSG
DELIMITED BY SIZE INTO OUTPUT-TEXT
PERFORM TERM-OUT
IF LAST-REQUEST NOT = ’DROP’
GOBACK
ELSE NEXT SENTENCE
ELSE
IF DBCAREA-FET-PARCEL-FLAVOR = RECORD-TYPE
MOVE DATA-VALUE OF DATA-RECORD TO DATA-FIELD-DISPLAY
STRING ’SUM OF FIELD I = ’, DATA-FIELD-DISPLAY
DELIMITED BY SIZE INTO OUTPUT-TEXT
PERFORM TERM-OUT.
**********************************************************
***************** DISPLAY ERROR MESSAGE **********
C: Single-Session/COBOL/IMS (CLI2SCI) Listing
Teradata® Tools and Utilities IBM IMS Interface for Teradata®
Reference, Release 17.00 61