ILE Call(e) error handling

475 pts.
Tags:
AS/400 Spooled Files
Call(e)
Error handling
ILE
ILE Call(e) Error
ILE Program
I am calling a CMD from an ILE program (simulates WRKSPLF) that emails a spool file. In my program I use Call(e) and %error indicator is on when CMD is executed if an error occurs during execution however I cannot determine which error happens. I tried using psds sds msgid 40 46 msgdsc 91 170 however both msgid and msgdsc are blank. If I use a MONMSG in the CL then my ILE program %error does not show an error. Any suggestions on how I can determine what error occured in my CL. The CL converts spoolfile to PDF and then sends it via email and then deletes (DLO) the pdf. I want to know which process errors out.
ASKED: November 26, 2008  5:56 PM
UPDATED: December 5, 2008  10:00 AM

Answer Wiki

Thanks. We'll let you know when a new response is added.

Hi,

Does *status or %status give you any details?

Regards,

Martin Gilbert.

——————————————————————————–

I’m a bit confused. You say you’re using CALL(E) to call a *CMD. But you can’t call a *CMD with CALL. The CALL statement is for *PGM calls. So you are most likely calling a *PGM which in turn is running a *CMD. If the CL *PGM has a MONMSG following the *CMD (or a global MONMSG) then, from the system point of view, there is no error. Your MONMSG says you are handling the situation.

Can you provide the source for your CL *PGM?

