IF THEN in JCL Sort Card to format records

The below example says how to use IFTHEN in JCL sort card. IFTHEN will be used to reformat either INREC or OUTREC.

Using IFTHEN clauses, you reformat different records in different ways by specifying how BUILD or OVERLAY items are applied to records that meet given criteria.

if then in jcl

IF Then in JCL Syntax

IFTHEN clauses let you use sophisticated conditional logic to choose how different record types are reformatted. You can use any INCLUDE logical expression to specify the criteria. You can use any BUILD or OVERLAY items to reformat the records that
meet those criteria.

You can also apply BUILD or OVERLAY items to all records, or only to records that do
not meet any of the criteria.

Here’s an example of reformatting with INREC and IFTHEN clauses:

INREC IFTHEN=(WHEN=INIT,OVERLAY=(73:SEQNUM,8,ZD)),
IFTHEN=(WHEN=(4,5,CH,EQ,C'TYPE1'),
BUILD=(1,4,61:C'1',73:73,8)),
IFTHEN=(WHEN=(4,5,CH,EQ,C'TYPE2'),
BUILD=(1,3,61:C'2',73:73,8)),
IFTHEN=(WHEN=NONE,BUILD=(1,5,61:C'',73:73,8))

One of the interview question is, IFTHEN is used  for conditional logic.

Author: Srini

Experienced software developer. Skills in Development, Coding, Testing and Debugging. Good Data analytic skills (Data Warehousing and BI). Also skills in Mainframe.

Comments are closed.