Linking by dynamic calls
When you develop your z/OS® application to call HTTP APIs from COBOL or PL/I, ensure that you use dynamic linkage where possible, between the z/OS application code and the Host API load module supplied with IBM® z/OS Connect.
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.
Why use dynamic linkage?
Using dynamic linkage is always preferred because it enables your program to use, without relinking, the most current version of the Host API load module and the associated transport modules delivered through regular z/OS Connect product maintenance. When static linkage is used, you must relink your z/OS application program to benefit from the latest maintenance.
When can dynamic linkage be used?
Dynamic linkage can be applied to the Host API module
<hlq>.SBAQLIB1(BAQHAPIC) for CICS applications, and
<hlq>.SBAQLIB(BAQHAPIW) for IMS and z/OS applications, and <hlq>.SBAQLIB2
(BAQHAPIT) for IMS applications that use the IMS Transaction Manager Resource Adapter.
How to make dynamic calls
| Environment | Language | Programming instructions |
|---|---|---|
| CICS | COBOL | Use the CALL
identifier statement 1
3 . For detailed instructions, see Using CALL identifier to make dynamic
calls in COBOL. |
| CICS | PL/I | For detailed instructions, see Making dynamic calls from PL/I applications. |
| z/OS applications | COBOL | Two methods are available:
|
- 1
CALLidentifier, where identifier is a data item that contains the name of a nonnested subprogram at run time, always results in the target subprogram being loaded when it is called. - 2
CALLliteral, where literal is the explicit name of a nonnested target subprogram, can be resolved either statically or dynamically. - 3 Use copybook BAQHCONC that defines a number of 77 Level
variables, one per Host API verb. For example,
BAQ-INIT-NAMEfor BAQINIT.
Making dynamic calls from COBOL applications
To help ensure that your COBOL application uses dynamic linkage with the Host API load module, you can use one of the following methods:
- Using
CALLidentifier to make dynamic calls in COBOL -
Using the
CALLidentifier statement is an explicit method for the COBOL programmer to use dynamic linkage.Note: For CICS COBOL applications, this method is the only one supported.An example of using this explicit dynamic link convention for COBOL is shown:B-INIT SECTION. B-010. * Initialise the Host API CALL BAQ-INIT-NAME USING BY REFERENCE BAQ-ZCONNECT-AREA. * Check for bad initialization IF NOT BAQ-SUCCESS THEN MOVE BAQ-ZCON-COMPLETION-CODE TO WS-CC9 MOVE BAQ-ZCON-REASON-CODE TO WS-RC9 STRING WS-PROGRAM '--INIT failed' '-CC-' WS-CC9 '-RC-' WS-RC9 DELIMITED BY '>' INTO WS-DISPLAY-MSG DISPLAY WS-DISPLAY-MSG DISPLAY BAQ-ZCON-RETURN-MESSAGE STOP RUN END-IF. B-999. EXIT. - Using
CALLliteral andDYNAMto make dynamic calls in COBOL (non-CICS) -
If your COBOL application specifies the
CALLtarget as a literal string,'BAQINIT', static linkage is used. To force your z/OS application to use dynamic linkage, you must set theDYNAMcompile option to YES when you compile your application.Note: This method is not supported for CICS COBOL applications when you use the z/OS Connect API requester feature because the Host API uses the CICS translator but the CICS translator cannot be used with theDYNAMoption.An example of using a static link convention for COBOL:* Invoke the z/OS Connect Host API by using static linkage CALL 'BAQINIT' USING BY REFERENCE BAQ-ZCONNECT-AREA.For more information about how to use
DYNAM, see thein the Enterprise COBOL for z/OS documentation.
Making dynamic calls from PL/I applications
To ensure that your PL/I application uses dynamic linkage with the Host API, you must declare the Host API verb as EXTERNAL together
with the ENTRY OPTIONS attribute NODESCRIPTOR. Then use a
FETCH statement to dynamically load the Host API verb, and then use a CALL
statement to invoke the verb. This method is considered best practice for PL/I applications when you
use the API requester feature and is handled for
you when you include the provided BAQHCONP include file.
// API requester Host API required copy books
%include BAQHAREP;
%include BAQHCONP;
// BAQ Call return code
DCL baq_rc UNSIGNED FIXED BIN(32);
// Initialise the Host API
baq_rc = BAQINIT(BAQ_ZCONNECT_AREA); BAQ_REQ_BASE_ADDRESS = SYSNULL();
BAQ_REQ_BASE_LENGTH = 0; BAQ_RESP_BASE_ADDRESS = SYSNULL();
BAQ_RESP_BASE_LENGTH = 0;