Discuss This Question: 5  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Sloopy
    One way to do this is to handle the errors in the CL and return a code to the calling program to tell it what happened. In our programs, we always include a 7-character return code in our parameter lists for calls. Seven characters allows us to send a word of up to seven sensible characters OR a proper message ID, which the calling program can send. If a call returns a blank return code, the caller can assume that the function completed correctly. If a CL program is used as a command processing program, it can still be called directly from a HLL program. To distinguish between the uses, the command definition is created with its first parameter a 7-character constant with the value '*CMD'. The CL program recognises this, and will handle errors and return them as escape messages, to be handled by whatever used the command. If a HLL program calls the CL, it does so directly and not through the command. In that case, the first parameter is the 7-character return code, and it will NOT contain the value '*CMD'. The CL now knows that it is being called directly and will not generate escape messages, but will instead pass a value back through the return code to the calling program. The additional advantage of this is that all the error checking is done in the CL, where it is easiest; there is no complicated processing in any of the programs thay may call it. Regards, Sloopy
    2,195 pointsBadges:
    report
  • filuphaze
    That works great Sloopy. Thanks.
    475 pointsBadges:
    report
  • filuphaze
    This has worked fine until I have come across a CMD over a CL program that prompts the user for input. From a HLL program call to the CL the return code is blank but it doesn't prompt the user and if I place the prompt in the CL it recursively calls itself with the '*CMD'. Could you show me some code examples of the CL and RPG code? Thanks for your help.
    475 pointsBadges:
    report
  • filuphaze
    I have a CMD that is compiled over a CL. In my ILE program I am calling the CL the CMD is compiled over and it doesn't prompt for the user's input. If I use qcmdexc to execute the CMD directly and if there is an error I do not know which procedure causes the error without looking at the job log. If I include the MONMSG in the CL that handles the error but I am not aware of it to display on the screen for the user to know the option did not complete. Here is the source for the CMD. I commented out the MONMSG's. My ILE program knows there was an error as the *STATUS is 00202 but I don't know which error it was on during or after the CVT2CMD. CMD PROMPT('Email an AS/400 Spool File') PARM KWD(ADDRESS) TYPE(*CHAR) LEN(80) MIN(1) + CASE(*MIXED) PROMPT('Email address') PARM KWD(ADDR1CC) TYPE(*CHAR) LEN(80) + CASE(*MIXED) PROMPT('Cc') PARM KWD(ADDR2CC) TYPE(*CHAR) LEN(80) + CASE(*MIXED) PROMPT('Cc') PARM KWD(ADDR3CC) TYPE(*CHAR) LEN(80) + CASE(*MIXED) PROMPT('Cc') PARM KWD(ADDR4CC) TYPE(*CHAR) LEN(80) + CASE(*MIXED) PROMPT('Cc') PARM KWD(FILE) TYPE(*NAME) MIN(1) MAX(1) + PROMPT('Spool file') PARM KWD(JOB) TYPE(JOB) DFT(*) SNGVAL((* ' ')) + MAX(1) PROMPT('Job') PARM KWD(SPLNBR) TYPE(*CHAR) LEN(5) DFT(*LAST) + SPCVAL((*LAST) (*ONLY)) MIN(0) + CHOICE('1-9999, *LAST') PROMPT('Spooled + file number') PARM KWD(DOC) TYPE(*CHAR) LEN(12) DFT(*DFT) + SPCVAL((*DFT)) PROMPT('Document name') PARM KWD(SUB) TYPE(*CHAR) LEN(44) SPCVAL((*DFT)) + PROMPT('Subject Line') PARM KWD(MSG) TYPE(*CHAR) LEN(256) DFT(*DFT) + SPCVAL((*DFT)) PROMPT('Message text') JOB: QUAL TYPE(*NAME) LEN(10) QUAL TYPE(*NAME) LEN(10) CHOICE(*NONE) + PROMPT('User') QUAL TYPE(*CHAR) LEN(6) CHOICE(*NONE) + PROMPT('Number') CL Source: PGM PARM(&ADDRESS &ADDR1CC &ADDR2CC &ADDR3CC + &ADDR4CC &FILE &JOB_IN &SPLNBR &DOC &SUB + &MSG) /* Parameters... */ DCL VAR(&ADDRESS) TYPE(*CHAR) LEN(80) DCL VAR(&ADDR1CC) TYPE(*CHAR) LEN(80) DCL VAR(&ADDR2CC) TYPE(*CHAR) LEN(80) DCL VAR(&ADDR3CC) TYPE(*CHAR) LEN(80) DCL VAR(&ADDR4CC) TYPE(*CHAR) LEN(80) DCL VAR(&FILE) TYPE(*CHAR) LEN(10) DCL VAR(&JOB_IN) TYPE(*CHAR) LEN(26) DCL VAR(&SPLNBR) TYPE(*CHAR) LEN(4) DCL VAR(&DOC) TYPE(*CHAR) LEN(12) DCL VAR(&SUB) TYPE(*CHAR) LEN(44) DCL VAR(&MSG) TYPE(*CHAR) LEN(256) /* Work fields... */ DCL VAR(&USER) TYPE(*CHAR) LEN(10) DCL VAR(&JOB) TYPE(*CHAR) LEN(10) DCL VAR(&NUMBER) TYPE(*CHAR) LEN(6) DCL VAR(&UTLLIB) TYPE(*CHAR) LEN(10) + VALUE('WDISTLIB') DCL VAR(&RMVLIB) TYPE(*CHAR) LEN(1) VALUE('1') DCL VAR(&FLR) TYPE(*CHAR) LEN(80) VALUE('TEMP') DCL VAR(&LF) TYPE(*CHAR) LEN(3) VALUE(X'0D0D0D') DCL VAR(&WORD) TYPE(*CHAR) LEN(30) /* 0010 - Split out job details... */ CHGVAR VAR(&NUMBER) VALUE(%SST(&JOB_IN 21 6)) CHGVAR VAR(&USER) VALUE(%SST(&JOB_IN 11 10)) CHGVAR VAR(&JOB) VALUE(%SST(&JOB_IN 01 10)) /* 0030 - Copy the spool file from either the qualified or current job... */ IF COND(&JOB_IN *EQ ' ') THEN(DO) RTVJOBA JOB(&JOB) USER(&USER) NBR(&NUMBER) ENDDO /* 0100 - Build the stream file to be sent... */ IF COND(&DOC *EQ '*DFT') THEN(DO) CHGVAR VAR(&DOC) VALUE('SP' *CAT &NUMBER *CAT '.PDF') ENDDO /* 0110 - If a default message is required then set it... */ IF COND(&MSG *EQ '*DFT') THEN(DO) CHGVAR VAR(&MSG) VALUE('Spoolfile ' *CAT &FILE + *TCAT ' from job ' *CAT &JOB *TCAT '/' + *CAT &USER *TCAT '/' *CAT &NUMBER *CAT ' + for your review.') ENDDO CHGVAR VAR(&MSG) VALUE(&MSG *TCAT &LF) /* 0120 - Convert Spooled File to PDF Document */ CVT2CMD FROMFILE(&FILE) TOSTMF(&DOC) + TODIR('qdlstemp') + JOB(&NUMBER/&USER/&JOB) SPLNBR(&SPLNBR) + TOFMT(*PDF) STMFOPT(*REPLACE) + TITLE('ESPLF PDF') /* MONMSG MSGID(CPF3482) EXEC(SNDPGMMSG MSG('File + cannot be sent because it is Open') + TOUSR(&USER)) */ /* 0200 - Email the document to the email address... */ IF COND(&SUB *NE ' ') THEN(DO) CHGDOCD DOC(&DOC) FLR(&FLR) DOCD(&SUB) ENDDO SNDDST TYPE(*DOC) TOINTNET((&ADDRESS) (&ADDR1CC + *CC) (&ADDR2CC *CC) (&ADDR3CC *CC) + (&ADDR4CC *CC)) DSTD('Email of Spool + File') MSG(&MSG) DOC(&DOC) FLR(&FLR) /* MONMSG MSGID(CPF901A) EXEC(SNDPGMMSG MSG('Send + Distribution Request Failed')) */ /* 9010 - Clear down the work files and documents... */ DLTDLO DLO(&DOC) FLR(&FLR) /* MONMSG MSGID(CPF8A16) EXEC(SNDPGMMSG MSG('Document + Object Deletion Failed')) */ /* 9100 - Remove the utility library from the library list... */ IF COND(&RMVLIB *EQ '1') THEN(DO) RMVLIBLE LIB(&UTLLIB) MONMSG MSGID(CPF0000) ENDDO /* 9900 - Finally exit the program... */ ENDIT: ENDPGM 
    475 pointsBadges:
    report
  • Sloopy
    Most of the problems with executing commands from RPG come from the use of QCMDEXC. If a command sends its error message to the previous program, that program will be QCMDEXC. QCMDEXC will return an error indication to the calling RPG program, but if the RPG program wants any details about the error, those could be hard to get. Since QCMDEXC can't return any values from the command back to the calling program, my original suggestion - to call the command processing program directly from the RPG, so that error information can be passed back - is a sound proposition, when you are able to add a return code parameter to the command definition and the processing CL. But if you can't do that, as in the example you give of an emailing command, the best solution is to write a 'wrapper' CL program which can be called directly from your RPG program. The wrapper program will have a return code, as previously described, to tell the RPG program whether an error ocurred, with some level of detail. It will also accept the parameters that the command requires. You can use the return code on the CALL to tell the wrapper whether you want to prompt the command or not - the parameter may be either blank or '*PROMPT'. The wrapper would then execute the command, with or without prompting. The command processing program will send its error messages to the previous program, which will be the wrapper program, which can then receive the messages and set the return code before returning back to the RPG. If your RPG program is a screen program, the wrapper could optionally resend the error messages to ITS previous program, which is the RPG program. If the program message queue specified in the screen message subfile is the same name as the program, then messages sent to it will appear in the message subfile when the screen is redisplayed. Sloopy
    2,195 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following