Substituting variables

JCL preparation can be:
SETUP=PROMPT
A user must assign the value.
SETUP=YES
A value is automatically assigned at JCL preparation, or at submit time if no JCL preparation is performed.
SETUP=NO
A value is assigned at submit time.

SELECT JCLPREP retrieves the promptable variables that do not have a value assigned. When returned, the data area parameter locates a JCL setup variable record, the header, a common segment, and a sequence of variable segments JSVV. The field JSVVVALUE of the JSVV segment can be assigned a new value.

INSERT JCLPREP is used to make the promptable variables in the JCL setup variable record assigned to the JCL record. When all promptable variables of the JCL record are assigned, SELECT JCLPREP receives a return code 4.

To update the JCL record, you must execute a SELECT JS request followed by an INSERT or REPLACE JS request. When the SELECT JS is returned, the retrieved JCL record will have promptable variables resolved if a value was assigned in the SELECT JCLPREP, INSERT JCLPREP sequence. Nonpromptable setup variables are also resolved, while submit variables remain unresolved. An INSERT or REPLACE JS request is required to have the updated JCL reflected in the database and must be complete to end the JCL preparation session.

If the JCL record is not present on the JS file, an INSERT JS request is required. A LIST JS request will get return code 4 if the JCL record is not found in the JS file. SELECT JS will retrieve the JCL from the job library EQQJBLIB.

If the JCL record does not contain promptable variables, SELECT JCLPREPA must be used to assign values to nonpromptable setup variables. So, if the first SELECT JCLPREP results in return code 4, a SELECT JCLPREPA must be executed instead of the SELECT JS before the INSERT or REPLACE JCL request.

The sample library member EQQPIFAP contains a sample program that resolves JCL variables using the program interface. See Sample library (SEQQSAMP) for more information about individual members of the sample library.

Example of a PIF request logic flow:
INIT
OPTIONS
DO while(RC=0)
  SELECT JCLPREP      (opno of the JOB operation)
    set up the prompt var
      INSERT JCLPREP  (opno of the JOB operation)
END
LIST JSCOM            (opno and wsn of JOB operation)
SELECT JS             (opno and wsn of JOB operation)
 check RC from the LIST JSCOM
 if RC=0 then
  REPLACE JS
 if RC=4 then
  INSERT  JS
TERM
Note: If there is a SETUP operation for this computer operation, and if you want to set it to Complete, add the following statements before the TERM request:
MODIFY CPOC
MODIFY CPOP           (opno and wsn of SETUP operation)
EXECUTE

For a description of the SETUP and JOB setup operations, see Managing the Workload.