CALLPGM

You can use this function to call a user-written program directly from a script. Many parameters can be passed to the program being called. The program being called must be defined either in LINKLIB or in STEPLIB of the job running the script. Parameters are passed to the user-written program by using standard z/OS linkage. Both numeric and character variables can be passed to the user program. Numeric variables are passed as a full word binary, while character data is passed as a string of characters.

Note: Character strings passed point to the first byte of the data, and are terminated by a single NULL character.

The program called by the CALLPGM function, should not update any of the variables. Variables cannot be updated from the called program. The only data that can be passed back to the script file is the return code. Variable %RC is updated with the return code set by the called program.

If the program defined in the CALLPGM function is not found, an error is displayed and the script is terminated. If an abend occurs while in control of the user-written program, error messages are displayed and the script is terminated.

The format of this function is CALLPGM program_name parm1 parm2 parm3 parm4 parm5 . . . parm n. For example, CALLPGM USERPGM %A %B 5 %CHARDATA. This command calls the USERPGM program and passes 4 parameters to the program. Assume that the variables are set in the following way: %A = "12", %B = 255, and %CHARDATA = "TESTDATA" . When control is passed to USERPGM, R1 points to the address of an address list containing 4 addresses: R1 > Address (parameter 1), Address (parameter 2), Address (parameter 3), Address (parameter 4) > c'12',x'00', x'000000FF', x'00000005', c'TESTDATA',x'00'.
Note: Because standard z/OS linkage conventions are used, USERPGM can be written in any language that supports z/OS linkage conventions.