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



Having a problem creating an RPG trigger to create two unique sequence
numbers
upon insert of a record.  I keep ending up with no values being inserted
into
the sequence fields and I'm not sure why.

The created table:


 CREATE TABLE TABLEA (
        FIELDA             CHAR(50) NOT NULL,
        FIELDB             CHAR(50) NOT NULL,
        FIELDC             CHAR(50) NOT NULL,
        SEQNUM1            DEC(9,0),
        FIELDD             CHAR(35) NOT NULL,
        SEQNUM2            DEC(9,0),
        FIELDF             CHAR(8),
        FIELDG             CHAR(8),
        FIELDH             CHAR(50) NOT NULL,
        FIELDI             CHAR(18) NOT NULL,
        FIELDJ             CHAR(35) NOT NULL,
        FIELDK             CHAR(3) NOT NULL,
        FIELDL             CHAR(8) NOT NULL
 );

Program Listing:

(I hardcoded the trigger buffer and fields for reference purposes.)


 FMT *   *. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7
...+... 8 ..
0000.22 D* Trigger Buffer Length

0000.23 DTRGBUFLEN        S              9B 0

0000.24 DSEQ1             S              9P 0

0000.25 DSEQ2             S              9P 0

0000.26 D*

0000.27 D* Trigger Buffer -- After Image of Modulus Number

0000.28 DTRGBUFDS         DS

0000.29 D* BEFORE BUFFER HEADER

0000.30 DBFBUFHDR                       96A

0000.44 D* BEFORE RECORD IMAGE

0000.45 DBFIELDA                        50A

0000.46 DBFIELDB                        50A

0000.47 DBFIELDC                        50A

0000.48 DBSEQNUM1                        9P 0

0000.49 DBFIELDD                        35A

0000.50 DBSEQNUM2                        9P 0

0000.51 DBFIELDE                         8A

0000.52 DBFIELDF                         8A

0000.53 DBFIELDG                        50A

0000.54 DBFIELDH                        18A
0000.55 DBFIELDI                        35A
0000.56 DBFIELDJ                         3A
0000.57 DBFIELDK                         8A
0000.60 D* BEFORE COLUMN MAP
0000.61 DBFCOLMAP                       13A
0000.62 D* AFTER IMAGE
0000.63 DAFIELDA                        50A
0000.64 DAFIELDB                        50A
0000.65 DAFIELDC                        50A
0000.66 DASEQNUM1                        9P 0
0000.67 DAFIELDD                        35A
0000.68 DASEQNUM2                        9P 0
0000.69 DAFIELDE                         8A
0000.70 DAFIELDF                         8A
0000.71 DAFIELDG                        50A
0000.72 DAFIELDH                        18A
0000.73 DAFIELDI                        35A
0000.74 DAFIELDJ                         3A
0000.75 DAFIELDK                         8A
0000.76 DACOLMAP                        13A

0000.89 D/EJECT

0000.90
C**********************************************************************

0000.91 C*  MAIN

0000.92
C**********************************************************************

0000.93 C* GET LAST USED SEQUENCE NUMBERS FROM DATA AREAS. INCREMENT BY ONE.

0000.94 C* MOVE NUMBER INTO SEQ1 & SEQ2

0000.95
C**********************************************************************

0000.96 C* SEQUENCE #1

0002.00 C     *DTAARA       DEFINE                  SEQ1

0003.00 C     *LOCK         IN        *DTAARA

0004.00 C                   EVAL      SEQ1 = SEQ1 + 1

0005.00 C                   Z-ADD     SEQ1          ASEQNUM1

0006.00 C                   OUT       *DTAARA

0006.01 C* SEQUENCE #2

0006.02 C     *DTAARA       DEFINE                  SEQ2

0006.03 C     *LOCK         IN        *DTAARA

0006.04 C                   EVAL      SEQ2 = SEQ2 + 1

0006.05 C                   Z-ADD     SEQ2          ASEQNUM2

0006.06 C                   OUT       *DTAARA

0006.07 C*

0006.08 C                   RETURN

0006.09 C*

0007.00 C* ENTRY TRIGGER PARMS

0008.00 C     *ENTRY        PLIST

0009.00 C                   PARM                    TRGBUFDS

0010.00 C                   PARM                    TRGBUFLEN

0011.00 C/EJECT


I add the trigger to the file.


 Type choices, press Enter.



 Physical file  . . . . . . . . . > TABLEA        Name

   Library  . . . . . . . . . . . >   MYLIB       Name, *LIBL, *CURLIB

 Trigger time . . . . . . . . . . > *AFTER        *BEFORE, *AFTER

 Trigger event  . . . . . . . . . > *INSERT       *INSERT, *DELETE, *UPDATE

 Program  . . . . . . . . . . . . > SELIDR        Name

   Library  . . . . . . . . . . . >   MYLIB       Name, *LIBL, *CURLIB

 Replace trigger  . . . . . . . . > *YES          *NO, *YES

 Allow Repeated Change  . . . . . > *YES          *NO, *YES

 Threadsafe . . . . . . . . . . .   *UNKNOWN      *UNKNOWN, *NO, *YES

 Multithreaded job action . . . .   *SYSVAL       *SYSVAL, *MSG, *NORUN,
*RUN




I don't end up getting any values in the sequence fields.

On V4R5 of the OS.

The data areas are defined as 9,0 *DEC each.












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.