IF Statements in JCL

So there you are one night at your neighbor’s cocktail party, enjoying the hors d’oeuvres and nice glass of wine or two, when you inexplicably find yourself cornered by this crusty old bore who prattles on and on and on about, of all things, some obscure old computer language.

“This is done through the use of condition codes,” he drones, and, taking a deep breath, proceeds to launch into a painful exposition of Job Control Language, (JCL for short!), and how and why condition codes are used to control the execution of batch programs.

Have no fear, my good man, (or woman), for with just a click of your fingers, you summon up the words of knowledge you may use to subdue this noxious beast.

“Condition codes are so passé,” you reply, and he looks back at you, stunned. “Indeed! JCL has included the “IF”, “ELSE”, and “ENDIF” commands for years now, and their use has vastly simplified and improved conditional branching within a job.”

“Allow me to give you an example. Suppose you have a job with four steps, AA, BB, CC, and DD. You want to run step BB only if the condition code from step AA is zero, and you want to run step CC only if the condition code from step AA is NOT zero. You want to run step DD regardless.”

“This simple set of JCL will do that, and it will do it in a way that is MUCH easier to follow than the old condition code step parameters which you describe:”

//STEPAA EXEC PGM=PROGRAMA

//DOBB IF (STEPAA.RC = 0) THEN

//STEPBB EXEC PGM=PROGRAMB

//DOCC ELSE

//STEPCC EXEC PGM=PROGRAMC

//ENDCHECK ENDIF

//STEPDD EXEC PGM=PROGRAMD

As you finish you hear him mutter something indistinct, then, looking at his feet, shuffle away. A few minutes later he has his coat on, and is leaving through the front door.

Your work is now done. Enjoy the rest of the party!