@IF, @ELSE, and @ENDIF statements

Use the @IF, @ELSE, and @ENDIF statements for conditional processing.

Nesting @IF statements is not supported. Only comparisons of strings are supported.

Syntax

//[label] @IF variable1 condition variable2 
BCL statements 
[  
//[label] @ELSE  BCL statements 
] 
//[label] @ENDIF   
variable#
The variable name or string. The variable must end with a period (.), as in the following example:
&TIME.
condition
A comparison of variables to determine if the are the same. Valid values are:
  • EQ = Equal
  • NE = Not equal
The condition must be delimited by leading and trailing periods (.), as in the following example:
&TIME..EQ.NOTIME
BCL statements
One or more BCL statements (with the exception of @IF, @ELSE, or @ENDIF statements) to be processed if the stated conditions are met.

Example

The following sample BCL shows how the @IF-@ELSE;@ENDIF logic can be used. Relevant logic is in bold font.
//COBC EXEC PGM=IGYCRCTL 
//DEFAULT VARS STEP=CONTINUE,TIME=GETTIME  
//SYSIN DD RCCEXT=CBL,DISP=(NEW,DELETE),  
// UNIT=VIO,SPACE=(TRK,(10,10)),  
// DCB=(RECFM=FB,LRECL=80,BLKSIZE=3200)  
//SYSLIB DD RCCEXT=CPY,DISP=(NEW,KEEP),  
// UNIT=VIO,SPACE=(TRK,(10,10)),  
// DCB=(RECFM=FB,LRECL=80,BLKSIZE=3200)  
//SYSLIN DD DISP=SHR,DSN=&HLQ..&SYSTEM..OBJ(&MBR)  
//SYSPRINT DD RCCEXT=RCCOUT,DISP=(NEW,DELETE),  
// UNIT=VIO,SPACE=(TRK,(30,10)), 
// DCB=(RECFM=FB,LRECL=133,BLKSIZE=1330)  
//SYSUT1 DD SPACE=(800,(2500,2500),,,ROUND),UNIT=VIO  
//SYSUT2 DD SPACE=(800,(2500,2500),,,ROUND),UNIT=VIO  
//SYSUT3 DD SPACE=(800,(2500,2500),,,ROUND),UNIT=VIO  
//SYSUT4 DD SPACE=(800,(2500,2500),,,ROUND),UNIT=VIO 
//SYSUT5 DD SPACE=(800,(2500,2500),,,ROUND),UNIT=VIO  
//SYSUT6 DD SPACE=(800,(2500,2500),,,ROUND),UNIT=VIO  
//SYSUT7 DD SPACE=(800,(2500,2500),,,ROUND),UNIT=VIO  
//CHK0 @IF &TIME..EQ.NOTIME   
//STEP3 EXEC PGM=IKJEFT01 
//SYSTSPRT DD RCCEXT=TIME,DISP=(NEW,DELETE),  
// UNIT=VIO,SPACE=(TRK,(30,10)),  
// DCB=(RECFM=FB,LRECL=121,BLKSIZE=1210)  
//SYSTSIN DD *  
TIME  
/*  
//CHK1 @ELSE  
//LKED EXEC PGM=IEWL,COND=(5,LT,COBC)  
//SYSLIB DD DISP=SHR,DSN=&COBCOMP   
//       DD DISP=SHR,DSN=&LERUN  
//CHKEND @ENDIF