×

Good News Everybody!

The new search engine is LIVE!

Please report any problems to david (at) midrange.com.




Michael, I'm at V5R2 and testing the following code at the moment...

             PGM        PARM(&FILE &TRIGGER &EXISTS) 
/*********************************************************************/ 
/* Declare variables...                                              */ 
/*********************************************************************/ 
             DCL        VAR(&FILE) TYPE(*CHAR) LEN(10) 
             DCL        VAR(&TRIGGER) TYPE(*CHAR) LEN(20) 
             DCL        VAR(&EXISTS) TYPE(*CHAR) LEN(1) 
             DCL        VAR(&YES) TYPE(*CHAR) LEN(1) VALUE('Y') 
             DCL        VAR(&NO) TYPE(*CHAR) LEN(1) VALUE('N') 
             DCL        VAR(&RECCOUNT) TYPE(*DEC) LEN(10 0) 
/*********************************************************************/ 
/* Delete workfile in qtemp, then build new workfile...              */ 
/*********************************************************************/ 
             DLTF       FILE(QTEMP/OUTFILE) 
             MONMSG     MSGID(CPF2105) /* Ignores object not found + 
                          error on DLTF attempt. */ 
             DSPFD      FILE(*LIBL/&FILE) TYPE(*TRG) + 
                          OUTPUT(*OUTFILE) OUTFILE(QTEMP/OUTFILE) 
/*********************************************************************/
/* Determine trigger state by attempting to copy a record from the   */
/* outfile, the result of this action can be used to deduce if the   */
/* trigger does or doesn't exist...                                  */
/*********************************************************************/
             DLTF       FILE(QTEMP/CPYFILE) 
             MONMSG     MSGID(CPF2105) /* Ignores object not found + 
                          error on DLTF attempt. */ 
             CPYF       FROMFILE(QTEMP/OUTFILE) + 
                          TOFILE(QTEMP/CPYFILE) MBROPT(*ADD) + 
                          CRTFILE(*YES) INCREL((*IF TRFILE *EQ + 
                          &FILE) (*AND TRNAM *EQ &TRIGGER)) 
             MONMSG     MSGID(CPF2817) EXEC(DO) /* If attempt to cpyf +
                          on empty member then file has no triggers. */
             CHGVAR     VAR(&EXISTS) VALUE(&NO) 
             GOTO       CMDLBL(EXIT) 
             ENDDO 
/*********************************************************************/
/* If the cpyf did copy records then that proves that the file does  */
/* have the trigger applied to it...                                 */
/*********************************************************************/
             CHGVAR     VAR(&EXISTS) VALUE(&NO) 
             RTVMBRD    FILE(QTEMP/CPYFILE) NBRCURRCD(&RECCOUNT) 
             IF         COND(&RECCOUNT *NE 0) THEN(DO) 
             CHGVAR     VAR(&EXISTS) VALUE(&YES) 
             ENDDO 
/*********************************************************************/
 EXIT:       RETURN 
 ENDPGM:     ENDPGM 

I can then test the value of &EXISTS in the CL that calls this program and 
that tells me if the trigger does or doesn't exist.

Regards, Jerry

Gerald Kern
IBM Certified AS/400 RPG IV Developer & RPG IV Programmer
MIS Project Leader, Lotus Notes/Domino Administrator
The Toledo Clinic, Inc.
4235 Secor Road
Toledo, OH 43623-4299
Phone 419-479-5535
gkern@xxxxxxxxxxxxxxxx

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