APIs by Example: Message Handling APIs & Additional Message Info Support

For native IBM i commands such as Work with Writers (WRKWTR), Work with User Jobs (WRKUSRJOB), Work with Submitted Jobs (WRKSBMJOB), and Work with Active Jobs (WRKACTJOB), it’s possible to reply to pending inquiry messages for the writer or job in question by means of these commands’ list panels’ option 7=Display message. The internal IBM program providing this functionality is called QMHSCLVL and is also employed by other message-related commands, including Display Messages (DSPMSG), Work with Messages (WRKMSG), and Display Job Log (DSPJOBLOG). If you run any of these commands and place the cursor on a message and press F1, you invoke the QMHSCLVL program and see the Additional Message Information panel for that message.

A couple of the general print APIs include information for writers in a message wait state about the message queue and message key identifying the actual message waiting for a reply, and with release 6.1 the same information has been made available for jobs in general with some of the job-related work management APIs. I’ve including links to the specific APIs at the end of this article. You can take advantage of these APIs and the information made accessible by them to create your own writer or job commands and utilities and include message-handling facilities similar to those presented by IBM’s commands. There’s, however, currently no API available providing a public and supported interface to the QMHSCLVL functionality. So that’s what today’s APIs by Example seeks to redress.

Bruce Vining, former system API lead at IBM, in a discussion a while ago on midrange.com revealed that IBM actually for some time has been working on providing such an API but that until now other activities of higher priority have been in the way of a successful completion of that endeavor. So when I recently encountered a situation calling for a message reply function very much like the one offered by the QMHSCLVL program, I decided to build my own Additional Message Information (AMI) function. And because from time to time I’ve noted some interest for this type of message support in the System iNetwork forums and elsewhere, I present the outcome here.

I should point out that IBM’s QMHSCLVL function supports both program and nonprogram messages, the former holding messages being sent to a job’s program or external message queue and the latter holding messages being sent to a message queue object of type *MSGQ. This means that whether you display messages in a message queue or messages from your job’s program message queue or job log, you employ that same function. The intention of the Additional Message Information function presented here, however, is to support messages sent to message queues only.

Messages being sent to a program message queue can be processed and replied to only from within the job running the programs issuing the messages, and most often the request for a public and supported interface to the QMHSCLVL function has to do with the requirement of being able to reply to messages being sent to a message queue object, typically for writers or jobs hanging in a message wait condition, waiting for somebody to reply to the message in either the writer’s or the operator’s message queue. Adding program message support to the version presented here would be quite simple, however, given the requirement. Anyway, let’s look at the steps and information involved in creating the Additional Message Information function.

Download the save file containing the source code.

Read the entire article.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s