JCL:带有 SET 语句的 IF 语句

JCL : IF Statement with SET Statement

我已将 FLAG 设置为 1,并且正在执行 ARG 值应该仅为 DEV。但是我得到的是 ARG= DEV + CLIENTID

000023 //         FLAG=1

000026 // IF (&FLAG=1) THEN        
000027 //SET1     SET ARG=DEV         
000028 // ELSE        
000029 //SET2     SET ARG=DEV+&CLIENT 
000030 // ENDIF                       

这意味着 JCL 在 RUNTIME 中赋值(在检查 IF 条件之前)。

请帮我理解。

谢谢! 巴拉蒂

JCL Manual 中有一些很好的信息来理解 IF/THEN/ELSE 的目的。

以下是手册中的一些要点:

  • The IF/THEN/ELSE/ENDIF statement construct does not conditionally control the processing of JCL; rather, it conditionally controls the
    execution of job steps.
  • The result of processing an IF/THEN/ELSE/ENDIF statement construct, once determined, remains unchanged regardless of the outcome from running any remaining steps in a job. The system does not reexamine the original condition at any later job step termination, either normal or abnormal. See Example 9.
  • The system allocates all DD statements defined to a step if the execution time evaluation of the relational-expression determines
    that a step is to be executed. All data sets defined on DD statements in the job must be available at the time the job is selected for execution.
  • You can nest IF/THEN/ELSE/ENDIF statement constructs up to a maximum of 15 levels. You can specify symbolic parameters on IF/THEN/ELSE/ENDIF statements provided that they resolve to one of the supported relational-expression keywords. Any other symbolic parameters, even if accepted by the system, are not intended or supported.

你所做的似乎合乎逻辑,但这不是 JCL SET 和条件逻辑的预期目的。

在您的情况下,最后执行的 SET 是使用的内容以及您看到 DEV + CLIENTID

的原因

@hogstrom 说的对。 JCL IF 语句测试 Step Return codes 而不是 变量值 :

//IFBAD     IF  (ABEND | STEP1.RC > 8) THEN

根据他的说法,您可以在 include 语句中使用变量

包含变量

//  INCLUDE MEMBER=OPT&FLAG

并在 proclib 中设置成员

成员=OPT1

  // SET ARG=DEV 

成员=OPT2

  // SET ARG=DEV+&CLIENT 

您必须为 每个 可能的 &FLAG 值设置一个包含,并且它对于一个 SET 来说非常冗长.当您可以设置 lots 个变量时,它更常用:

// INCLUDE MEMBER=ENV&ENV

其中 &ENV=PROD \ TEST

你的情况

不使用标志,只设置变量:

// SET ARG=DEV

// SET ARG=DEV+&CLIENT