How to retrieve a GoAnywhere error from an iSeries CL
View some of the Frequently Asked Questions to our support staff. Included are some tips and tricks making this forum ideal for users getting started with GoAnywhere MFT. Note: Users can reply to existing topics but only our support staff can add new topics to this forum.
1 post
Page 1 of 1
- Support Specialist
- Posts: 91
- Joined: Thu Mar 05, 2009 3:49 pm
- Location: Ashland, NE USA
-
Question:
On the iSeries, we have a CL that calls a GoAnywhere project. If an error is raised in the GoAnywhere project, how can the CL retrieve that error?
Answer:
The following example allows you to specify your errors with the Raise Error task and retrieve those in the calling CL.
Sample Project:
On the iSeries, we have a CL that calls a GoAnywhere project. If an error is raised in the GoAnywhere project, how can the CL retrieve that error?
Answer:
The following example allows you to specify your errors with the Raise Error task and retrieve those in the calling CL.
Sample Project:
Code: Select all
Sample CL:
<project name="Test" mainModule="Main" version="2.0" logLevel="verbose">
<module name="Main">
<createFileList numFilesFoundVariable="FileCount" version="1.0">
<fileset dir="/temp" />
</createFileList>
<if condition="${FileCount==0}">
<raiseError version="1.0">
<message>WAS1001 - Unexpected error!</message>
</raiseError>
</if>
</module>
</project>
Code: Select all
PGM
DCL VAR(&MSG) TYPE(*CHAR) LEN(100)
DCL VAR(&MSGID) TYPE(*CHAR) LEN(7)
DCL VAR(&GAMSGID) TYPE(*CHAR) LEN(7)
DCL VAR(&LOWKEY) TYPE(*CHAR) LEN(4)
DCL VAR(&HIKEY) TYPE(*CHAR) LEN(4)
DCL VAR(&MSGKEY) TYPE(*CHAR) LEN(4)
DCL VAR(&ERROR) TYPE(*CHAR) LEN(5) VALUE('NO')
/* Send a message so we can capture the low key value for later. */
SNDPGMMSG MSG('Preparing to RUNPROJECT') TOPGMQ(*SAME) +
KEYVAR(&LOWKEY)
RMVMSG MSGKEY(&LOWKEY)
RUNPROJECT PROJECT('/Test')
MONMSG MSGID(GAE1002) EXEC(DO)
CHGVAR VAR(&ERROR) VALUE('YES')
ENDDO
/* Send a message so we can capture the high key value for later. */
SNDPGMMSG MSG('RUNPROJECT complete') TOPGMQ(*SAME) +
KEYVAR(&HIKEY)
RMVMSG MSGKEY(&HIKEY)
IF COND(&ERROR *EQ 'YES') THEN(DO)
/*-----------------------------------------------------------------*/
/* LOOP TO RECEIVE MESSAGES WITH RCVMSG COMMAND */
/*-----------------------------------------------------------------*/
CHGVAR %BIN(&MSGKEY 1 4) (%BIN(&LOWKEY 1 4) + 1)
LOOP:
RCVMSG PGMQ(*SAME (*)) MSGKEY(&MSGKEY) RMV(*NO) +
MSG(&MSG) MSGID(&MSGID)
MONMSG CPF2410 EXEC(DO) /* HANDLE MSGKEY NOT FOUND */
RCVMSG MSGTYPE(*EXCP) RMV(*YES) /* REMOVE UNWANTED EXCEPTION */
GOTO SKIP
ENDDO
IF COND(&MSGID *EQ 'GAE9898') THEN(DO)
/* Parse out return from &MSG */
CHGVAR VAR(&GAMSGID) VALUE(%SST(&MSG 22 7))
/* [9001 - Raise Error] WAS1001 - Unexpected error! */
/* 12345678901234567890123456789012345678901234567890 */
ENDDO
SKIP:
CHGVAR %BIN(&MSGKEY 1 4) (%BIN(&MSGKEY 1 4) + 1)
IF (&MSGKEY *LT &HIKEY) GOTO LOOP
ENDDO
1 post
Page 1 of 1