示例: 生成并发送警报
此 ILE RPG 程序使用警报 API。 首先,它调用 "生成警报" (QALGENA) API 以生成警报,而不向 QSYSOPR 或 QHST 消息队列发送消息。 然后,它使用 "发送警报" (QALSNDA) API 将警报发送到警报管理器。
注: 通过使用代码示例,您同意 代码许可证和免责声明信息的条款。
H
D***************************************************************
D***************************************************************
D*
D* Program Name: ALERTS
D*
D* Programming Language: ILE RPG
D*
D* Description: This program uses alert APIs. First, it
D* calls the Generate Alert (QALGENA) API to
D* generate an alert without sending a message
D* to QSYSOPR or QHST message queue. Then it
D* uses the Send Alert (QALSNDA) API to send
D* the alert to the alert manager.
D*
D* Header Files Included: QUSEC - Error Code Parameter
D*
D***************************************************************
D***************************************************************
D*
D* Error Code parameter include
D*
D/COPY QSYSINC/QRPGLESRC,QUSEC
D*
D*
D* Miscellaneous data structure
D*
DRCVVAR S 512
DRCVLEN S 9B 0 INZ(%SIZE(RCVVAR))
DALERT_SIZE S 9B 0
DMSG_FILE S 20 INZ('QCPFMSG QSYS')
DMSG_ID S 7 INZ('CPA2601')
DMSG_DATA S 100
DMSG_SIZE S 9B 0 INZ(0)
DALERT_TYPE S 1 INZ('L')
DORIGIN S 10 INZ('ALERTS')
C*
C* Beginning of mainline
C*
C* Set error handling
C*
C EVAL QUSBPRV = %SIZE(QUSEC)
C*
C* Start by generating an alert for a specific message
C*
C CALL 'QALGENA'
C PARM RCVVAR
C PARM RCVLEN
C PARM ALERT_SIZE
C PARM MSG_FILE
C PARM MSG_ID
C PARM MSG_DATA
C PARM MSG_SIZE
C PARM QUSEC
C*
C* If no error reported, send the generated alert
C*
C QUSBAVL IFEQ 0
C CALL 'QALSNDA'
C PARM RCVVAR
C PARM ALERT_SIZE
C PARM ALERT_TYPE
C PARM ORIGIN
C PARM QUSEC
C*
C* If error on send, then display the error message
C*
C QUSBAVL IFNE 0
C QUSEI DSPLY
C END
C*
C* If error on generation, then display the error message
C*
C ELSE
C QUSEI DSPLY
C END
C*
C EVAL *INLR = '1'
C RETURN
C*
C* End of MAINLINE
C*