Utilities 400 | System i Solutions | Using triggers to improve your business processes  Using triggers to improve  busines...
Utilities 400 | System i Solutions | Using triggers to improve your business processes                                   T...
Utilities 400 | System i Solutions | Using triggers to improve your business processes                   Add a Trigger - T...
Utilities 400 | System i Solutions | Using triggers to improve your business processes                   Add a TriggerYour...
Utilities 400 | System i Solutions | Using triggers to improve your business processes                             Gotcha ...
Utilities 400 | System i Solutions | Using triggers to improve your business processes                             Gotcha ...
Utilities 400 | System i Solutions | Using triggers to improve your business processes                             Gotcha ...
Utilities 400 | System i Solutions | Using triggers to improve your business processes                             Gotcha ...
Utilities 400 | System i Solutions | Using triggers to improve your business processes                           Gotcha (i...
Utilities 400 | System i Solutions | Using triggers to improve your business processes                          Gotcha (ii...
Utilities 400 | System i Solutions | Using triggers to improve your business processes                                    ...
Utilities 400 | System i Solutions | Using triggers to improve your business processes                                    ...
Utilities 400 | System i Solutions | Using triggers to improve your business processes                                    ...
Utilities 400 | System i Solutions | Using triggers to improve your business processes                                    ...
Utilities 400 | System i Solutions | Using triggers to improve your business processes                                    ...
Utilities 400 | System i Solutions | Using triggers to improve your business processes         Generic program  The last t...
Utilities 400 | System i Solutions | Using triggers to improve your business processes         Generic program  Recommend ...
Utilities 400 | System i Solutions | Using triggers to improve your business processes         Generic program  Recommend ...
Utilities 400 | System i Solutions | Using triggers to improve your business processes         Generic program  Recommend ...
Utilities 400 | System i Solutions | Using triggers to improve your business processes         Generic program  In the cal...
Utilities 400 | System i Solutions | Using triggers to improve your business processes         Generic program  You now ha...
Utilities 400 | System i Solutions | Using triggers to improve your business processes         Generic program  And all th...
Utilities 400 | System i Solutions | Using triggers to improve your business processes            Client Examples  Sending...
Utilities 400 | System i Solutions | Using triggers to improve your business processes            Client Examples  Creatin...
Utilities 400 | System i Solutions | Using triggers to improve your business processesYour data, where, when and how you w...
Utilities 400 | System i Solutions | Using triggers to improve your business processes            Client Examples  Creatin...
Utilities 400 | System i Solutions | Using triggers to improve your business processes            Client Examples  Replica...
Utilities 400 | System i Solutions | Using triggers to improve your business processes        Other commands  CHGPFTRG    ...
Utilities 400 | System i Solutions | Using triggers to improve your business processes               Considerations  Consi...
Utilities 400 | System i Solutions | Using triggers to improve your business processes          Happy Shooting!  Keep your...
Utilities 400 | System i Solutions | Using triggers to improve your business processes    Questions and Answers  Steve Clo...
Upcoming SlideShare
Loading in …5
×

Utilities 400 NiSUG Trigger Presentation

637
-1

Published on

During the NiSUG event, Steve Close of Utilities 400 presented, "Using Triggers to Improve Business Processes" here is his presentation.

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
637
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
11
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Utilities 400 NiSUG Trigger Presentation

  1. 1. Utilities 400 | System i Solutions | Using triggers to improve your business processes Using triggers to improve business processes Steve Close Utilities 400 Limited.Your data, where, when and how you want it…
  2. 2. Utilities 400 | System i Solutions | Using triggers to improve your business processes Triggers - One of the most underused features on the operating system - Can cause a trigger to be executed (“fired”!) whenever a record is added, updated, deleted or read from a file - Triggers can call any program to perform additional business logicYour data, where, when and how you want it…
  3. 3. Utilities 400 | System i Solutions | Using triggers to improve your business processes Add a Trigger - To add a trigger to a file use command ADDPFTRG - Triggers are always added to a physical file, but trigger occurs however record is accessedYour data, where, when and how you want it…
  4. 4. Utilities 400 | System i Solutions | Using triggers to improve your business processes Add a TriggerYour data, where, when and how you want it…
  5. 5. Utilities 400 | System i Solutions | Using triggers to improve your business processes Gotcha (i) Need to get an exclusive lock on a file to be able to add or remove a trigger Solutions: 1) Log on late at night when nobody is using the system.Your data, where, when and how you want it…
  6. 6. Utilities 400 | System i Solutions | Using triggers to improve your business processes Gotcha (i) Need to get an exclusive lock on a file to be able to add or remove a trigger Solutions: 2) Give up!Your data, where, when and how you want it…
  7. 7. Utilities 400 | System i Solutions | Using triggers to improve your business processes Gotcha (i) Need to get an exclusive lock on a file to be able to add or remove a trigger Solutions: 3) Write a little application to perform the add remove triggers a) Create a file with add/remove flag and all the attributes for the commandYour data, where, when and how you want it…
  8. 8. Utilities 400 | System i Solutions | Using triggers to improve your business processes Gotcha (i) Need to get an exclusive lock on a file to be able to add or remove a trigger Solutions: 3) Write a little application to perform the add remove triggers b) write a program that runs at an appropriate time that reads this file, performs actions and deletesYour data, where, when and how you want it…
  9. 9. Utilities 400 | System i Solutions | Using triggers to improve your business processes Gotcha (ii) Once a job has fired the trigger the program referenced on trigger gets locked to the job. Solution: Write a generic trigger program that is called by any trigger that you ever add. This trigger program analyses the string passed to it by the trigger and reads a file to decide which program to call, passing the trigger data to it.Your data, where, when and how you want it…
  10. 10. Utilities 400 | System i Solutions | Using triggers to improve your business processes Gotcha (iii) The execution of the logic defined in the trigger becomes part of the I/O operation against the file. Solutions: If adding any long running operations as part of a trigger make sure it submits the job, preferably to a multi threaded job queue.Your data, where, when and how you want it…
  11. 11. Utilities 400 | System i Solutions | Using triggers to improve your business processes Data What data is passed by the operating system to the trigger program? Two parameters: 1) A long string containing control information followed by the before and after images of the record processes.Your data, where, when and how you want it…
  12. 12. Utilities 400 | System i Solutions | Using triggers to improve your business processes Data What data is passed by the operating system to the trigger program? Two parameters: 2) A 4 byte binary number containing the length of the string passed.Your data, where, when and how you want it…
  13. 13. Utilities 400 | System i Solutions | Using triggers to improve your business processes Data Trigger control information. 1-10 Name of the file being triggered 11-20 Library of the file being triggered 21-30 Member being triggered 31 Trigger event 1 = Insert 2 = Delete 3 = Update 4 = Read 32 Trigger time 1 = After 2 = BeforeYour data, where, when and how you want it…
  14. 14. Utilities 400 | System i Solutions | Using triggers to improve your business processes Data Trigger control information. 37-40 CCSID of the file (4 byte binary) 41-44 RRN of the record being processed (4 byte binary) 49-52 Offset to the before image of the record (4 byte binary) (orgoffset) 53-56 Length of the before record (orglen) 57-60 Offset to the after image of the record (newoffset) 61-64 Length of the after record (newlen)Your data, where, when and how you want it…
  15. 15. Utilities 400 | System i Solutions | Using triggers to improve your business processes Data To extract the before image in RPG:- Eval orgrecord=%subst(buffer:orgoffset:orglen) Eval newrecord=%subst(buffer:newoffset:newlen)Your data, where, when and how you want it…
  16. 16. Utilities 400 | System i Solutions | Using triggers to improve your business processes Generic program The last thing the generic program needs to do is access the file you have created to decide which program to call. For instance this file would tell the generic program that when a record is add to file CUSTOMER in library SHOWMEDEMO that it should call the relevant programYour data, where, when and how you want it…
  17. 17. Utilities 400 | System i Solutions | Using triggers to improve your business processes Generic program Recommend that all is a generic program and then pass to each individual routine 1) The current user (Defined in the program status data area of the generic programYour data, where, when and how you want it…
  18. 18. Utilities 400 | System i Solutions | Using triggers to improve your business processes Generic program Recommend that all is a generic program and then pass to each individual routine 2) The trigger event (Insert, Update, etc.) 3) The trigger time (Before or After)Your data, where, when and how you want it…
  19. 19. Utilities 400 | System i Solutions | Using triggers to improve your business processes Generic program Recommend that all is a generic program and then pass to each individual routine 4) The before image 5) The after imageYour data, where, when and how you want it…
  20. 20. Utilities 400 | System i Solutions | Using triggers to improve your business processes Generic program In the called program defined two data structures:- d b_recordstr e ds extname(CUSTOMER) prefix(b_) d a_recordstr e ds extname(CUSTOMER) prefix(a_) Then move the before image into structure b_recordstr move the after image into structure a_recordstrYour data, where, when and how you want it…
  21. 21. Utilities 400 | System i Solutions | Using triggers to improve your business processes Generic program You now have all fields from the before image available to the program, for example: B_BALANCE B_NUMORDSYour data, where, when and how you want it…
  22. 22. Utilities 400 | System i Solutions | Using triggers to improve your business processes Generic program And all the fields from the after image, for example: A_BALANCE A_NUMORDSYour data, where, when and how you want it…
  23. 23. Utilities 400 | System i Solutions | Using triggers to improve your business processes Client Examples Sending an email to customer services when a customer goes over their credit limit, maybe attaching a spreadsheet to all their open invoicesYour data, where, when and how you want it…
  24. 24. Utilities 400 | System i Solutions | Using triggers to improve your business processes Client Examples Creating a workflow for order acceptance including order acknowledgement, picking lists, delivery notes and invoicesYour data, where, when and how you want it…
  25. 25. Utilities 400 | System i Solutions | Using triggers to improve your business processesYour data, where, when and how you want it…
  26. 26. Utilities 400 | System i Solutions | Using triggers to improve your business processes Client Examples Creating an audit log of any changes to fields on required files. Can log user, date and time, program name, and before and after image of any or all fields.Your data, where, when and how you want it…
  27. 27. Utilities 400 | System i Solutions | Using triggers to improve your business processes Client Examples Replicate the data via an SQL statement into other tables or applicationsYour data, where, when and how you want it…
  28. 28. Utilities 400 | System i Solutions | Using triggers to improve your business processes Other commands CHGPFTRG Change trigger, can change status to *ENABLED or *DISABLED – needs exclusive lock RMVPFTRG Removes a trigger – needs exclusive lock PRTTRGPGM List all the triggers in a particular library *ALLYour data, where, when and how you want it…
  29. 29. Utilities 400 | System i Solutions | Using triggers to improve your business processes Considerations Consider writing your generic trigger program to read a file of triggers to ignore. In this way you can turn any particular trigger off and back on without needing to have an exclusive lock.Your data, where, when and how you want it…
  30. 30. Utilities 400 | System i Solutions | Using triggers to improve your business processes Happy Shooting! Keep your trigger finger handy! Should you wish to learn more on how we helped businesses with their automation requirements please contact me. sclose@uti400.com www.uti400.comYour data, where, when and how you want it…
  31. 31. Utilities 400 | System i Solutions | Using triggers to improve your business processes Questions and Answers Steve Close Utilities 400 Limited.Your data, where, when and how you want it…
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×