Date post: | 15-Apr-2017 |
Category: |
Technology |
Upload: | ca-technologies |
View: | 107 times |
Download: | 0 times |
World®’16
UnderstandingwhenandhowtouseJavaScriptattheEvent,ApplicationandJobLevelJohnRooney,CATechnologies,Sr.PrincipalConsultant
MFX36E
MAINFRAMEANDWORKLOADAUTOMATION
2 ©2016CA.ALLRIGHTSRESERVED.@CAWORLD#CAWORLD
©2016CA.Allrightsreserved.Alltrademarksreferencedhereinbelongtotheirrespectivecompanies.
Thecontentprovidedinthis CAWorld2016presentationisintendedforinformationalpurposesonlyanddoesnotformanytypeofwarranty. The informationprovidedbyaCApartnerand/orCAcustomerhasnotbeenreviewedforaccuracybyCA.
ForInformationalPurposesOnlyTermsofthisPresentation
3 ©2016CA.ALLRIGHTSRESERVED.@CAWORLD#CAWORLD
Abstract
AJavaScriptcanbeapowerfultooltoautomaticallyadjustApplication
andjobpropertiesatEventtriggertime.Therearemanyareasand
optionswhereaJavaScriptcanbeinvoked.Thissessionwillgoover
somebestpracticesforspecifyingJavaScripts attheEvent,Application
andJobLevelalongwithanylimitationsforCAWorkloadAutomation
(CAWA)DE.
JohnP.RooneyCATechnologiesSr.PrincipalConsultant
4 ©2016CA.ALLRIGHTSRESERVED.@CAWORLD#CAWORLD
Agenda
SOMEINFORMATIONONJAVASCRIPTS
WHERECANJAVASCRIPTS BEEXECUTED
WHATARETHEBUILT-INUTILITIES
BESTPRACTICE
1
2
3
4
Q&A
SUMMARY5
6
5 ©2016CA.ALLRIGHTSRESERVED.@CAWORLD#CAWORLD
JavaScriptisascriptinglanguage
§ CAWorkloadAutomationDEusesRhinoasitsJavaScriptengine– writtenfullyinJavaandmanagedbytheMozillaFoundationasopensourcesoftware– Rhino1.6R2version– Itisaruntimeinterpreterwhichdoesnotgetcompiledintonativemachinecodeand
generallywillrunmoreslowlythanacompiledlanguage– Nothingtodowhenupgrading
§ TheserverusesJavaScriptrelease1.5asitsinternalscriptinglanguageandconformstoEdition3oftheECMA-262Standardforscriptinglanguages.– AnECMAScriptengineisaprogramthatexecutessourcecodewritteninaversionofthe
ECMAScriptlanguagestandard
6 ©2016CA.ALLRIGHTSRESERVED.@CAWORLD#CAWORLD
AgoodsiteforJavaScriptSyntax– w3schools.com/js
7 ©2016CA.ALLRIGHTSRESERVED.@CAWORLD#CAWORLD
AllowJavacallsinJavaScript
8 ©2016CA.ALLRIGHTSRESERVED.@CAWORLD#CAWORLD
MaximumLengthofJavaScript
9 ©2016CA.ALLRIGHTSRESERVED.@CAWORLD#CAWORLD
EndusersecurityisnormallysettoREAD
10 ©2016CA.ALLRIGHTSRESERVED.@CAWORLD#CAWORLD
Whatarethe2mainpurposesofaJavaScriptforCAWADE?§ Usedasapre-processor
– forsettingupand/orcontrollingworkload
§ Usedasapost-processor– forsettingupand/orcontrollingworkload– Executingadditionalprocessesorintegrations
11 ©2016CA.ALLRIGHTSRESERVED.@CAWORLD#CAWORLD
YoucanuseJavaScripts to:
§ Createandmanipulatesymbolicvariables
§ Useserverbuilt-infunctions
§ Performcomparison,arithmetic,andlogicaloperations
§ Prepareprograminputandparameters
§ Builddecisionsintoschedules
§ Passdatatootherapplications
12 ©2016CA.ALLRIGHTSRESERVED.@CAWORLD#CAWORLD
HowmanyplacescanyouinvokeaJavaScript?
A.1
B.2
C.3
D.4
E.5
13 ©2016CA.ALLRIGHTSRESERVED.@CAWORLD#CAWORLD
YoucaninvokeaJavaScriptinthetheseplaces
§ TheEventdefinition
§ TheApplicationdefinition
§ TheJobdefinition
§ InanAlert
14 ©2016CA.ALLRIGHTSRESERVED.@CAWORLD#CAWORLD
GenerallytwowaystoinvokeaJavaScript
§ FromtheJavaScriptRepository– Generallytherecommendedplace– Canlocatewhereitisbeingused
§ EmbeddedIntheparticularApplication,JoborAlertdefinition– UsefulwhenmovingtheApplication/AlertfromoneCAWADEinstance
toanotheraspartofachangemanagementprocess– JavaScriptnotusedbyotherApplications,JobsorAlerts
15 ©2016CA.ALLRIGHTSRESERVED.@CAWORLD#CAWORLD
HowtofindwhereaJavaScriptintheRepositoryisbeingreferenced?§ SelectDeleteforaJavaScript
– ReferentialIntegrity
BUTDON’TDELETE!
16 ©2016CA.ALLRIGHTSRESERVED.@CAWORLD#CAWORLD
Whatarethebuilt-inSymbolicPrefixes?
§ ESP– ScopeisacrossallApplications
§ APPL– ScopeislimitedtoanApplication
§ WOB– ScopelimitedtoaspecificJob
§ EVAR– ScopelimitedtoanApplication– IfsetintheEvent,cannotbeoverriddeninaJavaScript
17 ©2016CA.ALLRIGHTSRESERVED.@CAWORLD#CAWORLD
AquickwordaboutApplicationParameters– EVARprefixedsymbolics§ CanbeusedlikeaTemplate
– DefinemultipleEvents
§ ResolvedatEventTriggertime
§ CanreplacetheneedforaJavaScript
18 ©2016CA.ALLRIGHTSRESERVED.@CAWORLD#CAWORLD
AsummaryofPrefixesandJavaScriptlocationsSpecifying the
JavaScripttoexecute
CansetthesePrefixedSymbolics
Embedded Repository Executeoneormany ESP. APPL. WOB. EVAR.
Event No Yes Many Yes Yes No Yes
Application:
EventTriggerTime No Yes One Yes Yes No Yes
AtJobRunTime No* Yes One Yes Yes Yes Yes
Job:
EventTriggerTime Yes Yes One Yes Yes Yes Yes
AtRunTime Yes Yes* One Yes Yes Yes Yes
Alert Yes Yes One No No No No
*YoucanembedalocalJavaScriptintheApplicationdefinitiontobeinvokedbyajobatRuntime.YouthenselectthelocalJavaScriptfromtheRepositoryintheJobdefinition.
19 ©2016CA.ALLRIGHTSRESERVED.@CAWORLD#CAWORLD
OrderofsearchpreferenceofdefinedJavaScriptsforsymbolicresolution
1. JobatEventTrigger
2. ApplicationatEventTrigger
3. Event
4. Jobatruntime
5. Applicationatjobruntime
Thefirstplaceasymbolicvalueisfoundwillbetheoneused
Lastplacesearchedforsymbolicvalue
NOTE:IfyouhavemultipleJavaScripts executingatEventtriggertime,beawareofwhentheSymbolicgetssubstitutedIfitisasymbolicthatisnecessarytoberesolvedatEventTrigger,
thentheJobLevelJavaScriptexecutedatEventTriggertimewilltakeprecedence
20 ©2016CA.ALLRIGHTSRESERVED.@CAWORLD#CAWORLD
WhentoRuntheScript:EventTriggerorRunTime§ YoucanchoosetorunascriptatEventtriggertimeorwhenoneormore
jobsrun(atruntime).Whenyourunthescriptdependsonthekindsofvaluesyouarecalculatingwithinthescript.Someinformationisrequiredattriggertime(whentheApplicationbuilds)andotherinformationisrequiredatruntime.– Example,whenanEventtriggersandtheserverbuildstheApplication,theserverneeds
toknowwhichjobswill be runaspartofthatApplication.ThismeansthatallrunfrequenciesneedtoberesolvedatEventtriggertime.Theserver,however,doesnotneedtoknowtheargumentbeingpassedtoaUNIXscriptuntilthescriptisreadytorun.Thismeansthatargumentsdonotneedtoberesolveduntilruntime.
§ Note: Ifyouplantouseasymbolicvariableaspartofajobnameorqualifier,thesymbolicvariablemustbeassignedavalueatEventtriggertime.
21 ©2016CA.ALLRIGHTSRESERVED.@CAWORLD#CAWORLD
ThefollowingApplicationandjobpropertiesmustberesolvedattriggertime.
PROPERTIES CAWADESKTOPCLIENTDIALOG CAWADESKTOPCLIENTFIELDS
Applicationname Applicationproperties dialog Name dialog
DefaultAgentname Applicationproperties dialog Agent dialog
Applicationrunfrequency Applicationproperties dialog Runfrequency section
Jobnameandqualifier JobdefinitionBasic dialog Name andQualifier fields
Jobrunfrequency JobdefinitionBasic dialog Runfrequency section
Notifications JobdefinitionNotifications dialog AllfieldswithintheAlerts tab
Jobresources JobdefinitionResources dialog Allfields
Jobtimedependencies JobdefinitionTimeDependencies dialog Allfields
Externaljobattributes ExternaljobdefinitionBasic dialog Allfields
22 ©2016CA.ALLRIGHTSRESERVED.@CAWORLD#CAWORLD
ThefollowingfieldsmustberesolvedatruntimePROPERTIES CAWADESKTOPCLIENTDIALOG CAWADESKTOPCLIENTFIELDS
Emailaddresses NewEmailNotification dialog To field
Agentspecifications JobdefinitionBasic dialogAgentname,Commandtorun,Script/commandname, Argumentstopass,andUserID fields
Environmentvariables Jobdefinition Environment Variables dialog Name andValue fields
OS/400environmentspecifications Environment dialog
Libraryspecifications, Jobspecifications, andOS/400exitprogram fields
Exitcodes JobdefinitionExitCodes tab Code andInterpretation fields
TriggerconditionsforFiletriggerjobs
JobdefinitionBasic dialogJobdefinitionUser/Groupspecifications dialog
Filename fieldOwneruserID,group,andMonitorasuser fields
StepspecificationsforSAPR/3jobs JobdefinitionStepSpecifications dialog Allfields
AgentspecificationsforPeopleSoftjobs JobdefinitionBasic dialog Processname andProcesstype fields
23 ©2016CA.ALLRIGHTSRESERVED.@CAWORLD#CAWORLD
SpecifyingaJavaScriptintheEventDefinition
24 ©2016CA.ALLRIGHTSRESERVED.@CAWORLD#CAWORLD
JavaScriptdefinedintheEvent
§ WhentheEventisTriggered
§ ExecutesfromtheJavaScriptRepository
§ CanspecifythatmultipleJavaScriptstobeexecuted
25 ©2016CA.ALLRIGHTSRESERVED.@CAWORLD#CAWORLD
JavaScriptdefinedintheEventScenarios
§ YouwanttorunmultiplescriptswhentheEventistriggered.Incontrast,theApplicationdefinitionandjobdefinitionletyouspecifyonlyonescriptusingtheAtruntime optionandonescriptusingtheAtEventtriggertime option.
§ Note: SpecifyingonescriptintheEventdefinitionisequivalenttospecifyingthescriptintheApplicationdefinitionusingtheAtEventtriggertime option.
§ Thescriptdefinesorsetsvaluesforsystem-levelsymbolicvariables.ThenamesofthesevariablesbeginwiththeprefixESP.
§ ThescriptdefinesorsetsvaluesforApplication-levelsymbolicvariables.ThenamesofthesevariablesbeginwiththeprefixAPPL.
26 ©2016CA.ALLRIGHTSRESERVED.@CAWORLD#CAWORLD
SpecifyingaJavaScriptintheApplicationDefinition
27 ©2016CA.ALLRIGHTSRESERVED.@CAWORLD#CAWORLD
SpecifyingaJavaScriptintheApplicationDefinitionEditlocalscriptforjobstoexecutetheJavaScriptatruntime
28 ©2016CA.ALLRIGHTSRESERVED.@CAWORLD#CAWORLD
JavaScriptdefinedintheApplication
§ ProbablythemostcommonlydefinedJavaScriptiswhentheEventistriggered
§ YoucanspecifyaJavascripttobeexecutedbeforeeach(andevery)jobisexecuted
29 ©2016CA.ALLRIGHTSRESERVED.@CAWORLD#CAWORLD
JavaScriptdefinedintheApplicationScenarios
§ ThescriptdefinesorsetsvaluesforsymbolicvariablesthatneedtobeavailabletomultiplejobswithintheApplication.Thesevariablescanbesystem-level(thenamesbeginwiththeprefixESP)orApplicationlevel(thenamesbeginwiththeprefixAPPL).
§ ThescriptpassesparametersfromtheEventtotheApplication.
§ Thescriptdetermineswhethermultiplejobswill run.
§ Thescriptgeneratesdateandtimevariablestobeusedbymultiplejobs.
§ Thescriptdefinesorsetsvaluesforjob-levelsymbolicvariables.ThenamesofthesevariablesbeginwiththeprefixWOB.Forthesescripts,youmustselecttheAtruntime option.ThescriptrunswheneachjobintheApplicationstartstorun.
30 ©2016CA.ALLRIGHTSRESERVED.@CAWORLD#CAWORLD
SpecifyingaJavaScriptintheJobdefinition
Importfromalocaldirectory
31 ©2016CA.ALLRIGHTSRESERVED.@CAWORLD#CAWORLD
JavaScriptdefinedintheJob
§ WhentheEventistriggered
§ Beforethejobisrun
§ EitherspecificationcanbefromtheJavaScriptrepositoryorfromanembeddedJavaScriptinthejobdefinition
§ CreateWOB,APPL,ESP,EVARprefixedvariables
32 ©2016CA.ALLRIGHTSRESERVED.@CAWORLD#CAWORLD
JavaScriptdefinedintheJobScenarios§ Thescriptsetsvaluesforvariables usedbyasinglejob.
§ Thescriptsetsavariablewhosevaluemustbeconfinedtoasinglejob(thesymbolicvariableisusedinmultiplejobsbutmusthaveauniquevalueforeachjob).
§ Thescriptspecifiesruncriteriaforasinglejob.
§ ThescriptdefinesorsetsvaluesforsymbolicvariablesthatbeginwiththeprefixWOB.
§ Thescriptdefinesorsetsvaluesforsystem-levelsymbolicvariables.ThenamesofthesevariablesbeginwiththeprefixESP.
§ ThescriptdefinesorsetsvaluesforApplication-levelsymbolicvariables.ThenamesofthesevariablesbeginwiththeprefixAPPL.
33 ©2016CA.ALLRIGHTSRESERVED.@CAWORLD#CAWORLD
SpecifyingaJavaScriptinanAlert
34 ©2016CA.ALLRIGHTSRESERVED.@CAWORLD#CAWORLD
JavaScriptdefinedinanAlert
§ ExecuteaJavaScriptfromtherepositoryorfromanembeddedJavaScriptintheAlertdefinition
§ Usedtoexecutecommandsaspartofjobpost-processing
35 ©2016CA.ALLRIGHTSRESERVED.@CAWORLD#CAWORLD
JavaScriptdefinedinanAlertScenarios
§ Triggeradditionalworkloadautomatically
§ CompleteanApplicationwhenajobisoverdue
§ Resubmitajobifitcompleteswithaparticularexitcodebeforeaspecifictime
§ Executeuserdefinedapplicationintegrations– Openupservicedesktickets
36 ©2016CA.ALLRIGHTSRESERVED.@CAWORLD#CAWORLD
UseanAlerttopassinformationaboutajobwhentriggeringanEvent
37 ©2016CA.ALLRIGHTSRESERVED.@CAWORLD#CAWORLD
CreatingaJavaScript
§ ManyJavaScriptsareonlyonestatementandusebuilt-infunctionstodoanactionorsetasymbolic
§ YoudonotneedtobeanexperttostartdefiningaJavaScript– Lotsofexamplesinthedocumentation
38 ©2016CA.ALLRIGHTSRESERVED.@CAWORLD#CAWORLD
Documentation
https://docops.ca.com/ca-wla-de/12-0/en/scheduling/javascripts/built-in-functions
39 ©2016CA.ALLRIGHTSRESERVED.@CAWORLD#CAWORLD
UsingContentAssistwhilecreatingaJavaScript
40 ©2016CA.ALLRIGHTSRESERVED.@CAWORLD#CAWORLD
Somecommonlyusedbuilt-infunctionstoautomatecommandexecution§ execCommand(jobname|ALL|SUBAPPL(subApplname),
applnameAndGeneration,action)
§ execTrigger(eventname,ADD|REPLACE,time,NOHOLD|HOLD,userparameter1,userparameter4,userparameter3,userparameter2,rootjobs)
§ resetResourceProperty(resourceName,property,count)
41 ©2016CA.ALLRIGHTSRESERVED.@CAWORLD#CAWORLD
Somecommonlyusedbuilt-infunctionsforDates
§ daysBetween(startDate,endDate,dateType)
§ daysFrom(date)§ daysTo(date)§ genTime(prefix,date)§ today(scheduleExpression)§ tomorrow(scheduleExpression)§ yesterday(scheduleExpression)
42 ©2016CA.ALLRIGHTSRESERVED.@CAWORLD#CAWORLD
Somecommonlyusedbuilt-infunctionsforGlobalVariables§ decrementVar(name,context)
§ deleteVar(name,context)
§ getVar(name,context)
§ incrementVar(name,context)
§ setVar(name,value,context)
43 ©2016CA.ALLRIGHTSRESERVED.@CAWORLD#CAWORLD
ExampleJavaScriptsthatyoushouldhaveinyourrepository§ LoadEventPrefixGlobalVariables
– loadContext(APPL,'%APPL._eventprefix');
§ ReadAPPL._ftfileandgetfilename– varpos=APPL._ftfile.lastIndexOf('\\');– APPL.filename=APPL._ftfile.substring(pos+1);
44 ©2016CA.ALLRIGHTSRESERVED.@CAWORLD#CAWORLD
ExampleJavaScriptsthatyoushouldhaveinyourrepository§ KillLongRunningJob
– execCommand('%WOB._name','%(APPL._name).%(APPL._gen)','ACTIONKILL');
§ SelfCompleteorForceCompleteJobfromAlert– execCommand('%WOB._name','%(APPL._name).%APPL._gen','ACTION
COMPLETE');
45 ©2016CA.ALLRIGHTSRESERVED.@CAWORLD#CAWORLD
ExampleJavaScriptsthatyoushouldhaveinyourrepository§ Retriggersameapplication
– execTrigger('%APPL._event','ADD');
§ TRIGGEREVENTANDPASSUSERPARAMETERS– execTrigger(‘Prefix.Application','','','','%WOB._name','%WOB._qualifier,
'%APPL._name','%APPL._gen');
§ Retriggersameeventiftimeisnot7pm– if(WOB._RHH<'19'&&APPL._SDATE==WOB._RDATE);
execTrigger('%APPL._event','ADD');
46 ©2016CA.ALLRIGHTSRESERVED.@CAWORLD#CAWORLD
ExampleJavaScriptsthatyoushouldhaveinyourrepository§ Gentime FirstDayofCurrentmonthinYYYYMMDDFormat
– genTime('FD','first dayofmonthless1month');APPL.first_day_of_month_yyyymmdd =FDYEAR+FDMM+FDDD
§ TodayinYYYYMMDDFormat– TODAY=‘%APPL._SYY%APPL._SMM%APPL._SDD'
47 ©2016CA.ALLRIGHTSRESERVED.@CAWORLD#CAWORLD
ExampleJavaScriptsthatyoushouldhaveinyourrepository§ SettimesbasedondayoftheweekusingIf/Else
elseif(TDDOWNUM=='5'){APPL.Start_batch="5PM";APPL.Late_end ="5AMtomorrow";}elseif(TDDOWNUM=='6'){APPL.Start_batch="6PM";APPL.Late_end ="6AMtomorrow";}elseif(TDDOWNUM=='7'){APPL.Start_batch="7PM";APPL.Late_end ="7AMtomorrow";}else{APPL.Start_batch="8PM";APPL.Late_end ="8AMtomorrow";}
genTime('TD','today');if(TDDOWNUM=='1'){APPL.Start_batch="1PM";APPL.Late_end ="1AMtomorrow";}elseif(TDDOWNUM=='2'){APPL.Start_batch="2PM";APPL.Late_end ="2AMtomorrow";}elseif(TDDOWNUM=='3'){APPL.Start_batch="3PM";APPL.Late_end ="3AMtomorrow";}elseif(TDDOWNUM=='4'){APPL.Start_batch="4PM";APPL.Late_end ="4AMtomorrow";}
48 ©2016CA.ALLRIGHTSRESERVED.@CAWORLD#CAWORLD
ExampleJavaScripts thatyoushouldhaveinyourrepository§ SettimesbasedondayoftheweekusingSwitch
case'5':APPL.Start_batch="5PM";APPL.Late_end ="5AMtomorrow";break;case'6':APPL.Start_batch="6PM";APPL.Late_end ="6AMtomorrow";break;case'7':APPL.Start_batch="7PM";APPL.Late_end ="7AMtomorrow";break;default:Start_batch="8PM";Late_end ="8AMtomorrow";}
genTime('TD','today');switch(TDDOWNUM){case'1':APPL.Start_batch="1PM";APPL.Late_end ="1AMtomorrow";break;case'2':APPL.Start_batch="2PM";APPL.Late_end ="2AMtomorrow";break;case'3':APPL.Start_batch="3PM";APPL.Late_end ="3AMtomorrow";break;case'4':APPL.Start_batch="4PM";APPL.Late_end ="4AMtomorrow";break;
49 ©2016CA.ALLRIGHTSRESERVED.@CAWORLD#CAWORLD
NamingConventions
§ Forsomebuilt-infunctions,includethefunction– GentimeYesterday– ResetResourceAvailability– SetVarSubAPPLB
§ Orincludetheactionoroutcome– RetriggersameEvent– ForceCompleteJob– ReadAPPL_ftfileandgetfilename
50 ©2016CA.ALLRIGHTSRESERVED.@CAWORLD#CAWORLD
Summary
§ JavaScriptcanprovideforpassing“uptothemomentofjobsubmission”datatoajob
§ JavaScriptisextremelyusefulforpost-processingofjobsandtriggeringadditionalprocessing
§ StoringJavaScriptsintherepositoryandusingsymbolicsinthecommandsenablesa“writeonce,usemany”scenario
51 ©2016CA.ALLRIGHTSRESERVED.@CAWORLD#CAWORLD
RecommendedSessionsSESSION# TITLE DATE/TIME
MFX23EBestPractices:CAWLADEArtifactstoMoveAppsthroughtheDevelopmentLifecycle
11/14/2016at4:00pm
JasmineB
MFX141ELLab:IncreasedAgilityandFlexibilitywithWebServicesforCAWLADEandESP
11/15/2016at9:30am
SouthSeasD
MFX30S CustomerUseCase:RealWorldAutomationinRetail11/16/2016at3:45pm
BanyanA/B
MFX136SDeliveringCAWorkloadAutomationfromaSaaSplatform
11/17/2016at4:30pm
JasmineB
52 ©2016CA.ALLRIGHTSRESERVED.@CAWORLD#CAWORLD
MustSeeDemos
Innovations:CrossEnterpriseWorkloadAutomationCAWLADE&AEMFandWorkloadAutomation
SeamlessApplicationAutomationAgents&AdvancedIntegrationsMFandWorkloadAutomation
CAConversionasaService
CAWorkloadAutomationMFandWorkloadAutomation
ModernWorkloadAutomation
CAWLADEMFandWorkloadAutomation
@CAWORLD#CAWORLD ©2016CA.AllRIGHTSRESERVED.53 @CAWORLD#CAWORLD
MainframeandWorkloadAutomation
FormoreinformationonMainframeandWorkloadAutomation,pleasevisit:http://cainc.to/9GQ2JI
54 ©2016CA.ALLRIGHTSRESERVED.@CAWORLD#CAWORLD
Questions?
55 ©2016CA.ALLRIGHTSRESERVED.@CAWORLD#CAWORLD
Thankyou
Stayconnectedatcommunities.ca.com