Invoking the API requester from a CICS application
Understand the structure of the CICS® COBOL or PL/I application, how to compile it, run it and extend it. Both the COBOL and PL/I programs are functionally the same.
zosConnect-3.0 Applies to zosConnect-3.0.
Started task Applies to z/OS Connect Servers run by using a z/OS started task procedure.
The CICS COBOL application
Understand the structure of the CICS COBOL application and how to compile it.
Before you begin
About this task
For more information about Host API, see Understanding the Host API.
DATA DIVISION
- Working Storage Section
-
The copybooks BAQHAREC and BAQHCONC are referenced. These contain the static data structures that are used by the Host API. For more information about where these copybooks are located, see Understanding the Host API.
The generated API-INFO copybooks are referenced, RBKnnI01, one per operation to be called. The API-INFO data structures contain static data that tells z/OS Connect the path and method of the operation to call, and the name of the API.
The generated operation request data structures, RBKnnQ01, are referenced, one per operation. These are populated by the program before calling the API operation.
- Linkage section
- The generated operation response data structures, RBKnnP01, are referenced, one per operation.
These are populated by the Host API after the call to
the API operation has returned via z/OS Connect.
Note: These are located in the Linkage Section as the COBOL program does not own the backing storage, the Host API does, and it frees that storage when requested to do so by the BAQFREE verb. For more information, see X-FREE.
PROCEDURE DIVISON
X-. For example, X-INIT, X-EXEC.- A-MAINLINE SECTION
-
This is the initial processing section and receives any terminal input that is associated with the transaction invocation. B-INIT-TX is then called to set up the transaction. Then, the transaction executioner C-EXECUTE-TX is called followed by the X-FREE and X-TERM utility functions to terminate cleanly.
- B-INIT-TX
-
Sets the CICS ABEND handler and calls the utility routine X-INIT to get a Host API connection to a z/OS Connect Server instance.
- C-EXECUTE
- Based on the invocation transaction, one of
CA-GET-ALL-REDBOOKS,CB-GET-REDBOOK,CC-CREATE-REDBOOK,CD-PATCH-REDBOOK, orCE-MERGE-REDBOOKis called. - C-EXECUTE-TX
-
Based on the invocation transaction one of CA-GET-ALL-REDBOOKS, CB-GET-REDBOOK, or CC-CREATE-REDBOOK is called.
- CA-GET-ALL-REDBOOKS
-
This section performs processing to prepare a request to operation
getAllRedbooksof the endpoint API application, makes the call via BAQEXEC and processes the response by using CAA-GET-EACH-REDBOOK and CAAA-GET-EACH-AUTHOR. For more information BAQEXEC, see X-EXEC. - CB-GET-REDBOOK
-
This section must also prepare a request, run that request, and process the response. However, unlike CA-GET-ALL-REDBOOKS it contains TODO's comments that help you, the CICS application developer, write the code to perform this operation.
- CC-CREATE-REDBOOK
-
This section is also to be written by you, to create a new Redbook by calling the
createRedbookoperation of the endpoint API application. You write CCAA-PUT-EACH-AUTHOR and X-PUT-DATA-AREA-ELEMENT to build the request authors Data Area using the BAQPUTN verb. However, there are even fewer TODOs to help you! - CD-PATCH-REDBOOK
-
This section shows an example of using RFC6902 to update a Redbook entity on a field-by-field bases.
- CE-MERGE-REDBOOK
-
This section shows an example of using RFC7396 to update a Redbook entity on a field-by-field bases.
- X-INIT
-
A common routine that is used to call the Host API BAQINIT verb possibly passing a URIMAP Parameter if one has been set up. The BAQINIT verb creates a WEB pooled connection from CICS to the z/OS Connect Server defined by the supplied or default URIMAP.
- X-PUT-DATA-AREA-ELEMENT
-
A common routine that you will write to put a Data Element into a Data Area. The section calls BAQPUTN, passing the Data Area name, element address, and element size that is defined in the calling section.
- X-EXEC
-
A common routine that is used to call the Host API BAQEXEC for any given operation that has been defined by the calling section.
- X-GET-DATA-AREA-ELEMENT
-
A common routine is used to get the next element from a Data Area provided by the BAQEXEC response. The section calls BAQGETN passing the Data Area name and element size that is defined in the calling section.
- X-FREE
-
A common routine that frees any storage that is allocated by BAQEXEC by calling BAQFREE.
- X-TERM
-
A common routine the frees the CICS web connection to z/OS Connect back to a pool for future use by using BAQTERM. CICS maintains the z/OS Connect connection for a specific period to allow for quicker reuse of the connection again with BAQINIT.
Compiling the CICS COBOL program
Procedure
- To compile the CICS COBOL program, transfer the code from COBOL/BAQHRBKC to a suitable z/OS PDS used for copybooks.
- Transfer the generated copybooks from
RedbookApi/build/generated/zosConnectRequester/structures/COBOL/
’operation’/RBKnnx01 to a suitable z/OS PDS used for copybooks. - Compile and link the program by using your appropriate site CICS compilation JCL. With the output-linked load module made available in a PDS that is in the CICS region DFHRPL PDS concatenation.
Configuring CICS for the z/OS Connect API requester tutorial
Before you begin
The following tasks must be completed.
About this task
The CICS region in which you are planning to run the tutorial must be configured with the tutorial program and transaction definitions. Use the following steps to process the CSD file provided in the tutorial. The BAQHRBKD CSD file is provided in the CSD subfolder of the tutorial. This CSD defines the program BAQHRBKC, and three transactions that call it, to CICS in the group BAQHRBKG.
Procedure
- Copy the example commands in the BAQHRBKD CSD file to an existing JCL file that runs DFHCSDUP.
- Submit this JCL to update the tutorial CICS region's CSD with the tutorial definitions.
What to do next
Running the CICS COBOL application as part of the z/OS Connect API requester tutorial
Before you begin
About this task
This task takes you through the steps to run to the CICS COBOL application as part of the z/OS ConnectAPI requester (OpenAPI 3.0) tutorial.
Procedure
- Logon on to your CICS region and run the
transaction
GARB. A list of 10 Redbooks® is displayed on the workstation. Browse the TDQ BAQH (DD BAQHMSG) for any possible errors if the list of 10 Redbooks is not displayed. - View the CICS region Job output CEEMSG for debug trace of the GARB transaction execution.
- View the messages.log of the IBM® z/OS Connect Server for any failure messages.
What to do next
You have completed the first operation of the z/OS ConnectAPI requester tutorial.
If you would like to extend the CICS COBOL application, see Extending the CICS COBOL application as part of the z/OS Connect API requester tutorial.
For more information on z/OS ConnectAPI requester, see Developing an API requester.