Home > Ask the AS/400 Experts > iSeries Application Development Questions & Answers > Creating a CL trigger program
Ask The iSeries 400 Expert: Questions & Answers
EMAIL THIS

Creating a CL trigger program

John Blenkinsop EXPERT RESPONSE FROM: John Blenkinsop

Pose a Question
Other iSeries 400 Categories
Meet all iSeries 400 Experts
Become an Expert for this site


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


>
QUESTION POSED ON: 15 September 2004
I need to know how to create a CL trigger program. I've already read many documents, but I can't find any "how to" information.


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


RELATED CONTENT
iSeries Application Development
Monitoring escape messages and using RCVMSG for diagnostic messages
Listing contents of multiple FTP directories on AS/400
Chain operation error after converting RPG3 to ILE RPG (RPGIV)
Space offset X'0015FF00' or X'0000000000000000' is outside current limit for object QIGC2424C
Searching fields for values
iSeries application display subfiles with other program windows
Searching part of a name or address in AS/400
Passing parameters in an ILE RPG module
What's happening to my subfile?
What happening to my subfile?

iSeries ILE programming
How to use an embedded SQL statement and display the result in a subfile
Eight steps for creating program documentation using AS/400 utilities
Searching fields for values
Searching part of a name or address in AS/400
Top 10 programmer tips YTD
How to use the binder language to manage service programs -- Part 3: Examples and pitfalls
Top 10 programmer tips of 2005
How to use the binder language to manage service programs -- Part 2: Understanding the binder language
How to use the binder language to manage service programs -- Part 1: Service program signatures
Display attributes made simple

iSeries CL programming
Checking in on your IBM i authorization lists
Running PHP open source applications: NOBODY needs authority
Simplify the process of converting a spool file from iSeries into an Excel spreadsheet
CL program for daily backups
An automated CL method of moving a query from AS/400 to Excel
Changing user password expiration
Eight steps for creating program documentation using AS/400 utilities
DAYSPAST CLLE program for AS/400: Compares object creation date with today's date
Advanced Job Scheduler help
How do I retrieve the source for an output queue description to put in to a CL program?

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary


A trigger program in CL is the same as a trigger program in RPG. It receives two parameters when it is called by the triggering event -- a parameter of variable length, and a 4-byte binary value giving the length of the first parameter.

You can determine the size of the first parameter by reference to the following structure, which is in RPG/IV -- it can be translated into substringed CL variables:

 
IP@TBUF      DS                           9999           
 * Trigger buffer definition                             
 *               Name of triggering file                 
I                                        1  10 TEPFNM     
 *               Library name of triggering file         
I                                       11  20 T@LIBR     
 *               Member name of triggering file           
I                                       21  30 T@MBR     
 *               Trigger event (1/2/3 = Insert/Update/Delete)           
I                                       31  31 T@EVNT     
 *               Trigger time  (1/2 = After/Before)               
I                                       32  32 T@TIME     
 *               Trigger commitment level                 
I                                       33  33 T@CMTL     
 *               Filler                                   
I                                       34  36 T@FIL1     
 *               Coded Character Set ID                   
I                                    B  37  400T@CSID     
 *               Filler                                   
I                                       41  48 T@FIL2     
 *               Offset to old record image             
I                                    B  49  520T@ORIO   
 *               Length of old record image             
I                                    B  53  560T@ORIL   
 *               Offset to old null field map           
I                                    B  57  600T@ONMO   
 *               Length of old null field map           
I                                    B  61  640T@ONML   
 *               Offset to new record image             
I                                    B  65  680T@NRIO   
 *               Length of new record image             
I                                    B  69  720T@NRIL   
 *               Offset to new null field map           
I                                    B  73  760T@NNMO   
 *               Length of new null field map           
I                                    B  77  800T@NNML   
 *               Reserved                               
I                                       81  96 T@RES1   
 *          *VAR Old record image                       
 *          *VAR Old record null field map             
 *          *VAR New record image                     
 *          *VAR New record null field map             
 *               Array over record images             

The total length of the parameter will be 96 + (2 * record length of file), unless there are any null field maps involved. It's easy enough to create a test program and look at the parameter and its parts in debug.

So if you need the old and/or new record images in your CL program, you can hard-code their start positions and lengths. But you can also be flexible, and use the length supplied in the other parameter, in case the file's record length is changed in the future.

Also, note that there will NOT be an OLD image if the operation is *INSERT, or a NEW image if the operation is *DELETE.

For myself, I usually use a CL program to pass these parameters to an RPG program for more complex processing, but the CL is a useful harness, providing error management and reporting via return codes from the RPG.




Search and Browse the Expert Answer Center
Search and browse more than 25,000 question and answer pairs from more than 250 TechTarget industry experts.
Browse our Expert Advice



iSeries Networking - Printing, Remote Access, TCP/IP
HomeNewsTopicsITKnowledge ExchangeTipsBlogsAsk the ExpertsMultimediaWhite PapersProducts
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 1999 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts