Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Pre-Con Ed: Understanding when and how to use JavaScript at the Event, Application and Job Level

317 views

Published on

Pre-Con Ed: Understanding when and how to use JavaScript at the Event, Application and Job Level

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Pre-Con Ed: Understanding when and how to use JavaScript at the Event, Application and Job Level

  1. 1. World® ’16 Understanding when and how to use JavaScript at the Event, Application and Job Level John Rooney, CA Technologies, Sr. Principal Consultant MFX36E MAINFRAME AND WORKLOAD AUTOMATION
  2. 2. 2 © 2016 CA. ALL RIGHTS RESERVED.@CAWORLD #CAWORLD © 2016 CA. All rights reserved. All trademarks referenced herein belong to their respective companies. The content provided in this CA World 2016 presentation is intended for informational purposes only and does not form any type of warranty. The information provided by a CA partner and/or CA customer has not been reviewed for accuracy by CA. For Informational Purposes Only Terms of this Presentation
  3. 3. 3 © 2016 CA. ALL RIGHTS RESERVED.@CAWORLD #CAWORLD Abstract A JavaScript can be a powerful tool to automatically adjust Application and job properties at Event trigger time. There are many areas and options where a JavaScript can be invoked. This session will go over some best practices for specifying JavaScripts at the Event, Application and Job Level along with any limitations for CA Workload Automation (CA WA) DE. John P. Rooney CA Technologies Sr. Principal Consultant
  4. 4. 4 © 2016 CA. ALL RIGHTS RESERVED.@CAWORLD #CAWORLD Agenda SOME INFORMATION ON JAVASCRIPTS WHERE CAN JAVASCRIPTS BE EXECUTED WHAT ARE THE BUILT-IN UTILITIES BEST PRACTICE 1 2 3 4 Q & A SUMMARY5 6
  5. 5. 5 © 2016 CA. ALL RIGHTS RESERVED.@CAWORLD #CAWORLD JavaScript is a scripting language § CA Workload Automation DE uses Rhino as its JavaScript engine – written fully in Java and managed by the Mozilla Foundation as open source software – Rhino 1.6 R2 version – It is a runtime interpreter which does not get compiled into native machine code and generally will run more slowly than a compiled language – Nothing to do when upgrading § The server uses JavaScript release 1.5 as its internal scripting language and conforms to Edition 3 of the ECMA-262 Standard for scripting languages. – An ECMAScript engine is a program that executes source code written in a version of the ECMAScript language standard
  6. 6. 6 © 2016 CA. ALL RIGHTS RESERVED.@CAWORLD #CAWORLD A good site for JavaScript Syntax – w3schools.com/js
  7. 7. 7 © 2016 CA. ALL RIGHTS RESERVED.@CAWORLD #CAWORLD Allow Java calls in JavaScript
  8. 8. 8 © 2016 CA. ALL RIGHTS RESERVED.@CAWORLD #CAWORLD Maximum Length of JavaScript
  9. 9. 9 © 2016 CA. ALL RIGHTS RESERVED.@CAWORLD #CAWORLD End user security is normally set to READ
  10. 10. 10 © 2016 CA. ALL RIGHTS RESERVED.@CAWORLD #CAWORLD What are the 2 main purposes of a JavaScript for CA WA DE? § Used as a pre-processor – for setting up and/or controlling workload § Used as a post-processor – for setting up and/or controlling workload – Executing additional processes or integrations
  11. 11. 11 © 2016 CA. ALL RIGHTS RESERVED.@CAWORLD #CAWORLD You can use JavaScripts to: § Create and manipulate symbolic variables § Use server built-in functions § Perform comparison, arithmetic, and logical operations § Prepare program input and parameters § Build decisions into schedules § Pass data to other applications
  12. 12. 12 © 2016 CA. ALL RIGHTS RESERVED.@CAWORLD #CAWORLD How many places can you invoke a JavaScript? A. 1 B. 2 C. 3 D. 4 E. 5
  13. 13. 13 © 2016 CA. ALL RIGHTS RESERVED.@CAWORLD #CAWORLD You can invoke a JavaScript in the these places § The Event definition § The Application definition § The Job definition § In an Alert
  14. 14. 14 © 2016 CA. ALL RIGHTS RESERVED.@CAWORLD #CAWORLD Generally two ways to invoke a JavaScript § From the JavaScript Repository – Generally the recommended place – Can locate where it is being used § Embedded In the particular Application, Job or Alert definition – Useful when moving the Application/Alert from one CA WA DE instance to another as part of a change management process – JavaScript not used by other Applications, Jobs or Alerts
  15. 15. 15 © 2016 CA. ALL RIGHTS RESERVED.@CAWORLD #CAWORLD How to find where a JavaScript in the Repository is being referenced? § Select Delete for a JavaScript – Referential Integrity BUT DON’T DELETE!
  16. 16. 16 © 2016 CA. ALL RIGHTS RESERVED.@CAWORLD #CAWORLD What are the built-in Symbolic Prefixes? § ESP – Scope is across all Applications § APPL – Scope is limited to an Application § WOB – Scope limited to a specific Job § EVAR – Scope limited to an Application – If set in the Event, cannot be overridden in a JavaScript
  17. 17. 17 © 2016 CA. ALL RIGHTS RESERVED.@CAWORLD #CAWORLD A quick word about Application Parameters – EVAR prefixed symbolics § Can be used like a Template – Define multiple Events § Resolved at Event Trigger time § Can replace the need for a JavaScript
  18. 18. 18 © 2016 CA. ALL RIGHTS RESERVED.@CAWORLD #CAWORLD A summary of Prefixes and JavaScript locations Specifying the JavaScript to execute Can set these Prefixed Symbolics Embedded Repository Execute one or many ESP. APPL. WOB. EVAR. Event No Yes Many Yes Yes No Yes Application: Event Trigger Time No Yes One Yes Yes No Yes At Job Run Time No* Yes One Yes Yes Yes Yes Job: Event Trigger Time Yes Yes One Yes Yes Yes Yes At Run Time Yes Yes* One Yes Yes Yes Yes Alert Yes Yes One No No No No * You can embed a local JavaScript in the Application definition to be invoked by a job at Run time. You then select the local JavaScript from the Repository in the Job definition.
  19. 19. 19 © 2016 CA. ALL RIGHTS RESERVED.@CAWORLD #CAWORLD Order of search preference of defined JavaScripts for symbolic resolution 1. Job at Event Trigger 2. Application at Event Trigger 3. Event 4. Job at run time 5. Application at job run time The first place a symbolic value is found will be the one used Last place searched for symbolic value NOTE: If you have multiple JavaScripts executing at Event trigger time, be aware of when the Symbolic gets substituted If it is a symbolic that is necessary to be resolved at Event Trigger, then the Job Level JavaScript executed at Event Trigger time will take precedence
  20. 20. 20 © 2016 CA. ALL RIGHTS RESERVED.@CAWORLD #CAWORLD When to Run the Script: Event Trigger or Run Time § You can choose to run a script at Event trigger time or when one or more jobs run (at run time). When you run the script depends on the kinds of values you are calculating within the script. Some information is required at trigger time (when the Application builds) and other information is required at run time. – Example, when an Event triggers and the server builds the Application, the server needs to know which jobs will be run as part of that Application. This means that all run frequencies need to be resolved at Event trigger time. The server, however, does not need to know the argument being passed to a UNIX script until the script is ready to run. This means that arguments do not need to be resolved until run time. § Note: If you plan to use a symbolic variable as part of a job name or qualifier, the symbolic variable must be assigned a value at Event trigger time.
  21. 21. 21 © 2016 CA. ALL RIGHTS RESERVED.@CAWORLD #CAWORLD The following Application and job properties must be resolved at trigger time. PROPERTIES CA WA DESKTOP CLIENT DIALOG CA WA DESKTOP CLIENT FIELDS Application name Application properties dialog Name dialog Default Agent name Application properties dialog Agent dialog Application run frequency Application properties dialog Run frequency section Job name and qualifier Job definition Basic dialog Name and Qualifier fields Job run frequency Job definition Basic dialog Run frequency section Notifications Job definition Notifications dialog All fields within the Alerts tab Job resources Job definition Resources dialog All fields Job time dependencies Job definition Time Dependencies dialog All fields External job attributes External job definition Basic dialog All fields
  22. 22. 22 © 2016 CA. ALL RIGHTS RESERVED.@CAWORLD #CAWORLD The following fields must be resolved at run time PROPERTIES CA WA DESKTOP CLIENT DIALOG CA WA DESKTOP CLIENT FIELDS Email addresses New Email Notification dialog To field Agent specifications Job definition Basic dialog Agent name, Command to run, Script/command name, Arguments to pass, and User ID fields Environment variables Job definition Environment Variables dialog Name and Value fields OS/400 environment specifications Environment dialog Library specifications, Job specifications, and OS/400 exit program fields Exit codes Job definition Exit Codes tab Code and Interpretation fields Trigger conditions for File trigger jobs Job definition Basic dialog Job definition User/Group specifications dialog File name field Owner user ID, group, and Monitor as user fields Step specifications for SAP R/3 jobs Job definition Step Specifications dialog All fields Agent specifications for PeopleSoft jobs Job definition Basic dialog Process name and Process type fields
  23. 23. 23 © 2016 CA. ALL RIGHTS RESERVED.@CAWORLD #CAWORLD Specifying a JavaScript in the Event Definition
  24. 24. 24 © 2016 CA. ALL RIGHTS RESERVED.@CAWORLD #CAWORLD JavaScript defined in the Event § When the Event is Triggered § Executes from the JavaScript Repository § Can specify that multiple JavaScripts to be executed
  25. 25. 25 © 2016 CA. ALL RIGHTS RESERVED.@CAWORLD #CAWORLD JavaScript defined in the Event Scenarios § You want to run multiple scripts when the Event is triggered. In contrast, the Application definition and job definition let you specify only one script using the At run time option and one script using the At Event trigger time option. § Note: Specifying one script in the Event definition is equivalent to specifying the script in the Application definition using the At Event trigger time option. § The script defines or sets values for system-level symbolic variables. The names of these variables begin with the prefix ESP. § The script defines or sets values for Application-level symbolic variables. The names of these variables begin with the prefix APPL.
  26. 26. 26 © 2016 CA. ALL RIGHTS RESERVED.@CAWORLD #CAWORLD Specifying a JavaScript in the Application Definition
  27. 27. 27 © 2016 CA. ALL RIGHTS RESERVED.@CAWORLD #CAWORLD Specifying a JavaScript in the Application Definition Edit local script for jobs to execute the JavaScript at run time
  28. 28. 28 © 2016 CA. ALL RIGHTS RESERVED.@CAWORLD #CAWORLD JavaScript defined in the Application § Probably the most commonly defined JavaScript is when the Event is triggered § You can specify a Javascript to be executed before each (and every) job is executed
  29. 29. 29 © 2016 CA. ALL RIGHTS RESERVED.@CAWORLD #CAWORLD JavaScript defined in the Application Scenarios § The script defines or sets values for symbolic variables that need to be available to multiple jobs within the Application. These variables can be system-level (the names begin with the prefix ESP) or Application level (the names begin with the prefix APPL). § The script passes parameters from the Event to the Application. § The script determines whether multiple jobs will run. § The script generates date and time variables to be used by multiple jobs. § The script defines or sets values for job-level symbolic variables. The names of these variables begin with the prefix WOB. For these scripts, you must select the At run time option. The script runs when each job in the Application starts to run.
  30. 30. 30 © 2016 CA. ALL RIGHTS RESERVED.@CAWORLD #CAWORLD Specifying a JavaScript in the Job definition Import from a local directory
  31. 31. 31 © 2016 CA. ALL RIGHTS RESERVED.@CAWORLD #CAWORLD JavaScript defined in the Job § When the Event is triggered § Before the job is run § Either specification can be from the JavaScript repository or from an embedded JavaScript in the job definition § Create WOB, APPL, ESP, EVAR prefixed variables
  32. 32. 32 © 2016 CA. ALL RIGHTS RESERVED.@CAWORLD #CAWORLD JavaScript defined in the Job Scenarios § The script sets values for variables used by a single job. § The script sets a variable whose value must be confined to a single job (the symbolic variable is used in multiple jobs but must have a unique value for each job). § The script specifies run criteria for a single job. § The script defines or sets values for symbolic variables that begin with the prefix WOB. § The script defines or sets values for system-level symbolic variables. The names of these variables begin with the prefix ESP. § The script defines or sets values for Application-level symbolic variables. The names of these variables begin with the prefix APPL.
  33. 33. 33 © 2016 CA. ALL RIGHTS RESERVED.@CAWORLD #CAWORLD Specifying a JavaScript in an Alert
  34. 34. 34 © 2016 CA. ALL RIGHTS RESERVED.@CAWORLD #CAWORLD JavaScript defined in an Alert § Execute a JavaScript from the repository or from an embedded JavaScript in the Alert definition § Used to execute commands as part of job post-processing
  35. 35. 35 © 2016 CA. ALL RIGHTS RESERVED.@CAWORLD #CAWORLD JavaScript defined in an Alert Scenarios § Trigger additional workload automatically § Complete an Application when a job is overdue § Resubmit a job if it completes with a particular exit code before a specific time § Execute user defined application integrations – Open up service desk tickets
  36. 36. 36 © 2016 CA. ALL RIGHTS RESERVED.@CAWORLD #CAWORLD Use an Alert to pass information about a job when triggering an Event
  37. 37. 37 © 2016 CA. ALL RIGHTS RESERVED.@CAWORLD #CAWORLD Creating a JavaScript § Many JavaScripts are only one statement and use built-in functions to do an action or set a symbolic § You do not need to be an expert to start defining a JavaScript – Lots of examples in the documentation
  38. 38. 38 © 2016 CA. ALL RIGHTS RESERVED.@CAWORLD #CAWORLD Documentation https://docops.ca.com/ca-wla-de/12-0/en/scheduling/javascripts/built-in-functions
  39. 39. 39 © 2016 CA. ALL RIGHTS RESERVED.@CAWORLD #CAWORLD Using Content Assist while creating a JavaScript
  40. 40. 40 © 2016 CA. ALL RIGHTS RESERVED.@CAWORLD #CAWORLD Some commonly used built-in functions to automate command execution § execCommand(jobname|ALL|SUBAPPL(subApplname), applnameAndGeneration,action) § execTrigger(eventname,ADD|REPLACE,time,NOHOLD|HOLD, userparameter1,userparameter4,userparameter3, userparameter2,rootjobs) § resetResourceProperty(resourceName,property,count)
  41. 41. 41 © 2016 CA. ALL RIGHTS RESERVED.@CAWORLD #CAWORLD Some commonly used built-in functions for Dates § daysBetween(startDate,endDate,dateType) § daysFrom(date) § daysTo(date) § genTime(prefix,date) § today(scheduleExpression) § tomorrow(scheduleExpression) § yesterday(scheduleExpression)
  42. 42. 42 © 2016 CA. ALL RIGHTS RESERVED.@CAWORLD #CAWORLD Some commonly used built-in functions for Global Variables § decrementVar(name,context) § deleteVar(name,context) § getVar(name,context) § incrementVar(name,context) § setVar(name,value,context)
  43. 43. 43 © 2016 CA. ALL RIGHTS RESERVED.@CAWORLD #CAWORLD Example JavaScripts that you should have in your repository § Load Event Prefix Global Variables – loadContext(APPL,'%APPL._eventprefix'); § Read APPL._ftfile and get filename – var pos = APPL._ftfile.lastIndexOf(''); – APPL.filename = APPL._ftfile.substring(pos+1);
  44. 44. 44 © 2016 CA. ALL RIGHTS RESERVED.@CAWORLD #CAWORLD Example JavaScripts that you should have in your repository § Kill Long Running Job – execCommand('%WOB._name','%(APPL._name).%(APPL._gen)','ACTIO N KILL'); § Self Complete or Force Complete Job from Alert – execCommand('%WOB._name','%(APPL._name).%APPL._gen','ACTION COMPLETE');
  45. 45. 45 © 2016 CA. ALL RIGHTS RESERVED.@CAWORLD #CAWORLD Example JavaScripts that you should have in your repository § Retrigger same application – execTrigger('%APPL._event','ADD'); § TRIGGER EVENT AND PASS USER PARAMETERS – execTrigger(‘Prefix.Application','','','','%WOB._name','%WOB._qualifier, '%APPL._name','%APPL._gen'); § Retrigger same event if time is not 7 pm – if (WOB._RHH < '19' && APPL._SDATE == WOB._RDATE); execTrigger('%APPL._event','ADD');
  46. 46. 46 © 2016 CA. ALL RIGHTS RESERVED.@CAWORLD #CAWORLD Example JavaScripts that you should have in your repository § Gentime First Day of Current month in YYYYMMDD Format – genTime('FD','first day of month less 1 month') ; APPL.first_day_of_month_yyyymmdd = FDYEAR+FDMM+FDDD § Today in YYYYMMDD Format – TODAY = ‘%APPL._SYY%APPL._SMM%APPL._SDD'
  47. 47. 47 © 2016 CA. ALL RIGHTS RESERVED.@CAWORLD #CAWORLD Example JavaScripts that you should have in your repository § Set times based on day of the week using If/Else else if(TDDOWNUM=='5') { APPL.Start_batch="5PM"; APPL.Late_end = "5AM tomorrow"; } else if(TDDOWNUM=='6') { APPL.Start_batch="6PM"; APPL.Late_end = "6AM tomorrow"; } else if(TDDOWNUM=='7') { APPL.Start_batch="7PM"; APPL.Late_end = "7AM tomorrow"; } else { APPL.Start_batch="8PM"; APPL.Late_end = "8AM tomorrow"; } genTime('TD','today'); if(TDDOWNUM=='1') { APPL.Start_batch="1PM"; APPL.Late_end = "1AM tomorrow"; } else if(TDDOWNUM=='2') { APPL.Start_batch="2PM"; APPL.Late_end = "2AM tomorrow"; } else if(TDDOWNUM=='3') { APPL.Start_batch="3PM"; APPL.Late_end = "3AM tomorrow"; } else if(TDDOWNUM=='4') { APPL.Start_batch="4PM"; APPL.Late_end = "4AM tomorrow"; }
  48. 48. 48 © 2016 CA. ALL RIGHTS RESERVED.@CAWORLD #CAWORLD Example JavaScripts that you should have in your repository § Set times based on day of the week using Switch case '5': APPL.Start_batch="5PM"; APPL.Late_end = "5AM tomorrow"; break; case '6': APPL.Start_batch="6PM"; APPL.Late_end = "6AM tomorrow"; break; case '7': APPL.Start_batch="7PM"; APPL.Late_end = "7AM tomorrow"; break; default: Start_batch="8PM"; Late_end = "8AM tomorrow"; } genTime('TD','today'); switch (TDDOWNUM) { case '1': APPL.Start_batch="1PM"; APPL.Late_end = "1AM tomorrow"; break; case '2': APPL.Start_batch="2PM"; APPL.Late_end = "2AM tomorrow"; break; case '3': APPL.Start_batch="3PM"; APPL.Late_end = "3AM tomorrow"; break; case '4': APPL.Start_batch="4PM"; APPL.Late_end = "4AM tomorrow"; break;
  49. 49. 49 © 2016 CA. ALL RIGHTS RESERVED.@CAWORLD #CAWORLD Naming Conventions § For some built-in functions, include the function – Gentime Yesterday – Reset Resource Availability – SetVar SubAPPL B § Or include the action or outcome – Retrigger same Event – Force Complete Job – Read APPL_ftfile and get filename
  50. 50. 50 © 2016 CA. ALL RIGHTS RESERVED.@CAWORLD #CAWORLD Summary § JavaScript can provide for passing “up to the moment of job submission” data to a job § JavaScript is extremely useful for post-processing of jobs and triggering additional processing § Storing JavaScripts in the repository and using symbolics in the commands enables a “write once, use many” scenario
  51. 51. 51 © 2016 CA. ALL RIGHTS RESERVED.@CAWORLD #CAWORLD Recommended Sessions SESSION # TITLE DATE/TIME MFX23E Best Practices: CA WLA DE Artifacts to Move Apps through the Development Lifecycle 11/14/2016 at 4:00pm Jasmine B MFX141EL Lab: Increased Agility and Flexibility with Web Services for CA WLA DE and ESP 11/15/2016 at 9:30 am South Seas D MFX30S Customer Use Case: Real World Automation in Retail 11/16/2016 at 3:45pm Banyan A/B MFX136S Delivering CA Workload Automation from a SaaS platform 11/17/2016 at 4:30 pm Jasmine B
  52. 52. 52 © 2016 CA. ALL RIGHTS RESERVED.@CAWORLD #CAWORLD Must See Demos Innovations: Cross Enterprise Workload Automation CA WLA DE & AE MF and Workload Automation Seamless Application Automation Agents & Advanced Integrations MF and Workload Automation CA Conversion as a Service CA Workload Automation MF and Workload Automation Modern Workload Automation CA WLA DE MF and Workload Automation
  53. 53. @CAWORLD #CAWORLD © 2016 CA. All RIGHTS RESERVED.53 @CAWORLD #CAWORLD Mainframe and Workload Automation For more information on Mainframe and Workload Automation, please visit: http://cainc.to/9GQ2JI
  54. 54. 54 © 2016 CA. ALL RIGHTS RESERVED.@CAWORLD #CAWORLD Questions?
  55. 55. 55 © 2016 CA. ALL RIGHTS RESERVED.@CAWORLD #CAWORLD Thank you Stay connected at communities.ca.com

×