|
Brad,
You might want to look at the sample of code below for getting at the
trigger buffers. It doesn't need the number of fields hard-coded but
instead uses pointers. And we now what happens when that number is wrong :)
d old_recordp s *
d old_record e ds extname(xxxxxxxx) prefix(old_)
d based(old_recordp)
d new_recordp s *
d new_record e ds extname(xxxxxxxx) prefix(new_)
d based(new_recordp)
c *entry plist
c parm trgbuf
c eval old_recordp = %addr(trgbuf) + tbooff
c eval new_recordp = %addr(trgbuf) + tbnoff
The tbooff and tonoff are the old/new record offsets.
Scott Mildenberger
> -----Original Message-----
> From: Stone, Brad V (TC) [mailto:bvstone@taylorcorp.com]
> Sent: Wednesday, July 11, 2001 7:25 AM
> To: 'MIDRANGE-L@midrange.com'
> Subject: RE: triggers
>
>
> If you're looking for a decent starting place for triggers,
> here's what I
> use. It's RPG, but could be translated to COBOL or any other language
> you're using:
>
> D TrigFlds E DS EXTNAME(TRGFLDPF)
> D FileImage E DS EXTNAME(FILENAME)
> *
> D WPPARM1 DS
> D P_Trigger LIKE(TrigFlds)
> D P_Before LIKE(FileImage)
> D O_FldMap 15
> D P_After LIKE(FileImage)
> D N_FldMap LIKE(O_FldMap)
> *
> D WPPARM2 DS
> D T_BuffLen 1 4B 0
>
> WPPARM1 and WPPARM2 are the two input parms used by a
> trigger. FileImage is
> an external DS defined using the filename the trigger is attached to.
>
> O_FldMap must be set to the number of fields in the file the
> trigger is
> attached to. In this case there are 15 fields in the file,
> so the size of
> this field is 15.
>
> TRGFLDPF is used to externally define the trigger specific
> fields. This is
> just a PF used only for external DS definition. It looks like this:
>
> A R TRGFLD TEXT('TRIGGER FILE')
>
> A TGFILE 10 TEXT('FILE NAME')
>
> A TGLIB 10 TEXT('LIBRARY NAME')
>
> A TGMBR 10 TEXT('MEMBER NAME')
>
> A TGEVENT 1 TEXT('TRIGGER EVENT')
>
> A TGTIME 1 TEXT('TRIGGER TIME')
>
> A TGCOMLEV 1 TEXT('COMMIT LEVEL')
>
> A TGRSVD1 3 TEXT('RESERVED FIELD
> 1')
> A TGCCSID 6 0B TEXT('CODED CHARACTER
> SET ID')
> A TGRSVD2 8 TEXT('RESERVED FIELD
> 2')
> A TGO_OFFSET 6 0B TEXT('ORIGINAL RECORD
> OFFSET')
> A TGO_LEN 6 0B TEXT('ORIGINAL RECORD
> LENGTH')
> A TGO_NULLOS 6 0B TEXT('ORIGINAL NULL
> OFFSET')
> A TGO_NULLLN 6 0B TEXT('ORIGINAL NULL
> LENGTH')
> A TGN_OFFSET 6 0B TEXT('NEW RECORD
> OFFSET')
> A TGN_LEN 6 0B TEXT('NEW RECORD
> LENGTH')
> A TGN_NULLOS 6 0B TEXT('NEW NULL
> OFFSET')
> A TGN_NULLLN 6 0B TEXT('NEW NULL
> LENGTH')
> A TGRSVD3 16 TEXT('RESERVED FIELD 3')
>
> Once this is all defined, you add a few lines of code and you've got a
> trigger "shell" program. The only thing you need to change
> is the O_FldMap
> as stated above to be the same number as how many fields are
> in the file.
>
> C *ENTRY PLIST
> C PARM WPPARM1
> C PARM WPPARM2
> *
> C eval FileImage = P_After
> * now you can do anything you want checking the values using
> the file name
> field names
>
>
> Brad
> +---
> | This is the Midrange System Mailing List!
> | To submit a new message, send your mail to MIDRANGE-L@midrange.com.
> | To subscribe to this list send email to MIDRANGE-L-SUB@midrange.com.
> | To unsubscribe from this list send email to
> MIDRANGE-L-UNSUB@midrange.com.
> | Questions should be directed to the list owner/operator:
> david@midrange.com
> +---
>
+---
| This is the Midrange System Mailing List!
| To submit a new message, send your mail to MIDRANGE-L@midrange.com.
| To subscribe to this list send email to MIDRANGE-L-SUB@midrange.com.
| To unsubscribe from this list send email to MIDRANGE-L-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator: david@midrange.com
+---
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 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.