× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



I >think< I understand this. For an insert, the data structure New_Rcd gets the new data. And, since it is an external data structure, based on a file, then the field names associated with the file are then available in the program? In what I envision, for an insert operation, a call to qcmdexc would be built and run, passing appropriate information. The command that would be run would be SBMJOB CMD(CALL PGM(mypgm) PARM(x, y, z)) JOB(SNDNOTICE).

I haven't worked with pointers in RPG and it has been over twenty years since I worked with pointers in C.


John McKee

-----Original message-----
From: Sam_L lennon_s_j@xxxxxxxxxxx
Date: Tue, 10 May 2011 19:49:45 -0500
To: midrange-l@xxxxxxxxxxxx
Subject: Re: Creating a trigger program

Here's a template that I brought from a prior job. Haven't used it
recently, but I believe it is fairly efficient using pointers instead of
moving records to data structures. Obviously you have to add your logic
in the Insert, Delete and Update routines.

Sam

*=== Output File ==============================================
F*RBHDRPA O E K DISK

*=== Data Structures for Old and New Records ===================
DOld_Rcd E DS extname($MENUOPT)
D prefix(O_)
D based(OPtr)
DNew_Rcd E DS extname($MENUOPT)
D prefix(N_)
D based(NPtr)

DOPtr s *
DNPtr s *

*=== Passed Trigger Buffer =====================================
DBuffer DS 32767

*--- Physical File Name
D FileName 10
*
*--- Physical File Library.
D LibraryName 10
*
*--- Member Name.
D MemberName 10
*
*--- Trigger Event.
D TrgEvent 1
*
*--- Trigger Time.
D TrgTime 1
*
*--- Commit Lock Level.
D CommitLckLvl 1
*
*--- Reserved.
D Filler1 3
*
*--- CCSID.
D CCSID 10I 0
*
*--- Reserved.
D Filler2 8
*
*--- Offset to the Original Record.
D OldOff 10I 0
*
*--- Length of the Original Record.
D OldLen 10I 0
*
*--- Offset to the Original record null byte map.
D OldNullOffset 10I 0
*
*--- Length of the null byte map.
D OldNullLength 10I 0
*
*--- Offset to the new record.
D NewOff 10I 0
*
*--- Length of the new record.
D NewLen 10I 0
*
*--- Offset to the new record null byte map.
D NewNullOffset 10I 0
*
*--- Length of the null byte map.
D NewNullLength 10I 0
*
*--- Reserved.
D Resv3 16


D BufLen s 10I 0

*=== Passed Parameters =========================================
C *ENTRY plist
C Buffer parm Buffer
C BufLen parm BufLen


//=== Program flow starts here ==================================

/FREE
select;
when TrgEvent = '1';
exsr Insert;
when TrgEvent = '2';
exsr Delete;
when TrgEvent = '3';
exsr Update;
endsl;

*inlr = *on;

//=== Insert ====================================================
//
begsr Insert;
NPtr=%addr(Buffer) + NewOff;
endsr;

//=== Delete ====================================================
//
begsr Delete;
OPtr=%addr(Buffer) + OldOff;
endsr;
//
//=== Update ====================================================
//
begsr Update;
NPtr=%addr(Buffer) + NewOff;
OPtr=%addr(Buffer) + OldOff;
endsr;

/END-FREE


On 5/10/2011 7:54 PM, jmmckee wrote:
Seeing a working example would be helpful. Thanks.

John McKee
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.