SlideShare ist ein Scribd-Unternehmen logo
1 von 31
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…
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 logic
Your data, where, when and how you want it…
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 accessed




Your data, where, when and how you want it…
Utilities 400 | System i Solutions | Using triggers to improve your business processes



                   Add a Trigger




Your data, where, when and how you want it…
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…
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…
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
           command
Your data, where, when and how you want it…
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 deletes
Your data, where, when and how you want it…
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…
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…
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…
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…
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 = Before
Your data, where, when and how you want it…
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…
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…
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 program
Your data, where, when and how you want it…
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 program




Your data, where, when and how you want it…
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…
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 image




Your data, where, when and how you want it…
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_recordstr



Your data, where, when and how you want it…
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_NUMORDS




Your data, where, when and how you want it…
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_NUMORDS




Your data, where, when and how you want it…
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 invoices

Your data, where, when and how you want it…
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 invoices


Your data, where, when and how you want it…
Utilities 400 | System i Solutions | Using triggers to improve your business processes




Your data, where, when and how you want it…
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…
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 applications




Your data, where, when and how you want it…
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 *ALL

Your data, where, when and how you want it…
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…
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.com
Your data, where, when and how you want it…
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…

Weitere ähnliche Inhalte

Ähnlich wie Utilities 400 NiSUG Trigger Presentation

香港六合彩
香港六合彩香港六合彩
香港六合彩taoyan
 
Importance of ‘Centralized Event collection’ and BigData platform for Analysis !
Importance of ‘Centralized Event collection’ and BigData platform for Analysis !Importance of ‘Centralized Event collection’ and BigData platform for Analysis !
Importance of ‘Centralized Event collection’ and BigData platform for Analysis !Piyush Kumar
 
Library Management System using oracle database
Library Management System using oracle databaseLibrary Management System using oracle database
Library Management System using oracle databaseSaikot Roy
 
AMB110: IT Asset Management – How to Start When You Don’t Know Where to Start
AMB110: IT Asset Management – How to Start When You Don’t Know Where to StartAMB110: IT Asset Management – How to Start When You Don’t Know Where to Start
AMB110: IT Asset Management – How to Start When You Don’t Know Where to StartIvanti
 
SplunkLive! Presentation - Data Onboarding with Splunk
SplunkLive! Presentation - Data Onboarding with SplunkSplunkLive! Presentation - Data Onboarding with Splunk
SplunkLive! Presentation - Data Onboarding with SplunkSplunk
 
IT PRO | Connections 2020 : Introduction to Logic Apps and automation solutio...
IT PRO | Connections 2020 : Introduction to Logic Apps and automation solutio...IT PRO | Connections 2020 : Introduction to Logic Apps and automation solutio...
IT PRO | Connections 2020 : Introduction to Logic Apps and automation solutio...George Grammatikos
 
Practical operability techniques for distributed systems - Velocity EU 2017
Practical operability techniques for distributed systems - Velocity EU 2017Practical operability techniques for distributed systems - Velocity EU 2017
Practical operability techniques for distributed systems - Velocity EU 2017Skelton Thatcher Consulting Ltd
 
Replace this Line with the Title of Your Paper.docx
Replace this Line with the Title of Your Paper.docxReplace this Line with the Title of Your Paper.docx
Replace this Line with the Title of Your Paper.docxdebishakespeare
 
System analysis and design
System analysis and designSystem analysis and design
System analysis and designRobinsonObura
 
London atlassian meetup 31 jan 2016 jira metrics-extract slides
London atlassian meetup 31 jan 2016 jira metrics-extract slidesLondon atlassian meetup 31 jan 2016 jira metrics-extract slides
London atlassian meetup 31 jan 2016 jira metrics-extract slidesRudiger Wolf
 
ITAM Portfolio-The Big Umbrella-Slideshare.pptx
ITAM Portfolio-The Big Umbrella-Slideshare.pptxITAM Portfolio-The Big Umbrella-Slideshare.pptx
ITAM Portfolio-The Big Umbrella-Slideshare.pptxSandeep Bhatia
 
Logicaworks brochure
Logicaworks brochureLogicaworks brochure
Logicaworks brochureAshwini Rath
 
SharePoint Governance: stories, myths, legends and real life
SharePoint Governance: stories, myths, legends and real lifeSharePoint Governance: stories, myths, legends and real life
SharePoint Governance: stories, myths, legends and real lifeToni Frankola
 
HotButton Solutions : HotLeap Tracker Brochure v1.9
HotButton Solutions : HotLeap Tracker Brochure v1.9HotButton Solutions : HotLeap Tracker Brochure v1.9
HotButton Solutions : HotLeap Tracker Brochure v1.9Nathan Watt
 
Implementing and auditing security controls part 2
Implementing and auditing security controls   part 2Implementing and auditing security controls   part 2
Implementing and auditing security controls part 2Rafel Ivgi
 
15 hacks for better ITAM with ServiceDesk Plus
15 hacks for better ITAM with ServiceDesk Plus15 hacks for better ITAM with ServiceDesk Plus
15 hacks for better ITAM with ServiceDesk PlusLeeben Amirthavasagam
 
FAST PHRASE SEARCH FOR ENCRYPTED CLOUD STORAGE.pptx
FAST PHRASE SEARCH FOR ENCRYPTED CLOUD STORAGE.pptxFAST PHRASE SEARCH FOR ENCRYPTED CLOUD STORAGE.pptx
FAST PHRASE SEARCH FOR ENCRYPTED CLOUD STORAGE.pptxgattamanenitejeswar
 
College management
College managementCollege management
College managementanandhan30
 

Ähnlich wie Utilities 400 NiSUG Trigger Presentation (20)

香港六合彩
香港六合彩香港六合彩
香港六合彩
 
Libnova ICoC
Libnova ICoCLibnova ICoC
Libnova ICoC
 
Importance of ‘Centralized Event collection’ and BigData platform for Analysis !
Importance of ‘Centralized Event collection’ and BigData platform for Analysis !Importance of ‘Centralized Event collection’ and BigData platform for Analysis !
Importance of ‘Centralized Event collection’ and BigData platform for Analysis !
 
Library Management System using oracle database
Library Management System using oracle databaseLibrary Management System using oracle database
Library Management System using oracle database
 
AMB110: IT Asset Management – How to Start When You Don’t Know Where to Start
AMB110: IT Asset Management – How to Start When You Don’t Know Where to StartAMB110: IT Asset Management – How to Start When You Don’t Know Where to Start
AMB110: IT Asset Management – How to Start When You Don’t Know Where to Start
 
SplunkLive! Presentation - Data Onboarding with Splunk
SplunkLive! Presentation - Data Onboarding with SplunkSplunkLive! Presentation - Data Onboarding with Splunk
SplunkLive! Presentation - Data Onboarding with Splunk
 
IT PRO | Connections 2020 : Introduction to Logic Apps and automation solutio...
IT PRO | Connections 2020 : Introduction to Logic Apps and automation solutio...IT PRO | Connections 2020 : Introduction to Logic Apps and automation solutio...
IT PRO | Connections 2020 : Introduction to Logic Apps and automation solutio...
 
Practical operability techniques for distributed systems - Velocity EU 2017
Practical operability techniques for distributed systems - Velocity EU 2017Practical operability techniques for distributed systems - Velocity EU 2017
Practical operability techniques for distributed systems - Velocity EU 2017
 
Replace this Line with the Title of Your Paper.docx
Replace this Line with the Title of Your Paper.docxReplace this Line with the Title of Your Paper.docx
Replace this Line with the Title of Your Paper.docx
 
System analysis and design
System analysis and designSystem analysis and design
System analysis and design
 
London atlassian meetup 31 jan 2016 jira metrics-extract slides
London atlassian meetup 31 jan 2016 jira metrics-extract slidesLondon atlassian meetup 31 jan 2016 jira metrics-extract slides
London atlassian meetup 31 jan 2016 jira metrics-extract slides
 
ITAM Portfolio-The Big Umbrella-Slideshare.pptx
ITAM Portfolio-The Big Umbrella-Slideshare.pptxITAM Portfolio-The Big Umbrella-Slideshare.pptx
ITAM Portfolio-The Big Umbrella-Slideshare.pptx
 
Audit and syslog lightning talk
Audit and syslog lightning talkAudit and syslog lightning talk
Audit and syslog lightning talk
 
Logicaworks brochure
Logicaworks brochureLogicaworks brochure
Logicaworks brochure
 
SharePoint Governance: stories, myths, legends and real life
SharePoint Governance: stories, myths, legends and real lifeSharePoint Governance: stories, myths, legends and real life
SharePoint Governance: stories, myths, legends and real life
 
HotButton Solutions : HotLeap Tracker Brochure v1.9
HotButton Solutions : HotLeap Tracker Brochure v1.9HotButton Solutions : HotLeap Tracker Brochure v1.9
HotButton Solutions : HotLeap Tracker Brochure v1.9
 
Implementing and auditing security controls part 2
Implementing and auditing security controls   part 2Implementing and auditing security controls   part 2
Implementing and auditing security controls part 2
 
15 hacks for better ITAM with ServiceDesk Plus
15 hacks for better ITAM with ServiceDesk Plus15 hacks for better ITAM with ServiceDesk Plus
15 hacks for better ITAM with ServiceDesk Plus
 
FAST PHRASE SEARCH FOR ENCRYPTED CLOUD STORAGE.pptx
FAST PHRASE SEARCH FOR ENCRYPTED CLOUD STORAGE.pptxFAST PHRASE SEARCH FOR ENCRYPTED CLOUD STORAGE.pptx
FAST PHRASE SEARCH FOR ENCRYPTED CLOUD STORAGE.pptx
 
College management
College managementCollege management
College management
 

Kürzlich hochgeladen

DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????blackmambaettijean
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 

Kürzlich hochgeladen (20)

DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 

Utilities 400 NiSUG Trigger Presentation

  • 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. 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 logic Your data, where, when and how you want it…
  • 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 accessed Your data, where, when and how you want it…
  • 4. Utilities 400 | System i Solutions | Using triggers to improve your business processes Add a Trigger Your data, where, when and how you want it…
  • 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. 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. 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 command Your data, where, when and how you want it…
  • 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 deletes Your data, where, when and how you want it…
  • 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. 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. 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. 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. 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 = Before Your data, where, when and how you want it…
  • 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. 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. 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 program Your data, where, when and how you want it…
  • 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 program Your data, where, when and how you want it…
  • 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. 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 image Your data, where, when and how you want it…
  • 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_recordstr Your data, where, when and how you want it…
  • 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_NUMORDS Your data, where, when and how you want it…
  • 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_NUMORDS Your data, where, when and how you want it…
  • 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 invoices Your data, where, when and how you want it…
  • 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 invoices Your data, where, when and how you want it…
  • 25. Utilities 400 | System i Solutions | Using triggers to improve your business processes Your data, where, when and how you want it…
  • 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. 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 applications Your data, where, when and how you want it…
  • 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 *ALL Your data, where, when and how you want it…
  • 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. 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.com Your data, where, when and how you want it…
  • 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…