× 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.


  • Subject: Re: Trigger program input buffer layout
  • From: "R. Bruce Hoffman, Jr." <rbruceh@xxxxxxxxxxxxx>
  • Date: Sat, 8 Jan 2000 13:02:50 -0500

Boy, I don't normally do this... but


the following code works for me... view with fixed font...

----- Begin RPG IV -----
      * ---------------------------------------------------------------
      * Standard ILE RPG IV specs for DB2/400 trigger program.
      *
      * Author: R. Bruce Hoffman, Jr.
      *
      * Built for V3R2.
      *
      * Reviewed for V3R7.
      * Revised for V4R1.
      * Revised for V4R2.
      *
      * ---------------------------------------------------------------

     H extbinint

      * Externally described table name.
     D fileName        c                   const('FILENAME')

      * Pointer based data structures for the input buffer.
     D newPoint        s               *
     D oldPoint        s               *

      * Map data structure for before and after images of the record
      *  in the buffer from the external description for the file.
     D newFile       e ds                  based(newPoint)
     D                                      extname(fileName)
     D                                      prefix(n_)

     D oldFile       e ds                  based(oldPoint)
     D                                      extname(fileName)
     D                                      prefix(o_)

      * First parameter of trigger call.  Trigger buffer header information.
     D trigParm        ds
     D  file                         10a
     D  library                      10a
     D  member                       10a
     D  trigEvent                     1a
     D  trigTime                      1a
     D  commitLock                    1a
     D  skip3                         3a
     D  ccsid                        10i 0
     D  currrn                       10i 0
     D  skip4                         4a
     D  oldrecoff                    10i 0
     D  oldreclen                    10i 0
     D  oldnuloff                    10i 0
     D  oldnullen                    10i 0
     D  newrecoff                    10i 0
     D  newreclen                    10i 0
     D  newnuloff                    10i 0
     D  newnullen                    10i 0
     D  skip16                       16a

      * Second parameter of trigger call.  Ignored by program.
     D bufferLen       s             10i 0

      * Constants used for trigger verification: triggering event,
      *  trigger time and commitment lock levels.
     D triggerEventInsert...
     D                 c                   const('1')
     D triggerEventDelete...
     D                 c                   const('2')
     D triggerEventUpdate...
     D                 c                   const('3')

     D triggerTimeAfter...
     D                 c                   const('1')
     D triggerTimeBefore...
     D                 c                   const('2')

     D commit_none...
     D                 c                   const('0')
     D commit_changes...
     D                 c                   const('1')
     D commit_cursorStability...
     D                 c                   const('2')
     D commit_all...
     D                 c                   const('3')

      * Trigger entry parameter list.
     C     *entry        plist
     C                   parm                    trigParm
     C                   parm                    bufferLen

      * Verify file, library and/or member names.
     C                   if        file <> fileName
     C                   eval       *inH9 = *on
     C                   return
     C                   endif

      * Verify Trigger event and time.
     C                   if        trigEvent <> triggerEventInsert
     C                   eval       *inH8 = *on
     C                   return
     C                   endif

     C                   if        trigTime <> triggerTimeAfter
     C                   eval       *inH7 = *on
     C                   return
     C                   endif

      * Address the data structures to the appropriate locations in the
      *  trigger buffer.
     C                   eval      oldPoint = %addr(trigParm) + oldrecoff
     C                   eval      newPoint = %addr(trigParm) + newrecoff


      * When done, leave program.
     C                   return
----- End RPG IV Code -----


===========================================================
R. Bruce Hoffman, Jr.
 -- IBM Certified AS/400 Professional System Administrator
 -- IBM Certified AS/400 Professional Network Administrator

"The sum of all human knowledge is a fixed constant.
    It's the population that keeps growing!"

-----Original Message-----
From: Jim Langston <jlangston@conexfreight.com>
To: RPG400-L@midrange.com <RPG400-L@midrange.com>
Date: Friday, January 07, 2000 6:42 PM
Subject: Re: Trigger program input buffer layout


>I found out why I was getting a blank record, but the
>question still stands, how do I use Parm1 without
>knowing the sizes of the Null Byte Record Map before
>hand?
>
>Regards,
>
>Jim Langston
>
>Jim Langston wrote:
>
>> I'm writing my first trigger program and am basing it on
>> the sample from the Infoseeker Bookshelf for V3R7M0.
>>
>> When this program runs, I am expecting the file I am opening,
>> APUNIONBNK, to contain a new record that is an exact
>> copy of the record added to my file.  But it is blank.  Here is the
>> code it it's entirety.
>>
>> Also, the example shows the data structure being set up with the
>> OldRecordBuffer, OldRecordMap, NewRecordBuffer and
>> NewRecordMaps laid out.  This is somewhat difficult to do.
>> Mostly, because I don't know the size of the Null Byte Map
>> before hand.  What I wound up doing in this case was setting
>> their size to the same as in the example (something like 4 bytes)
>> and running it, and getting an error on my SubSt because the
>> pointer was running off into la-la land.  So I ran it in Debug,
>> and displayed the value of the Null Byte Map Size, then went
>> into the program and changed the DDS to reflect this.
>>
>> This seems an awfully cumbersome way to do it though, is there
>> a better way?
>>
>>      FAPUNIONBNKUF A F  150        DISK
>>
>>      D Parm1           DS
>>      D  FileName               1     10
>>      D  LibName               11     20
>>      D  MemName               21     30
>>      D  TrigEvent             31     31
>>      D  TrigTime              32     32
>>      D  CommLockLvl           33     33
>>      D  Reserved01            34     36
>>      D  CCSID                 37     40B 0
>>      D  Reserved02            41     48
>>      D  OldOffset             49     52B 0
>>      D  OldLength             53     56B 0
>>      D  OldByteMapOff         57     60B 0
>>      D  OldByteMapLen         61     64B 0
>>      D  NewOffset             65     68B 0
>>      D  NewLength             69     72B 0
>>      D  NewByteMapOff         73     76B 0
>>      D  NewByteMapLen         77     80B 0
>>      D  Reserved03            81     96
>>      D*********
>>      D  OldRecord             97    246
>>      D  OldByteMap           247    276
>>      D  NewRecord            277    426
>>      D  NewByteMap           427    556
>>      D*********
>>      D
>>      D Parm2           DS
>>      D  Length                 1      4B 0
>>      D
>>      D NewBuffer       DS           150
>>      D
>>      D Offset          S              5  0
>>
>>      IAPUNIONBNKNS
>>      I                                  1  150  NewRecord
>>
>>      C     *Entry        PList
>>      C     Parm1         Parm                    Parm1
>>      C     Parm2         Parm                    Parm2
>>      C
>>      C                   Eval      Offset = NewOffset + 1
>>      C
>>      C                   Eval      NewRecord =
>> %SubSt(Parm1:Offset:150)
>>      C                   Write     APUnionBnk    NewBuffer
>>      C                   Eval      *INLR = *ON
>>
>> Thanks in advance,
>>
>> Regards,
>>
>> Jim Langston
>
>+---
>| This is the RPG/400 Mailing List!
>| To submit a new message, send your mail to RPG400-L@midrange.com.
>| To subscribe to this list send email to RPG400-L-SUB@midrange.com.
>| To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com.
>| Questions should be directed to the list owner/operator:
david@midrange.com
>+---
>

+---
| This is the RPG/400 Mailing List!
| To submit a new message, send your mail to RPG400-L@midrange.com.
| To subscribe to this list send email to RPG400-L-SUB@midrange.com.
| To unsubscribe from this list send email to RPG400-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 thread ...


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.