Upload
avi-srivastava
View
301
Download
15
Embed Size (px)
DESCRIPTION
JCL Quick Guide
Citation preview
15/07/2015 JCLQuickGuide
http://www.tutorialspoint.com/cgibin/printpage.cgi 1/39
http://www.tutorialspoint.com/jcl/jcl_quick_guide.htm Copyrighttutorialspoint.com
JCLQUICKGUIDE
JCLOVERVIEW
WhentouseJCL
JCLisusedinamainframeenvironmenttoactasacommunicationbetweenaprogram(Example:COBOL,AssemblerorPL/I)andtheoperatingsystem.Inamainframeenvironment,programscanbeexecutedinbatchandonlinemode.ExampleofabatchsystemcanbeprocessingthebanktransactionsthroughaVSAM(VirtualStorageAccessMethod)fileandapplyingittothecorrespondingaccounts.Exampleofanonlinesystemcanbeabackofficescreenusedbystaffsinabanktoopenanaccount.Inbatchmode,programsaresubmittedtotheoperatingsystemasajobthroughaJCL.
BatchandOnlineprocessingdifferintheaspectofinput,outputandprogramexecutionrequest.Inbatchprocessing,theseaspectsarefedintoaJCLwhichisinturnreceivedbytheOperatingSystem.
JobProcessing
Ajobisaunitofworkwhichcanbemadeupofmanyjobsteps.EachjobstepisspecifiedinaJobControlLanguage(JCL)throughasetofJobControlStatements.
TheOperatingSystemusesJobEntrySystem(JES)toreceivejobsintotheOperatingSystem,toschedulethemforprocessingandtocontroltheoutput.
Jobprocessinggoesthroughaseriesofstepsasgivenbelow:
JobSubmissionSubmittingtheJCLtoJES.
JobConversionTheJCLalongwiththePROCisconvertedintoaninterpretedtexttobe
15/07/2015 JCLQuickGuide
http://www.tutorialspoint.com/cgibin/printpage.cgi 2/39
understoodbyJESandstoredintoadataset,whichwecallasSPOOL.
JobQueuingJESdecidesthepriorityofthejobbasedonCLASSandPRTYparametersintheJOBstatement(explainedinJCLJOBStatementchapter).TheJCLerrorsarecheckedandthejobisscheduledintothejobqueueiftherearenoerrors.
JobExecutionWhenthejobreachesitshighestpriority,itistakenupforexecutionfromthejobqueue.TheJCLisreadfromtheSPOOL,theprogramisexecutedandtheoutputisredirectedtothecorrespondingoutputdestinationasspecifiedintheJCL.
PurgingWhenthejobiscomplete,theallocatedresourcesandtheJESSPOOLspaceisreleased.Inordertostorethejoblog,weneedtocopythejoblogtoanotherdatasetbeforeitisreleasedfromtheSPOOL.
JCLENVIRONMENTSETUP
InstallingJCLonWindows/Linux
TherearemanyFreeMainframeEmulatorsavailableforWindowswhichcanbeusedtowriteandlearnsampleJCLs.
OnesuchemulatorisHercules,whichcanbeeasilyinstalledinWindowsbyfollowingfewsimplestepsgivenbelow:
DownloadandinstalltheHerculesemulator,whichisavailablefromtheHercules'homesite:www.hercules390.eu
OnceyouinstalledpackageonWindowsmachine,itwillcreateafolderlikeC:\Mainframes.
RunCommandPrompt(CMD)andreachthedirectoryC:\MainframesonCMD.
ThecompleteguideonvariouscommandstowriteandexecuteaJCLcanbefoundonURLwww.jaymoseley.com/hercules/installmvs/instmvs2.htm
HerculesisanopensourcesoftwareimplementationofthemainframeSystem/370andESA/390architectures,inadditiontothelatest64bitz/Architecture.HerculesrunsunderLinux,Windows,Solaris,FreeBSD,andMacOSX.
RunningJCLonMainframes
Ausercanconnecttoamainframeserverinanumberofwayssuchathinclient,dummyterminal,VirtualClientSystem(VCS)orVirtualDesktopSystem(VDS).
EveryvaliduserisgivenaloginidtoenterintotheZ/OSinterface(TSO/EorISPF).IntheZ/OSinterface,theJCLcanbecodedandstoredasamemberinaPartitionedDataset(PDS).WhentheJCLissubmitted,itisexecutedandtheoutputreceivedasexplainedinthejobprocessingsectionofpreviouschapter.
StructureofaJCL
ThebasicstructureofaJCLwiththecommonstatementsisgivenbelow:
15/07/2015 JCLQuickGuide
http://www.tutorialspoint.com/cgibin/printpage.cgi 3/39
//SAMPJCLJOB1,CLASS=6,MSGCLASS=0,NOTIFY=&SYSUID(1)//*(2)//STEP010EXECPGM=SORT(3)//SORTINDDDSN=JCL.SAMPLE.INPUT,DISP=SHR(4)//SORTOUTDDDSN=JCL.SAMPLE.OUTPUT,(5)//DISP=(NEW,CATLG,CATLG),DATACLAS=DSIZE50//SYSOUTDDSYSOUT=*(6)//SYSUDUMPDDSYSOUT=C(6)//SYSPRINTDDSYSOUT=*(6)//SYSINDD*(6)SORTFIELDS=COPYINCLUDECOND=(28,3,CH,EQ,C'XXX')/*(7)
ProgramDescription
ThenumberedJCLstatementshavebeenexplainedbelow:
(1)JOBstatementSpecifiestheinformationrequiredforSPOOLingofthejobsuchasjobid,priorityofexecution,useridtobenotifieduponcompletionofthejob.
(2)//*statementThisisacommentstatement.
(3)EXECstatementSpecifiesthePROC/Programtobeexecuted.Intheaboveexample,aSORTprogramisbeingexecuted(i.e.,sortingtheinputdatainaparticularorder)
(4)InputDDstatementSpecifiesthetypeofinputtobepassedtotheprogrammentionedin(3).Intheaboveexample,aPhysicalSequential(PS)fileispassedasinputinsharedmode(DISP=SHR).
(5)OutputDDstatementSpecifiesthetypeofoutputtobeproducedbytheprogramuponexecution.Intheaboveexample,aPSfileiscreated.Ifastatementextendsbeyondthe70thpositioninaline,thenitiscontinuedinthenextline,whichshouldstartwith"//"followedbyoneormorespaces.
(6)TherecanbeothertypesofDDstatementstospecifyadditionalinformationtotheprogram(Intheaboveexample:TheSORTconditionisspecifiedintheSYSINDDstatement)andtospecifythedestinationforerror/executionlog(Example:SYSUDUMP/SYSPRINT).DDstatementscanbecontainedinadataset(mainframefile)orasinstreamdata(informationhardcodedwithintheJCL)asgiveninaboveexample.
(7)/*markstheendofinstreamdata.
AlltheJCLstatementsexceptinstreamdatastartswith//.ThereshouldbeatleastonespacebeforeandafterJOB,EXECandDDkeywordsandthereshouldnotbeanyspacesinrestofthestatement.
JOBParameterTypes
EachoftheJCLstatementsisaccompaniedbyasetofparameterstohelptheOperatingSystemsincompletingtheprogramexecution.Theparameterscanbeoftwotypes:
PositionalParameters
Appearsatpredefinedpositionandorderinthestatement.Example:Accountinginformation
15/07/2015 JCLQuickGuide
http://www.tutorialspoint.com/cgibin/printpage.cgi 4/39
ParametercanappearonlyaftertheJOBkeywordandbeforetheprogrammernameparameterandtheKeywordParameters.Ifapositionalparameterisomitted,ithastobereplacedwithacomma.
PositionalParametersarepresentinJOBandEXECstatements.Intheaboveexample,PGMisapositionalparametercodedaftertheEXECkeyword.
KeywordParameters
Theyarecodedafterthepositionalparameters,butcanappearinanyorder.Keywordparameterscanbeomittedifnotrequired.ThegenericsyntaxisKEYWORD=value.Example:MSGCLASS=X,i.e.,thejoblogisredirectedtotheoutputSPOOLafterthejobcompletion.
Intheaboveexample,CLASS,MSGCLASSandNOTIFYarekeywordparametersofJOBstatement.TherecanbekeywordparametersinEXECstatementaswell.
Theseparametershavebeendetailedoutinthesubsequentchaptersalongwithappropriateexamples.
JCLJOBSTATEMENT
JOBStatementisthefirstcontrolstatementinaJCL.ThisgivestheidentityofthejobtotheOperatingSystem(OS),inthespoolandinthescheduler.TheparametersintheJOBstatementhelptheOperatingSystemsinallocatingtherightscheduler,requiredCPUtimeandissuingnotificationstotheuser.
Syntax
FollowingisthebasicsyntaxofaJCLJOBstatement:
//JobnameJOBPositionalparam,Keywordparam
Description
LetusseethedescriptionofthetermsusedinaboveJOBstatementsyntax.
Jobname
ThisgivesanidtothejobwhilesubmittingittotheOS.Itiscanbelengthof1to8withalphanumericcharactersandstartsjustafter//.
JOB
ThisisthekeywordtoidentifyitasaJOBstatement.
Positionalparam
Therearepositionalparameters,whichcanbeoftwotypes:
Positional Description
15/07/2015 JCLQuickGuide
http://www.tutorialspoint.com/cgibin/printpage.cgi 5/39
Parameter
Accountinformation
ThisreferstothepersonorgrouptowhichtheCPUtimeisowed.Itissetaspertherulesofthecompanyowningthemainframes.Ifitisspecifiedas(*),thenittakestheidoftheuser,whohascurrentlyloggedintotheMainframeTerminal.
Programmername Thisidentifiesthepersonorgroup,whoisinchargeoftheJCL.Thisisnotamandatoryparameterandcanbereplacedbyacomma.
Keywordparam
Followingarethevariouskeywordparameters,whichcanbeusedinJOBstatement.Youcanuseoneormoreparametersbasedonrequirementsandtheyareseparatedbycomma:
KeywordParameter Description
CLASSBasedonthetimedurationandthenumberofresourcesrequiredbythejob,companiesassigndifferentjobclasses.ThesecanbevisualizedasindividualschedulersusedbytheOStoreceivethejobs.Placingthejobsintherightschedulerwillaidineasyexecutionofthejobs.Somecompanieshavedifferentclassesforjobsintestandproductionenvironment.
ValidvaluesforCLASSparameterareAtoZcharactersand0to9numeric(oflength1).Followingisthesyntax:
CLASS=0to9|AtoZ
PRTYTospecifythepriorityofthejobwithinajobclass.Ifthisparameterisnotspecified,thenthejobisaddedtotheendofthequeueinthespecifiedCLASS.Followingisthesyntax:
PRTY=N
WhereNisanumberinbetween0to15andhigherthenumber,higheristhepriority.
NOTIFY
15/07/2015 JCLQuickGuide
http://www.tutorialspoint.com/cgibin/printpage.cgi 6/39
Thesystemsendsthesuccessorfailuremessage(MaximumConditionCode)totheuserspecifiedinthisparameter.Followingisthesyntax:
NOTIFY="userid|&SYSUID"
Heresystemsendsthemessagetotheuser"userid"butifweuseNOTIFY=&SYSUID,thenthemessageissenttotheusersubmittingtheJCL.
MSGCLASSTospecifytheoutputdestinationforthesystemandJobmessageswhenthejobiscomplete.Followingisthesyntax:
MSGCLASS=CLASS
ValidvaluesofCLASScanbefrom"A"to"Z"and"0"to"9".MSGCLASS=YcanbesetasaclasstosendthejoblogtotheJMR(JOBLOGManagementandRetrieval:arepositorywithinmainframestostorethejobstatistics).
MSGLEVELSpecifiesthetypeofmessagestobewrittentotheoutputdestinationspecifiedintheMSGCLASS.Followingisthesyntax:
MSGLEVEL=(ST,MSG)
ST=Typeofstatementswrittentooutputlog
WhenST=0,Jobstatementsonly.
WhenST=1,JCLalongwithsymbolicparametersexpanded.
WhenST=2,InputJCLonly.
MSG=Typeofmessageswrittentooutputlog.
WhenMSG=0,AllocationandTerminationmessageswrittenuponabnormaljobcompletion.
WhenMSG=1,AllocationandTerminationmessageswrittenirrespectiveofthenatureofjobcompletion.
TYPRUNSpecifiesaspecialprocessingforthejob.Followingisthesyntax:
15/07/2015 JCLQuickGuide
http://www.tutorialspoint.com/cgibin/printpage.cgi 7/39
TYPRUN=SCAN|HOLD
WhereSCANandHOLDhasthefollowingdescription
TYPRUN=SCANchecksthesyntaxerrorsoftheJCLwithoutexecutingit.
TYPRUN=HOLDputsthejobonHOLDinthejobqueue.Toreleasethejob,"A"canbetypedagainstthejobintheSPOOL,whichwillbringthejobtoexecution.
TIMESpecifiesthetimespantobeusedbytheprocessortoexecutethejob.Followingisthesyntax:
TIME=(mm,ss)orTIME=ss
Wheremm=minutesandss=seconds
Thisparametercanbeusefulwhiletestinganewlycodedprogram.Inordertoensurethattheprogramdoesnotrunforlongbecauseofloopingerrors,atimeparametercanbecodedsothattheprogramabendswhenthespecifiedCPUtimeisreached.
REGIONSpecifiestheaddressspacerequiredtorunajobstepwithinthejob.Followingisthesyntax:
REGION=nK|nM
Here,regioncanbespecifiedasnKornMwherenisanumber,KiskilobyteandMisMegabyte.
WhenREGION=0Kor0M,largestaddressspaceisprovidedforexecution.Incriticalapplications,codingof0Kor0Misprohibitedtoavoidwastingtheaddressspace.
Example
//URMISAMPJOB(*),"tutpoint",CLASS=6,PRTY=10,NOTIFY=&SYSUID,//MSGCLASS=X,MSGLEVEL=(1,1),TYPRUN=SCAN,
15/07/2015 JCLQuickGuide
http://www.tutorialspoint.com/cgibin/printpage.cgi 8/39
//TIME=(3,0),REGION=10K
Here,JOBstatementisgettingextendedbeyondthe70thpositioninaline,sowecontinueinthenextlinewhichshouldstartwith"//"followedbyoneormorespaces.
MiscellaneousParameters
Therearefewotherparameters,whichcanbeusedwithJOBStatementbuttheyarenotfrequentlyused:
ADDRSPC Typeofstorageused:VirtualorReal
BYTES Sizeofdatatobewrittentooutputlogandtheactiontobetakenwhenthesizeisexceeded.
LINES Maximumnumberoflinestobeprintedtooutputlog.
PAGES Maximumnumberofpagestobeprintedtooutputlog.
USER Useridusedtosubmitthejob
PASSWORD PasswordoftheuseridspecifiedintheUSERparameter.
CONDandRESTART TheseareusedinconditionaljobstepprocessingandareexplainedindetailwhilediscussingconditionalProcessing.
JCLEXECSTATEMENT
EachJCLcanbemadeofmanyjobsteps.Eachjobstepcanexecuteaprogramdirectlyorcancallaprocedure,whichinturnexecutesoneormoreprograms(jobsteps).Thestatement,whichholdsthejobstepprogram/procedureinformationistheEXECstatement.
ThepurposeoftheEXECstatementistoproviderequiredinformationfortheprogram/procedureexecutedinthejobstep.Parameterscodedinthisstatementcanpassdatatotheprograminexecution,canoverridecertainparametersofJOBstatementandcanpassparameterstotheprocedureiftheEXECstatementcallsaprocedureinsteadofdirectlyexecutingaprogram.
Syntax
FollowingisthebasicsyntaxofaJCLEXECstatement:
//StepnameEXECPositionalparam,Keywordparam
Description
15/07/2015 JCLQuickGuide
http://www.tutorialspoint.com/cgibin/printpage.cgi 9/39
LetusseethedescriptionofthetermsusedinaboveEXECstatementsyntax.
STEPNAME
ThisidentifiesthejobstepwithintheJCL.Itcanbeoflength1to8withalphanumericcharacters.
EXEC
ThisisthekeywordtoidentifyitasanEXECstatement.
POSITIONALPARAM
Thesearepositionalparameters,whichcanbeoftwotypes:
PositionalParameter Description
PGM Thisreferstotheprogramnametobeexecutedinthejobstep.
PROC Thisreferstotheprocedurenametobeexecutedinthejobstep.Wewilldiscussitaseparatechapter.
KEYWORDPARAM
FollowingarethevariouskeywordparametersforEXECstatement.Youcanuseoneormoreparametersbasedonrequirementsandtheyareseparatedbycomma:
KeywordParameter Description
PARMUsedtoprovideparametrizeddatatotheprogramthatisbeingexecutedinthejobstep.Thisisaprogramdependantfieldanddonothavedefiniterules,exceptthatthePARMvaluehastobeincludedwithinquotationintheeventofhavingspecialcharacters.
Forexamplegivenbelow,thevalue"CUST1000"ispassedasanalphanumericvaluetotheprogram.IftheprogramisinCOBOL,thevaluepassedthroughaPARMparameterinaJCLisreceivedintheLINKAGESECTIONoftheprogram.
ADDRSPCThisisusedtospecifywhetherthejobsteprequirevirtualorreal
15/07/2015 JCLQuickGuide
http://www.tutorialspoint.com/cgibin/printpage.cgi 10/39
storageforexecution.Virtualstorageispageablewhereasrealstorageisnotandisplacedinthemainmemoryforexecution.Jobsteps,whichrequirefasterexecutioncanbeplacedinrealstorage.Followingisthesyntax:
ADDRSPC=VIRT|REAL
WhenanADDRSPCisnotcoded,VIRTisthedefaultone.
ACCTThisspecifiestheaccountinginformationofthejobstep.Followingisthesyntax:
ACCT=(userid)
ThisissimilartothepositionalparameteraccountinginformationintheJOBstatement.IfitiscodedbothinJOBandEXECstatement,thentheaccountinginformationinJOBstatementappliestoalljobstepswhereanACCTparameterisnotcoded.TheACCTparameterinanEXECstatementwilloverridetheonepresentintheJOBstatementforthatjobsteponly.
CommonKeywordParametersofEXECandJOBStatement
KeywordParameter Description
ADDRSPC ADDRSPCcodedinJOBstatementoverridestheADDRSPCcodedinEXECstatementofanyjobstep.
TIME IfTIMEiscodedinanEXECstatement,thenitappliestothatjobsteponly.IfitisspecifiedinbothJOBandEXECstatement,thenbothwillbeineffectandcancausetimeouterrorduetoeitherofit.ItisnotrecommendedtouseTIMEparameterinboththeJOBandEXECstatementtogether.
REGIONIfREGIONiscodedinanEXECstatement,thenitappliestothatjobsteponly.
REGIONcodedinJOBstatementoverridestheREGIONcodedinEXEC
15/07/2015 JCLQuickGuide
http://www.tutorialspoint.com/cgibin/printpage.cgi 11/39
statementofanyjobstep.
CONDUsedtocontrolthejobstepexecutionbasedonthereturncodeofthepreviousstep.
IfaCONDparameteriscodedinanEXECstatementofajobstep,thentheCONDparameteroftheJOBstatement(ifpresent)isignored.ThevariousteststhatcanbeperformedusingaCONDparameterisexplainedinconditionalProcessing.
Example
FollowingisasimpleexampleofJCLscriptalongwithJOBandEXECstatements:
//TTYYSAMPJOB'TUTO',CLASS=6,MSGCLASS=X,REGION=8K,//NOTIFY=&SYSUID//*//STEP010EXECPGM=MYCOBOL,PARAM=CUST1000,//ACCT=(XXXX),REGION=8K,ADDRSPC=REAL,TIME=1440
JCLDDSTATEMENT
Datasetsaremainframefileswithrecordsorganisedinaspecificformat.DatasetsarestoredontheDirectAccessStorageDevice(DASD)orTapesofthemainframeandarebasicdatastorageareas.Ifthesedataarerequiredtobeused/createdinabatchprogram,thenthefile(i.e.,dataset)physicalnamealongwiththefileformatandorganisationarecodedinaJCL.
ThedefinitionofeachdatasetusedintheJCLisgivenusingtheDDstatement.TheinputandoutputresourcesrequiredbyajobstepneedstobedescribedwithinaDDstatementwithinformationsuchasthedatasetorganisation,storagerequirementsandrecordlength.
Syntax
FollowingisthebasicsyntaxofaJCLDDstatement:
//DDnameDDParameters
Description
LetusseethedescriptionofthetermsusedinaboveDDstatementsyntax.
DDNAME
15/07/2015 JCLQuickGuide
http://www.tutorialspoint.com/cgibin/printpage.cgi 12/39
ADDNAMEidentifiesthedatasetorinput/outputresource.Ifthisisaninput/outputfileusedbyaCOBOL/Assemblerprogram,thenthefileisreferencedbythisnamewithintheprogram.
DD
ThisisthekeywordtoidentifyitasanDDstatement.
PARAMETERS
FollowingarethevariousparametersforDDstatement.Youcanuseoneormoreparametersbasedonrequirementsandtheyareseparatedbycomma:
Parameter Description
DSNTheDSNparameterreferstothephysicaldatasetnameofanewlycreatedorexistingdataset.TheDSNvaluecanbemadeupofsubnameseachof1to8characterslength,separatedbyperiodsandoftotallengthof44characters(alphanumeric).Followingisthesyntax:
DSN=PhysicalDatasetName
Temporarydatasetsneedstorageonlyforthejobdurationandaredeletedatjobcompletion.SuchdatasetsarerepresentedasDSN=&nameorsimplywithoutaDSNspecified.
Ifatemporarydatasetcreatedbyajobstepistobeusedinthenextjobstep,thenitisreferencedasDSN=*.stepname.ddname.ThisiscalledBackwardReferencing.
DISPTheDISPparameterisusedtodescribethestatusofthedataset,dispositionattheendofthejobsteponnormalandabnormalcompletion.DISPisnotrequiredinaDDstatementonlywhenthedatasetgetscreatedanddeletedinthesamejobstep(likethetemporarydatasets).Followingisthesyntax:
DISP=(status,normaldisposition,abnormaldisposition)
Followingarevalidvaluesforstatus:
NEW:Thedatasetisnewlycreatedbythejobstep.OUTPUT1intheexampleabove.
15/07/2015 JCLQuickGuide
http://www.tutorialspoint.com/cgibin/printpage.cgi 13/39
OLD:Thedatasetisalreadycreatedandwillbeoverwritteninthejobstep.Thejobstepgainsexclusiveaccessonthedatasetandnootherjobcanaccessthisdatasetuntilthecompletionofthejobstep.
SHR:Thedatasetisalreadycreatedandwillbereadinthejobstep.Thedatasetcanbereadbymultiplejobsatthesametime.Example:INPUT1andINPUT2.
MOD:Thedatasetisalreadycreated.Thisdispositionwillbeusedwhenthereisaneedtoappendnewrecordstotheexistingdataset(existingrecordswillnotbeoverwritten).
Anormaldispositionparametercantakeoneofthefollowingvalues
CATLG,UNCATLG,DELETE,PASSandKEEP
Aabnormaldispositionparametercantakeoneofthefollowingvalues
CATLG,UNCATLG,DELETEandKEEP
HereisthedescriptionofCATLG,UNCATLG,DELETE,PASSandKEEPparameters:
CATLG:Thedatasetisretainedwithaentryinthesystemcatalog.
UNCATLG:Thedatasetisretainedbutsystemcatalogentryisremoved.
KEEP:Thedatasetisretainedwithoutchanginganyofthecatalogentries.KEEPistheonlyvaliddispositionforVSAMfiles.Thisistobeusedonlyforpermanentdatasets.
DELETE:Datasetisdeletedfromuserandsystemcatalog.
PASS:Thisisvalidonlyfornormaldisposition.ThisisusedwhenthedatasetistobepassedandprocessedbythenextjobstepinaJCL
WhenanyofthesubparametersofDISParenotspecified,thedefaultvaluesareasfollows:
status:NEWisthedefaultvalue.
normaldisposition:IfstatusisNEW,defaultnormaldispositionisDELETE,elseitisKEEP.
15/07/2015 JCLQuickGuide
http://www.tutorialspoint.com/cgibin/printpage.cgi 14/39
abnormaldisposition:Sameasnormaldisposition.
DCBTheDataControlBlock(DCB)parameterdetailsthephysicalcharacteristicsofadataset.Thisparameterisrequiredfordatasetsthatarenewlycreatedinthejobstep.
LRECListhelengthofeachrecordheldwithinthedataset.
RECFMistherecordformatofthedataset.RECFMcanholdvaluesFB,VorVB.FBisafixedblockorganisationwhereoneormorelogicalrecordsaregroupedwithinasingleblock.Visvariableorganisationwhereonevariablelengthlogicalrecordisplacedwithinonephysicalblock.VBisVariableBlockorganisationwhereoneormorevariablelengthlogicalrecordsareplacedwithinonephysicalblock.
BLKSIZEisthesizeofthephysicalblock.Thelargertheblock,greateristhenumberofrecordsforaFBorVBfile.
DSORGisthetypeofdatasetorganisation.DSORGcanholdvaluesPS(PhysicalSequential),PO(PartitionedOrganisation)andDA(DirectOrganisation).
WhenthereisaneedtoreplicatetheDCBvaluesofonedatasettoanotherwithinthesamejobsteporJCL,thenitisspecifiedasDCB=*.stepname.ddnamewherestepnameisthenameofthejobstepandddnameisthedatasetfromwhichtheDCBiscopied.
CheckbelowexamplewhereRECFM=FB,LRECL=80formstheDCBofdatasetOUTPUT1.
SPACETheSPACEparameterspecifiesthespacerequiredforthedatasetintheDASD(DirectAccessStorageDisk).Followingisthesyntax:
SPACE=(spcunits,(pri,sec,dir),RLSE)
Hereisthedescriptionofalltheusedparameters:
spcunits:ThiscanbeoneoftheCYL(Cylinder),TRK(Tracks)orBLKSIZE(BlockSize).
15/07/2015 JCLQuickGuide
http://www.tutorialspoint.com/cgibin/printpage.cgi 15/39
pri:Thisistheprimaryspacerequiredforthedataset.
sec:Thisistheadditionalspacerequired,whentheprimaryspaceisnotbeingsufficient.
ir:Thisisthedirectoryblocksrequired,ifthedatasetisaPDS(PartitionedDataset)withmemberswithinit.
RLSE:Thisisusedtoreleasetheunusedspaceatjobcompletion.
UNITTheUNITandVOLparametersarelistedinthesystemcatalogforcatalogueddatasetsandhencecanbeaccessedwithjustthephysicalDSNname.Butforuncatalogeddatasets,theDDstatementshouldincludetheseparameters.Fornewdatasetstobecreated,theUNIT/VOLparameterscanbespecifiedortheZ/OSallocatesthesuitabledeviceandvolume.
TheUNITparameterspecifiesthetypeofdeviceonwhichthedatasetisstored.ThedevicetypecanbeidentifiedusingHardwareAddressorDevicetypegroup.Followingisthesyntax:
UNIT=DASD|SYSDA
WhereDASDstandsforDirectAccessStorageDeviceandSYSDAstandsforSystemDirectAccessandreferstothenextavailablediskstoragedevice.
VOLTheVOLparameterspecifiesthevolumenumberonthedeviceidentifiedbytheUNITparameter.Followingisthesyntax:
VOL=SER=(v1,v2)
Wherev1,v2arevolumeserialnumbers.Youcanusethefollowingsyntaxaswell:
VOL=REF=*.DDNAME
WhereREFisthebackwardreferencetothevolumeserialnumberofadatasetinanyoftheprecedingjobstepsintheJCL.
SYSOUTTheDDstatementparametersdiscussedsofarcorrespondstodatabeing
15/07/2015 JCLQuickGuide
http://www.tutorialspoint.com/cgibin/printpage.cgi 16/39
storedinadataset.TheSYSOUTparameterdirectsthedatatooutputdevicebasedontheclassspecified.Followingisthesyntax
SYSOUT=class
WhereifclassisAthenitdirectsoutputtoprinter,andifclassis*thenitdirectsoutputtosamedestinationasthatoftheMSGCLASSparameterintheJOBstatement.
Example
Followingisanexample,whichmakesuseofDDstatementsalongwithvariousparametersexplainedabove:
//TTYYSAMPJOB'TUTO',CLASS=6,MSGCLASS=X,REGION=8K,//NOTIFY=&SYSUID//*//STEP010EXECPGM=ICETOOL,ADDRSPC=REAL//*//INPUT1DDDSN=TUTO.SORT.INPUT1,DISP=SHR//INPUT2DDDSN=TUTO.SORT.INPUT2,DISP=SHR,UNIT=SYSDA,//VOL=SER=(1243,1244)//OUTPUT1DDDSN=MYFILES.SAMPLE.OUTPUT1,DISP=(,CATLG,DELETE),//RECFM=FB,LRECL=80,SPACE=(CYL,(10,20))//OUTPUT2DDSYSOUT=*
JCLBASELIBRARY
BaseLibraryisthePartitionedDataset(PDS),whichholdstheloadmodulesoftheprogramtobeexecutedintheJCLorthecataloguedprocedure,whichiscalledintheprogram.BaselibrariescanbespecifiedforthewholeJCLinaJOBLIBlibraryorforaparticularjobstepinaSTEPLIBstatement.
JOBLIBStatement
AJOBLIBstatementisusedinordertoidentifythelocationoftheprogramtobeexecutedinaJCL.TheJOBLIBstatementisspecifiedaftertheJOBstatementandbeforetheEXECstatement.Thiscanbeusedonlyfortheinstreamproceduresandprograms.
Syntax
FollowingisthebasicsyntaxofaJCLJOBLIBstatement:
//JOBLIBDDDSN=dsnname,DISP=SHR
TheJOBLIBstatementisapplicabletoalltheEXECstatementswithintheJCL.TheprogramspecifiedintheEXECstatementwillbesearchedintheJOBLIBlibraryfollowedbythesystemlibrary.
15/07/2015 JCLQuickGuide
http://www.tutorialspoint.com/cgibin/printpage.cgi 17/39
Forexample,iftheEXECstatementisexecutingaCOBOLprogram,theloadmoduleoftheCOBOLprogramshouldbeplacedwithintheJOBLIBlibrary.
STEPLIBStatement
ASTEPLIBstatementisusedinordertoidentifythelocationoftheprogramtobeexecutedwithinaJobStep.TheSTEPLIBstatementisspecifiedaftertheEXECstatementandbeforetheDDstatementofthejobstep.
Syntax
FollowingisthebasicsyntaxofaJCLSTEPLIBstatement:
//STEPLIBDDDSN=dsnname,DISP=SHR
TheprogramspecifiedintheEXECstatementwillbesearchedintheSTEPLIBlibraryfollowedbythesystemlibrary.STEPLIBcodedinajobstepoverridestheJOBLIBstatement.
Example
ThefollowingexampleshowstheusageofJOBLIBandSTEPLIBstatements:
//MYJCLJOB,,CLASS=6,NOTIFY=&SYSUID//*//JOBLIBDDDSN=MYPROC.BASE.LIB1,DISP=SHR//*//STEP1EXECPGM=MYPROG1//INPUT1DDDSN=MYFILE.SAMPLE.INPUT1,DISP=SHR//OUTPUT1DDDSN=MYFILES.SAMPLE.OUTPUT1,DISP=(,CATLG,DELETE),//RECFM=FB,LRECL=80//*//STEP2EXECPGM=MYPROG2//STEPLIBDDDSN=MYPROC.BASE.LIB2,DISP=SHR//INPUT2DDDSN=MYFILE.SAMPLE.INPUT2,DISP=SHR//OUTPUT2DDDSN=MYFILES.SAMPLE.OUTPUT2,DISP=(,CATLG,DELETE),//RECFM=FB,LRECL=80
Here,theloadmoduleoftheprogramMYPROG1(inSTEP1)issearchedintheMYPROC.SAMPLE.LIB1.Ifnotfound,itissearchedinthesystemlibrary.InSTEP2,STEPLIBoverridesJOBLIBandloadmoduleoftheprogramMYPROG2issearchedinMYPROC.SAMPLE.LIB2andtheninthesystemlibrary.
INCLUDEStatement
AsetofJCLstatementscodedwithinamemberofaPDScanbeincludedtoaJCLusinganINCLUDEstatement.WhentheJESinterpretstheJCL,thesetofJCLstatementswithintheINCLUDEmemberreplacestheINCLUDEstatement.
Syntax
FollowingisthebasicsyntaxofaJCLINCLUDEstatement:
15/07/2015 JCLQuickGuide
http://www.tutorialspoint.com/cgibin/printpage.cgi 18/39
//nameINCLUDEMEMBER=membername
ThemainpurposeofINCLUDEstatementisreusability.Forexample,commonfilestobeusedacrossmanyJCLscanbecodedasDDstatementswithinINCLUDEmemberandusedinaJCL.
DummyDDstatements,datacardspecifications,PROCs,JOB,PROCstatementscannotbecodedwithinanINCLUDEmember.AnINLCUDEstatementcanbecodedwithinanINCLUDEmemberandfurthernestingcanbedoneupto15levels.
JCLLIBStatement
AJCLLIBstatementisusedtoidentifytheprivatelibrariesusedinthejob.Itcanbeusedbothwithinstreamandcatalogedprocedures.
Syntax
FollowingisthebasicsyntaxofaJCLJCLLIBstatement:
//nameJCLLIBORDER=(library1,library2....)
ThelibrariesspecifiedintheJCLLIBstatementwillbesearchedinthegivenordertolocatetheprograms,proceduresandINCLUDEmemberusedinthejob.TherecanbeonlyoneJCLLIBstatementinaJCLspecifiedafteraJOBstatementandbeforeEXECandINCLUDEstatementbutitcannotbecodedwithinanINCLUDEmember.
Example
Inthefollowingexample,theprogramMYPROG3andINCLUDEmemberMYINCLissearchedintheorderofMYPROC.BASE.LIB1,MYPROC.BASE.LIB2,systemlibrary.
//MYJCLJOB,,CLASS=6,NOTIFY=&SYSUID//*//MYLIBJCLLIBORDER=(MYPROC.BASE.LIB1,MYPROC.BASE.LIB2)//*//STEP1EXECPGM=MYPROG3//INCINCLUDEMEMBER=MYINCL//OUTPUT1DDDSN=MYFILES.SAMPLE.OUTPUT1,DISP=(,CATLG,DELETE),//RECFM=FB,LRECL=80//*
JCLPROCEDURES
TheJCLProceduresaresetofstatementsinsideaJCLgroupedtogethertoperformaparticularfunction.Usually,thefixedpartoftheJCLiscodedinaprocedure.ThevaryingpartoftheJobiscodedwithintheJCL.
Youcanuseaproceduretoachieveparallelexecutionofaprogramusingmultipleinputfiles.AJCLcanbecreatedforeachinputfile,andasingleprocedurecanbecalledsimultaneouslybypassingtheinputfilenameasasymbolicparameter.
15/07/2015 JCLQuickGuide
http://www.tutorialspoint.com/cgibin/printpage.cgi 19/39
Syntax
FollowingisthebasicsyntaxofaJCLproceduredefinition:
//*//StepnameEXECprocedurename
ThecontentsoftheprocedureareheldwithintheJCLforaninstreamprocedure.Thecontentsareheldwithinadifferentmemberofthebaselibraryforacatalogedprocedure.ThischapterisgoingtoexplaintwotypesofproceduresavailableinJCLandthenfinallywewillseehowwecannestvariousprocedures.
InstreamProcedure
WhentheprocedureiscodedwithinthesameJCLmember,itiscalledanInstreamProcedure.ItshouldstartwithaPROCstatementandendwithaPENDstatement.
//SAMPINSTJOB1,CLASS=6,MSGCLASS=Y,NOTIFY=&SYSUID//*//INSTPROCPROC//*STARTOFPROCEDURE//PROC1 EXECPGM=SORT//SORTIN DDDSN=&DSNAME,DISP=SHR//SORTOUT DDSYSOUT=*MYINCL//SYSOUT DDSYSOUT=*//SYSIN DDDSN=&DATACLRECL=80//PEND//*ENDOFPROCEDURE//*//STEP1EXECINSTPROC,DSNME=MYDATA.URMI.INPUT1,//DATAC=MYDATA.BASE.LIB1(DATA1)//*//STEP2EXECINSTPROC,DSNME=MYDATA.URMI.INPUT2//DATAC=MYDATA.BASE.LIB1(DATA1)//*
Intheaboveexample,theprocedureINSTPROCiscalledinSTEP1andSTEP2usingdifferentinputfiles.TheparametersDSNAMEandDATACcanbecodedwithdifferentvalueswhilecallingtheprocedureandthesearecalledassymbolicparameters.ThevaryinginputtotheJCLsuchasfilenames,datacards,PARMvalues,etc.,arepassedassymbolicparameterstoprocedures.
Whilecodingsymbolicparameters,donotuseKEYWORDS,PARAMETERSorSUBPARAMETERSassymbolicnames.Example:DonotuseTIME=&TIMEbutyesyoucanuseTIME=&TManditisassumedasarightwayofcodingsymbolics.
UserdefinedsymbolicparametersarecalledJCLSymbols.Therearecertainsymbolscalledsystemsymbols,whichareusedforlogonjobexecutions.Theonlysystemsymbolusedinbatchjobsbynormalusersis&SYSUIDandthisisusedintheNOTIFYparameterintheJOBstatement.
CatalogedProcedure
WhentheprocedureisseparatedoutfromtheJCLandcodedinadifferentdatastore,itiscalledaCatalogedProcedure.APROCstatementisnotmandatorytobecodedinacatalogedprocedure.FollowingisanexampleofJCLwhereit'scallingCATLPROCprocedure:
15/07/2015 JCLQuickGuide
http://www.tutorialspoint.com/cgibin/printpage.cgi 20/39
//SAMPINSTJOB1,CLASS=6,MSGCLASS=Y,NOTIFY=&SYSUID//*//STEPEXECCATLPROC,PROG=CATPRC1,DSNME=MYDATA.URMI.INPUT//DATAC=MYDATA.BASE.LIB1(DATA1)
Here,theprocedureCATLPROCiscatalogedinMYCOBOL.BASE.LIB1.PROG,DATACandDSNAMEarepassedassymbolicparameterstotheprocedureCATLPROC.
//CATLPROCPROCPROG=,BASELB=MYCOBOL.BASE.LIB1//*//PROC1EXECPGM=&PROG//STEPLIBDDDSN=&BASELB,DISP=SHR//IN1DDDSN=&DSNAME,DISP=SHR//OUT1DDSYSOUT=*//SYSOUTDDSYSOUT=*//SYSINDDDSN=&DATAC//*
Withintheprocedure,thesymbolicparametersPROGandBASELBarecoded.PleasenotethatthePROGparameterwithintheprocedureisoverriddenbythevalueintheJCLandhencePGMtakesthevalueCATPRC1duringexecution.
NestedProcedures
Callingaprocedurefromwithinaprocedureiscalledanestedprocedure.Procedurescanbenestedupto15levels.Thenestingcanbecompletelyinstreamorcataloged.Wecannotcodeaninstreamprocedurewithinacatalogedprocedure.
//SAMPINSTJOB1,CLASS=6,MSGCLASS=Y,NOTIFY=&SYSUID//*//SETNMSETDSNM1=INPUT1,DSNM2=OUTPUT1//INSTPRC1PROC//*STARTOFPROCEDURE1//STEP1EXECPGM=SORT,DISP=SHR//SORTINDDDSN=&DSNM1,DISP=SHR//SORTOUTDDDSN=&DSNM2,DISP=(,PASS)//SYSOUTDDSYSOUT=*//SYSINDDDSN=&DATAC//*//STEP2EXECPROC=INSTPRC2,DSNM2=MYDATA.URMI.OUTPUT2//PEND//*ENDOFPROCEDURE1//*//INSTPRC2PROC//*STARTOFPROCEDURE2//STEP1EXECPGM=SORT//SORTINDDDSN=*.INSTPRC1.STEP1.SORTOUT//SORTOUTDDDSN=&DSNM2,DISP=OLD//SYSOUTDDSYSOUT=*//SYSINDDDSN=&DATAC//PEND//*ENDOFPROCEDURE2//*//JSTEP1EXECINSTPRC1,DSNM1=MYDATA.URMI.INPUT1,//DATAC=MYDATA.BASE.LIB1(DATA1)
15/07/2015 JCLQuickGuide
http://www.tutorialspoint.com/cgibin/printpage.cgi 21/39
//*
Intheaboveexample,theJCLcallstheprocedureINSTPRC1inJSTEP1andprocedureINSTPRC2isbeingcalledwithintheprocedureINSTPRC1.Here,theoutputofINSTPRC1(SORTOUT)ispassedasinput(SORTIN)toINSTPRC2.
ASETstatementisusedtodefinecommonlyusedsymbolicsacrossjobstepsorprocedures.Itinitializesthepreviousvaluesinthesymbolicnames.IthastobedefinedbeforethefirstuseofthesymbolicnamesintheJCL.
Let'shavealookatthebelowdescriptiontounderstandalittlemoreabouttheaboveprogram:
SETparameterinitializesDSNM1=INPUT1andDSNM2=OUTPUT1.
WhenINSTPRC1iscalledinJSTEP1ofJCL,DSNM1=MYDATA.URMI.INPUT1andDSNM2=OUTPUT1.,i.e.,thevalueinitializedinSETstatementisresetwiththevaluesetinanyofthejobstep/procedures.
WhenINSTPRC2iscalledinSTEP2ofINSTPRC1,DSNM1=MYDATA.URMI.INPUT1andDSNM2=MYDATA.URMI.OUTPUT2.
JCLCONDITIONALPROCESSING
TheJobEntrySystemusestwoapproachestoperformconditionalprocessinginaJCL.Whenajobcompletes,areturncodeissetbasedonthestatusofexecution.Thereturncodecanbeanumberbetween0(successfulexecution)to4095(nonzeroshowserrorcondition).Themostcommonconventionalvaluesare:
0=NormalallOK
4=Warningminorerrorsorproblems.
8=Errorsignificanterrorsorproblems.
12=Severeerrormajorerrorsorproblems,theresultsshouldnotbetrusted.
16=Terminalerrorveryseriousproblems,donotusetheresults.
Ajobstepexecutioncanbecontrolledbasedonthereturncodeofthepreviousstep(s)usingtheCONDparameterandIFTHENELSEconstruct,whichhasbeenexplainedinthistutorial.
CONDparameter
ACONDparametercanbecodedintheJOBorEXECstatementofJCL.Itisatestonthereturncodeoftheprecedingjobsteps.Ifthetestisevaluatedtobetrue,thecurrentjobstepexecutionisbypassed.Bypassingisjustomissionofthejobstepandnotanabnormaltermination.Therecanbeatmosteightconditionscombinedinasingletest.
15/07/2015 JCLQuickGuide
http://www.tutorialspoint.com/cgibin/printpage.cgi 22/39
Syntax
FollowingisthebasicsyntaxofaJCLCONDParameter:
COND=(rc,logicaloperator)orCOND=(rc,logicaloperator,stepname)orCOND=EVENorCOND=ONLY
Hereisthedescriptionofparametersused:
rc:Thisisthereturncode
logicaloperator:ThiscanbeGT(GreaterThan),GE(GreaterthanorEqualto),EQ(Equalto),LT(LesserThan),LE(LesserthanorEqualto)orNE(NotEqualto).
stepname:Thisisthejobstepwhosereturncodeisusedinthetest.
Lasttwoconditions(a)COND=EVENand(b)COND=ONLY,havebeenexplainedbelowinthistutorial.
TheCONDcanbecodedeitherinsideJOBstatementorEXECstatement,andinboththecases,itbehavesdifferentlyasexplainedbelow:
CONDinsideJOBstatement
WhenCONDiscodedinJOBstatement,theconditionistestedforeveryjobstep.Whentheconditionistrueatanyparticularjobstep,itisbypassedalongwiththejobstepsfollowingit.Followingisanexample:
//CNDSAMPJOBCLASS=6,NOTIFY=&SYSUID,COND=(5,LE)//*//STEP10EXECPGM=FIRSTP//*STEP10executeswithoutanytestbeingperformed.
//STEP20EXECPGM=SECONDP//*STEP20isbypassed,ifRCofSTEP10is5orabove.//*SaySTEP10endswithRC4andhencetestisfalse.//*SoSTEP20executesandletssayitendswithRC16.
//STEP30EXECPGM=SORT//*STEP30isbypassedsince5
15/07/2015 JCLQuickGuide
http://www.tutorialspoint.com/cgibin/printpage.cgi 23/39
//STP01EXECPGM=SORT//*AssumingSTP01endswithRC0.
//STP02EXECPGM=MYCOBB,COND=(0,EQ,STP01)//*InSTP02,conditionevaluatestoTRUEandstepbypassed.
//STP03EXECPGM=IEBGENER,COND=((10,LT,STP01),(10,GT,STP02))//*InSTP03,firstconditionfailsandhenceSTP03executes.//*SinceSTP02isbypassed,thecondition(10,GT,STP02)in//*STP03isnottested.
COND=EVEN
WhenCOND=EVENiscoded,thecurrentjobstepisexecuted,evenifanyofthepreviousstepsabnormallyterminate.IfanyotherRCconditioniscodedalongwithCOND=EVEN,thenthejobstepexecutesifnoneoftheRCconditionistrue.
//CNDSAMPJOBCLASS=6,NOTIFY=&SYSUID//*//STP01EXECPGM=SORT//*AssumingSTP01endswithRC0.
//STP02EXECPGM=MYCOBB,COND=(0,EQ,STP01)//*InSTP02,conditionevaluatestoTRUEandstepbypassed.
//STP03EXECPGM=IEBGENER,COND=((10,LT,STP01),EVEN)//*InSTP03,condition(10,LT,STP01)evaluatestotrue,//*hencethestepisbypassed.
COND=ONLY
WhenCOND=ONLYiscoded,thecurrentjobstepisexecuted,onlywhenanyofthepreviousstepsabnormallyterminate.IfanyotherRCconditioniscodedalongwithCOND=ONLY,thenthejobstepexecutesifnoneoftheRCconditionistrueandanyofthepreviousjobstepsfailabnormally.
//CNDSAMPJOBCLASS=6,NOTIFY=&SYSUID//*//STP01EXECPGM=SORT//*AssumingSTP01endswithRC0.
//STP02EXECPGM=MYCOBB,COND=(4,EQ,STP01)//*InSTP02,conditionevaluatestoFALSE,stepisexecuted//*andassumethestepabends.
//STP03EXECPGM=IEBGENER,COND=((0,EQ,STP01),ONLY)//*InSTP03,thoughtheSTP02abends,thecondition//*(0,EQ,STP01)ismet.HenceSTP03isbypassed.
IFTHENELSEConstruct
15/07/2015 JCLQuickGuide
http://www.tutorialspoint.com/cgibin/printpage.cgi 24/39
AnotherapproachtocontrolthejobprocessingisbyusingIFTHENELSEconstructs.Thisgivesmoreflexibilityanduserfriendlywayofconditionalprocessing.
Syntax
FollowingisthebasicsyntaxofaJCLIFTHENELSEConstruct:
//nameIFconditionTHENlistofstatements//*actiontobetakenwhenconditionistrue//nameELSElistofstatements//*actiontobetakenwhenconditionisfalse//nameENDIF
FollowingisthedescriptionoftheusedtermsintheaboveIFTHENELSEConstruct:
name:Thisisoptionalandanamecanhave1to8alphanumericcharactersstartingwithalphabet,#,$or@.
Condition:Aconditionwillhaveaformat:KEYWORDOPERATORVALUE,whereKEYWORDScanbeRC(ReturnCode),ABENDCC(Systemorusercompletioncode),ABEND,RUN(stepstartedexecution).AnOPERATORcanbelogicaloperator(AND(&),OR(|))orrelationaloperator(=,).
Example
FollowingisasimpleexampleshowingtheusageofIFTHENELSE:
//CNDSAMPJOBCLASS=6,NOTIFY=&SYSUID//*//PRC1PROC//PST1 EXECPGM=SORT//PST2 EXECPGM=IEBGENER//PEND//STP01EXECPGM=SORT//IF1IFSTP01.RC=0THEN//STP02EXECPGM=MYCOBB1,PARM=123//ENDIF//IF2IFSTP01.RUNTHEN//STP03aEXECPGM=IEBGENER//STP03bEXECPGM=SORT//ENDIF//IF3IFSTP03b.!ABENDTHEN//STP04EXECPGM=MYCOBB1,PARM=456//ELSE//ENDIF//IF4IF(STP01.RC=0&STP02.RC
15/07/2015 JCLQuickGuide
http://www.tutorialspoint.com/cgibin/printpage.cgi 25/39
//ENDIF
Let'strytolookintotheaboveprogramtounderstanditinlittlemoredetail:
ThereturncodeofSTP01istestedinIF1.Ifitis0,thenSTP02isexecuted.Else,theprocessinggoestothenextIFstatement(IF2).
InIF2,IfSTP01hasstartedexecution,thenSTP03aandSTP03bareexecuted.
InIF3,IfSTP03bdoesnotABEND,thenSTP04isexecuted.InELSE,therearenostatements.ItiscalledaNULLELSEstatement.
InIF4,ifSTP01.RC=0andSTP02.RC
15/07/2015 JCLQuickGuide
http://www.tutorialspoint.com/cgibin/printpage.cgi 26/39
theDDstatement.
RD=RNCallowsautomatedrestarts,butoverrides(ignores)theCHKPTparameter.
RD=NRspecifiesthatthejob/stepcannotbeautomaticallyrestarted.ButwhenitismanuallyrestartedusingtheRESTARTparameter,CHKPTparameter(ifany)willbeconsidered.
RD=NCdisallowsautomatedrestartandcheckpointprocessing.
Ifthereisarequirementtodoautomatedrestartforspecificabendcodesonly,thenitcanbespecifiedintheSCHEDxxmemberoftheIBMsystemparmliblibrary.
RESTARTparameteriscodedintheJOBorEXECstatementandithelpsinmanualrestartoftheJOB/STEPafterthejobfailure.RESTARTcanbeaccompaniedwithacheckid,whichisthecheckpointwritteninthedatasetcodedintheSYSCKEOVDDstatement.Whenacheckidiscoded,theSYSCHKDDstatementshouldbecodedtoreferencethecheckpointdatasetaftertheJOBLIBstatement(ifany),elseaftertheJOBstatement.
//CHKSAMPJOBCLASS=6,NOTIFY=&SYSUID,RESTART=(STP01,chk5)//*//SYSCHKDDDSN=SAMPLE.CHK,DISP=OLD//STP01EXECPGM=MYCOBB//*SYSCKEOV DDDSNAME=SAMPLE.CHK,DISP=MOD//IN1DDDSN=SAMPLE.IN,DISP=SHR//OUT1DDDSN=SAMPLE.OUT,DISP=(,CATLG,CATLG)//CHKPT=EOV,LRECL=80,RECFM=FB
Intheaboveexample,chk5isthecheckid,i.e.,STP01isrestartedatcheckpoint5.PleasenotethataSYSCHKstatementisaddedandSYSCKEOVstatementiscommentedoutinthepreviousprogramexplainedinSettingCheckpointsection.
JCLDEFININGDATASETS
AdatasetnamespecifiesthenameofafileanditisdenotedbyDSNinJCL.TheDSNparameterreferstothephysicaldatasetnameofanewlycreatedorexistingdataset.TheDSNvaluecanbemadeupofsubnameseachof1to8characterslength,separatedbyperiodsandoftotallengthof44characters(alphanumeric).Followingisthesyntax:
DSN=&name|*.stepname.ddname
Temporarydatasetsneedstorageonlyforthejobdurationandaredeletedatjobcompletion.SuchdatasetsarerepresentedasDSN=&nameorsimplywithoutaDSNspecified.
Ifatemporarydatasetcreatedbyajobstepistobeusedinthenextjobstep,thenitisreferencedasDSN=*.stepname.ddname.ThisiscalledBackwardReferencing.
ConcatenatingDatasets
Ifthereismorethanonedatasetofthesameformat,theycanbeconcatenatedandpassedasaninputtotheprograminasingleDDname.
15/07/2015 JCLQuickGuide
http://www.tutorialspoint.com/cgibin/printpage.cgi 27/39
//CONCATEXJOBCLASS=6,NOTIFY=&SYSUID//*//STEP10EXECPGM=SORT//SORTINDDDSN=SAMPLE.INPUT1,DISP=SHR//DDDSN=SAMPLE.INPUT2,DISP=SHR//DDDSN=SAMPLE.INPUT3,DISP=SHR//SORTOUTDDDSN=SAMPLE.OUTPUT,DISP=(,CATLG,DELETE),//LRECL=50,RECFM=FB
Intheaboveexample,threedatasetsareconcatenatedandpassedasinputtotheSORTprogramintheSORTINDDname.Thefilesaremerged,sortedonthespecifiedkeyfieldsandthenwrittentoasingleoutputfileSAMPLE.OUTPUTintheSORTOUTDDname.
OverridingDatasets
InastandardisedJCL,theprogramtobeexecutedanditsrelateddatasetsareplacedwithinacatalogedprocedure,whichiscalledintheJCL.Usually,fortestingpurposesorforanincidentfix,theremightbeaneedtousedifferentdatasetsotherthantheonesspecifiedinthecatalogedprocedure.Inthatcase,thedatasetintheprocedurecanbeoverriddenintheJCL.
//SAMPINSTJOB1,CLASS=6,MSGCLASS=Y,NOTIFY=&SYSUID//*//JSTEP1EXECCATLPROC,PROG=CATPRC1,DSNME=MYDATA.URMI.INPUT//DATAC=MYDATA.BASE.LIB1(DATA1)//STEP1.IN1DDDSN=MYDATA.OVER.INPUT,DISP=SHR//*//*Thecatalogedprocedureisasbelow://*//CATLPROCPROCPROG=,BASELB=MYCOBOL.BASE.LIB1//*//STEP1EXECPGM=&PROG//STEPLIBDDDSN=&BASELB,DISP=SHR//IN1DDDSN=MYDATA.URMI.INPUT,DISP=SHR//OUT1DDSYSOUT=*//SYSOUTDDSYSOUT=*//SYSINDDMYDATA.BASE.LIB1(DATA1),DISP=SHR//*//STEP2EXECPGM=SORT
Intheaboveexample,thedatasetIN1usesthefileMYDATA.URMI.INPUTinthePROC,whichisoverriddenintheJCL.Hence,theinputfileusedinexecutionisMYDATA.OVER.INPUT.PleasenotethatthedatasetisreferredasSTEP1.IN1.IfthereisonlyonestepintheJCL/PROC,thenthedatasetcanbereferredwithjusttheDDname.Similarly,iftherearemorethanonestepintheJCL,thenthedatasetistobeoverriddenasJSTEP1.STEP1.IN1.
//SAMPINSTJOB1,CLASS=6,MSGCLASS=Y,NOTIFY=&SYSUID//*//STEPEXECCATLPROC,PROG=CATPRC1,DSNME=MYDATA.URMI.INPUT//DATAC=MYDATA.BASE.LIB1(DATA1)//STEP1.IN1DDDSN=MYDATA.OVER.INPUT,DISP=SHR//DDDUMMY
15/07/2015 JCLQuickGuide
http://www.tutorialspoint.com/cgibin/printpage.cgi 28/39
//DDDUMMY//*
Intheaboveexample,outofthethreedatasetsconcatenatedinIN1,thefirstoneisoverriddenintheJCLandtherestiskeptasthatpresentinPROC.
DefiningGDGsinaJCL
GenerationDataGroups(GDGs)aregroupofdatasetsrelatedtoeachotherbyacommonname.ThecommonnameisreferredasGDGbaseandeachdatasetassociatedwiththebaseiscalledaGDGversion.
Forexample,MYDATA.URMI.SAMPLE.GDGistheGDGbasename.ThedatasetsarenamedasMYDATA.URMI.SAMPLE.GDG.G0001V00,MYDATA.URMI.SAMPLE.GDG.G0002V00andsoon.ThelatestversionoftheGDGisreferredasMYDATA.URMI.SAMPLE.GDG(0),previousversionsarereferredas(1),(2)andsoon.ThenextversiontobecreatedinaprogramisreferedasMYDATA.URMI.SAMPLE.GDG(+1)intheJCL.
Create/AlterGDGinaJCL
TheGDGversionscanhavesameordifferentDCBparameters.AninitialmodelDCBcanbedefinedtobeusedbyallversions,butitcanbeoverriddenwhencreatingnewversions.
//GDGSTEP1EXECPGM=IDCAMS//SYSPRINTDDSYSOUT=*//SYSINDD*DEFINEGDG(NAME(MYDATA.URMI.SAMPLE.GDG)LIMIT(7)NOEMPTYSCRATCH)/*//GDGSTEP2EXECPGM=IEFBR14//GDGMODLDDDDSN=MYDATA.URMI.SAMPLE.GDG,//DISP=(NEW,CATLG,DELETE),//UNIT=SYSDA,//SPACE=(CYL,10,20),//DCB=(LRECL=50,RECFM=FB)//
Intheaboveexample,IDCAMSutilitydefinestheGDGbaseinGDGSTEP1withbelowparameterspassedintheSYSINDDstatement:
NAMEspecifiesthephysicaldatasetnameoftheGDGbase.
LIMITspecifiesthemaximumnumberofversionsthattheGDGbasecanhold.
EMPTYuncatalogesallthegenerationswhentheLIMITisreached.
NOEMPTYuncatalogestheleastrecentgeneration.
SCRATCHphysicallydeletesthegenerationwhenitisuncataloged.
15/07/2015 JCLQuickGuide
http://www.tutorialspoint.com/cgibin/printpage.cgi 29/39
NOSCRATCHdonotdeletethedataset,i.e.,itcanbereferredusingtheUNITandVOLparameters.
InGDGSTEP2,IEFBR14utilityspecifiesmodelDDparameterstobeusedbyallversions.
IDCAMScanbeusedtoalterthedefinitionparametersofaGDGsuchasincreasingLIMIT,changingEMPTYtoNOEMPTY,etc.,anditsrelatedversionsusingtheSYSINcommandisALTERMYDATA.URMI.SAMPLE.GDGLIMIT(15)EMPTY.
DeleteGDGinaJCL
UsingIEFBR14utility,wecandeleteasingleversionofaGDG.
//GDGSTEP3EXECPGM=IEFBR14//GDGDELDDDSN=MYDATA.URMI.SAMPLE.GDG(0),//DISP=(OLD,DELETE,DELETE)
Intheaboveexample,thelatestversionofMYDATA.URMI.SAMPLE.GDGisdeleted.PleasenotethattheDISPparameteronnormaljobcompletioniscodedasDELETE.Hence,thedatasetisdeletedwhenthejobcompletesexecution.
IDCAMScanbeusedtodeletetheGDGanditsrelatedversionsusingtheSYSINcommandDELETE(MYDATA.URMI.SAMPLE.GDG)GDGFORCE/PURGE.
FORCEdeletestheGDGversionsandtheGDGbase.IfanyoftheGDGversionsaresetwithanexpirationdatewhichisyettoexpire,thenthosearenotdeletedandhencetheGDGbaseisretained.
PURGEdeletestheGDGversionsandtheGDGbaseirrespectiveoftheexpirationdate.
UsingGDGinaJCL
Inthefollowingexample,thelatestversionofMYDATA.URMI.SAMPLE.GDGisusedasinputtotheprogramandanewversionofMYDATA.URMI.SAMPLE.GDGiscreatedastheoutput.
//CNDSAMPJOBCLASS=6,NOTIFY=&SYSUID//*//STP01EXECPGM=MYCOBB//IN1DDDSN=MYDATA.URMI.SAMPLE.GDG(0),DISP=SHR//OUT1DDDSN=MYDATA.URMI.SAMPLE.GDG(+1),DISP=(,CALTG,DELETE)//LRECL=100,RECFM=FB
Here,iftheGDGhadbeenreferredbytheactualnamelikeMYDATA.URMI.SAMPLE.GDG.G0001V00,thenitleadstochangingtheJCLeverytimebeforeexecution.Using(0)and(+1)makesitdynamicallysubstitutetheGDGversionforexecution.
INPUTOUTPUTMETHODS
AnybatchprogramexecutedthroughaJCLrequiresdatainput,whichisprocessedandanoutputiscreated.Therearedifferentmethodsoffeedinginputtotheprogramandwritingoutputreceivedfroma
15/07/2015 JCLQuickGuide
http://www.tutorialspoint.com/cgibin/printpage.cgi 30/39
JCL.Inbatchmode,thereisnouserinteractionrequiredbutinputandoutputdevicesandrequiredorganisationaredefinedinJCLandsubmitted.
DataInputinaJCL
TherearevariouswaystofeedthedatatoaprogramusingJCLandthesemethodshavebeenexplainedbelow:
INSTREAMDATA
InstreamdatatoaprogramcanbespecifiedusingaSYSINDDstatement.
//CONCATEXJOBCLASS=6,NOTIFY=&SYSUID//*Example1://STEP10EXECPGM=MYPROG//IN1DDDSN=SAMPLE.INPUT1,DISP=SHR//OUT1DDDSN=SAMPLE.OUTPUT1,DISP=(,CATLG,DELETE),//LRECL=50,RECFM=FB//SYSINDD*//CUST11000//CUST21001/*//*//*Example2://STEP20EXECPGM=MYPROG//OUT1DDDSN=SAMPLE.OUTPUT2,DISP=(,CATLG,DELETE),//LRECL=50,RECFM=FB//SYSINDDDSN=SAMPLE.SYSIN.DATA,DISP=SHR//*
InExample1,inputtoMYPROGispassedthroughSYSIN.ThedataisprovidedwithintheJCL.Tworecordsofdataarepassedtotheprogram.Pleasenotethat/*markstheendofinstreamSYSINdata.
"CUST11000"isrecord1and"CUST21001"isrecord2.Endofdataconditionismetwhenthesymbol/*isencounteredwhilereadingthedata.
InExample2,theSYSINdataisheldwithinadataset,whereSAMPLE.SYSIN.DATAisaPSfile,whichcanholdoneormorerecordsofdata.
DataInputthroughfiles
Asmentionedinmostoftheexamplesinpreviouschapters,datainputtoaprogramcanbeprovidedthroughPS,VSAMorGDGfiles,withrelevantDSNnameandDISPparametersalongwithDDstatements.
InExample1,SAMPLE.INPUT1istheinputfilethroughwhichdataispassedtoMYPROG.ItisreferredasIN1withintheprogram.
DataOutputinaJCL
TheoutputinaJCLcanbecatalogedintoadatasetorpassedtotheSYSOUT.AsmentionedinDDstatementschapter,SYSOUT=*redirectstheoutputtothesameclassasthatmentionedinthe
15/07/2015 JCLQuickGuide
http://www.tutorialspoint.com/cgibin/printpage.cgi 31/39
MSGCLASSparameteroftheJOBstatement.
SavingJobLogs
SpecifyingMSGCLASS=YsavesthejoblogintheJMR(JoblogManagementandRetrieval).TheentireJOBlogcanberedirectedtotheSPOOLandcanbesavedtoadatasetbygivingtheXDCcommandagainstthejobnameintheSPOOL.WhentheXDCcommandisgivenintheSPOOL,adatasetcreationscreenisopenedup.ThejoblogcanthenbesavedbygivingappropriatePSorPDSdefinition.
JoblogscanalsobesavedintoadatasetbymentioninganalreadycreateddatasetforSYSOUTandSYSPRINT.Buttheentirejoblogcannotbecapturedthroughthisway(i.e.,JESMSGwillnotbecataloged)asdoneinJMRorXDC.
//SAMPINSTJOB1,CLASS=6,MSGCLASS=Y,NOTIFY=&SYSUID//*//STEP1EXECPGM=MYPROG//IN1DDDSN=MYDATA.URMI.INPUT,DISP=SHR//OUT1DDSYSOUT=*//SYSOUTDDDSN=MYDATA.URMI.SYSOUT,DISP=SHR//SYSPRINTDDDSN=MYDATA.URMI.SYSPRINT,DISP=SHR//SYSINDDMYDATA.BASE.LIB1(DATA1),DISP=SHR//*//STEP2EXECPGM=SORT
Intheaboveexample,SYSOUTiscatalogedinMYDATA.URMI.SYSOUTandSYSPRINTinMYDATA.URMI.SYSPRINT.
RUNNINGCOBOLPROGRAMSUSINGJCL
CompilingCOBOLPrograms
InordertoexecuteaCOBOLprograminbatchmodeusingJCL,theprogramneedstobecompiledandaloadmoduleiscreatedwithallthesubprograms.TheJCLusestheloadmoduleandnottheactualprogramatthetimeofexecution.TheloadlibrariesareconcatenatedandgiventotheJCLatthetimeofexecutionusingJCLLIBorSTEPLIB.
TherearemanymainframecompilerutilitiesavailabletocompileaCOBOLprogram.SomecorporatecompaniesuseChangeManagementtoolslikeEndevor,whichcompilesandstoreseveryversionoftheprogram.Thisisusefulintrackingthechangesmadetotheprogram.
//COMPILEJOB,CLASS=6,MSGCLASS=X,NOTIFY=&SYSUID//*//STEP1EXECIGYCRCTL,PARM=RMODE,DYNAM,SSRANGE//SYSINDDDSN=MYDATA.URMI.SOURCES(MYCOBB),DISP=SHR//SYSLIBDDDSN=MYDATA.URMI.COPYBOOK(MYCOPY),DISP=SHR//SYSLMODDDDSN=MYDATA.URMI.LOAD(MYCOBB),DISP=SHR//SYSPRINTDDSYSOUT=*//*
15/07/2015 JCLQuickGuide
http://www.tutorialspoint.com/cgibin/printpage.cgi 32/39
IGYCRCTLisanIBMCOBOLcompilerutility.ThecompileroptionsarepassedusingPARMparameter.Intheaboveexample,RMODEinstructsthecompilertouserelativeaddressingmodeintheprogram.TheCOBOLprogramispassedusingSYSINparameterandthecopybookisthelibraryusedbytheprograminSYSLIB.
ThisJCLproducestheloadmoduleoftheprogramasoutputwhichisusedastheinputtotheexecutionJCL.
RunningCOBOLPrograms
BelowaJCLexamplewheretheprogramMYPROGisexecutedusingtheinputfileMYDATA.URMI.INPUTandproducestwooutputfileswrittentothespool.
//COBBSTEPJOBCLASS=6,NOTIFY=&SYSUID////STEP10EXECPGM=MYPROG,PARM=ACCT5000//STEPLIBDDDSN=MYDATA.URMI.LOADLIB,DISP=SHR//INPUT1DDDSN=MYDATA.URMI.INPUT,DISP=SHR//OUT1DDSYSOUT=*//OUT2DDSYSOUT=*//SYSINDD*//CUST11000//CUST21001/*
TheloadmoduleofMYPROGislocatedinMYDATA.URMI.LOADLIB.ThisisimportanttonotethattheaboveJCLcanbeusedforanonDB2COBOLmoduleonly.
PassingDatatoCOBOLPrograms
DatainputtoCOBOLbatchprogramcanbethroughfiles,PARAMparameterandSYSINDDstatement.Intheaboveexample:
DatarecordsarepassedtoMYPROGthroughfileMYDATA.URMI.INPUT.ThisfilewillbereferredintheprogramusingtheDDnameINPUT1.Thefilecanbeopened,readandclosedintheprogram.
ThePARMparameterdataACCT5000isreceivedintheLINKAGEsectionoftheprogramMYPROGinavariabledefinedwithinthatsection.
ThedataintheSYSINstatementisreceivedthroughACCEPTstatementinthePROCEDUREdivisionoftheprogram.EveryACCEPTstatementreadsonewholerecord(i.e.,CUST11000)intoaworkingstoragevariabledefinedintheprogram.
RunningaCOBOLDB2program
ForrunningCOBOLDB2program,specialisedIBMutilityisusedintheJCLandprogramDB2regionandrequiredparametersarepassedasinputtotheutility.
ThebelowstepsarefollowedinrunningaCOBOLDB2program:
WhenaCOBOLDB2programiscompiled,aDBRM(DatabaseRequestModule)iscreatedalong
15/07/2015 JCLQuickGuide
http://www.tutorialspoint.com/cgibin/printpage.cgi 33/39
withtheloadmodule.TheDBRMcontainstheSQLstatementsoftheCOBOLprogramswithitssyntaxcheckedtobecorrect.
TheDBRMisboundtotheDB2region(environment)inwhichtheCOBOLwillrun.ThiscanbedoneusingtheIKJEFT01utilityinaJCL.
Afterthebindstep,theCOBOLDB2programisrunusingIKJEFT01(again)withtheloadlibraryandDBRMlibraryastheinputtotheJCL.
//STEP001EXECPGM=IKJEFT01//*//STEPLIBDDDSN=MYDATA.URMI.DBRMLIB,DISP=SHR//*//inputfiles//outputfiles//SYSPRINTDDSYSOUT=*//SYSABOUTDDSYSOUT=*//SYSDBOUTDDSYSOUT=*//SYSUDUMPDDSYSOUT=*//DISPLAYDDSYSOUT=*//SYSOUTDDSYSOUT=*//SYSTSPRTDDSYSOUT=*//SYSTSINDD*DSNSYSTEM(SSID)RUNPROGRAM(MYCOBB)PLAN(PLANNAME)PARM(parameterstocobolprogram)LIB('MYDATA.URMI.LOADLIB')END/*
Intheaboveexample,MYCOBBistheCOBOLDB2programrunusingIKJEFT01.Pleasenotethattheprogramname,DB2SubSystemId(SSID),DB2PlannamearepassedwithintheSYSTSINDDstatement.TheDBRMlibraryisspecifiedintheSTEPLIB.
JCLUTILITYPROGRAMS
IBMDatasetUtilities
Utilityprogramsareprewrittenprograms,widelyusedinmainframesbysystemprogrammersandapplicationdeveloperstoachievedaytodayrequirements,organisingandmaintainingdata.Afewofthemarelistedbelowwiththeirfunctionality:
UtilityName Functionality
IEHMOVE Movesorcopiessequentialdatasets.
IEHPROGM DeletingandrenamingdatasetscatalogoruncatalogdatasetsotherthanVSAM.
15/07/2015 JCLQuickGuide
http://www.tutorialspoint.com/cgibin/printpage.cgi 34/39
IEHCOMPR Comparesdatainsequentialdatasets.
IEBCOPY Copy,Merge,compress,backuporrestorePDS.
IEFBR14Nooperationutility.Usedtoreturncontroltouserandterminate.Itisusuallyusedtocreateemptydatasetordeleteanexistingdataset.
Forexample,ifadatasetispassedasinputtoaIEFBR14programwithDISP=(OLD,DELETE,DELETE),thedatasetisdeletedatjobcompletion.
IEBEDIT UsedtocopyselectedpartsofaJCL.ForExample,ifaJCLhas5stepsandwerequiretoexecutestep1and3only,thenaIEBEDITJCLcanbecodedwithadatasetwhichcontainstheactualJCLtobeexecuted.IntheSYSINofIEBEDIT,wecanspecifySTEP1andSTEP3asparameters.WhenthisJCLisexecuted,itexecutestheSTEP1andSTEP3oftheactualJCL.
IDCAMS Create,delete,rename,catalog,uncatalogdatasets(otherthanPDS).UsuallyusedtomanageVSAMdatasets.
TheseutilityprogramsneedtobeusedwithappropriateDDstatementsinaJCLinordertoachievethespecifiedfunctionality.
DFSORTOverview
DFSORTisapowerfulIBMutilityusedtocopy,sortormergedatasets.SORTINandSORTINnnDDstatementsareusedtospecifyinputdatasets.SORTOUTandOUTFILstatementsareusedtospecifyoutputdata.
SYSINDDstatementisusedtospecifythesortandmergeconditions.DFSORTisgenerallyusedtoachievethebelowfunctionalities:
SORTtheinputfile(s)intheorderofthespecifiedfield(s)positioninthefile.
INCLUDEorOMITrecordsfromtheinputfile(s)basedonthespecifiedcondition.
SORTMERGEinputfile(s)intheorderofthespecifiedfield(s)positioninthefile.
SORTJOINtwoormoreinputfilesbasedonaspecifiedJOINKEY(field(s)ineachinputfile).
Whenthereisadditionalprocessingtobedoneontheinputfiles,aUSEREXITprogramcanbecalledfromtheSORTprogram.Forexample,ifthereisaheader/trailertobeaddedtotheoutputfile,thenaUSERwrittenCOBOLprogramcanbecalledfromtheSORTprogramtoperformthisfunctionality.Usingacontrolcard,datacanbepassedtotheCOBOLprogram.
Ontheotherwayround,aSORTcanbecalledinternallyfromaCOBOLprogramtoarrangethe
15/07/2015 JCLQuickGuide
http://www.tutorialspoint.com/cgibin/printpage.cgi 35/39
inputfileinaparticularorderbeforebeingprocessed.Usually,thisisnotrecommendedinviewofperformanceforlargefiles.
ICETOOLOverview
ICETOOLisamultipurposeDFSORTutilityusedtoperformavarietyofoperationsondatasets.InputandoutputdatasetscanbedefinedusinguserdefinedDDnames.ThefileoperationsarespecifiedintheTOOLINDDstatement.Additionalconditionscanbespecifiedinuserdefined'CTL'DDstatements.
FewoftheutilitiesofICETOOLaregivenbelow:
ICETOOLcanachieveallthefunctionalitiesofDFSORTinoneormoreconditions.
SPLICEisapowerfuloperationofICETOOLwhichissimilartoSORTJOIN,butwithadditionalfeatures.Itcancomparetwoormorefilesonspecifiedfield(s)andcreateoneormoreoutputfileslikefilewithmatchingrecords,filewithnonmatchingrecords,etc.
DatainonefileinaparticularpositioncanbeOVERLAYedintoanotherpositioninthesameordifferentfile.
AFilecanbesplitintonfilesbasedonaspecifiedcondition.Forexample,afilecontainingnamesofemployeescanbesplitinto26files,eachcontainingthenamesstartingwithA,B,Candsoon.
DifferentcombinationoffilemanipulationispossibleusingICETOOLwithalittleexplorationofthetool.
SYNCSORTOverview
SYNCSORTisusedtocopy,mergeorsortdatasetswithahighperformance.Itgivesbestutilizationofsystemresourcesandefficientoperationin31bitand64bitaddressspaces.
ItcanbeusedinthesamelinesofDFSORTandcanachievethesamefeatures.ItcanbeinvokedbyaJCLorfromwithinaprogramcodedinCOBOL,PL/1orAssemblerlanguage.ItalsosupportsUserExitprogramstobecalledfromtheSYNCSORTprogram.
Frequentlyusedsorttricksusingtheseutilitiesareexplainedinthenextchapter.Complexrequirements,whichrequiresahugeprogramminginCOBOL/ASSEMBLERcanbeachievedusingtheaboveutilitiesinsimplesteps.
JCLBASICSORTTRICKS
ThedaytodayapplicationrequirementsinacorporateworldthatcanbeachievedusingUtilityProgramsareillustratedbelow:
1.Afilehas100records.Thefirst10recordsneedtobewrittentooutputfile.
//JSTEP020EXECPGM=ICETOOL//TOOLMSGDDSYSOUT=*//DFSMSGDDSYSOUT=*//IN1DDDSN=MYDATA.URMI.STOPAFT,DISP=SHR//OUT1 DDSYSOUT=*
15/07/2015 JCLQuickGuide
http://www.tutorialspoint.com/cgibin/printpage.cgi 36/39
//TOOLINDD*COPYFROM(IN1)TO(OUT1)USING(CTL1)/*//CTL1CNTLDD*OPTIONSTOPAFT=10/*
TheoptionSTOPAFTwillstopreadingtheinputfileafter10threcordandterminatestheprogram.Hence,10recordsarewrittentooutput.
2.Inputfilehasoneormorerecordsforsameemployeenumber.Writeuniquerecordstooutput.
//STEP010EXECPGM=SORT//SYSOUTDDSYSOUT=*//SORTINDDDSN=MYDATA.URMI.DUPIN,DISP=SHR//SORTOUTDDSYSOUT=*//SYSINDD*SORTFIELDS=(1,15,ZD,A)SUMFIELDS=NONE/*
SUMFIELDS=NONEremovesduplicatesonfieldsspecifiedinSORTFIELDS.Intheaboveexample,employeenumberisinthefieldposition1,15.Theoutputfilewillcontaintheuniqueemployeenumberssortedinascendingorder.
3.Overwriteinputrecordcontent.
//JSTEP010EXECPGM=SORT//SORTINDDDSN=MYDATA.URMI.SAMPLE.MAIN,DISP=SHR//SORTOUTDDSYSOUT=*//SYSPRINTDDSYSOUT=*//SYSOUTDDSYSOUT=*//SYSINDD*OPTIONCOPYINRECOVERLAY=(47:1,6)/*
Intheinputfile,thecontentinposition1,6isoverwrittentotheposition47,6andthencopiedtotheoutputfile.INRECOVERLAYoperationisusedinordertorewritedataininputfilebeforecopyingtooutput.
4.Addingasequencenumbertotheoutputfile.
//JSTEP010EXECPGM=SORT//SORTINDD*data1data2data3/*//SORTOUTDDSYSOUT=*//SYSPRINTDDSYSOUT=*
15/07/2015 JCLQuickGuide
http://www.tutorialspoint.com/cgibin/printpage.cgi 37/39
//SYSOUTDDSYSOUT=*//SYSINDD*OPTIONCOPYBUILD=(1:1,5,10:SEQNUM,4,ZD,START=1000,INCR=2)/*
Theoutputwillbe:
data11000data21002data31004
4digitsequencenumberisaddedinoutputatposition10,startingat1000andincrementedby2foreveryrecord.
5.AddingHeader/Trailertooutputfile.
//JSTEP010EXECPGM=SORT//SORTINDD*data1data2data3/*//SORTOUTDDSYSOUT=*//SYSPRINTDDSYSOUT=*//SYSOUTDDSYSOUT=*//SYSINDD*SORTFIELDS=COPYOUTFILREMOVECC,HEADER1=(1:C'HDR',10:X'020110131C'),TRAILER1=(1:C'TRL',TOT=(10,9,PD,TO=PD,LENGTH=9))/*
Theoutputwillbe:
HDR20110131data1data2data3TRL000000003
TOTcalculatesthenumberofrecordsintheinputfile.HDRandTRLareaddedasidentifierstoheader/trailer,whichisuserdefinedandcanbecustomisedaspertheusers'needs.
6.ConditionalProcessing
//JSTEP010EXECPGM=SORT//SORTINDD*data1selectdata2
15/07/2015 JCLQuickGuide
http://www.tutorialspoint.com/cgibin/printpage.cgi 38/39
data3select/*//SORTOUTDDSYSOUT=*//SYSPRINTDDSYSOUT=*//SYSOUTDDSYSOUT=*//SYSINDD*INRECIFTHEN=(WHEN=(6,1,CH,NE,C''),BUILD=(1:1,15),IFTHEN=(WHEN=(6,1,CH,EQ,C''),BUILD=(1:1,5,7:C'EMPTY')OPTIONCOPY/*
Theoutputwillbe:
data1selectdata2EMPTYdata3select
Basedonthe6thpositionofthefile,theBUILDofoutputfilevaries.If6thpositionisSPACES,thentext"EMPTY"isappendedtoinputrecord.Else,theinputrecordiswrittentooutput,asis.
7.Backingupafile
//JSTEP001EXECPGM=IEBGENER//SYSPRINTDDSYSOUT=*//SYSINDD*//SYSOUTDDSYSOUT=*//SORTOUTDDDUMMY//SYSUT1DDDSN=MYDATA.URMI.ORIG,DISP=SHR//SYSUT2DDDSN=MYDATA.URMI.BACKUP,DISP=(NEW,CATLG,DELETE),//DCB=*.SYSUT1,SPACE=(CYL,(50,1),RLSE)
IEBGENERcopiesthefileinSYSUT1tofileinSYSUT2.PleasenotethatfileinSYSUT2takesthesameDCBasthatoftheSYSUT1intheaboveexample.
8.FileComparison
//STEP010EXECPGM=SORT//MAINDD*1000100110031005//LOOKUPDD*100010021003//MATCHDDDSN=MYDATA.URMI.SAMPLE.MATCH,DISP=OLD//NOMATCH1DDDSN=MYDATA.URMI.SAMPLE.NOMATCH1,DISP=OLD//NOMATCH2DDDSN=MYDATA.URMI.SAMPLE.NOMATCH2,DISP=OLD//SYSOUTDDSYSOUT=*//SYSINDD*
15/07/2015 JCLQuickGuide
http://www.tutorialspoint.com/cgibin/printpage.cgi 39/39
JOINKEYSF1=MAIN,FIELDS=(1,4,A)JOINKEYSF2=LOOKUP,FIELDS=(1,4,A)JOINUNPAIRED,F1,F2REFORMATFIELDS=(?,F1:1,4,F2:1,4)OPTIONCOPYOUTFILFNAMES=MATCH,INCLUDE=(1,1,CH,EQ,C'B'),BUILD=(1:2,4)OUTFILFNAMES=NOMATCH1,INCLUDE=(1,1,CH,EQ,C'1'),BUILD=(1:2,4)OUTFILFNAMES=NOMATCH2,INCLUDE=(1,1,CH,EQ,C'2'),BUILD=(1:2,4)/*
JOINKEYSspecifiesthefieldonwhichthetwofilesarecompared.
REFORMATFIELDS=?places'B'(matchedrecords),'1'(presentinfile1,butnotinfile2),or'2'(presentinfile2butnotinfile1)inthe1stpositionoftheoutputBUILD.
JOINUNPAIREDdoesafullouterjoinonthetwofiles.
Theoutputwillbe:
MATCHFile10001003
NOMATCH1File10011005
NOMATCH2File1002
ThesamefunctionalitycanbeachievedusingICETOOLalso.