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




Two problems. Read on:

On 16/04/2009, at 6:15 AM, John McKee wrote:

I need a nudge here. I wrote a stripped down program to issue a single
command in QSH. Then, I ran it in debug mode to see the variables. This does
not make sense at this point. First, the stripped down mimimal code:

0001.00 PGM
0002.00 DCL VAR(&Msgdta) type(*char) len(4)
0003.00 DCL VAR(&MSGID) TYPE(*CHAR) LEN(7)
0004.00 DCL VAR(&MSGTXT) TYPE(*CHAR) LEN(170)
0005.00 DCL VAR(&RETURNCODE) TYPE(*INT) LEN(4)
0006.00 DCL VAR(&RC) TYPE(*CHAR) LEN(5)
0007.00
0008.00 QSH CMD('ls')
0009.00 MONMSG MSGID(QSH0005) EXEC(DO)

QSH0005 is sent as a completion message. You can't monitor for that. You can only monitor for exception messages (*ESCAPE, *NOTIFY, and *STATUS). No exception occurs so the MONMSG never runs thus the message is not received and your variables are left with their initial values.

0010.00 RCVMSG MSGTYPE(*COMP) RMV(*YES) +
0011.00 MSGDTA(&MSGDTA) +
0012.00 MSGID(&MSGID)

Receiving any non-exception message will receive the first message of that type on the call stack message queue. In this case that's the only one you're likely to have but in a production environment you could have many completion messages. You can either loop using the msgkey received from one message and specifying MSGTYPE(*NEXT) which is clumsy and usually unnecessary or you can receive the *LAST message knowing that it is either the expected message or an unwanted message. Test the message ID to be sure.

Simplest immediate modification to your code is to comment out the MONMSG and ENDDO. Compile and run. Magic will happen.

0013.00 CHGVAR VAR(&RETURNCODE) +
0014.00 VALUE(%BIN(&MSGDTA 1 4))
0015.00 CHGVAR VAR(&RC) VALUE(&RETURNCODE)
0016.00 ENDDO
0017.00 CHGVAR VAR(&MSGTXT) VALUE('RETURN CODE IS' *BCAT &RC)
0018.00 SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA(&MSGTXT) +
0019.00 TOMSGQ(MISC003)
0020.00 END:
0021.00 DMPCLPGM
0022.00 ENDPGM

Running in debug with breakpoint set on the DMPCLPGM command, I get this:

EVAL &msgdta:x
00000 40404040

EVAL &msgid:x
00000 40404040 404040.. ........ ....

EVAL &msgtxt:x
00000 D9C5E3E4 D9D540C3 D6C4C540 C9E24040 - RETURN CODE IS
00010 40404040 40404040 40404040 40404040 -

I am left wondering if something is removing the message, thus preventing this
little program from seeing it.

No, you're simply not receiving it (which would be apparent if you stepped through the code in debug).

I have not done debug on a batch job in a long
time. So, I was doing this interactively.

Doesn't matter. Same effect will occur.

If I type the QSH command on a
command line, I do see the QSH0005 message on the bottom of the screen. But,
it does not seem to be here in this program.

Because you're not receiving it.

Regards,
Simon Coulter.
--------------------------------------------------------------------
FlyByNight Software OS/400, i5/OS Technical Specialists

http://www.flybynight.com.au/
Phone: +61 2 6657 8251 Mobile: +61 0411 091 400 /"\
Fax: +61 2 6657 8251 \ /
X
ASCII Ribbon campaign against HTML E-Mail / \
--------------------------------------------------------------------




As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

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.