COBOL parameter passing considerations

COBOL users cannot explicitly set the PLIST and EXECOPS runtime options for an enclave containing a COBOL main program. When COBOL is the main program, Language Environment sets the argument list passed to the application on initialization as follows:
  • z/OS (non-CICS)
    • If the COBOL main is invoked via the ATTACH SVC, a halfword-prefixed string is passed to the application after runtime options have been removed. The source of this string is dependent on the environment in which the ATTACH is issued, as follows:
      • If the ATTACH is issued by z/OS to invoke a batch program, the string is specified via the EXEC statement's PARM field.
      • If the ATTACH is issued by TSO to attach a Command Processor (CP), the string is specified as part of the command embedded within the CP parameter of the TSO ATTACH CP command.
      • Otherwise, the string is specified via the PARM field of the ATTACH macro.
      Note: The parameter list processing when COBOL is invoked with the ATTACH SVC can be altered with the COBOL parameter list exit IGZEPSX so that register 1 and the argument list are passed without change. If your program is not seeing the behavior mentioned previously, then see your system programmer to determine what changes were made to the COBOL parameter list exit. For information on the COBOL parameter list exit, see z/OS Language Environment Customization.

      If changing IGZEPSX is not an approach that can be used in your environment, another approach is to ATTACH to a Language Environment-conforming assembler routine with MAIN=YES and PLIST=OS on the CEEENTRY macro. The Language Environment-conforming assembler routine can then invoke the COBOL program, passing the unchanged contents of register 1 (the address of the parameter list) to the COBOL program.

    • If the COBOL main is not invoked by the ATTACH SVC, the halfword-prefixed string provided by the caller is passed to the application after runtime options have been removed if the following linkage is used:
      • The caller of the COBOL program provides an RSA that contains a back chain (HSA) field of binary 0.
      • Register 1 is nonzero.
      • The word addressed by Register 1 (the first parameter pointer word) has the End of List (EOL) bit on and the parameter it addresses is aligned on a halfword or greater boundary.
    • Otherwise register 1 and the argument list are passed without change.
  • TSO
    • In addition to the previous z/OS (non-CICS) considerations, if the COBOL main is invoked from a REXX clist, parameter list processing depends on the method used to invoke the COBOL program.
      • If Address TSO (the default) or Address ATTCHMVS is used, the halfword-prefixed string provided by the caller is passed to the application after runtime options have been removed. Runtime options are processed. Updates made by COBOL to the parameter are not available to the calling REXX.
      • If Address LINKMVS is used, the parameter list provided by the caller is passed unchanged to the application program. Runtime options, if provided are ignored. Updates made by COBOL to the parameter are available to the calling REXX.
      • Address LINK, Address ATTACH, Address LINKPGM, and Address ATTCHPGM are not supported since they use a different convention for parameter lists and save area chaining.
  • z/OS UNIX
    • The parameter list consists of three parameters passed by reference:
      • Argument-count: a binary fullword integer containing the number of elements in each of the arrays that is passed as the second and third parameters.
      • Argument-length-list: an array of pointers. The Nth entry in the array is the address of a fullword binary integer containing the length of the Nth entry in the Argument-list (the third argument).
      • Argument-list: an array of pointers. The Nth entry in the array is the address of the Nth character string passed as an argument on the spawn(), exec(), or command invocation.
  • CICS®
    • If the COBOL main is invoked in a CICS environment, register 1 is passed without change.