Invocation - Calling
Enhanced Definition
In the mainframe context, **invocation** or **calling** refers to the process by which one program or routine transfers control to another program, subroutine, or function to perform a specific task. This mechanism is fundamental to modular programming, allowing for code reuse and structured application design within environments like z/OS, COBOL, JCL, CICS, and DB2.
Key Characteristics
-
- Control Transfer: The calling program temporarily relinquishes control to the called program, which executes its logic. Upon completion, the called program typically returns control to the point of invocation in the calling program.
- Parameter Passing: Data can be passed between the calling and called programs using various mechanisms, such as
BY REFERENCE(passing the address of data) orBY CONTENT(passing a copy of data) in COBOL, or via a COMMAREA in CICS. - Linkage Conventions: Standardized conventions (e.g., IBM's OS linkage conventions for z/OS) dictate how registers are used, parameters are passed, and control is returned, ensuring interoperability between programs written in different languages (COBOL, Assembler, PL/I).
- Static vs. Dynamic Calls: Programs can be linked statically at compile/link-edit time (e.g.,
CALL 'SUBPROG') or dynamically loaded at runtime (e.g.,CALL identifierwhereidentifiercontains the program name). Dynamic calls offer greater flexibility but incur a slight runtime overhead. - Program Types: Invocation applies to various program types, including subroutines, subprograms, CICS programs (via
LINKorXCTL), DB2 stored procedures, and even operating system utilities invoked via JCL.
Use Cases
-
- COBOL Subroutine Execution: A main COBOL program calls a common utility subroutine (e.g., a date formatting routine or a data validation module) using the
CALLstatement to perform a specific, reusable function.
cobol CALL 'DATEUTIL' USING WS-INPUT-DATE, WS-FORMATTED-DATE.- CICS Program Linking: A CICS transaction program invokes another CICS program using
EXEC CICS LINK PROGRAM('PROGNAME')to perform a logical unit of work, with the called program returning control to the caller.
cobol EXEC CICS LINK PROGRAM('SUBPROG') COMMAREA(WS-COMMAREA) LENGTH(LENGTH OF WS-COMMAREA) END-EXEC.- JCL Program Execution: A JCL
EXECstatement invokes a batch program or utility (e.g.,PGM=IDCAMSfor VSAM operations orPGM=MYBATCHPfor a
- COBOL Subroutine Execution: A main COBOL program calls a common utility subroutine (e.g., a date formatting routine or a data validation module) using the
Related Products
Related Vendors
IBM
646 products
Trax Softworks
3 products